Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A dragon curve in pretty colours, produced by a floor turtle.
import turtle as t
from math import sin, pi, log
f = 1
l, r = True, False
t.reset()
t.speed(0)
t.hideturtle()
t.bgcolor(0, 0, 0)
i = 0
t.forward(f)
ds = [r]
while True:
if i >= len(ds):
ds += [r] + [not d for d in reversed(ds)]
h = log(i + 1)
t.pencolor((sin(h)+1)/2, (sin(h+(pi*2/3))+1)/2, (sin(h+(pi*4/3))+1)/2)
if ds[i] == l:
t.left(90)
else:
t.right(90)
t.forward(f)
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.