From 95231b375e27af8994e9790cabb19d245fd7e826 Mon Sep 17 00:00:00 2001 From: Discusser <47938380+Discusser@users.noreply.github.com> Date: Wed, 11 Jun 2025 07:58:11 +0200 Subject: [PATCH] Fix list comprehension issue with fill_rectangle --- src/visual/visual.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/visual/visual.py b/src/visual/visual.py index 6299e88..d5d3eb7 100644 --- a/src/visual/visual.py +++ b/src/visual/visual.py @@ -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) @@ -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) \ No newline at end of file + P=Point(round(x),round(y));set_pixel(P.x,P.y,color) if thickness==1 else fill_circle(P,thickness,color,1)