- /
-
Sedative
on 18 Oct 2024
- 22
- 161
- 0
- 0
- 759
Cite your audio source here (if applicable):
drawframe(1);
Write your drawframe function below
function drawframe(f)
t = linspace(0,2*pi,200);
h = linspace(-2.3,2.3,96);
a = h(f);
x = a*sin(3*t)-sin(5*t);
y = a*cos(3*t)+cos(5*t);
clf;
hold on;
addStars(f);
% rainbow color map
cmap = hsv(200);
patch(x, y, 1:length(x), 'EdgeColor', 'none', 'FaceColor', 'interp');
colormap(cmap);
plot(x, y, 'LineWidth', 3, 'Color', [1 1 1]);
axis equal;
axis([-3.5 3.5 -3.5 3.5]);
axis off;
set(gcf, 'Color', 'k');
for i = 1:3
plot(x, y, 'LineWidth', 6-i, 'Color', [1 1 1, 0.2], 'LineSmoothing', 'on');
end
hold off;
end
function addStars(f)
persistent starPositions
if isempty(starPositions)
numStars = 50;
starPositions = 7 * (rand(numStars, 2) - 0.5);
end
for i = 1:size(starPositions, 1)
if rand < 0.7
brightness = 0.5 + 0.5 * sin(f/5 + i);
plot(starPositions(i,1), starPositions(i,2), '.', 'Color', [1 1 1] * brightness, 'MarkerSize', 3 + 2*brightness);
end
end
end