• Remix
  • Share
  • New Entry

on 16 Nov 2023
  • 36
  • 118
  • 1
  • 3
  • 1734
drawframe(1);
Write your drawframe function below
function drawframe(f)
cla;
tiledlayout(1,1,"Padding","none")
nexttile
q=[1 1];
fc='FaceColor';
cu='Curvature';
po='Position';
% star
rng(1)
s=10+2*randn(1,101);
plot(-10:0.2:10,s,'yp','MarkerFaceColor','y')
hold on
% moon
rectangle(po,[-9.5 12 1.5 1.5],cu,q,fc,'y','EdgeColor','y')
rectangle(po,[-9 12 1.3 1.3],cu,q,fc,[.09 .09 .71],'EdgeColor',[.09 .09 .71])
% color of traffic lights
if f<4
cg='r';
cy='k';
cr='k';
elseif f<8
cg='k';
cy='y';
cr='k';
elseif f<32
cg='k';
cy='k';
cr='g';
else
cg='r';
cy='k';
cr='k';
end
% traffic lights
rectangle(po,[-1 9.9 1.2 3.2],fc,'k')
rectangle(po,[-0.5 5 0.2 4.9],fc,'k')
rectangle(po,[-0.9 10 1 1],cu,q,fc,cr)
rectangle(po,[-0.9 11 1 1],cu,q,fc,cy)
rectangle(po,[-0.9 12 1 1],cu,q,fc,cg)
% stree sign
rectangle(po,[-9.4 8.9 3 0.8],fc,[.48 .04 .1],'EdgeColor',[.48 .04 .1])
rectangle(po,[-8 5 0.2 3.9],fc,[.48 .04 .1])
text(-9.4,9.3,'\bf MATropolis','fontsize',4.5,'Color','w')
% road
rectangle(po,[-10 0 20 5],fc,[.5 .5 .5])
% crosswalk
for i=1:9
rectangle(po,[-2 0.5*i-0.1 3 0.25],fc,'w')
end
% blood
if f>6
plot([-0.5 0 0.1],[2.1 2.1 2.5],'r.','markersize',50)
end
% car
if f<=6
t=f-1;
elseif f>6 && f<32
t=6;
else
t=f-32+6;
end
patch('Faces',1:7,'Vertices',[-10+t 2;-6.8+t 2;-7.2+t 3; -7.6+t 3; -8+t 4; -10+t 4;-10+t 2],fc,'k');
patch('Faces',1:4,'Vertices',[-8.5+t 3.2;-8+t 3.2;-8.2+t 3.7;-8.5+t 3.7],fc,'y');
rectangle(po,[-8.3+t 1.6 1 1],cu,q,fc,'y')
rectangle(po,[-9.8+t 1.6 1 1],cu,q,fc,'y')
rectangle(po,[-8.05+t 1.85 0.5 0.5],cu,q,fc,'k')
rectangle(po,[-9.55+t 1.85 0.5 0.5],cu,q,fc,'k')
hold on
% kid
if f<=6
y=f*5.5/10;
x=0;
z=0;
elseif f>6
y=f*6/25;
x=f*5.5/25;
z=(-1+(-1).^f)/2;
end
rectangle(po,[-1+x 0+y+z 0.5 0.5],cu,q,fc,[.64 .08 .18])
plot([-1.5+x -0.75+x 0+x],[-0.75+y 0+y+z -0.75+y],'-','linewidth',2,'color',[.93 .69 .13]);
plot([-0.5+x -0.5+x -1+x -1+x],[-1+y -0.4+y+z -0.4+y+z -1+y],'c-','linewidth',4);
xticklabels([])
yticklabels([])
axis equal
axis([-10 10 -1 14])
box on
set(gca,'Color',[.09 .09 .71])
end
Animation
Remix Tree