- /
-
New Year 🎆
on 23 Oct 2024
- 22
- 155
- 0
- 0
- 1708
Cite your audio source here (if applicable):
% Audio - https://youtu.be/rKt3oF2-Q4M?si=Rh9R-SMBMh7iViqp
drawframe(1);
Write your drawframe function below
function drawframe(f)
% Holiday Theme
persistent textHandle;
clf;
figure
set(gcf,'color',[0,0,0]);
axis off;
ns = 200; % Number of sparkles
s = rand(ns, 2);
sv = -rand(ns, 1) * 0.02 - 0.005;
sc = rand(ns, 3);
c0 = 10; % Starting countdown number
fpn = 5; % Number of frames per countdown number
if f>=1 && f<=70
% Initialize sparkle scatter plot
ss = scatter(s(:,1), s(:,2), 70, sc, 'filled');
ss.MarkerEdgeColor = 'none';
ss.MarkerFaceAlpha = 0.7;
% Calculate which number to show based on the current frame
c = c0 - floor((f-1) / fpn);
if c >= 0
% Display countdown number
textHandle = text(0.5, 0.5, num2str(c), 'Color', [1, 0.84, 0], 'FontSize', 150, ...
'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle', 'Units', 'normalized', ...
'FontWeight', 'bold', 'Interpreter', 'latex');
axis off;
else
% Display "2025" after the countdown
textHandle = text(0.5, 0.5, '2025', 'Color', [1, 0.84, 0], 'FontSize', 130, ...
'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle', 'Units', 'normalized', ...
'FontWeight', 'bold', 'Interpreter', 'latex');
axis off;
end
% Update sparkle positions continuously
s(:,2) = s(:,2) + sv; % Move particles downwards
ob = s(:,2) < 0;
s(ob,2) = 1;
s(ob,1) = rand(sum(ob),1);
% Update sparkle scatter plot
ss.XData = s(:,1);
ss.YData = s(:,2);
elseif f>=71 && f<=96
axis([-6 6 1 11]);
hold on
text(0, 6, 'Happy New Year', 'Color', [1, 0.84, 0], 'FontSize', 50, ...
'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle', ...
'Units', 'data', 'FontWeight', 'bold', 'Interpreter', 'latex');
drawnow;
n=5;
f = mod(f,71)+1;
for i=1:n
pS = i*f/2 ;
inc = 0.2*i ;
circ([-0.5,8.5],f/40+inc,pS,11,[1 0 0; 0 1 0]);
circ([-4.5,9],f/40+inc,pS,11,rand(2,3));
circ([-3.5,3.5],f/40+inc,pS,11,[1 1 0;0.8500 0.3250 0.0980]);
circ([0,2.5],f/50+inc,pS,9,rand(2,3));
circ([3.5,9],f/40+inc,pS,13,[0.5 0 1; 0 1 1]);
circ([4,4],f/50+inc,pS,13,rand(2,3));
end
end
end
function circ(c, r, ps, np, clr)
gs = ps + 200;
th = linspace(0, 2*pi, np);
x = c(1) + r * cos(th);
y = c(2) + r * sin(th);
cl = repmat(clr, ceil(np/2), 1);
cl = cl(1:np, :);
hold on;
scatter(x, y, ps, cl, 'filled'); %Create single circular layers of points
for g = 1:3 %Glow effect
scatter(x, y, ps + g*gs, cl, 'filled', 'MarkerFaceAlpha', 0.05);
end
end