fromkandinskyimport*defadjust_color(color,dr,dg,db):r=min(max(color[0]+dr,0),255)g=min(max(color[1]+dg,0),255)b=min(max(color[2]+db,0),255)return (r,g,b)defdraw_tetris_block(x,y,size,base_color,mode="out"):border=max(2,size//8)# Déduction automatique
light=adjust_color(base_color,+40,+40,+40)dark=adjust_color(base_color,-50,-50,-50)inner=adjust_color(base_color,-20,-10,-30)# Mode 3D extérieur ("out") ou intérieur ("in")
ifmode=="out":top_left=lightbottom_right=darkelse:# "in"
top_left=darkbottom_right=light# Bloc principal
fill_rect(x,y,size,size,base_color)# Bord haut-gauche
foriinrange(border):fill_rect(x+i,y,size-2*i,1,top_left)fill_rect(x,y+i,1,size-2*i,top_left)# Bord bas-droit
foriinrange(border):fill_rect(x+i,y+size-1-i,size-2*i,1,bottom_right)fill_rect(x+size-1-i,y+i,1,size-2*i,bottom_right)# Centre
inset=border+1fill_rect(x+inset,y+inset,size-2*inset,size-2*inset,inner)draw_tetris_block(10,10,50,(255,0,100),mode="out")# 3D positif
draw_tetris_block(70,10,50,(255,0,100),mode="in")# 3D négatif
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
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.