Created
November 15, 2010 16:33
-
-
Save dpritchett/700558 to your computer and use it in GitHub Desktop.
Draw a polygon with an arbitrary number of sides using turtle graphics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turtle | |
def drawPolygon(sides, fillcolor='DarkOliveGreen'): | |
init pen | |
turtle.reset() | |
turtle.fillcolor(fillcolor) | |
turtle.fill(True) | |
#draw a shape | |
degree = 360.0 / sides | |
for i in range(sides): | |
turtle.right(degree) | |
turtle.forward(degree) | |
turtle.fill(False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment