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))

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 <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.