Skip to content

Instantly share code, notes, and snippets.

@kierendavies
Created May 21, 2013 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kierendavies/5621061 to your computer and use it in GitHub Desktop.
Save kierendavies/5621061 to your computer and use it in GitHub Desktop.
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