Back to index

python3.2  3.2.2
Public Member Functions
turtledemo.fractalcurves.CurvesTurtle Class Reference

List of all members.

Public Member Functions

def hilbert
def fractalgon
def fractal

Detailed Description

Definition at line 17 of file fractalcurves.py.


Member Function Documentation

def turtledemo.fractalcurves.CurvesTurtle.fractal (   self,
  dist,
  depth,
  dir 
)

Definition at line 66 of file fractalcurves.py.

00066 
00067     def fractal(self, dist, depth, dir):
00068         if depth < 1:
00069             self.fd(dist)
00070             return
00071         self.fractal(dist / 3, depth - 1, dir)
00072         self.lt(60 * dir)
00073         self.fractal(dist / 3, depth - 1, dir)
00074         self.rt(120 * dir)
00075         self.fractal(dist / 3, depth - 1, dir)
00076         self.lt(60 * dir)
00077         self.fractal(dist / 3, depth - 1, dir)

Here is the call graph for this function:

Here is the caller graph for this function:

def turtledemo.fractalcurves.CurvesTurtle.fractalgon (   self,
  n,
  rad,
  lev,
  dir 
)

Definition at line 47 of file fractalcurves.py.

00047 
00048     def fractalgon(self, n, rad, lev, dir):
00049         import math
00050 
00051         # if dir = 1 turn outward
00052         # if dir = -1 turn inward
00053         edge = 2 * rad * math.sin(math.pi / n)
00054         self.pu()
00055         self.fd(rad)
00056         self.pd()
00057         self.rt(180 - (90 * (n - 2) / n))
00058         for i in range(n):
00059             self.fractal(edge, lev, dir)
00060             self.rt(360 / n)
00061         self.lt(180 - (90 * (n - 2) / n))
00062         self.pu()
00063         self.bk(rad)
00064         self.pd()

Here is the call graph for this function:

def turtledemo.fractalcurves.CurvesTurtle.hilbert (   self,
  size,
  level,
  parity 
)

Definition at line 22 of file fractalcurves.py.

00022 
00023     def hilbert(self, size, level, parity):
00024         if level == 0:
00025             return
00026         # rotate and draw first subcurve with opposite parity to big curve
00027         self.left(parity * 90)
00028         self.hilbert(size, level - 1, -parity)
00029         # interface to and draw second subcurve with same parity as big curve
00030         self.forward(size)
00031         self.right(parity * 90)
00032         self.hilbert(size, level - 1, parity)
00033         # third subcurve
00034         self.forward(size)
00035         self.hilbert(size, level - 1, parity)
00036         # fourth subcurve
00037         self.right(parity * 90)
00038         self.forward(size)
00039         self.hilbert(size, level - 1, -parity)
00040         # a final turn is needed to make the turtle
00041         # end up facing outward from the large square
00042         self.left(parity * 90)

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: