From 64fb498e6e07f867afba866f6aafa2d6fbf2bcd5 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Fri, 11 Jan 2019 12:19:16 +0100 Subject: [PATCH] UniversalBox: Use a more robust way of placing the pieces No longer rely on all side walls having the same height --- boxes/generators/universalbox.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/boxes/generators/universalbox.py b/boxes/generators/universalbox.py index 912c030..0f37184 100644 --- a/boxes/generators/universalbox.py +++ b/boxes/generators/universalbox.py @@ -31,7 +31,7 @@ class UniversalBox(_TopEdge, _ChestLid): self.argparser.add_argument( "--lid", action="store", type=str, default="default (none)", choices=("default (none)", "chest", "flat"), - help="additional lid") + help="additional lid (for straight top_edge only)") self.angle = 0 def top_hole(self, x, y, top_edge): @@ -66,19 +66,15 @@ class UniversalBox(_TopEdge, _ChestLid): d2 = d3 = None - self.rectangularWall(y, h, [b, "f", t2, "f"], - bedBolts=[d3], move="right") + + self.ctx.save() self.rectangularWall(x, h, [b, "F", t1, "F"], bedBolts=[d2], move="up") self.rectangularWall(x, h, [b, "F", t3, "F"], - bedBolts=[d2]) - self.rectangularWall(y, h, [b, "f", t4, "f"], - bedBolts=[d3], move="left") - self.rectangularWall(x, h, [b, "F", t3, "F"], - bedBolts=[d2], move="up only") + bedBolts=[d2], move="up") if self.bottom_edge != "e": - self.rectangularWall(x, y, "ffff", bedBolts=[d2, d3, d2, d3], move="right") + self.rectangularWall(x, y, "ffff", bedBolts=[d2, d3, d2, d3], move="up") if (self.drawLid(x, y, self.top_edge, [d2, d3]) and self.bottom_edge != "e"): self.rectangularWall(x, y, "ffff", move="left only") @@ -89,5 +85,13 @@ class UniversalBox(_TopEdge, _ChestLid): self.ctx.set_source_rgb(0, 0, 0) self.drawAddOnLid(x, y, self.lid) + self.ctx.restore() + self.rectangularWall(x, h, [b, "F", t3, "F"], + bedBolts=[d2], move="right only") + self.rectangularWall(y, h, [b, "f", t2, "f"], + bedBolts=[d3], move="up") + self.rectangularWall(y, h, [b, "f", t4, "f"], + bedBolts=[d3], move="up") + self.close()