Version plus générale :
import turtle from random import * t = turtle.Turtle() t.speed(0) t.hideturtle() p = 3 w, h = 400, 300 wn = turtle.Screen() wn.setup(2 * w, 2 * h) wn.colormode(255) wn.tracer(0) c = -w c1, c2 = (60,200,230), (30,) *3 rvb = [0,0,0] t.speed(0) def T(u,a1,a2,b1,b2): return int((b2-b1)/(a2-a1)*(u-a1)+b1) while c < w: l = -h t.pensize(1) for i in range(3): rvb[i] = T(c,-w,w,c1[i],c2[i]) t.pencolor((rvb[0],rvb[1],rvb[2])) while l < 1.1 * h: t.penup() t.goto(c,l) t.pendown() t.setheading(choice((randint(-60,-30),randint(-150,-120)))) t.fd(p*1.414) l += 3 p += 1 c += 5 wn.update()
from turtle import * from random import choice, randint speed(0) t = 3 c = -160 c1, c2 = (60,200,230), (30,) *3 rvb = [0,0,0] def T(u,a1,a2,b1,b2): return (b2-b1)/(a2-a1)*(u-a1)+b1 while c < 170: l = -110 pensize(1) for i in range(3): rvb[i] = T(c,-160,170,c1[i],c2[i]) pencolor((rvb[0],rvb[1],rvb[2])) while l < 150: penup() goto(c,l) pendown() setheading(choice((randint(-60,-30),randint(-150,-120)))) fd(t*1.414) l += 3 t += 2 c += 5