• Remix
  • Share
  • New Entry

on 3 Dec 2023
  • 13
  • 93
  • 0
  • 4
  • 1843
drawframe(1);
Write your drawframe function below
function drawframe(n)
persistent Z imgHdl
if n==1
ax=gca;hold on;axis off;
ax.DataAspectRatio=[1,1,1];
ax.YDir='reverse';
axis([0,100,0,100]);
[X,Y]=meshgrid(linspace(0,1,200));
Z=sqrt((X-.5).^2+(Y-.5).^2).*2.*pi;
imgHdl=image([0,100],[0,100],(sin(Z-pi*n/20).*0.8).^2*420);
colormap(summer)
% 配色及基础数据 ===========================================================
C=[255,255,255; 83, 70, 63;
158,158,157; 254,201,206;
246,213,85 ; 253,247,197]./255;
T=linspace(0,2*pi,200);
LW='LineWidth';EN={'EdgeColor','none'};E2={'EdgeColor',C(2,:)};
% 绘制叉子 =================================================================
plot([85,91.3],[24.8,52.8],'Color',C(2,:),LW,6)
plot([80,82,92.5,90.7],[28,34.3,31,25.2],'Color',C(2,:),LW,6)
% 绘制身体 =================================================================
fill([19.3,15.1,12.7,10,8.9,9.6,linspace(10,90,200),91.3,92.4,91.3,88.4,84.1,77],...
[43.4,54.7,63.2,72.6,79,82,-linspace(-1.5,1.5,200).^2+3.*sin(linspace(0,7*pi,200))+85,...
80.9,76.6,71.5,64.2,54.5,39.2],C(1,:),LW,6,E2{:})
fill([24,cos(T(80:200)).*3.5+16],...
[60,sin(T(80:200)).*4.1+46],...
C(1,:),LW,6,E2{:})
fill([76,cos(T([100:200,1:40])).*3.5+82],...
[55,sin(T([100:200,1:40])).*4.5+43.5],...
C(1,:),LW,6,E2{:})
fill(cos(T).*30+49.5,sin(T).*30+47.5,C(1,:),LW,6,'EdgeColor',C(1,:))
plot(cos(T(100:195)).*30+49.5,sin(T(100:195)).*30+47.5,'Color',C(2,:),LW,6)
fill([42.8,41.3,40,38.6,37.4,36.8,36],[19,16.6,14.3,13.3,15.1,17.8,20.6],C(3,:),LW,6,EN{:})
plot([42.8,41.3,40,38.6,37.4,36.8,36],[19,16.6,14.3,13.3,15.1,17.8,20.6],'Color',C(2,:),LW,6)
fill([61.7,61.3,60.3,59,57.5,56.1,54.7,52],[20,18.6,16.3,14.3,13.4,15.5,17.2,17.5],C(3,:),LW,6,EN{:})
plot([61.7,61.3,60.3,59,57.5,56.1,54.7,52],[20,18.6,16.3,14.3,13.4,15.5,17.2,17.5],'Color',C(2,:),LW,6)
% 绘制五官 =================================================================
fill(cos(T).*6.2+33.7,sin(T).*5.9+42.5,C(4,:),EN{:})
fill(cos(T).*6.2+62.1,sin(T).*5.9+39.7,C(4,:),EN{:})
fill(cos(T).*2.2+39.1,sin(T).*2.8+37.8,C(2,:),EN{:})
fill(cos(T).*2.2+56.3,sin(T).*2.8+35.9,C(2,:),EN{:})
fill(cos(T).*1.1+51,sin(T).*1.2+39.3,C(2,:),EN{:})
plot([43.7,45.7,48,50,51.7],[39.1,39.7,39.5,38.8,38.1],'Color',C(2,:),LW,2)
end
imgHdl.CData=(sin(Z-pi*n/20).*0.8).^2*420;
end
Animation
Remix Tree