Advertisement
here2share

# t_square_spiral.py

Aug 5th, 2020
1,360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. # t_square_spiral.py
  2.  
  3. import turtle
  4. t = turtle
  5.  
  6. colors = ['blue', 'green', 'yellow', 'orange', 'red']
  7.  
  8. def spiral(t, step, step_incr, angle):
  9.     color_ind = 0
  10.     colors_len = len(colors)
  11.     t.pencolor(colors[color_ind])
  12.     while True:
  13.         t.forward(step)
  14.         step = step + step_incr
  15.         if step > 500:
  16.             break
  17.         t.right(angle)
  18.         color_ind = (color_ind + 1) % colors_len
  19.         t.pencolor(colors[color_ind])
  20.  
  21.     t.hideturtle()
  22.  
  23. t.speed(0)
  24. spiral(t, 20, 5, 90.2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement