forked from boyska/infissi
knotta!
This commit is contained in:
parent
2d14369d62
commit
5085cc104a
2 changed files with 40 additions and 0 deletions
35
knot.py
Normal file
35
knot.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
|
||||
class K(object):
|
||||
def __init__(self, s="FLFRFLFRFLFRFLFRFLFRFLF", i=1):
|
||||
self.kf = s
|
||||
self.i = i
|
||||
|
||||
def __xor__(self, o):
|
||||
return K(self.kf.replace("F", "FLFRFLF"), self.i+1)
|
||||
|
||||
def __nonzero__(self):
|
||||
import turtle
|
||||
k_ = turtle.Turtle()
|
||||
turtle.resetscreen()
|
||||
turtle.title("Iteration: %d" % self.i)
|
||||
k_.ht()
|
||||
turtle.setup(400, 400)
|
||||
k_.down()
|
||||
k_.speed('fastest')
|
||||
k_.penup()
|
||||
k_.goto(-150, 100)
|
||||
k_.pendown()
|
||||
for move in self.kf:
|
||||
if move == "F":
|
||||
k_.forward(100.0 / (3 ** (self.i - 1)))
|
||||
elif move == "L":
|
||||
k_.left(60)
|
||||
elif move == "R":
|
||||
k_.right(120)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
k = K()
|
||||
|
||||
|
5
knotta.py
Normal file
5
knotta.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from knoth import k
|
||||
not k ^ k
|
||||
#not k ^ k ^ k
|
||||
import turtle; turtle.done()
|
||||
|
Loading…
Reference in a new issue