• Remix
  • Share
  • New Entry

on 26 Oct 2024
  • 23
  • 209
  • 0
  • 1
  • 1925
Cite your audio source here (if applicable): Nintendo. N64 'power star' sound.
drawframe(1);
f1 =
Figure (1) with properties: Number: 1 Name: '' Color: [1 1 1] Position: [0 0 1000 1000] Units: 'pixels' Use GET to show all properties
Write your drawframe function below
function drawframe(f)
persistent f1
if f==1
f1=figure('Position',[0 0 1000 1000])
end
p=@pol2cart;
o=@rotate;
an=linspace(0,360,97);
%inner and outer star radii
r_out=1;
r_out2=0.95;
r_out3=0.80;
r_in=.5;
r_in2=.45;
r_in3=.3;
ar=5;
th=[(-pi/2:2*pi/(2*ar):2*pi-pi/2)+pi/2].'; %star angles
c4=cat(3,.94,.83,.16); %star colour
am=ones(1,ar);
ro=r_out*am; %star layers to create curvature
roa=r_out2*am;
rob=r_out3*am;
ri=r_in*am;
ria=r_in2*am;
rib=r_in3*am;
r=[];
ra=[];
rb=[];
for i=1:ar %star radii vertices
r=[r ro(i) ri(i)];
ra=[ra roa(i) ria(i)];
rb=[rb rob(i) rib(i)];
end
r1=[r r_out].';
r1a=[ra r_out2].';
r1b=[rb r_out3].';
[Z,Y]=p(th,r1); %star vertices Carterian
[Za,Ya]=p(th,r1a);
[Zb,Yb]=p(th,r1b);
o_s=ones(length(Z),1);
X1=-.05*o_s; %depth coordinates for layers
X2=+.05*o_s;
x1a=.15;
x2a=-.15;
x1b=.20;
x2b=-.20;
x1c=.20;
x2c=-.20;
v_s=zeros(length(Z),1);
%star layers to make surfaces
X_s=[v_s+x2c v_s+x2b v_s+x2a X1 X2 v_s+x1a v_s+x1b v_s+x1c];
Z_s=[v_s Zb Za Z Z Za Zb v_s];
Y_s=[v_s Yb Ya Y Y Ya Yb v_s];
P(1)=surf(X_s,Y_s,Z_s+1,0.*X_s+c4);%star surface
hold on
[Xs,Ys,Zs]=sphere(50);% for eyes
P(2)=surf(.15*Xs/2+0.2,.15*Ys./3+.15,.15*Zs+.15+1,0.*Ys+0*c4);
P(3)=surf(.15*Xs/2+0.2,.15*Ys./3-.15,.15*Zs+.15+1,0.*Ys+0*c4);
%rotate star on each frame through z plane
o(P(1),[0 0 1],an(f),[0 0 0]);
o(P(2),[0 0 1],an(f),[0 0 0]);
o(P(3),[0 0 1],an(f),[0 0 0]);
%for mushroom
a=500;
%spheres for hat and head
[Xs,Ys,Zs]=sphere(a);
[Xh,Yh,Zh]=sphere(a);
%mushroom colours and grass
c4=cat(3,.89,.225,.32);
c3=cat(3,.96,.84,.54);
c5=cat(3,.18,.87,.03);
X=linspace(-1,1,a+1);
[x,y]=meshgrid(X,X');
xp=[.5 -.5 0];
yp=[-.3 -.3 .7];
m=ones(a+1,a+1,3); %pattern matrix for mushroom spots
m2=m.*c4;
for k=1:3
[t,r]=cart2pol(X+xp(k),X'+yp(k));
r=repmat(r,1,1,3);
m2(r<0.4)=m(r<0.4);
end
%this was a bit of a fudge to try to create a curve on the lower edge of
%the hat
inc=linspace(0.01,0.3,30);
for k=1:30
Zs(Zs>0.6+inc(k))=Zs(Zs>0.6+inc(k)).*Zs(Zs>0.6+inc(k)).^inc(k);
end
Zs=Zs.*-1;
%mushroom spheres for hat, eyes and face
P(2)=surf(1*Xs,1*Ys,1*Zs-1.5,m2);
P(4)=surf(.6*Xh,.6*Yh,.5*Zh-.8-1.5,0.*Ys+c3);
P(5)=surf(.06*Xh+.27*2,.06*Yh-.16,.14*Zh-.9-1.5,0.*Ys+0*c3);
P(6)=surf(.06*Xh+.27*2,.06*Yh+.16,.14*Zh-.9-1.5,0.*Ys+0*c3);
y = [-4 4 -4; -4 4 4 ; -4 4 -4; -4 4 4 ];
x = [-4 -4 -4; -4 -4 -4; -2 -2 -2; -2 -2 -2];
z = [-1 -1 -1; -4 -4 -4;-1 -1 -1; -4 -4 -4];
%grass
P(7)=surf(x,y,z,0.*z+c5);
shading interp
light
view([90 0])
lightangle(-60,30);
lighting gouraud
material shiny
material([.6, .6, .8, 3])
axis equal
axis off
set(gcf,'Color',[.30 .54 .82])
camva(4.6)
xlim([-4 1])
ylim([-4 4])
zlim([-4 3])
hold off
end

Movie

Audio

Remix Tree