• Remix
  • Share
  • New Entry

on 29 Nov 2023
  • 12
  • 7
  • 0
  • 0
  • 903
drawframe(1);
Write your drawframe function below
function drawframe(f)
cla
ax=axes('Position',[0 0 1 1],'color',[0.5 0.5 0.5]);
if f<=24
t=(f-1)*pi/30;
c='k';
else
t=23*pi/30;
c='y';
end
patch([-0.5 2.5 2.5 -0.5],[0 0 2 2],'c');
patch([0 2 2 0],[0 0 2 2],c);
patch([0.8 1.2 1],[1.8 1.8 2],[0.5 0.5 0.5]);
x1 = [0 0 1*cos(t) 1*cos(t)];
y1 = [2 0 0-sin(t) 2-sin(t)];
patch(x1,y1,'r')
x2 = [2 2 1+(1-cos(t)) 1+(1-cos(t))];
y2 = [0 2 2-sin(t) 0-sin(t)];
patch(x2,y2,'r')
%
hold on
theta=-2*pi:pi/16:2*pi;
a=cos(theta);
b=sin(theta);
c=a.*b;
if f>28
% bow tie
fill(1+[a flipud(a)],0.8*[c flipud(c)],'b')
end
if f>32
% nose
fill(1+[a flipud(a)]/8,[b flipud(b)]/8+0.5,'k')
end
if f>36
% hat
fill(1+[2*a flipud(2*a)]/1.5,[b flipud(b)]/2+2,'k')
fill(1+[2*a flipud(2*a)]/2,[b flipud(b)]/2+2.2,'b')
end
if f>40
% eyes
fill(1+[a flipud(a)]/5-0.7,[2*b flipud(2*b)]/5+1,'k')
fill(1+[a flipud(a)]/5+0.7,[2*b flipud(2*b)]/5+1,'k')
fill(1+[a flipud(a)]/10-0.6,[2*b flipud(2*b)]/10+1,'w')
fill(1+[a flipud(a)]/10+0.6,[2*b flipud(2*b)]/10+1,'w')
end
xlim([-0.5 2.5])
ylim([-0.5 2])
end
Animation
Remix Tree