moutons.py

Created by fedyna-kevin

Created on July 09, 2020

740 Bytes


from kandinsky import fill_rect
from ion import keydown
from time import monotonic

s_sheep = (96,96,0,254,224,64,255,224,0,127,0,0,62,0,0,18,18,0)
b_sheep = (126,6,0,255,7,2,255,7,0,254,0,0,124,0,0,72,72,0)

def _draw(x, y, s, h, t):
    for i in range(0,18,3):
        for j in range(8):
            p_color = sum(map(lambda a: a>>j & 1,s[i:i+3]))
            if p_color:
                fill_rect(x+t*j,y+t*i//3,t,t,((255, 105, 180),(239, 228, 176),(0,180,246))[p_color-1])

def _degrade(x, y, w, h, c1, c2):
    for i in range(h):
        fill_rect(x, y+i, w, 1, tuple(c1[j]+(c2[j]-c1[j])*i//(h-1) for j in range(3)))

_degrade(0,0,320,222,(239, 228, 176),(0,180,246))
_draw(10,10,s_sheep,0,10)
_draw(10,100,b_sheep,0,10)

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