Advertisement
GCK

GCK/ turtle_modern_art

GCK
Sep 19th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.37 KB | None | 0 0
  1. from random import *
  2. from turtle import *
  3.  
  4. tina=Turtle()
  5. tina.screen.colormode(255)
  6.  
  7. def randomcolour(name_turtle):
  8.     red=randint(0,255)
  9.     green=randint(0,255)
  10.     blue=randint(0,255)
  11.     name_turtle.color(red,green,blue)
  12.    
  13. def randomplace(name_turtle):
  14.     x=randint(-100,100)
  15.     y=randint(-100,100)
  16.     name_turtle.goto(x,y)
  17.  
  18. def randomsize_circle(name_turtle):
  19.     radius=randint(0,100)
  20.     name_turtle.dot(radius*2)
  21.    
  22. def base_rectangle(name_turtle,distance):
  23.     name_turtle.forward(distance)
  24.     name_turtle.right(90)
  25.    
  26. def drawrectangle(name_turtle):
  27.     name_turtle.penup()
  28.     randomcolour(name_turtle)
  29.     randomplace(name_turtle)
  30.     length=randint(10,100)
  31.     height=randint(10,100)
  32.     name_turtle.begin_fill()
  33.     base_rectangle(tina,length)
  34.     base_rectangle(tina,height)
  35.     base_rectangle(tina,length)
  36.     name_turtle.forward(height)
  37.     name_turtle.end_fill()
  38.     name_turtle.pendown()
  39.    
  40. def draw_circle_random(name_turtle):
  41.     name_turtle.penup()
  42.     randomcolour(name_turtle)
  43.     randomsize_circle(name_turtle)
  44.     pos_turtle=name_turtle.position()
  45.     print("original position> "+ str(pos_turtle))
  46.     randomplace(name_turtle)
  47.     print("new_position of "+ str(name_turtle) + " is " + str(name_turtle.position()))
  48.     name_turtle.pendown()
  49.  
  50.  
  51. for i in range(25):
  52.     draw_circle_random(tina)
  53.     drawrectangle(tina)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement