nsixyz24.py

Created by schraf

Created on September 20, 2024

766 Bytes

Version papier-peint des années 70 :

from math import *
from kandinsky import *
for i in range(321*222):
 set_pixel(i%321,i//321,[(194,156,94),(255,255,0),(255,128,0),(77,40,4)][int(3*sin((i%321-160)/16)*cos((i//321-111)/16))])


from math import *
from kandinsky import *

# parametrage du zoom
zoom = 20

# couleurs principales de l'arc en ciel
#arc_en_ciel = (75, 0, 130), (0, 0, 255), (0, 128, 0), (255, 255, 0), (255, 165, 0), (255, 0, 0)
arc_en_ciel = (0, 0, 0), (0, 0, 255), (255, 0, 0), (0, 0, 255), (0, 0, 0), (255, 0, 0)

for c in range(321):
  # valeur de x suivant la colonne
  x = sin((c - 160) / zoom)
  for l in range(222):
    # valeur de y suivant la ligne
    y = cos((l - 111) / zoom)
    # x et y sont des reels entre -1 et 1 donc x * y aussi
    # 1 + x * y est entre 0 et 2
    # z sera l'index de la couleur entre 0 et 6
    z = int(3 + 3 * x * y)
    # on place le pixel
    # Rouge = valeur haute, Violet = valeur basse
    set_pixel(c, l, arc_en_ciel[z])

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