function DrawFlower(r,n,backPetalColor,frontPetalColor, diskColor)
% In the current figure window this function draws a unit radius flower
% with n petals fiwhere n is an even integer >= 4.
% The inner radius is specied by r and 0<r<1.
% The back petal color, front petal color, and inner disk color are
% specified by backPetalColor, frontPetalColor, and diskColor. Valid
% colors are 'k', 'y', 'c', 'm', 'r', 'b', 'w', 'g'.

theta = linspace(2*pi/n,2*pi,n);
xP = r*cos(theta);
yP = r*sin(theta);
xQ = cos(theta);
yQ = sin(theta);
% Draw the back petals...
for k=1:2:n
% Determine the xy coordinates of the kth petal...
if k==1
xPetal = [xQ(1) xP(n) xP(2)];
yPetal = [yQ(1) yP(n) yP(2)];
else
xPetal = [xQ(k) xP(k-1) xP(k+1)];
yPetal = [yQ(k) yP(k-1) yP(k+1)];
end
fill(xPetal,yPetal,backPetalColor)
end
% Draw the front petals...
for k=2:2:n
% Determine the xy coordinates of the kth petal...
if k==n
xPetal = [xQ(n) xP(n-1) xP(1)];
yPetal = [yQ(n) yP(n-1) yP(1)];
else
xPetal = [xQ(k) xP(k-1) xP(k+1)];
yPetal = [yQ(k) yP(k-1) yP(k+1)];
end
fill(xPetal,yPetal,frontPetalColor)
end
DrawDisk(0,0,r,diskColor)
title(sprintf('DrawFlower(%1d,%5.2f,''%s'',''%s'',''%s'')',...
n,r,backPetalColor,frontPetalColor,diskColor'),'fontsize',14)