JkSoftware

Day 18 - Dot Picture

Nov 30th, 2021
663
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from turtle import Turtle, Screen
  2. import turtle as t
  3. import random
  4.  
  5. t.colormode(255)
  6. timmy = Turtle()
  7. timmy.penup()
  8. timmy.hideturtle()
  9. timmy.speed(0)
  10.  
  11. rgb_colors = [(202, 164, 109), (238, 240, 245), (150, 75, 49), (223, 201, 135), (52, 93, 124), (172, 154, 40),
  12.               (140, 30, 19), (133, 163, 185), (198, 91, 71), (46, 122, 86), (72, 43, 35), (145, 178, 148),
  13.               (13, 99, 71), (233, 175, 164), (161, 142, 158), (105, 74, 77), (55, 46, 50), (183, 205, 171),
  14.               (36, 60, 74), (18, 86, 90), (81, 148, 129), (148, 17, 20), (14, 70, 64), (30, 68, 100), (107, 127, 153),
  15.               (174, 94, 97), (176, 192, 209)]
  16. timmy.setheading(225)
  17. timmy.forward(350)
  18. timmy.setheading(0)
  19. number_of_dots = 100
  20.  
  21.  
  22. for dot_count in range(1, number_of_dots + 1):
  23.     timmy.dot(20, random.choice(rgb_colors))
  24.     timmy.forward(50)
  25.  
  26.     if dot_count % 10 == 0:
  27.         timmy.setheading(90)
  28.         timmy.forward(50)
  29.         timmy.setheading(180)
  30.         timmy.forward(500)
  31.         timmy.setheading(0)
  32.  
  33. screen = Screen()
  34. screen.exitonclick()
RAW Paste Data