easter2026.py

Created by schraf

Created on March 31, 2026

2.69 KB


from kandinsky import *
from math import sin, pi
from random import random

A=(255,255,255); B=(188,145,159); C=(143,160,204); D=(212,203,202)
E=(231,139,154); F=(234,122,118); G=(182,146,112); H=(243,142,82)
I=(248,176,97);  J=(251,228,100)

grille=[[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],[A,A,A,A,A,B,C,B,C,C,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],[A,A,A,D,E,F,F,F,B,E,C,A,A,A,A,A,A,A,D,D,D,A,A,A,A,A],[A,A,D,C,B,E,B,F,F,F,E,B,A,A,A,A,A,G,H,H,H,H,D,A,A,A],[A,A,C,C,C,C,C,B,F,E,E,F,D,A,A,A,G,H,H,H,H,H,H,D,A,A],[A,D,B,B,C,C,C,C,C,C,C,F,B,A,A,D,H,H,H,H,H,H,H,I,A,A],[A,B,E,E,B,C,C,C,C,C,C,C,C,A,A,G,I,H,H,H,H,I,J,J,D,A],[D,B,E,E,E,C,C,B,C,C,C,C,C,A,A,J,J,J,J,J,J,J,J,I,F,A],[D,C,C,B,E,E,E,E,C,C,B,C,C,A,D,F,I,I,I,I,I,H,F,H,F,A],[D,C,C,B,E,E,E,E,E,B,E,E,C,A,D,H,I,F,F,H,H,F,H,I,F,D],[D,C,C,C,C,C,C,E,E,E,E,E,D,A,D,F,H,F,F,I,H,F,F,F,J,D],[D,B,C,C,C,C,C,C,B,C,C,B,D,A,D,G,I,H,F,F,H,I,J,J,J,D],[D,E,C,B,C,C,C,C,C,C,C,C,A,A,A,G,J,J,J,J,J,J,J,J,J,A],[A,B,F,F,E,B,B,C,C,B,B,D,A,A,A,D,J,J,J,J,J,J,I,H,F,A],[A,D,B,C,F,F,F,E,E,E,D,A,A,A,A,A,G,H,H,H,H,H,H,H,D,A],[A,A,D,C,C,C,C,B,C,D,A,A,A,A,A,A,D,G,H,H,H,H,H,G,A,A],[A,A,A,D,C,C,C,C,D,A,A,A,A,A,A,A,A,D,G,H,H,H,G,A,A,A],[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,D,D,A,A,A,A,A],[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A]]

ROWS=len(grille); COLS=len(grille[0]); GAP=1
Tx=(320-GAP)//(COLS+GAP)+1; Ty=(222-GAP)//(ROWS+GAP)+1
total_w=COLS*Tx+(COLS+1)*GAP; total_h=ROWS*Ty+(ROWS+1)*GAP
OX=(320-total_w)//2; OY=(222-total_h)//2
JOINT=(120,160,190)
AMP=1.1; WL=50

def clamp(v): return max(0,min(255,int(v)))

def source_color(sx, sy):
    # Hors de la zone de grille -> joint
    lx = sx - OX; ly = sy - OY
    if lx < 0 or ly < 0: return JOINT
    col = lx // (Tx + GAP); row = ly // (Ty + GAP)
    if col >= COLS or row >= ROWS: return JOINT
    # Position dans la tuile
    dx = lx - col*(Tx+GAP) - GAP
    dy = ly - row*(Ty+GAP) - GAP
    if dx < 0 or dy < 0 or dx >= Tx or dy >= Ty: return JOINT
    r,g,b = grille[row][col]
    if dy==Ty-1 or dx==Tx-1:
        return (clamp(r-65),clamp(g-65),clamp(b-65))
    elif dy<1 or dx<2:
        return (clamp(r+75),clamp(g+75),clamp(b+75))
    else:
        fade=(dx+dy)*40//(Tx+Ty)
        return (clamp(r-fade),clamp(g-fade),clamp(b-fade))

W=320; H=222
for y in range(H):
    oy = AMP*sin(2*pi*(y/WL))
    for x in range(W):
        sx = int(x + AMP*sin(2*pi*(y/WL + random()/5)))
        sy = int(y + oy + AMP*0.4*sin(2*pi*(x/WL + random()/5)))
        sx = max(0,min(W-1,sx)); sy = max(0,min(H-1,sy))
        r,g,b = source_color(sx,sy)
        lum = 1 + (2*random()-1)/10 + 0.09*sin(2*pi*(x/WL + y/WL))
        set_pixel(x, y, (clamp(r*lum), clamp(g*lum), clamp(b*lum+15*lum)))

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 cookies policy.