Advertisement
tokyoedtech

Python Lines Demo

Jun 20th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. # Lines Demo
  2. # By @TokyoEdTech
  3.  
  4. import turtle
  5. import random
  6. import time
  7.  
  8. wn = turtle.Screen()
  9. wn.title("Lines Demo")
  10. wn.bgcolor("black")
  11. wn.setup (width=400, height=400)
  12. wn.tracer(0)
  13.  
  14. pen = turtle.Turtle()
  15. pen.speed(0)
  16. pen.hideturtle()
  17. pen.color("yellow")
  18. pen.width(3)
  19.  
  20. colors = ["red", "orange", "green", "blue", "purple"]
  21.  
  22. def draw_line(pen, x1, y1, x2, y2):
  23.     pen.penup()
  24.     pen.goto(x1, y1)
  25.     pen.pendown()
  26.     pen.goto(x2, y2)
  27.     pen.color(random.choice(colors))
  28.  
  29. while True:
  30.     for x1 in range(-200, 200, 4):
  31.         for y1 in range(-200, 200, 4):
  32.             draw_line(pen, x1, y1, 0, 0)
  33.             wn.update()
  34.             if y1 % 20 == 0:
  35.                 pen.clear()
  36.  
  37.     for x1 in range(200, -200, -4):
  38.         for y1 in range(200, -200, -4):
  39.             draw_line(pen, x1, y1, 0, 0)
  40.             wn.update()
  41.             if y1 % 20 == 0:
  42.                 pen.clear()
  43.  
  44.  
  45.  
  46. wn.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement