From 1875742b8d9f2e57f298f344231c8e85d353ac65 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Sun, 1 Jan 2023 15:26:07 +0100 Subject: [PATCH] polygonWall: Take all edge type into account when calculating the extent of the polygon. This is a less than ideal, worst case estimate. Should be replaced by something a bit smarter that only looks at the current edge and the space it needs. --- boxes/__init__.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/boxes/__init__.py b/boxes/__init__.py index 4122a3e..2c169a8 100755 --- a/boxes/__init__.py +++ b/boxes/__init__.py @@ -2638,7 +2638,7 @@ class Boxes: ### polygonWall and friends - def _polygonWallExtend(self, borders, edge, close=False): + def _polygonWallExtend(self, borders, edges, close=False): posx, posy = 0, 0 ext = [ 0.0 ] * 4 angle = 0 @@ -2686,10 +2686,12 @@ class Boxes: posy += borders[i] * math.sin(math.radians(angle)) checkpoint(ext, posx, posy) - ext[0] -= edge.margin() - ext[1] -= edge.margin() - ext[2] += edge.margin() - ext[3] += edge.margin() + margin = max((e.margin() for e in edges)) + + ext[0] -= margin + ext[1] -= margin + ext[2] += margin + ext[3] += margin return ext @@ -2713,7 +2715,7 @@ class Boxes: t = self.thickness # XXX edge.margin() - minx, miny, maxx, maxy = self._polygonWallExtend(borders, edges[0]) + minx, miny, maxx, maxy = self._polygonWallExtend(borders, edges) tw, th = maxx - minx, maxy - miny