- /
-
Happy Shaping!!!
on 13 Oct 2024
- 78
- 399
- 0
- 4
- 744
Cite your audio source here (if applicable):
drawframe(1);
Write your drawframe function below
function drawframe(f)
clf;
bgColor = [0.1 + 0.5*abs(sin(f/10)), 0.1 + 0.5*abs(cos(f/15)), 0.9 - 0.5*abs(sin(f/20))]; % Changing background color
set(gcf, 'Color', bgColor);
axis([-15 15 -15 15]);
axis off;
hold on;
t = f / 24;
x = 10 * cos(t * 2 * pi) * (1 + 0.5 * sin(t * pi));
y = 10 * sin(t * 2 * pi) * (1 + 0.5 * cos(t * pi));
r = 3 + sin(t * 2 * pi);
sides = 3 + round(3 * abs(sin(t)));
theta = linspace(0, 2 * pi, sides + 1);
xp = r * cos(theta) + x;
yp = r * sin(theta) + y;
c = [abs(sin(t)), 0.5 * abs(cos(t)), 1 - abs(sin(t))];
fill(xp, yp, c, 'EdgeColor', 'none');
bx = 12 * cos(t * pi / 2);
by = 8 * abs(sin(t * 1.5 * pi));
br = 2; % Ball radius
rectangle('Position', [bx-br, by-br, 2*br, 2*br], ...
'Curvature', [1, 1], ...
'FaceColor', [1, 0.5, 0.5], ...
'EdgeColor', 'none');
plot([x bx], [y by], 'w--', 'LineWidth', 2);
hold off;
axis equal;
end