• Remix
  • Share
  • New Entry

  • Nil

  • /
  • Hypnotic Spirograph Animation

on 29 Nov 2023
  • 4
  • 13
  • 0
  • 0
  • 597
drawframe(1);
Write your drawframe function below
function createAnimation()
% Parameters
duration = 8; % seconds
fps = 30; % frames per second
num_frames = duration * fps;
% Create Animation
for f = 1:num_frames
drawframe(f);
end
end
function drawframe(f)
persistent frames
if f == 1
% Parameters
duration = 8; % seconds
fps = 30; % frames per second
num_frames = duration * fps;
% Preallocate frames cell array
frames = cell(1, num_frames);
% Create each frame
for i = 1:num_frames
figure;
% Hypnotic Spirograph Animation
num_spirals = 6;
for j = 1:num_spirals
theta = linspace(0, 10*pi, 1000);
radius = j * exp(0.2 * theta);
x = radius .* cos(theta);
y = radius .* sin(theta);
% Plot spirograph
plot(x, y, 'Color', rand(1, 3), 'LineWidth', 2);
hold on;
end
% Adjust plot settings
axis equal;
xlim([-800 800]);
ylim([-800 800]);
xlabel('X');
ylabel('Y');
title('Hypnotic Spirograph Animation');
% Capture frame
frames{i} = getframe(gcf);
close;
end
end
% Display frame
imshow(frames{f}.cdata);
axis off;
end
Animation
Remix Tree