On 2005-03-27, Joal Heagney <[EMAIL PROTECTED]> wrote: > Couldn't help myself. I had to write the Dragon Fractal in python.turtle >:) >
That's nice. I ported it to use the pygsear Turtle class. http://www.nongnu.org/pygsear/ --- Dragon.py 2005-03-27 08:48:13.000000000 -0500 +++ pDragon.py 2005-03-27 16:33:48.000000000 -0500 @@ -1,9 +1,14 @@ """Generates the L-System for the Dragon Fractal, using -the turtle module.""" +the pygsear.Drawable.Turtle class.""" -import re, turtle +import re +#import turtle +from pygsear.Drawable import Turtle from math import sin, pi +turtle = Turtle() +#turtle.visible = False + """The default L-System rules for the dragon fractal are: Angle 45 degrees Starting Axiom FX @@ -65,7 +70,7 @@ red = 1.0 green = 0.0 blue = 1.0 - fract - return red, green, blue + return red*255, green*255, blue*255 # The default is that the turtle will only move one pixel def parser(parsestring, distance=1, angle=45): @@ -73,13 +78,14 @@ newstring = re.sub("X", "", parsestring) newstring = re.sub("Y", "", newstring) # Clear the screen - turtle.clear() + #turtle.clear() strlen = len(newstring) colorinc = 1.0 / float(strlen) - turtle.color(colorator(0)) + turtle.set_color(colorator(0)) for i in range(strlen): value = newstring[i] - turtle.color(colorator(float(i) * colorinc)) + color = colorator(float(i) * colorinc) + turtle.set_color(color) if value == "+": turtle.right(angle) elif value == "-": @@ -87,7 +93,7 @@ elif value == "F": turtle.forward(distance) # Hide the cursor - turtle.color(1.0,1.0,1.0) + turtle.uclear() def run(count=15, distance=1, angle=45, width=1): string = "FX" @@ -96,14 +102,15 @@ count -= 1 # "Hide" the cursor while we are moving it. ## print string - turtle.width(width) - turtle.color(1.0,1.0,1.0) + turtle.set_width(width) + #turtle.color(1.0,1.0,1.0) # Move the cursor so the turtle won't go off the screen. # You might want to resize the turtle screen while the program is doing this - turtle.setx(100) - turtle.sety(-200) + #turtle.setx(100) + #turtle.sety(-200) parser(string, distance=distance, angle=angle) if __name__ == "__main__": run(15) + raw_input() -- http://mail.python.org/mailman/listinfo/python-list