diff --git a/boxes/generators/coinbanksafe.py b/boxes/generators/coinbanksafe.py index d167acae..d5424cef 100644 --- a/boxes/generators/coinbanksafe.py +++ b/boxes/generators/coinbanksafe.py @@ -85,6 +85,43 @@ def drawNumbers(self, radius, cover): self.text(str(num+1), align="center middle", fontsize=fontsize, angle=-angle, color=[1,0,0], y=y, x=x) + def lockPin(self, layers, move=None): + t = self.thickness + cutout_width = t/3 + barb_length = t + base_length = layers * t + base_width = t + total_length = base_length + barb_length + total_width = base_width + cutout_width * 0.5 + cutout_angle = math.degrees(math.atan(cutout_width / base_length)) + cutout_length = math.sqrt(cutout_width**2 + base_length**2) + + #self.rectangularWall(5*t, t) + + if self.move(total_length, total_width, move, True): + return + + self.edge(total_length) + self.corner(90) + self.edge(base_width * 1/3) + self.corner(90) + self.edge(base_length) + self.corner(180+cutout_angle, 0) + self.edge(cutout_length) + self.corner(90-cutout_angle) + self.edge(cutout_width * 1.5) + self.corner(90) + self.edge(barb_length) + self.corner(90) + self.corner(-90, cutout_width * 0.5) + self.edge(base_length - cutout_width * 0.5) + self.corner(90) + self.edge(t) + self.corner(90) + + self.move(total_length, total_width, move) + + def render(self): x, y, h = self.x, self.y, self.h t = self.thickness @@ -208,15 +245,18 @@ def render(self): # lock pins with self.saved_context(): - self.rectangularWall(5*t, t, move="up") - self.rectangularWall(5*t, t, move="up") - self.rectangularWall(5*t, t, move="up") - self.rectangularWall(5*t, t, move="right only") + self.lockPin(5, move="up") + self.lockPin(5, move="up") + self.lockPin(5, move="up") + self.lockPin(5, move="right only") # handle + self.moveTo(0) handle_curve_radius = 0.2 * t - self.moveTo(2 * handle_curve_radius,0) + self.moveTo(t * 2.5) self.polyline( + 0, + (90, handle_curve_radius), handle_length - 2 * handle_curve_radius, (90, handle_curve_radius), handle_clearance - handle_curve_radius, @@ -232,4 +272,4 @@ def render(self): handle_length / 4, 90, handle_clearance - handle_curve_radius, - (90, handle_curve_radius)) + )