The code below creates a fractal tree. I want to draw it as quick as possible -- I don't want any animation to occur, otherwise it takes a long time to draw. In earlier versions of python, this is achieved with turtle.speed(0), as shown below. This doesn't work in python 3.4
import turtle
import random
red = 125
green = 70
blue = 38
pen = 10
def tree(branchLen, t, red, green, blue, pen):
if branchLen > 3:
pen = pen*0.8
t.pensize(pen)
red = red - 15
green = green + 8
if branchLen > 5:
angle = random.randrange(10, 70)
angleTwo = 0.50*angle
sub = (0.8*(random.randrange(1,24)))
t.forward(branchLen)
t.right(angleTwo)
tree(branchLen-sub,t, red, green, blue, pen)
t.left(angle)
tree(branchLen-sub, t, red, green, blue, pen)
t.right(angleTwo)
t.backward(branchLen)
def main():
t = turtle.Turtle()
t.hideturtle()
t.speed(0)
myWin = turtle.Screen()
t.left(90)
t.up()
t.backward(170)
t.down()
tree(random.randrange(40,47),t,red,green,blue, pen)
myWin.exitonclick()
main()
It seems the speed module doesn't do anything in 3.4. No matter what number (0-10) used, it's always the same speed and doesn't display an error -- Meaning it still animates.
How can I achieve no animation with turtle in python 3.4? http://interactivepython.org/runestone/static/pythonds/Recursion/graphical.html This is a good place to run the code in Python 2, just replace one of the windows codes with mine.