Python and Turtle Difficulty Level 10,math,recursion Spiral of Spirals Fractals 2 with Python Turtle (Source Code)

Spiral of Spirals Fractals 2 with Python Turtle (Source Code)

Modify spiral of spirals such that the direction of sub spirals start from almost the opposite direction to the current spiral.

Spiral of Spirals Fractal

Source Code: (This code may run a few minutes)

import turtle

screen = turtle.Screen()
screen.title('Spiral of Spirals Fractal - PythonTurtle.Academy')
screen.setup(1000,1000)
screen.setworldcoordinates(-1000,-1000,1000,1000)
turtle.speed(0)
turtle.hideturtle()
screen.tracer(0,0)

def draw_spiral(x,y,length,direction):
    L = length
    c = 0
    while length>1 or c<20:
        if length>2:
            draw_spiral(x,y,length*0.255,160+direction)
        turtle.up()
        turtle.seth(direction)
        turtle.goto(x,y)
        if length <= 2: turtle.down()
        turtle.fd(length)
        x,y = turtle.xcor(), turtle.ycor()
        length *= 0.93
        direction += 20
        c += 1

draw_spiral(500,-500,300,90)
screen.update()
ts=turtle.getscreen()
ts.getcanvas().postscript(file = "spiral.eps")

Related Post