drawing_with_fractals.py

Created by lorem-ipsum-42

Created on November 07, 2021

1.33 KB

Inspiré d’un tableau japonais… Avec les fractales de la magnifique “Courbe du Dragon” et de la “Courbe de Lévy”.


from turtle import *
from kandinsky import fill_rect

hideturtle()
x, y, length = -60, 0, 1
fill_rect(0,0, 320, 222, (105, 105, 105))
penup()
goto(x, y)
pendown()
speed(0)
pensize(1)

def dragon(etape, orientation=90): #etape = nombres d’étapes nécessaires pour faire la fractale
    if etape == 0: #si on a fini de parcourir toutes les étapes
        forward(length)
    else:
        dragon(etape - 1, 90)
        left(orientation)
        dragon(etape - 1, -90)

color(35, 100, 170); dragon(13)

left(90); color(15, 8, 75); dragon(13)

left(-90); color(136, 183, 181); dragon(13)

left(90); color(35, 100, 170); dragon(13)

left(90); penup(); goto(4, 64); pendown(); color(245, 236, 244); dragon(12)
left(90);dragon(10)
left(90);dragon(11)

x, y, length = 115, -65, 0.5
penup(); left(-90); goto(x, y); pendown(); color(63, 193, 32)

def c_levy(etape): #etape = nombres d’étapes nécessaires pour faire la fractale (+ il y en a, + grande et varié elle est)
    if etape == 0: #si on a fini de parcourir toutes les étapes
        forward(length)
    else:
        left(-45)
        color(63, 193, 32)
        c_levy(etape - 1)
        left(90)
        color(255, 77, 126)
        c_levy(etape - 1)
        left(-45)
        
c_levy(14); penup(); goto(91,-57); pendown()
length = 0.5
left(-135); color(88, 38, 0); dragon(13)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.