Julia Set with Different Parameters

In this project, we are generate several Julia Sets by varying the constant c in the normal Julia Set function. Turtle will be too slow to do this work. Instead we are going to use the PIL library. Please check out Julia Set Animation project for source code.

c = -0.618 (Max Iteration=38)
c = 0.355534-0.337292i (Max Iteration=4064)
c = 0.355+0.355i (Max Iteration=512)
c = 0.285+0.01i (Max Iteration=204)
c = -0.8+0.156i (Max Iteration=924)
c = -0.835+0.2321i (Max Iteration=104)
c = 0.7269+0.1889i (Max Iteration=1024)

Related Projects:

Zooming 10^13 Times into Julia Set Animation

Julia Set Fractal Animation

Colored Pentaflake Fractal (Source Code)

Based on petaflake fractal, color it with colorsys library.

Colored Pentaflake Fractal

Source Code:

import turtle
import math
import colorsys

screen = turtle.Screen()
screen.title('Pentaflake Fractal Colored - PythonTurtle.Academy')
screen.setup(1000,1000)
screen.setworldcoordinates(-1000,-1000,1000,1000)
turtle.speed(0)
turtle.hideturtle()
screen.tracer(0,0)
turtle.fillcolor('dark cyan')

def pentagon(x,y,r,direction): #x,y is the center
    turtle.up()
    turtle.goto(x,y)
    turtle.seth(direction)
    turtle.fd(r)
    turtle.left(126)
    turtle.down()
    c = colorsys.hsv_to_rgb((x+1000)/2000,1,0.7)
    turtle.color(c)
    turtle.begin_fill()
    for _ in range(5):
        turtle.fd(2*r*math.sin(math.radians(36)))
        turtle.left(72)
    turtle.end_fill()
    
def pentaflake(x,y,r,direction,n):
    if n==0:
        pentagon(x,y,r,direction)
        return

    r2 = r/(1+2*math.cos(math.radians(36)))
    d = 2*r2*math.cos(math.radians(36))
    for _ in range(5):
        x2,y2 = x+d*math.cos(math.radians(direction)),y+d*math.sin(math.radians(direction))
        pentaflake(x2,y2,r2,direction,n-1)
        direction += 72
    pentaflake(x,y,r2,direction+180,n-1)
    
pentaflake(0,0,1000,90,6)
screen.update()

Colored Spiral of Spirals with Python Turtle (Source Code)

Just for fun, draw a colored version of spiral of spirals using the colorsys library.

Colored Spiral of Spirals
Colored Spiral of Spirals

Source Code: (This may a few minutes)

import turtle
import colorsys

screen = turtle.Screen()
screen.title('Colored 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
    color=colorsys.hsv_to_rgb((y+900)/1800,1,0.8)
    turtle.color(color)
    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
LL=300
draw_spiral(500,-500,LL,90)
screen.update()
ts=turtle.getscreen()
ts.getcanvas().postscript(file = "spiral.eps")

Colored Square Spiral in a Square (Source Code)

In a previous project, we draw a 5 degree square spiral in a square. Use the colosys library to fill the square with gradually changing hues. Also, reduce the tilting degree from 5 degrees to 0.1 degree to see smooth change in color. If you use recursion make sure you increase the maximum recursion depth with sys.setrecursionlimit() function.

Colored Square Spiral

Source Code:

import turtle
import math
import colorsys
import sys

screen = turtle.Screen()
screen.title('5 Degree Square Spiral in a Square - PythonTurtle.Academy')
screen.setup(1000,1000)
screen.setworldcoordinates(-1000,-1000,1000,1000)
screen.tracer(0,0)
turtle.speed(0)
turtle.hideturtle()
sys.setrecursionlimit(10000)

def draw_square(x,y,direction,length):
    turtle.up()
    turtle.goto(x,y)
    turtle.seth(direction)
    turtle.back(length/2)
    turtle.left(90)
    turtle.back(length/2)
    turtle.seth(direction)
    turtle.down()
    c = colorsys.hsv_to_rgb(0.9*length/L,1,1)
    turtle.fillcolor(c)
    c = colorsys.hsv_to_rgb(0.9*length/L,1,1)
    turtle.pencolor(c)
    turtle.begin_fill()
    for _ in range(4):
        turtle.fd(length)
        turtle.left(90)
    turtle.end_fill()

def square_spiral(x,y,direction,length):
    if length < 5: return
    
    draw_square(x,y,direction,length)
    square_spiral(x,y,direction+alpha,length/(math.sin(math.radians(alpha)) + math.cos(math.radians(alpha))))


alpha=0.1
L=1600
square_spiral(0,0,0,L)
screen.update()

Chase the Cycler Simulation (with Source Code)

In a previous project called massive chasing game, you simulated a game where you created 100 turtles and each turtle chase the next one and the last turtle chase the first one.

In this project, instead of making the last turtle chase the first one, make it move on a circle forever. It will create an interesting animation shown above.

Source Code:

import turtle
import random
import colorsys

screen = turtle.Screen()
screen.tracer(0,0)
screen.setup(1000,1000)
screen.title('Chase the Cycler - PythonTurtle.Academy')
turtle.hideturtle()

n=200
chasers = []
for i in range(n):
    chasers.append(turtle.Turtle())

h = 0
for i in range(n):
    c = colorsys.hsv_to_rgb(h,1,0.8)
    h += 1/n
    chasers[i].color(c)
    chasers[i].up()
    chasers[i].goto(random.uniform(-500,500), random.uniform(-500,500))
chasers[n-1].goto(0,-300)
chasers[n-1].shape('circle')
chasers[n-1].shapesize(1)

def chase():
    for i in range(n-1):
        angle = chasers[i].towards(chasers[i+1])
        chasers[i].seth(angle)
    chasers[n-1].left(2)
    chasers[n-1].fd(10)
    for i in range(n-1):
        chasers[i].fd(10)
    screen.update()
    screen.ontimer(chase,1000//20)
    
chase()

Game of Snake with Python Turtle

Develop a Game of Snake with Python Turtle with multiple difficulty levels.

You may need to use features or libraries: List, Random, Keyboard Event, Timer Event, Colorsys.

Game of Snake with Python Turtle