• Remix
  • Share
  • New Entry

on 1 Dec 2023
  • 20
  • 122
  • 0
  • 4
  • 1968
drawframe(1);
Write your drawframe function below
function drawframe(f)
n=nan;
% resample
f = mod(ceil((f)/2)-1,12)+1;
% canvas
C=ones(69,124)*13;
% rainbow
r=([1;1;1]*(7:12));
r=r(:);
r1=28:45;r2=r1-1;
if mod(f,4)<2
r1=r2;r2=r1+1;
end
C(r1,[1:6,15:22,31:38,47:53])=repmat(r,[1,29]);
C(r2,[7:14,23:30,39:46])=repmat(r,[1,24]);
% stars
a=[2,4,2,0,0,3];
a=mod(a+f-1,6);
y=[-1,8,20,42,54,64];
x=[61,3,21,30,9,55];
x=x-(f-1)*7;
for i=1:6
C=p(C,x(i),y(i),s(a(i)));
C=p(C,x(i)+84,y(i),s(a(i)));
end
% tail (detail)
% z=nan(10,7);
% a=z;a(3:5,3:4)=1;a(5:6,5:7)=1;a([4,7],6:7)=0;a(3:4,[2,5])=0;
% a([22,25,32,36,46])=0;t{1}=a;t{5}=a;t{7}=a;t{11}=a;
% a(2,:)=n;a([4,5,15,26,56,65])=0;a([14,25])=1;t{4}=a;t{10}=a;
% a=z;a([12:11:67,13:11:46,31:11:64,41:11:63,11,21,66])=0;
% a([22:11:55,32:11:65])=1;t{6}=a;t{12}=a;
% a=z;a(7:8,3:6)=1;a(67)=1;a([6,9],4:6)=0;
% a([17,18,27,29,58,65,66,68])=0;t{2}=a;t{8}=a;
% a([17,59,56,66])=n;a([19,30,40,55])=0;a([29,39])=1;t{3}=a;t{9}=a;
% C=p(C,46,33,t{f});
% tail (simple)
z=nan(10,7);
a=z;a(3:5,3:4)=1;a(5:6,5:7)=1;a([4,7],6:7)=0;a(3:4,[2,5])=0;
a([22,25,32,36,46])=0;t{1}=a;t{6}=a;t{7}=a;t{12}=a;
a(2,:)=n;a([4,5,15,26,56,65])=0;a([14,25])=1;t{2}=a;t{5}=a;t{8}=a;t{11}=a;
a=z;a(7:8,3:6)=1;a(67)=1;a([6,9],4:6)=0;
a([17,18,27,29,58,65,66,68])=0;t{3}=a;t{4}=a;t{9}=a;t{10}=a;
C=p(C,46,33,t{f});
% foot
a=nan(3,6);a(:,2:5)=0;a(1:2,3:4)=1;a(6)=n;a(16)=0;
x=[6,7,6,4,4,6];x=[x,x]+50;x=x(f);
y=[3,4,4,4,4,3];y=[y,y]+40;y=y(f);
C=p(C,x,y,a);C=p(C,x+10,y,a);C=p(C,x+15,y,a);
a=zeros(5,4);a([1,2,6,20])=n;a(3:4,2:3)=1;a(18)=1;
C=p(C,x-4,y-2,a);
% body
a=zeros(18,21);a([1,2,18,19])=n;a(2:17,2:20)=4;a([20,35])=0;
a(3:16,3:19)=5;a([39,40,51,52,57,70])=4;a(:,21:-1:18)=a(:,1:4);
b=[66,77,87,100,140,152];a([b,b+143])=6;
y=ones(1,12);y([1,6,7,12])=0;y=y+26;
C=p(C,53,y(f),a);
% head
a=ones(13,16);a([1:5,11:14,25:26,39])=n;
a(1,5:9)=n;a(2,6:9)=n;a(3,7:9)=n;
a(6:9,1)=0;a(2:5,2)=0;a([10:14:52,40:14:82,27])=0;
a(13,5:9)=0;a(4,8:9)=0;a(:,16:-1:8)=a(:,1:9);
a(9:10,[3,4,14,15])=2;a(11,6:12)=0;a([75,114,153,125])=0;
a(7:8,[5,6,12,13])=0;a([59,150])=3;
x=[1,1,1,0,0,0];x=[x,x]+63;
y=[0,1,1,1,0,0];y=[y,y]+31;
C=p(C,x(f),y(f),a);
% color map
m=[0,0,0;164,164,164;248,176,165;254,254,254;
252,218,170;247,185,251;245,123,188;245,62,31;
250,167,52;254,238,71;89,216,58;19,154,248;
109,92,247;0,78,147]/255;
% draw
imshow(uint8(C),m);
end
function b=s(n)
x4=@(a) a([1:4,3:-1:1],[1:4,3:-1:1]);
z=nan(4);
a=z;a(16)=3;s{1}=x4(a);
a=z;a([12,15])=3;s{2}=x4(a);
a=z;a([8,12,14,15])=3;s{3}=x4(a);
a=z;a([4,8,13,14,16])=3;s{4}=x4(a);
a=z;a([4,6,13])=3;s{5}=x4(a);
a=z;a([4,13])=3;s{6}=x4(a);
b=s{n+1};
end
function Y=p(I,x,y,S)
Y=padarray(I,[84,84]);
a=y+83+(1:size(S,1));
b=x+83+(1:size(S,2));
Y_=Y(a,b);
i=~isnan(S);
Y_(i)=S(i);
Y(a,b)=Y_;
Y=Y(85:153,85:208);
end
Animation
Remix Tree