from kandinsky import * from random import randint class rect(): def __init__(self, x, y, w, h, c): self.x = x self.y = y self.w = w self.h = h self.c = c def affiche(self): for i in range(self.h): y = self.y + i for j in range(self.w): x = self.x + j v = list(get_pixel(x, y)) if i == self.h - 1 or i == 0 or j ==0 or j == self.w -1: rvb2 = (255,) * 3 else: rvb2 = list(self.c) for i in range(3): rvb2[i] = (rvb2[i] + v[i]) // 2 set_pixel(x, y, rvb2) def degrade(a, b, nbVal = 10): (r1,g1,b1) = a (r2,g2,b2) = b dr = (r2 - r1) // nbVal dg = (g2 - g1) // nbVal db = (b2 - b1) // nbVal color = [] for _ in range(nbVal): color.append((r2, g2, b2)) r2 -= dr g2 -= dg b2 -= db return color color = degrade((255,255,0), (255,0,255), 10) for i in range(150): r = rect(randint(-20,310),randint(-20,220),randint(20,100),randint(20,100),color[i%10]) r.affiche()