From e8e75765b9f9d10b70d48d5ea0619d0593eb0e0d Mon Sep 17 00:00:00 2001 From: "suks.ae" Date: Wed, 30 Mar 2022 05:02:20 +0200 Subject: [PATCH] fixed error generating an empty path list --- boxes/drawing.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/boxes/drawing.py b/boxes/drawing.py index de45253..9617e53 100644 --- a/boxes/drawing.py +++ b/boxes/drawing.py @@ -150,8 +150,10 @@ class Path: def __repr__(self): l = len(self.path) # x1,y1 = self.path[0][1:3] - x2, y2 = self.path[-1][1:3] - return f"Path[{l}] to ({x2:.2f},{y2:.2f})" + if l>0: + x2, y2 = self.path[-1][1:3] + return f"Path[{l}] to ({x2:.2f},{y2:.2f})" + return f"empty Path" def extents(self): e = Extents() @@ -208,7 +210,8 @@ class Path: else: self.path[i] = ("L", x, y) # filter duplicates - self.path = [p for n, p in enumerate(self.path) if p != self.path[n-1]] + if len(self.path) > 1: # no need to find duplicates if only one element in path + self.path = [p for n, p in enumerate(self.path) if p != self.path[n-1]] class Context: def __init__(self, surface, *al, **ad): @@ -759,14 +762,13 @@ class LBRN2Surface(Surface): path.faster_edges(inner_corners) num = 0 cnt = 1 - ende = len(path.path)-1 if self.dbg: for c in path.path: print ("6",num, c) num += 1 + num = 0 - num = 0 c = path.path[num] C, x, y = c[0:3] if self.dbg: print("ende:" ,ende)