From 3dff5d92afbc3282cfe7b1d0c04b50ce395405db Mon Sep 17 00:00:00 2001 From: alban Date: Tue, 29 Sep 2020 23:39:09 +0200 Subject: [PATCH] [fix] kaleidoscope should not ignore the last point of the original list --- clitools/filters/kaleidoscope.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/clitools/filters/kaleidoscope.py b/clitools/filters/kaleidoscope.py index 52e6a2b..2e68d8d 100755 --- a/clitools/filters/kaleidoscope.py +++ b/clitools/filters/kaleidoscope.py @@ -52,11 +52,21 @@ def kaleidoscope( pl ): # Stage 1: Crop points in single quadrant quad1 = [] # Iterate trough the segments - for i in range( 0, len(pl) - 1 ): + for i in range( 0, len(pl) ): + + #debug(name+" point #", i) currentpoint = cp = pl[i] - nextpoint = pl[i+1] cx,cy,cc = [cp[0],cp[1],cp[2]] + + # Exception: escape early if last point + if i == len(pl) - 1: + if cx >= centerX and cy >= centerY : + quad1.append( currentpoint ) + break + + # Search for the couple of points + nextpoint = pl[i+1] nx,ny,nc = [nextpoint[0],nextpoint[1],nextpoint[2]] rect=[[cx,cy],[cx,ny],[nx,ny],[nx,cy]] @@ -134,7 +144,7 @@ def kaleidoscope( pl ): point = quad3[iterator] quad4.append([ 2*centerX - point[0], point[1], point[2] ]) - #debug(name+" quad1:",quad1) + debug(name+" quad1:",quad1) #debug(name+" quad2:", quad2 ) debug(name+" quad3:", quad3 ) debug(name+" quad4:", quad4 )