• Remix
  • Share
  • New Entry

on 23 Oct 2024
  • 21
  • 127
  • 1
  • 1
  • 1917
Cite your audio source here (if applicable):
Audio - Die for you by Joji
https://youtu.be/kIEWJ1ljEro?si=08-dRwX0GJSNlV9F
drawframe(1);
Write your drawframe function below
function drawframe(f)
% This entry is a remix of Zhaoxu Liu's Particle Heart 2 along with
% the modified full-rotation version by Mike Croucher.
% Thanks to both of them. I’ve changed the heart’s color to cyan and
% added a section to the code that animates the particles falling to the ground.
% particle heart 2 : https://www.mathworks.com/matlabcentral/communitycontests/contests/6/entries/12797
% Particle Heart : https://www.mathworks.com/matlabcentral/communitycontests/contests/6/entries/12837
global t1 t2 t3 heartHdl star1Hdl star2Hdl hpnts sx1 sx2 sy1 sy2
k = 48; %Half no of frames
view(60,-14)
if f == 1
clr1=@(n) repmat([0 0.8 1],[n,1])+repmat([0 0.8 1],[n,1]).*repmat(rand([n,1]),[1,3]);
clr2=@(n) repmat([118,156,216]./255,[n,1])+repmat([137,99,39].*.1./255,[n,1]).*repmat(rand([n,1]),[1,3]);
szFunc=@(n) rand([n,1]).*15+8;
hold on
n = 120;
x = linspace(-3,3,n);
y = linspace(-3,3,n);
z = linspace(-3,3,n);
[X,Y,Z] = ndgrid(x,y,z);
F = ((-(X.^2).*(Z.^3)-(9/80).*(Y.^2).*(Z.^3)) + ((X.^2)+(9/4).*(Y.^2)+(Z.^2)-1).^3);
FV = isosurface(F,0);
hpnts = FV.vertices;
hpnts = (hpnts-repmat(mean(hpnts),[size(hpnts,1),1])).*repmat([.75,.7,.7],[size(hpnts,1),1]);
hpnts = hpnts + rand(size(hpnts)).*.7;
heartHdl = scatter3(hpnts(:,1),hpnts(:,2),hpnts(:,3),'.','SizeData',9,'CData',clr1(size(hpnts,1)));
sx1 = rand([2e3,1]).*120-60;
sy1 = rand([2e3,1]).*120-60;
sz1 = ones(size(sx1)).*-30;
star1Hdl = scatter3(sx1,sy1,sz1,'.','SizeData',szFunc(length(sx1)),'CData',clr2(size(sx1,1)),'LineWidth',1);
sx2 = rand([2e3,1]).*120-60;
sy2 = rand([2e3,1]).*120-60;
sz2 = rand([2e3,1]).*120-20;
star2Hdl = scatter3(sx2,sy2,sz2,'.','SizeData',szFunc(length(sx2)),'CData',[1,1,1]);
% Axis adjustments
ax = gca;
ax.XLim = [-30,30];
ax.YLim = [-30,30];
ax.ZLim = [-40,30];
ax.Projection = 'perspective';
ax.Color = [0,0,0];
axis off;
set(ax,'LooseInset',[0,0,0,0]);
set(ax,'Position',[-1/5,-1/5,1+2/5,1+2/5]);
set(gcf,'Color',[0,0,0]);
% Initialize rotation angles
t1 = 0; t2 = 0; t3 = 0;
elseif f>=2 && f<=k
% Heart rotation
t1 = t1 - pi/48;
t2 = t2 - 0.003;
t3 = t3 - 0.02;
set(heartHdl,'XData', hpnts(:,1).*cos(t1)-hpnts(:,2).*sin(t1),...
'YData', hpnts(:,1).*sin(t1)+hpnts(:,2).*cos(t1));
% Star rotation
set(star1Hdl,'XData',sx1.*cos(t2)-sy1.*sin(t2),...
'YData',sx1.*sin(t2)+sy1.*cos(t2));
set(star2Hdl,'XData',sx2.*cos(t3)-sy2.*sin(t3),...
'YData',sx2.*sin(t3)+sy2.*cos(t3));
else
%Particles Falling Scene : (added by Malik)
tf = 96 - k + 1; % Number of frames for breaking
fpm = 0.2*(f - k) / (tf); % Fraction of particles falling per frame
% Z-range for heart points (-16.5 to 30)
zS = -16.5;
zE = 30;
zR = zE - zS;
% Percentage of particles falling at current frame
fT = zS + (f - k) * zR * fpm; %falling threshold
% Selecting particles that are at or below the falling threshold
fp = hpnts(:,3) <= fT; %falling particles
% After the fall, The final Z position of the particles is at z=-30
% which is the ground
zData = get(heartHdl, 'ZData');
zData(fp) = zData(fp) - (zData(fp) - (-30)) * fpm;
set(heartHdl, 'ZData', zData);
end
end
Movie
Audio
Remix Tree