citrouille.py
Created by
schraf
Created on
October 04, 2022
4.79 KB
from kandinsky import fill_rect
from time import sleep
from random import randint
def light ( coul , i ):
r , v , b = coul >> 16 , coul >> 8 & 255 , coul & 255
c = i / 10
return ( int ( r - r * c ), int ( v - v * c ), int ( b - b * c ))
def draw_image ( rle , x0 , y0 , w , pal , zoomx = 1 , zoomy = 1 , itransp =- 1 , li = 0 ):
i , x = 0 , 0
x0 , y0 = int ( x0 ), int ( y0 )
nvals = len ( pal )
nbits = 0
nvals -= 1
while ( nvals ):
nvals >>= 1
nbits += 1
maskval = ( 1 << nbits ) - 1
maskcnt = ( 0xFF >> nbits >> 1 ) << nbits
while i < len ( rle ):
v = rle [ i ]
mv = v & maskval
c = ( v & maskcnt ) >> nbits
if ( v & 0b10000000 or nbits == 8 ):
i += 1
c |= rle [ i ] << ( 7 - nbits + ( nbits == 8 ))
c = c + 1
while c :
cw = min ( c , w - x )
if mv != itransp :
fill_rect ( x0 + x * zoomx , y0 , cw * zoomx , zoomy , light ( pal [ mv ], li ))
c -= cw
x = ( x + cw ) % w
y0 += x == 0 and zoomy
i += 1
palette = (
0 , 2622464 , 6299648 , 9453568 , 12605440 , 14712832 , 4730896 , 15233024 , 0
)
image = (
b " \x90 P \21\xb0\6\21\x80\4\22\xb0\6\1\2\xf0\3\22\3\1\x80\6\1\"\1\xd0\3\1\22\3\2\1\xd0\5\1\2\x03 2 \xc0\3\1\x13 2 \xc0\5\2\4\5\3 B \xb0\3\22\3\2\3\22\6\xa0\5\2\3\24\23\6\"\xa0\3\22\3\2\3\2\3\"\xf0\4\1\3 ' \4\5\x04 2 \1\x90\3 # \2\3\x02 3 \6\xd0\4\1\3\5\24\a $ \3\22\3\2\x80\3\22 C \2\3 $ \2\xb0\4\3\4\5\27\x05 7 \4\22\3\2\1\xe0\2\6\x83\1 $ \3\1\x90\4\2\27\5\a\4\25 ' \x13 2 \xe0\2\xf3\0\24\3 $ \3\1\xe0\3\2\4\5 G \x04 7 \5\4\3\2\23\1\x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3\4\a $ ' \24\3\6\1\x80\6\1 T \a\x04 7 \xc0\1\3 $ \a\4\a\4\a\4\3\1\xc0\6\1\2\6\3\24 G \xc0\1\x02 4# \6\xa0\a\1\2\23\4 ' \xc0\1\2\24\3\4\2\1\x90\b\1\6\2\xc0\1\6\2\1\x80 < "
)
fill_rect ( 0 , 0 , 320 , 222 ,( 0 , 0 , 0 ))
k , d = 4 , 2
x , y = 40 , 50
while True :
draw_image ( image , x , y , 89 , palette , zoomx = 1 , zoomy = 1 , itransp = 0 , li = k )
k += d
if k == 0 or k == 10 : d = - d
if k == 10 : x , y = randint ( 0 , 230 ), randint ( 0 , 130 )
sleep (. 1 )