• Remix
  • Share
  • New Entry

on 14 Oct 2024
  • 12
  • 154
  • 0
  • 0
  • 1384
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 fp ths x_snow y_snow h_snow
set(gcf,'Color', '#191970'); % midnight blue
num_snow = 100;
if f == 1
% set snow
x_snow = rand(num_snow,1)*300 - 150;
y_snow = rand(num_snow,1)*300 - 150;
s_snow = rand(num_snow,1)*30;
h_snow = scatter(x_snow, y_snow, s_snow, 'filled','MarkerFaceColor','#d0d0d0');
% foreground animation
d = 2;
dth = pi/96;
ths = -pi:dth:pi-dth;
a1 = 60; a2 = 20; a3 = 25;
b1 = 60; b2 = 30; b3 = 30;
wx1 = 1; wx2 = 4; wx3 = 10;
wy1 = 1; wy2 = 3; wy3 = 9;
fp = gobjects(1,length(ths)+1);
hold on
for k = 1:length(ths)
th = ths(k);
u = a1 * sin(wx1 * th) + a2 * sin(wx2 * th) + a3 * sin(wx3 * th);
v = b1 * sin(wy1 * th + pi/2) + b2 * sin(wy2 * th + pi/2) + b3 * sin(wy3 * th + pi/2);
fp([k end]) = feather(u,-v);
fp(k).XData(end+1) = fp(k).XData(end-2);
fp(k).YData(end+1) = fp(k).YData(end-2);
fp(k).LineWidth = 1.5;
fp(k).Color = [fp(k).Color 0];
end
hold off
ax = gca;
xlim(ax, [-150 150])
ylim(ax, [-150 150])
axis(ax,'off')
axis equal
end
% let it snow
y_snow = y_snow - 1; % snow speed
out_of_bounds = y_snow < -150;
y_snow(out_of_bounds) = 150;
x_snow(out_of_bounds) = rand(sum(out_of_bounds),1)*300 - 150;
s_snow = rand(num_snow,1)*30;
set(h_snow, 'YData', y_snow, 'XData', x_snow, 'SizeData',s_snow);
hold on
N2 = 5;
j = f * 2 - 1;
maxN = N2 * 2;
for k=0:maxN
idx = mod(j+k, length(ths));
idx = max(idx,1);
alpha = max((k-1)/maxN,0);
if (j+k)>length(ths); alpha = 0; end
fp(idx).Color = [fp(idx).Color alpha];
end
for k = 0:1
x = fp(j+k).XData(2); y = fp(j+k).YData(2);
s = scatter(x,y,100,"filled");
% distfromzero = norm([x, y]);
% s.AlphaData = distfromzero;
% s.MarkerFaceAlpha = 'flat';
end
hold off
end

Movie

Audio

Remix Tree