# ShowRect.py """ Illustrates the procedure DrawRect. """ from simpleGraphics import * from math import sqrt # Create a figure with a plot window that displays # the region -6<=x<=6, -6<=y<=6 MakeWindow(6, bgcolor=WHITE) # Draw six nested squares. DrawRect(0,0,9,9,color=MAGENTA,stroke=10) DrawRect(0,0,7,7,color=CYAN,stroke=8) DrawRect(0,0,5,5,color=YELLOW,stroke=6) DrawRect(0,0,3,3,color=PURPLE,stroke=4) DrawRect(0,0,1,1,stroke=5) MakeWindow(6, labels=False, bgcolor=WHITE) # Draw six nested squares with rotation. # The "next" radius is the current radius divided by sqrt(2) r = 10 DrawRect(0,0,r,r,color=MAGENTA,stroke=3) r = r/sqrt(2) DrawRect(0,0,r,r,color=CYAN,stroke=3,rotate=45) r = r/sqrt(2) DrawRect(0,0,r,r,color=YELLOW,stroke=3) r = r/sqrt(2) DrawRect(0,0,r,r,color=PURPLE,stroke=3,rotate=45) r = r/sqrt(2) DrawRect(0,0,r,r,color=GREEN,stroke=3) r = r/sqrt(2) DrawRect(0,0,r,r,color=None,stroke=3,rotate=45) ShowWindow()