tartan.py

Created by schraf

Created on November 17, 2023

614 Bytes


from kandinsky import fill_rect
from time import sleep
from random import randint

def carre(x, y): fill_rect(2 * x, 2 * y, 2, 2, (80, 150, 200))

def tartan(motif):
 fill_rect(0, 0, 320, 222, (255,)*3)
 m = motif + ''.join(reversed(list(motif)))
 n = len(motif)
 for v in range(160):
  if m[v % (2 * n)] != "0":
   for w in range(v % 4, 111, 4):
    carre(v, w)
    carre(v, w + 1)
 for w in range(111):
  if m[w % (2 * n)] != "0":
   for v in range((w + 1) % 4, 160, 4):
    carre(v, w)
    carre(v + 1, w)               

while True:
 motif = bin(randint(10**4,10**9))[2:]
 tartan(motif)
 sleep(1)