• Remix
  • Share
  • New Entry

on 19 Oct 2024
  • 12
  • 86
  • 1
  • 0
  • 1781
Cite your audio source here (if applicable):
I composed 30 sound loops for use in the Mini Hack.
If you like them, please feel free to use them for free.
drawframe(1);
Write your drawframe function below
function drawframe(f)
persistent p p1 p2 swarm particles_x0 particles_y0
if f == 1
set(gcf,'Color','k')
c.darkgoldenrod = "#b8860b";
c.darkorange = "#ff8c00";
c.col1 = c.darkgoldenrod;
c.col2 = c.darkorange;
fc = @(x,y) x.^5 + y.^6 - 1;
fp = fimplicit(fc);
fp.Color = c.col1;
fp.LineWidth = 5;
axis equal
axis off
hold on
xlim([-10 1.2])
ylim([-4 4])
% get edge points
p1 = [fp.XData(1), fp.YData(1)];
p2 = [fp.XData(end), fp.YData(end)];
lambda = sin((f-1)/24*2*pi) * 2;
% control point
c_point = [(p1(1) + p2(1))/2 + lambda, (p1(2) + p2(2))/2];
% diaphragm & edge
t = 0:0.05:1;
x = (1-t).^2 * p1(1) + 2*(1-t).*t * c_point(1) + t.^2 * p2(1);
y = (1-t).^2 * p1(2) + 2*(1-t).*t * c_point(2) + t.^2 * p2(2);
p = plot(x, y, 'Color', c.col2, 'LineWidth', 3);
plot(p1(1), p1(2), 'bo', 'MarkerSize', 10, 'MarkerFaceColor', 'b');
plot(p2(1), p2(2), 'bo', 'MarkerSize', 10, 'MarkerFaceColor', 'b');
% particles
num_particles = 200;
particles_x0 = -7 - rand(1, num_particles) * 3;
particles_y0 = -4 + rand(1, num_particles) * 8;
swarm = swarmchart(particles_x0, particles_y0, 30, 'filled', ...
'MarkerFaceAlpha',0.75);
compression_ratio = 1 - 0.5 * lambda / 2;
particles_x = particles_x0 * compression_ratio;
for i = 1:length(particles_x)
idx = find(y <= particles_y0(i), 1);
left_boundary_x = p.XData(idx);
particles_x(i) = min(particles_x(i),left_boundary_x);
end
swarm.XData = particles_x;
hold off
view(90,90)
drawnow
end
if f > 1
lambda = sin((f-1)/24*2*pi) * 2;
c_point = [(p1(1) + p2(1))/2 + lambda, (p1(2) + p2(2))/2];
t = 0:0.05:1;
x = (1-t).^2 * p1(1) + 2*(1-t).*t * c_point(1) + t.^2 * p2(1);
y = (1-t).^2 * p1(2) + 2*(1-t).*t * c_point(2) + t.^2 * p2(2);
p.XData = x;
p.YData = y;
compression_ratio = 1 - 0.5 * lambda / 2;
particles_x = particles_x0 * compression_ratio;
for i = 1:length(particles_x)
idx = find(y <= particles_y0(i), 1);
left_boundary_x = p.XData(idx);
particles_x(i) = min(particles_x(i),left_boundary_x);
end
swarm.XData = particles_x;
drawnow
end
end
Movie
Audio
Remix Tree