% Script moreNestedStars
% Draw a sequence of *a sequence of nested stars*!

close all
figure
axis equal
axis([-1 9 -1 9])
hold on

% Center of each figure in the sequence is (0,0),(2,2),...,(8,8)
for x = 0:2:8

y = x;

% Draw background: s-by-s black square centered at (x,y)
s = 2.1;
DrawRect(x-s/2,y-s/2,s,s,'k')

% Sequence of stars...
% The radius of the kth star is stored in r...
r = 1; k = 1; rSmallest=.1;
rScale= .8; % Scaling for radius of each subsequent star
while r >= rSmallest
% Draw kth star
if rem(k,2)==1
% Odd-indexed stars are magenta...
DrawStar(x,y,r,'m')
else
% Even indexed stars are yellow...
DrawStar(x,y,r,'y')
end
% Updates for next iteration
r = r*rScale;
k = k+1;
end

end

hold off
shg