Back to index

python3.2  3.2.2
Functions | Variables
turtledemo.penrose Namespace Reference

Functions

def kite
def dart
def inflatekite
def inflatedart
def draw
def sun
def star
def makeshapes
def start
def test
def demo
def main

Variables

tuple f = (5**0.5-1)
int d = 2
tuple msg = main()

Function Documentation

Definition at line 37 of file penrose.py.

00037 
00038 def dart(l):
00039     fl = f * l
00040     lt(36)
00041     fd(l)
00042     rt(144)
00043     fd(fl)
00044     lt(36)
00045     fd(fl)
00046     rt(144)
00047     fd(l)
00048     rt(144)

Here is the caller graph for this function:

def turtledemo.penrose.demo (   fun = sun)

Definition at line 154 of file penrose.py.

00154 
00155 def demo(fun=sun):
00156     start()
00157     for i in range(8):
00158         a = clock()
00159         test(300, i, fun)
00160         b = clock()
00161         t = b - a
00162         if t < 2:
00163             sleep(2 - t)

Here is the call graph for this function:

Here is the caller graph for this function:

def turtledemo.penrose.draw (   l,
  n,
  th = 2 
)

Definition at line 90 of file penrose.py.

00090 
00091 def draw(l, n, th=2):
00092     clear()
00093     l = l * f**n
00094     shapesize(l/100.0, l/100.0, th)
00095     for k in tiledict:
00096         h, x, y = k
00097         setpos(x, y)
00098         setheading(h)
00099         if tiledict[k]:
00100             shape("kite")
00101             color("black", (0, 0.75, 0))
00102         else:
00103             shape("dart")
00104             color("black", (0.75, 0, 0))
00105         stamp()

Here is the caller graph for this function:

def turtledemo.penrose.inflatedart (   l,
  n 
)

Definition at line 71 of file penrose.py.

00071 
00072 def inflatedart(l, n):
00073     if n == 0:
00074         px, py = pos()
00075         h, x, y = int(heading()), round(px,3), round(py,3)
00076         tiledict[(h,x,y)] = False
00077         return
00078     fl = f * l
00079     inflatekite(fl, n-1)
00080     lt(36)
00081     fd(l)
00082     rt(180)
00083     inflatedart(fl, n-1)
00084     lt(54)
00085     fd(l*d)
00086     rt(126)
00087     inflatedart(fl, n-1)
00088     fd(l)
00089     rt(144)

Here is the call graph for this function:

Here is the caller graph for this function:

def turtledemo.penrose.inflatekite (   l,
  n 
)

Definition at line 49 of file penrose.py.

00049 
00050 def inflatekite(l, n):
00051     if n == 0:
00052         px, py = pos()
00053         h, x, y = int(heading()), round(px,3), round(py,3)
00054         tiledict[(h,x,y)] = True
00055         return
00056     fl = f * l
00057     lt(36)
00058     inflatedart(fl, n-1)
00059     fd(l)
00060     rt(144)
00061     inflatekite(fl, n-1)
00062     lt(18)
00063     fd(l*d)
00064     rt(162)
00065     inflatekite(fl, n-1)
00066     lt(36)
00067     fd(l)
00068     rt(180)
00069     inflatedart(fl, n-1)
00070     lt(36)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 25 of file penrose.py.

00025 
00026 def kite(l):
00027     fl = f * l
00028     lt(36)
00029     fd(l)
00030     rt(108)
00031     fd(fl)
00032     rt(36)
00033     fd(fl)
00034     rt(108)
00035     fd(l)
00036     rt(144)

Here is the caller graph for this function:

Definition at line 164 of file penrose.py.

00164 
00165 def main():
00166     #title("Penrose-tiling with kites and darts.")
00167     mode("logo")
00168     bgcolor(0.3, 0.3, 0)
00169     demo(sun)
00170     sleep(2)
00171     demo(star)
00172     pencolor("black")
00173     goto(0,-200)
00174     pencolor(0.7,0.7,1)
00175     write("Please wait...",
00176           align="center", font=('Arial Black', 36, 'bold'))
00177     test(600, 8, startpos=(70, 117))
00178     return "Done"

Here is the call graph for this function:

Definition at line 116 of file penrose.py.

00116 
00117 def makeshapes():
00118     tracer(0)
00119     begin_poly()
00120     kite(100)
00121     end_poly()
00122     register_shape("kite", get_poly())
00123     begin_poly()
00124     dart(100)
00125     end_poly()
00126     register_shape("dart", get_poly())
00127     tracer(1)

Here is the call graph for this function:

Here is the caller graph for this function:

def turtledemo.penrose.star (   l,
  n 
)

Definition at line 111 of file penrose.py.

00111 
00112 def star(l,n):
00113     for i in range(5):
00114         inflatedart(l, n)
00115         lt(72)

Here is the call graph for this function:

Definition at line 128 of file penrose.py.

00128 
00129 def start():
00130     reset()
00131     ht()
00132     pu()
00133     makeshapes()
00134     resizemode("user")

Here is the call graph for this function:

Here is the caller graph for this function:

def turtledemo.penrose.sun (   l,
  n 
)

Definition at line 106 of file penrose.py.

00106 
00107 def sun(l, n):
00108     for i in range(5):
00109         inflatekite(l, n)
00110         lt(72)

Here is the call graph for this function:

def turtledemo.penrose.test (   l = 200,
  n = 4,
  fun = sun,
  startpos = (0,0,
  th = 2 
)

Definition at line 135 of file penrose.py.

00135 
00136 def test(l=200, n=4, fun=sun, startpos=(0,0), th=2):
00137     global tiledict
00138     goto(startpos)
00139     setheading(0)
00140     tiledict = {}
00141     a = clock()
00142     tracer(0)
00143     fun(l, n)
00144     b = clock()
00145     draw(l, n, th)
00146     tracer(1)
00147     c = clock()
00148     print("Calculation:   %7.4f s" % (b - a))
00149     print("Drawing:  %7.4f s" % (c - b))
00150     print("Together: %7.4f s" % (c - a))
00151     nk = len([x for x in tiledict if tiledict[x]])
00152     nd = len([x for x in tiledict if not tiledict[x]])
00153     print("%d kites and %d darts = %d pieces." % (nk, nd, nk+nd))

Here is the call graph for this function:


Variable Documentation

Definition at line 23 of file penrose.py.

tuple turtledemo.penrose.f = (5**0.5-1)

Definition at line 22 of file penrose.py.

Definition at line 180 of file penrose.py.