feuille.py

Created by schraf

Created on April 10, 2023

490 Bytes

L’idée est de générer un dégradé entre 2 couleurs (Tweet de Vincent Robert) de façon plus organique. Ma première version est ce pinceau et la seconde cette sorte de feuille vue en transparence.

Les scripts sont longs à s’exécuter !


from turtle import *
from random import *

dep = -190
c1, c2 = (130,220,110), (40,77,30)
rvb = [0,0,0]
speed(0)
pensize(3)

def T(u,a1,a2,b1,b2): return int((b2-b1)/(a2-a1)*(u-a1)+b1)

while dep < 160:
 penup()
 goto(dep,randint(-110,110))
 for i in range(3): rvb[i] = T(dep,-190,160,c1[i],c2[i])
 pencolor((rvb[0],rvb[1],rvb[2]))
 setheading(0)
 pendown()
 while abs(position()[1]) < 110 and position()[0] < 160:
  setheading(heading() + randint(-30, 30))
  fd(3)
 dep += .5

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 <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.