2 """ xturtle-example-suite:
6 Constructs two aperiodic penrose-tilings,
7 consisting of kites and darts, by the method
8 of inflation in six steps.
10 Starting points are the patterns "sun"
11 consisting of five kites and "star"
12 consisting of five darts.
14 For more information see:
15 http://en.wikipedia.org/wiki/Penrose_tiling
16 -------------------------------------------
19 from math
import cos
, pi
20 from time
import clock
, sleep
22 f
= (5**0.5-1)/2.0 # (sqrt(5)-1)/2 -- golden ratio
49 def inflatekite(l
, n
):
52 h
, x
, y
= int(heading()), round(px
,3), round(py
,3)
53 tiledict
[(h
,x
,y
)] = True
71 def inflatedart(l
, n
):
74 h
, x
, y
= int(heading()), round(px
,3), round(py
,3)
75 tiledict
[(h
,x
,y
)] = False
93 shapesize(l
/100.0, l
/100.0, th
)
100 color("black", (0, 0.75, 0))
103 color("black", (0.75, 0, 0))
121 register_shape("kite", get_poly())
125 register_shape("dart", get_poly())
135 def test(l
=200, n
=4, fun
=sun
, startpos
=(0,0), th
=2):
147 print "Calculation: %7.4f s" % (b
- a
)
148 print "Drawing: %7.4f s" % (c
- b
)
149 print "Together: %7.4f s" % (c
- a
)
150 nk
= len([x
for x
in tiledict
if tiledict
[x
]])
151 nd
= len([x
for x
in tiledict
if not tiledict
[x
]])
152 print "%d kites and %d darts = %d pieces." % (nk
, nd
, nk
+nd
)
165 #title("Penrose-tiling with kites and darts.")
174 write("Please wait...",
175 align
="center", font
=('Arial Black', 36, 'bold'))
176 test(600, 8, startpos
=(70, 117))
179 if __name__
== "__main__":