Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- draw rectangles of different sizes and shapes
- """
- from turtle import *
- from random import *
- colormode(255)
- def randomColor():
- red = (randint(0,255))
- green = (randint(0,255))
- blue = (randint(0,255))
- color(red, green, blue)
- def randomPlace():
- penup()
- x = (randint(-100, 100))
- y = (randint(-100, 100))
- goto(x,y)
- pendown()
- #random direction
- def randomHeading():
- dir = (randint(0,360))
- setheading(dir)
- def drawRectangle():
- randomColor()
- randomPlace()
- hideturtle()
- length = randint(1,100)
- height= randint(1,100)
- begin_fill()
- forward(length)
- right(90)
- forward(height)
- right(90)
- forward(length)
- right(90)
- forward(height)
- right(90)
- end_fill()
- for i in range(20):
- drawRectangle()
Advertisement
Add Comment
Please, Sign In to add comment