From 44bce898e03081878db78edaab2618aa808e081f Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Mon, 2 Jul 2018 18:58:02 +0200 Subject: [PATCH] UniversalBox: Add alternative "lid" for f and F top_edges: A rim leaving the box open --- boxes/generators/universalbox.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/boxes/generators/universalbox.py b/boxes/generators/universalbox.py index 9e305a9..418e69e 100644 --- a/boxes/generators/universalbox.py +++ b/boxes/generators/universalbox.py @@ -34,9 +34,27 @@ class UniversalBox(_TopEdge, _ChestLid): help="additional lid") self.angle = 0 + def top_hole(self, x, y, top_edge): + t = self.thickness + + if top_edge == "f": + edge = self.edges["F"] + self.moveTo(2*t+self.burn, 2*t, 90) + elif top_edge == "F": + edge = self.edges["f"] + self.moveTo(t+self.burn, 2*t, 90) + else: + raise ValueError("Only f and F supported") + + for l in (y, x, y, x): + edge(l) + if top_edge == "F": self.edge(t) + self.corner(-90) + if top_edge == "F": self.edge(t) def render(self): x, y, h = self.x, self.y, self.h + t = self.thickness self.open() @@ -62,6 +80,11 @@ class UniversalBox(_TopEdge, _ChestLid): self.rectangularWall(x, y, "ffff", bedBolts=[d2, d3, d2, d3], move="right") if self.drawLid(x, y, self.top_edge, [d2, d3]): self.rectangularWall(x, y, "ffff", move="left only") + if self.top_edge in "fF": + self.ctx.set_source_rgb(1., 0, 0) + self.rectangularWall(x+4*t, y+4*t, callback=[ + lambda:self.top_hole(x, y, self.top_edge)], move="right") + self.ctx.set_source_rgb(0, 0, 0) self.drawAddOnLid(x, y, self.lid) self.close()