• Remix
  • Share
  • New Entry

on 30 Nov 2023
  • 6
  • 20
  • 0
  • 1
  • 678
drawframe(1);
Write your drawframe function below
function drawframe(f)
Ncols = 8;
Nrows = 8;
rng(floor(f/6)+1);
for row=0:Nrows
for col=0:Ncols
if mod(col,2) == mod(row,2)
N = 6 + 2*(rand>0.999999);
M = randi([3 5],1);
alpha = 2*pi/N;
R = @(a) [cos(a) -sin(a); sin(a) cos(a)];
xy = [0,0;0,0.5;cumsum(rand(M,2),1)/M*2];
s = randi([1 M],1);
SZ = randi([1 4]);
for i=1:randi([1 3])
xy2 = xy*R(alpha)/N*SZ/i+xy(s,:);
xy3 = xy*R(-alpha)/N*SZ/i+xy(s,:);
xy = [xy;NaN(1,2);xy2;NaN(1,2);xy3;NaN(1,2)];
end
xy = [xy;flipud(xy)*[-1 0;0 1]];
XY = [];
for i=1:N
XY = [XY; xy*R(alpha*(i-1)); NaN(1,2)];
end
XY = XY/max(abs(XY(:)))/2;
plot((XY(:,1)+col-1)/Ncols,(XY(:,2)+row-1)/Ncols,'w'); hold on;
end
end
end
axis equal off;
set(gca,'units','normalized','position',[0 0 1 1]);
set(gcf,'color','k');
hold off;
end
Animation
Remix Tree