• Remix
  • Share
  • New Entry

on 29 Nov 2023
  • 22
  • 27
  • 0
  • 2
  • 613
function drawframe(f)
persistent P Srf Zx
spring=sinpi(f/24)+2;
n=300;% Resolution of the sphere
S=10; % Number of spirals
w=.1/spring;% Thickness of the ribbon.
nb=12;% Number of bumps in the punkin
% Theta goes around S times, with n verts per round.
T=linspace(0,S*2,n*S);
T=[T;T];% top and bottom of ribbon
% Phi slowly goes from -.5 to .5 (top+bottom of sphere) with same # verts
% as theta.
P=linspace(-.5+w,.5,3000);
%P=-.5:.0003:.5;
P=[P;P-w];% top and bottom of ribbon, thickness of w.
% Radius of punkin has bumps. R modulates # of bumps.
R=1-(1-mod(T*nb,2)).^2/15;
% Make the surface coordinates
X=cospi(P).*cospi(T);
Y=cospi(P).*sinpi(T);
if f==1
Z=(.8+(0-(P*2).^4)*.2).*sinpi(P);
Zx=max(Z,[],'all');
% Draw
Srf=surf(R.*X,R.*Y,R.*Z,'FaceColor','#f71','EdgeColor','n');
surface(X/12,Y/12,Z/2+.7,'FaceColor','#080','EdgeColor','n');
camlight
lighting g
material([.6 .9 .3 2 .5])
daspect([1 1 1]);
axis([-1 1 -1 1 -3 .5],'off');
set(gca,'pos',[0 0 1 1],'clipping','off');
set(gcf,'color','w');
end
Z2=(.8+(0-(P*2).^4)*.2).*sinpi(P)*spring;
Z2x=max(Z2,[],'all');
set(Srf,'ZData',Z2-diff([Zx Z2x]));
end
Animation
Remix Tree