tramage.py

Created by schraf

Created on April 06, 2023

450 Bytes


from kandinsky import set_pixel

# https://en.wikipedia.org/wiki/Ordered_dithering
# Utilisation d'une matrice 4x4 pour les niveaux de gris

gris = [0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5]

for l in range(0,222,4):
 for c in range(0,320,4):
   # intensite du gris, blanc vers noir
   n = int(c / 320 * 16)
   # Motif 4x4 pour ce niveau de gris
   for i in range(16):
     if n >= gris[i]: set_pixel(c + (i % 4), l + (i // 4), (0, 0, 0))