- /
-
Classic optical illusion
on 24 Nov 2023
- 19
- 30
- 0
- 2
- 544
drawframe(1);
Write your drawframe function below
function drawframe(f)
F1=figure('Color','w');
A1=axes(F1);
Nr=8;
Nc=7;
sq=cell(Nr,Nc);
C1=119/255*ones(1,3);
ops={'LineWidth',2.0,'Color',C1};
yline(A1,0,ops{:})
hold(A1,'on')
for i1 = 1:Nr
for i2 = 1:Nc
sq{i1,i2}=patch(A1,'XData',2*i2-[2,1,1,2],'YData',...
i1-[1,1,0,0],'FaceColor','k','EdgeColor',C1,...
'LineWidth',2.0);
end
yline(A1,i1,ops{:})
end
axis(A1,'equal')
set(A1,'XLim',[0,2*Nc],'YLim',[0,Nr],'Visible','off')
% A1.XAxis.Visible = 'off';
% A1.YAxis.Visible = 'off';
% maxS=0.7;
for i1 = 1:Nr
for i2 = 1:Nc
T1=0.7*f/48;
T2={'XData',2*i2-[2,1,1,2]+.5*T1}
if mod(i1,2)==0
set(sq{i1,i2},T2{:});
elseif mod(i1,4)==3
T2{2}=T2{2}+.5*T1
set(sq{i1,i2},T2{:});
end
end
end
end