• Remix
  • Share
  • New Entry

on 12 Nov 2023
  • 12
  • 27
  • 1
  • 1
  • 920
drawframe(1);
Write your drawframe function below
function drawframe(f)
persistent pgon
if f == 1
vq = -1:2/12:1;
vqL = length(vq);
pgon = polyshape([vq ones(1,vqL-1) -vq(2:end) -ones(1,vqL-1)], ...
[ones(1,vqL) -vq(2:end) -ones(1,vqL-1) vq(2:end)],'KeepCollinearPoints', true);
% len = length(pgon.Vertices);
end
boxf = true;
len = 48;
col = [0.3020 0.7451 0.9333];
t=0:pi/50:2*pi;
a = sqrt(2)+0.05;
dth = 5;
l = f;
plot(a*cos(t), a*sin(t), 'r', LineWidth=2)
hold on
alpha = max(0.5 - abs((l+len/4)/len-1)*1.25, 0);
for th = 0:dth:45
r = rotate(pgon,th);
if boxf
if th==45
wid = 1.5;
boxCol = 'r';
else
wid = 0.7;
boxCol = 'b';
end
plot(r, EdgeColor=boxCol, EdgeAlpha=alpha, FaceColor='w', FaceAlpha=0, LineWidth=wid);
end
idx = mod(l + th/dth*2, len) + 1;
if (boxf && th==45)
p = plot(r.Vertices(idx,1), r.Vertices(idx,2), 'o', MarkerSize=10, ...
MarkerFaceColor= [col(1)+(1-col(1))*(alpha/0.7) col(2)*(1-alpha/0.7) col(3)*(1-alpha/0.7)]);
else
p = plot(r.Vertices(idx,1), r.Vertices(idx,2), 'o', MarkerSize=10, ...
MarkerFaceColor=col);
end
end
axis off
axis(gca,'equal')
hold off
end
Animation
Remix Tree