• Remix
  • Share
  • New Entry

on 11 Nov 2023
  • 5
  • 81
  • 0
  • 1
  • 1033
drawframe(1);
Write your drawframe function below
function drawframe(f)
cla
f=49-f;
t=0.03+f/300;
a=[1 2 3 4];
b=[1 2 3];
c1=[0.53, 0.36, 0.02];
c2=[0.02, 0.53, 0.12];
% sky
patch('Faces',[1 2 3 4],'Vertices',[0 0; 1 0; 1 1; 0 1],'FaceColor',[0.53, 0.81, 0.98]);
hold on
% sun
plot(f/50,1.6*sin(t*pi),'.','markersize',100,'Color',[1, 0.8, 0])
% river
for i = 1:f-15
x=0:0.01:1;
y = cos(20*x*pi)/60+0.02*i+0.1;
line(x, y, 'Color', [0.12, 0.56, 1], 'LineWidth', 2);
end
% fish
j=0.9*(f-5)/100;
k=2*j;
patch('Faces',b,'Vertices',[0+k 0.1+j; 0.05+k 0.15+j; 0+k 0.2+j],'FaceColor','r');
patch('Faces',a,'Vertices',[0.05+k 0.15+j; 0.1+k 0.1+j; 0.15+k 0.15+j; 0.1+k 0.2+j],'FaceColor','r');
plot(0.12+k,0.15+j,'k.','markersize',8)
% tree
trunk={[0.2 0; 0.22 0; 0.22 0.1; 0.2 0.1],[0.4 0; 0.42 0; 0.42 0.1; 0.4 0.1],...
[0.6 0; 0.62 0; 0.62 0.1; 0.6 0.1],[0.8 0; 0.82 0; 0.82 0.1; 0.8 0.1]};
tree={[0.21-t 0.1; 0.21+t 0.1; 0.21 0.5],[0.41-t 0.1; 0.41+t 0.1; 0.41 0.5],...
[0.61-t 0.1; 0.61+t 0.1; 0.61 0.5],[0.81-t 0.1; 0.81+t 0.1; 0.81 0.5]};
for i=1:4
patch('Faces',a,'Vertices',trunk{i},'FaceColor',c1);
patch('Faces',b,'Vertices',tree{i},'FaceColor',c2);
end
xlim([0 1])
ylim([0 1])
axis off
end
Animation
Remix Tree