fire.py

Created by schraf

Created on November 03, 2024

811 Bytes


from kandinsky import fill_rect
from time import sleep
from gif0 import *

w,h = 74,28
r = 5
COUL = [(0,0,0),(255,0,0)]

def taille(n):
 return  54 * (n[0] - 35) + n[1] - 34

def remplir(x,y,t,c):
    while t > 0:
        d = min(t, w - x)
        fill_rect(-25+r*x,80+r*y,r*d,r,c)
        x += d
        t -= d
        if x == w:
            x = 0
            y += 1
            if y >= h: y = 0
    return x,y   
       
def aff():
  k = 0
  while True: 
    k = (k + 1) % 5 
    img = memoire(k)    
    i = 0
    x,y = 0,0
    while i < len(img):
     v = img[i] 
     if v in (32, 33):
         c = v - 32
         i += 1
         sleep(.2)
     else:
         t = taille(img[i:i+2])
         x,y = remplir(x,y,t,COUL[c])
         i += 2
         c = 1 - c

fill_rect(0,0,320,222,COUL[0])
aff()

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