Advertisement
Fareehausman00

Artwork

Sep 21st, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #!/bin/python3
  2.  
  3. from turtle import *
  4. from random import *
  5.  
  6. def random_color():
  7. red = randint(0, 255)
  8. blue = randint(0, 255)
  9. green = randint (0, 255)
  10. color(red, blue, green)
  11.  
  12. def random_place():
  13. penup()
  14. x = randint (-100, 100)
  15. y = randint (-100, 100)
  16. goto(x, y)
  17. pendown()
  18.  
  19. def random_heading():
  20. setheading(randint (1, 360))
  21.  
  22. def draw_rectangle():
  23. random_color()
  24. random_place()
  25. hideturtle()
  26. length = randint(10, 100)
  27. height = randint (10, 100)
  28. begin_fill()
  29. forward(length)
  30. right(90)
  31. forward(height)
  32. right(90)
  33. forward(length)
  34. right(90)
  35. forward(height)
  36. right(90)
  37. end_fill()
  38.  
  39. def draw_triangle():
  40. random_color()
  41. random_place()
  42. hideturtle()
  43. length = randint (10, 100)
  44. height = randint (10, 100)
  45. begin_fill()
  46. forward(length)
  47. right(120)
  48. forward(length)
  49. right(120)
  50. forward(length)
  51. right(120)
  52. end_fill()
  53.  
  54. def draw_star():
  55. random_color()
  56. random_place()
  57. begin_fill()
  58. for side in range(5):
  59. left(144)
  60. forward(50)
  61. end_fill()
  62.  
  63.  
  64. shape("turtle")
  65. speed(7)
  66. random_color()
  67. random_place()
  68. random_heading()
  69. clear()
  70. setheading(0)
  71.  
  72. for i in range(20):
  73. draw_rectangle()
  74. draw_triangle()
  75. draw_star()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement