• Remix
  • Share
  • New Entry

on 25 Oct 2024
  • 20
  • 172
  • 0
  • 2
  • 1962
Cite your audio source here (if applicable):
drawframe(1);
Write your drawframe function below
function drawframe(frame)
% Set up the figure
clf;
set(gcf, 'Color', 'black');
axis([-10 10 -10 10]);
axis equal;
hold on;
% Time variables
t = frame/8; % Smooth time progression
% Draw stars (twinkling effect)
numStars = 100;
starX = 20 * rand(numStars, 1) - 10;
starY = 20 * rand(numStars, 1) - 10;
starBrightness = 0.3 + 0.7 * rand(numStars, 1) + 0.2 * sin(t + rand(numStars, 1) * 2 * pi);
scatter(starX, starY, 20, [starBrightness starBrightness starBrightness], 'filled');
% Draw planet
theta = linspace(0, 2*pi, 100);
planetRadius = 3;
planetX = planetRadius * cos(theta);
planetY = planetRadius * sin(theta);
% Planet rotation and color variation
rotationOffset = t/2;
planetColor = [0.4 + 0.2*sin(t/2), 0.6 + 0.2*cos(t/3), 0.8];
fill(planetX, planetY, planetColor);
% Draw atmospheric rings
for ring = 1:3
ringRadius = planetRadius + 0.3*ring;
ringX = ringRadius * cos(theta);
ringY = ringRadius * sin(theta);
plot(ringX, ringY, 'Color', [1 1 1 0.2], 'LineWidth', 1);
end
% Draw orbiting satellite
satellitePos = t * 2;
orbitRadius = 5;
satelliteX = orbitRadius * cos(satellitePos);
satelliteY = orbitRadius * sin(satellitePos);
% Satellite trail
trailLength = 20;
trailTheta = linspace(satellitePos-pi/4, satellitePos, trailLength);
trailX = orbitRadius * cos(trailTheta);
trailY = orbitRadius * sin(trailTheta);
for i = 1:length(trailTheta)
alpha = i/length(trailTheta);
plot(trailX(i), trailY(i), '.', 'Color', [1 1 1 alpha], 'MarkerSize', 5);
end
% Draw satellite
rectangle('Position', [satelliteX-0.3 satelliteY-0.3 0.6 0.6], ...
'Curvature', [1 1], 'FaceColor', 'white');
% Solar flares (random bursts)
numFlares = 5;
for i = 1:numFlares
flareAngle = 2*pi * rand() + t;
flareLength = 1 + 0.5*sin(t*2 + i);
flareX = [0 flareLength*cos(flareAngle)] + planetRadius*cos(flareAngle);
flareY = [0 flareLength*sin(flareAngle)] + planetRadius*sin(flareAngle);
plot(flareX, flareY, 'Color', [1 0.8 0 0.5], 'LineWidth', 2);
end
% Text overlay
if frame < 24 % First 3 seconds
text(0, 8, 'Space Journey', 'Color', 'white', ...
'FontSize', 14, 'HorizontalAlignment', 'center');
elseif frame > 72 % Last 3 seconds
text(0, -8, 'The End', 'Color', 'white', ...
'FontSize', 14, 'HorizontalAlignment', 'center');
end
% Keep axis off for clean look
axis off;
end
% To create the movie (96 frames = 12 seconds at 8 fps):
function createMovie()
figure('Position', [100 100 800 800]);
movie = struct('cdata', [], 'colormap', []);
for frame = 1:96
drawframe(frame);
movie(frame) = getframe(gcf);
end
% Play the movie
movie(gcf, movie, 1, 8); % Play once at 8 fps
end
Movie
Audio
Remix Tree