illusion2.py

Created by schraf

Created on April 09, 2023

570 Bytes

Illusion du mur du café : Il n’y a que des lignes horizontales et des carrés noirs !

🖥 Visiter ma chaine Youtube Maths-info


from kandinsky import fill_rect as fr
from math import sin, pi
from time import sleep

while True:
  # 3 animations
  for t in range(20,31,5):  
    # pour chaque ligne
    for l in range(21 - t // 3):
      # marge gauche
      m = int(abs(t / 2 * sin(l * pi / 4)))
      y = - t // 2 + (t + 1) * l
      # Les carres noirs
      for c in range(0, 20 - t // 5, 2):
        fr(m + t * c, y, t, t, (0, 0, 0))
      # ligne horizontale
      fr(0, y, 320, 1, (140, 140, 140))
    # pause + efface ecran
    sleep(2)
    fr(0, 0, 320, 222, (255, 255, 255))