- /
-
A Dynamic Pattern
on 20 Oct 2024
- 12
- 144
- 0
- 0
- 398
Cite your audio source here (if applicable):
drawframe(1);
Write your drawframe function below
function drawframe(f)
t = linspace(0, 2*pi, 100); % Parametric time (100 points per frame)
h = linspace(-5, 5, 96); % Control parameter changes for each frame
a = h(f); % Amplitude varies with frame number
% Creative shape combining spirals and rotating waves
r = 1 + 0.5 * sin(3*t + f/20); % Radial distance with a time-varying spiral
theta = t + a/5 * sin(f/10); % Add rotation and wave effect based on frame number
% Parametric equations for x and y using r and theta
x = r .* cos(theta) + sin(a*t); % Mix cosine with a time-varying sine wave
y = r .* sin(theta) + cos(a*t); % Mix sine with cosine to create a twisted pattern
% Plot with evolving color: shift color for each frame
plot(x, y, 'LineWidth', 6, 'Color', [0.5+0.5*cos(f/10), 0.5+0.5*sin(f/20), 0.5+0.5*sin(f/30)]);
% Smooth plot settings for better visual aesthetics
set(gca, 'Color', [0 0 0]); % Background color black for contrast
axis equal; % Equal scaling for x and y axes
axis([-6 6 -6 6]); % Fix axis to prevent movement
title(['Frame: ' num2str(f)], 'FontSize', 12, 'Color', [1 1 1]); % Frame counter in white
grid off; % Remove grid for cleaner look
% Animate the drawing with real-time frame updates
drawnow;
end