cristal_de_givre_fractal.py

Created by arthurmichel-scolaire

Created on October 14, 2025

646 Bytes

Ce dessin représente un flocon de neige fractal, généré par des fonctions récursives. Chaque branche principale se divise en branches secondaires, créant un motif cristallin complexe et symétrique. Les couleurs dégradées du bleu clair vers le blanc rappellent la pureté et la transparence de la glace, tandis que le fond sombre parsemé d’étoiles met en valeur le flocon comme suspendu dans la nuit hivernale. Ce rendu allie mathématiques et esthétique pour illustrer la beauté des structures fractales dans la nature.


from turtle import *
from kandinsky import fill_rect
from random import randint
speed(0);hideturtle()
fill_rect(0,0,320,240,(10,10,25))
for _ in range(80):
 x=randint(-150,150);y=randint(-110,110);b=randint(200,255);s=randint(1,2)
 fill_rect(max(0,160+x-s//2),max(0,120-y-s//2),s,s,(255,255,b))
def p(n,l):
 if n<=0 or l<2:return
 r=min(150+n*15,255);g=min(180+n*12,255);pencolor(r,g,255)
 pensize(max(1,int(n*1.2)));fd(l);lt(25);p(n-1,l*0.65);rt(50)
 p(n-1,l*0.65);lt(25)
 if n>2:rt(15);p(n-2,l*0.4);lt(15)
 bk(l)
def f(n,l,nb):
 for i in range(nb):p(n,l);rt(360/nb)
penup();goto(0,0);pendown();seth(90);f(6,45,6)

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.