from turtle import * from math import * from random import * from kandinsky import fill_rect from time import sleep def raz(): hideturtle() sleep(.2) fill_rect(0,0,320,222,(255,255,255)) showturtle() speed(0) raz() def trait(actuel): pensize(randint(1,3)) setheading(actuel) forward(randint(20,40)) def fin(x,y): pensize(1) circle(randint(1,4)) goto(x,y) MX=70 # taille cadre actuel = 0 for i in range(100): if actuel%180==0: # chgt direction actuel = choice([270,90]) else: actuel = choice([0,180]) trait(actuel) [x,y] = position() if y<-MX: fin(x,-MX) # extremites elif y>MX: fin(x,MX) if x<-MX: fin(-MX,y) elif x>MX: fin(MX,y) raz() for c in range(32): for l in range(20): taille = 1+ int(5*sin(pi*c/32)*sin(pi*l/20)) penup() goto(-160 + 10*c, 110-11*l) pendown() pensize(taille) circle(taille) def polyg(): cotes = sorted(range(6), key=lambda x: random())[:2] for i in range(6): penup() if i in cotes: pendown() epais = 1 if cotes.index(i)==0 else randint(1,3) pensize(epais) forward(10) right(60) raz() for j in range(32*13): penup() setheading(0) goto(-160 + 10*(j%32),110-17*(j//32)) polyg() raz() for a in range(180): penup() r = 30 + randint(-10,10) goto(r*cos(pi*a/90),r*sin(pi*a/90)) setheading(2*a) pendown() d = randint(1,80) for k in range(d): pensize(int(5*k/d)) forward(1)