sapin2023.py

Created by schraf

Created on December 17, 2023

1.14 KB

Image originale


from kandinsky import fill_rect, set_pixel

fill_rect(0,0,140,222,(226,31,27))
fill_rect(140,0,180,222,(171,33,26))

B = (1,35,0)

tr = (B,((74,204),(110,110),(22,110))),\
(B,((110,110),(22,110),(70,11))),\
((21,180,0),((86,209),(224,115),(31,115))),\
((11,128,0),((224,115),(31,115),(81,10))),\
(B,((143,167),(224,111),(101,131))),\
(B,((101,131),(224,111),(150,100))),\
(B,((100,40),(143,50),(134,116))),\
((21,180,0),((151,173),(253,109),(128,153))),\
((11,128,0),((128,153),(253,109),(137,33))),\
(B,((204,140),(253,109),(190,141))),\
(B,((253,109),(190,141),(203,126))),\
(B,((203,126),(253,109),(177,77))),\
((113,206,107),((211,166),(299,110),(210,81))),\
((11,128,0),((210,81),(299,110),(221,60)))

def remplir(coul, *u):
 (ax,ay),(bx,by),(cx,cy)=u[0]
 for col in range(min(ax,bx,cx), max(ax,bx,cx)+1):
  for lig in range(min(ay,by,cy), max(ay,by,cy)+1):
   if 0 <= col <= 320 and 0 <= lig <= 222:
    xa,xb,xc = ax-col,bx-col,cx-col
    ya,yb,yc = ay-lig,by-lig,cy-lig
    d1,d2,d3 = xa*yb-ya*xb,xb*yc-yb*xc,xc*ya-yc*xa
    u,v,w = d1>=0,d2>=0,d3>=0
    if u == v == w:
     set_pixel(col,222 - lig,coul)

for t in tr: remplir(t[0],t[1])

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.