• Remix
  • Share
  • New Entry

on 12 Oct 2024
  • 10
  • 99
  • 0
  • 0
  • 609
drawframe(1);
Write your drawframe function below
% Set up figure window
figure('Color', 'k');
% Total number of frames
nFrames = 96;
% Create Movie function
for loop = 1:3 % Loop 3 times for a 12-second video
for f = 1:nFrames
drawframe(f); % Call drawframe for each frame
end
end
% Draw frame function: generates different frames based on frame number
function drawframe(f)
% f is the frame number (1 to 96)
% Set up axes
axis off;
hold on;
maxRadius = 50; % Maximum radius of explosion
nFrames = 96; % Total number of frames
% Explosion expansion
radius = maxRadius * (f / nFrames);
theta = linspace(0, 2 * pi, 100);
xCircle = radius * cos(theta);
yCircle = radius * sin(theta);
% Plot explosion
plot(xCircle, yCircle, 'r', 'LineWidth', 2); % Red explosion circle
% Stick figure (man shape)
alpha = 1 - f/nFrames; % Fading effect based on frame number
plot(0, 1.5, 'wo', 'MarkerSize', 20, 'LineWidth', 2, 'Color', [1 1 1] * alpha); % Head
plot([0 0], [1 0], 'w', 'LineWidth', 2, 'Color', [1 1 1] * alpha); % Body
plot([-0.5 0 0.5], [0.5 1 0.5], 'w', 'LineWidth', 2, 'Color', [1 1 1] * alpha); % Arms
plot([-0.5 0 0.5], [0 -1 0], 'w', 'LineWidth', 2, 'Color', [1 1 1] * alpha); % Legs
hold off;
drawnow; % Update figure window to animate
end
Movie
Audio
Remix Tree