• Remix
  • Share
  • New Entry

on 8 Nov 2023
  • 9
  • 109
  • 2
  • 0
  • 911
drawframe(1);
Write your drawframe function below
function drawframe(f)
%% Hack so last frame is first frame making our icon look compelling
f = mod(f-2,48)+1;
%% Water Lilly Part
openness = min((f-1)/40,1);
opencenter = openness*.3;
pnum = 6.6;
nr = 30;
pr = 10;
B = 1.27689;
np = 60;
petalTheta = (1/pnum) * pi * 2;
nt = np * pr + 1;
r=linspace(0,1,nr);
theta=linspace(0, np*petalTheta,nt);
[R,THETA]=ndgrid(r,theta);
M = (1 - mod(pnum*THETA, 2*pi)/pi);
x = 1-(abs(M)*.7);
phi = (pi/2)*linspace(opencenter,openness,nt).^2;
y = 1.2*(R.^2).*(B*R - 1).^2.*sin(phi);
R2 = x.*(R.*sin(phi) + y.*cos(phi));
X=R2.*sin(THETA);
Y=R2.*cos(THETA);
Z=x.*(R.*cos(phi)-y.*sin(phi))*.6;
C=hypot(hypot(X,Y), Z*1.2);
surf(X,Y,Z,C, FaceC='i', EdgeC='n');
%% A light emerges! Our little fairy will be a round marker.
lpos = [ 0 0 .2 + openness*1.9];
lclr = hsv2rgb([ mod(openness+.2,1) 1 1 ]);
light('position', lpos, 'style', 'local', 'color', lclr);
patch('vertices', lpos, 'faces', 1, 'Marker', 'o', ...
'MarkerF', lclr, 'MarkerE', 'n', 'MarkerS', openness*16+.01);
%% Decorations
set(gcf,'color', 'k');
colormap spring
daspect([1 1 1])
axis([-1 1 -1 1 -.1 1.5], 'off')
set(gca,'clipping','off')
camzoom(1.6)
camorbit(-f*3,0)
end
Animation
Remix Tree