from turtle import * from random import randint from math import sqrt from kandinsky import fill_rect def degrade(a, b, nbVal = 10): (r1,g1,b1) = a (r2,g2,b2) = b dr = int((r2 - r1) / nbVal) dg = int((g2 - g1) / nbVal) db = int((b2 - b1) / nbVal) color = [] for i in range(nbVal): color.append((r2, g2, b2)) r2 = r2 - dr g2 = g2 - dg b2 = b2 - db return color def carre(cote) : for _ in range(4) : forward(cote) right(90) def pythagore(cote, profondeur): if profondeur > 0 : color(coul[profondeur]) pensize(profondeur // 2) profondeur -= 1 carre(cote) forward(cote) cote2 = cote/sqrt(2) left(45) pythagore(cote2, profondeur) right(90) penup() forward(cote2) pendown() pythagore(cote2, profondeur) penup() backward(cote2) pendown() left(45) backward(cote) coul = degrade((150,80,0), (0,255,0), 11) fill_rect(0,0,320,222,(0,0,0)) cote = 55 penup() goto(-cote/2,-105) pendown() setheading(90) speed(0) pythagore(cote,10) hideturtle()