Bibliothèque pour améliorer kandinsky.
Permet d’utiliser draw_line
et fill_circle
.
Date d’Avril 2022.
from kandinsky import * from time import * def fill_circle(x,y,r,c): rr=int(r*0.7071067811865475) r2=r**2 fill_rect(x-rr,y-rr,2*rr,2*rr,c) for xx in range(x-rr-1,x+rr+1): for yy in list(range(y-r-1,y-rr))+list(range(y+rr,y+r+1)): if ((yy-y)**2+(xx-x)**2)<=r2: set_pixel(xx,yy,c) for yy in range(y-rr-1,y+rr+1): for xx in list(range(x-r-1,x-rr))+list(range(x+rr,x+r+1)): if ((yy-y)**2+(xx-x)**2)<=r2: set_pixel(xx,yy,c) def draw_line(x1,y1,x2,y2,c): width=x2-x1 height=y2-y1 if abs(width)>=abs(height): div=height/width for i in range(0,width,(width>0)*2-1): set_pixel(x1+i,y1+int(div*i+0.5),c) else: div=width/height for i in range(0,height,(height>0)*2-1): set_pixel(x1+int(div*i+0.5),y1+i,c)