Skip to content

Commit e1eb889

Browse files
authored
Merge pull request #2 from Discusser/bugfix/list-comprehension
Fix list comprehension issue with fill_rectangle
2 parents 8c51dcd + 95231b3 commit e1eb889

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/visual/visual.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ def fill_polygone(n,rayon,coord,color='0',c_map=None,alpha=1):
6464
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)
6565
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)
6666
def fill_rectangle(P1,P4,color='0',alpha=1):
67-
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)
67+
for x in range(P4.x-P1.x if P4.x>P1.x else P1.x-P4.x):
68+
for y in range(P4.y-P1.y if P4.y>P1.y else P1.y-P4.y):
69+
alpha_pixel(P1.x+x,P1.y+y,color,alpha)
6870
def draw_circle(center,rayon,color='0'):
6971
for x in range(-abs(rayon),abs(rayon)):
7072
l=round((abs(rayon)**2-x**2)**0.5)
@@ -77,4 +79,4 @@ def bezier_curve(liste,color='0',thickness=1,N=1500):
7779
for _t in range(N):
7880
x,y,t=0,0,_t/N
7981
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
80-
P=Point(round(x),round(y));set_pixel(P.x,P.y,color) if thickness==1 else fill_circle(P,thickness,color,1)
82+
P=Point(round(x),round(y));set_pixel(P.x,P.y,color) if thickness==1 else fill_circle(P,thickness,color,1)

0 commit comments

Comments
 (0)