Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # parameters
- from turtle import *
- from random import randint
- colormode(255) # needed as different colour mode used??
- tina = Turtle()
- def draw_circle(t_name, xpos, ypos, radius, col):
- t_name.goto(xpos, ypos)
- t_name.pendown() # order is important!!
- t_name.color(col) # set the colour first
- t_name.dot(radius*2)
- t_name.penup()
- def draw_rectangle(t_name, xpos, ypos, t_width, t_height, color):
- t_name.penup()
- t_name.goto(xpos,ypos)
- t_name.color("pink")
- t_name.pendown()
- t_name.begin_fill()
- t_name.forward(t_width)
- t_name.right(90)
- t_name.forward(t_height)
- t_name.right(90)
- t_name.forward(t_width)
- t_name.right(90)
- t_name.forward(t_height)
- t_name.right(90)
- t_name.end_fill()
- def randomcolour():
- red = randint(0,255)
- green = randint(0, 255)
- blue = randint(0, 255)
- color(red, green, blue)
- def randomplace():
- x = randint(-180, 180)
- y = randint(-180, 180)
- goto(x,y)
- def randomrect():
- height = randint(-50, 50)
- width = randint(-50, 50)
- penup()
- randomplace()
- randomcolour()
- pendown()
- begin_fill()
- forward(width)
- right(90)
- forward(height)
- right(90)
- forward(width)
- right(90)
- forward(height)
- right(90)
- end_fill()
- # tina.dot(100)
- draw_circle(tina, 20, 20, 160, "yellow")
- draw_circle(tina, -50, -60, 80, "blue")
- draw_circle(tina, 99, 99, 40, "green")
- draw_rectangle(tina, 50, -40, 100, 100, "grey")
- randomrect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement