-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDragon.py
31 lines (27 loc) · 824 Bytes
/
Dragon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import turtle
from math import sin,pi
window = turtle.Screen()
dragon = turtle.Turtle()
dragon.ht()
dragon.speed(0)
turtle.colormode(255)
#If the dragon goes off the screen, this can help
#dragon.up()
#dragon.right(90)
#dragon.forward(150)
#dragon.right(-90)
#dragon.down()
length = 1 #Increasing this will make lines
iterations = 15 #This will change how many chunks there are and it determins the size
turns = 2**iterations
for i in range(turns):
red = max(min(int(256*1.5*sin((i/turns+1/4)*2*pi)+256/2),255),0)
green = max(min(int(256*1.5*sin((i/turns+1/4+1/3)*2*pi)+256/2),255),0)
blue = max(min(int(256*1.5*sin((i/turns+1/4+2/3)*2*pi)+256/2),255),0)
dragon.color(red, green, blue)
j=i+1
while j%2 == 0:
j=j/2
dragon.right((j%4)*90)
dragon.forward(length)
window.exitonclick()