Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/visual/visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def fill_polygone(n,rayon,coord,color='0',c_map=None,alpha=1):
for p,c in zip(connect_points(points,True),[color for _ in range(len(points))] if not isinstance(c_map,list) else c_map):fill_triangles([([coord,p[0],p[1]])],c,alpha)
def draw_rectangle(P1,P4,color='0'):fill_rect(P1.x,P1.y,P4.x-P1.x,1,color);fill_rect(P4.x,P1.y,1,P4.y-P1.y+1,color);fill_rect(P1.x,P4.y,P4.x-P1.x,1,color);fill_rect(P1.x,P1.y,1,P4.y-P1.y,color)
def fill_rectangle(P1,P4,color='0',alpha=1):
for x,y in [(x,y) for x in range(P4.x-P1.x if P4.x>P1.x else P1.x-P4.x) for y in range(P4.y-P1.y if P4.y>P1.y else P1.y-P4.y)]:alpha_pixel(P1.x+x,P1.y+y,color,alpha)
for x in range(P4.x-P1.x if P4.x>P1.x else P1.x-P4.x):
for y in range(P4.y-P1.y if P4.y>P1.y else P1.y-P4.y):
alpha_pixel(P1.x+x,P1.y+y,color,alpha)
def draw_circle(center,rayon,color='0'):
for x in range(-abs(rayon),abs(rayon)):
l=round((abs(rayon)**2-x**2)**0.5)
Expand All @@ -77,4 +79,4 @@ def bezier_curve(liste,color='0',thickness=1,N=1500):
for _t in range(N):
x,y,t=0,0,_t/N
for i in range(len(liste)):x+=((perm(len(liste)-1,i)/factorial(i))*(t**i)*((1-t)**(len(liste)-1-i)))*liste[i].x;y+=((perm(len(liste)-1,i)/factorial(i))*(t**i)*((1-t)**(len(liste)-1-i)))*liste[i].y
P=Point(round(x),round(y));set_pixel(P.x,P.y,color) if thickness==1 else fill_circle(P,thickness,color,1)
P=Point(round(x),round(y));set_pixel(P.x,P.y,color) if thickness==1 else fill_circle(P,thickness,color,1)