spirales_enchantes.py

Created by cent20

Created on December 19, 2021

1.66 KB


# Auteur : Aël D.
# Réalisé par un de mes élèves de seconde 
# dans le cadre d'un DM "Les mathématiques sont belles"
# https://twitter.com/nsi_xyz/status/1380526928671674373

from math import *
from turtle import *
from random import *


speed(10)
hideturtle()

def spirale(a,xS,yS,longr,nbr,clr):
  penup()
  goto(xS,yS)
  pendown()
  for f in range (2500):
    x=randint(0,255)
    pencolor(f/clr,x,clr)
    setheading(f+nbr*a)
    forward(f/longr)
  penup()
  goto(xS,yS)
  pendown()
  
  
def lignes(xL,yL,dis,ran1,ran2):
  penup()
  goto(xL,yL)
  pendown()
  setheading(90)
  for l in range(ran1,ran2):
    x=randint(0,255)
    color(210,210,210)
    setheading(8*l)
    forward(dis)
    goto(xL,yL)

def clean(C,xC,yC,longrC,nbrC):
  penup()
  goto(xC,yC)
  pendown()
  pensize(2)
  for f in range (2500):
    pencolor(255,255,255)
    setheading(f+nbrC*C)
    forward(f/longrC)
  penup()
  goto(xC,yC)
  pendown()
    
def autres():
  pensize(2)
  clean(1,-100,100,3000,288)
  clean(1,-100,-100,3000,288)
  clean(1,100,100,3000,288)
  clean(1,100,-100,3000,288)
  pensize(1)
  for g5 in range(3): 
   spirale(g5,-150,0,3000,288,13)
  for g6 in range(3): 
   spirale(g6,150,0,3000,288,14)
  for g7 in range(3): 
   spirale(g7,0,-150,3000,288,15)
  for g8 in range(3): 
   spirale(g8,0,150,3000,288,16)
   

def principal():
  pensize(2)
  for g in range(6):
    spirale(g,0,0,1500,72,10)
  pensize(1)

pensize(1)  
lignes(0,0,200,0,45)
lignes(-100,-100,350,0,24)
lignes(-100,100,350,23,46)
lignes(100,-100,350,0,24)
lignes(100,100,350,23,46)
pensize(10)
for c in range (6):
  clean(c,0,0,1500,72)
principal()
penup()
goto(-100,-100)
pendown()
pensize(1)
autres()

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.