From 7fdd01ef976694edf9433c894a2c06340a3ead1c Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Sat, 23 Mar 2024 19:22:16 +0100 Subject: [PATCH] BurnTest: Add datie and id options Resolves: #621 --- boxes/generators/burntest.py | 67 +++++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/boxes/generators/burntest.py b/boxes/generators/burntest.py index 7180feefc..b291f3d8c 100644 --- a/boxes/generators/burntest.py +++ b/boxes/generators/burntest.py @@ -1,4 +1,5 @@ # Copyright (C) 2013-2019 Florian Festi +# Copyright (C) 2024 Seth Fischer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,11 +14,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +from datetime import date + from boxes import * class BurnTest(Boxes): """Test different burn values""" + description = """This generator will make shapes that you can use to select optimal value for burn parameter for other generators. After burning try to attach sides with the same value and use best fitting one on real projects. @@ -40,35 +44,72 @@ def __init__(self) -> None: self.addSettingsArgs(edges.FingerJointSettings) self.buildArgParser(x=100) self.argparser.add_argument( - "--step", action="store", type=float, default=0.01, - help="increases in burn value between the sides") + "--step", + action="store", + type=float, + default=0.01, + help="increases in burn value between the sides", + ) self.argparser.add_argument( - "--pairs", action="store", type=int, default=2, - help="number of pairs (each testing four burn values)") - + "--pairs", + action="store", + type=int, + default=2, + help="number of pairs (each testing four burn values)", + ) + self.argparser.add_argument( + "--date", + action="store", + type=boolarg, + default=False, + help="add current date etching to each piece", + ) + self.argparser.add_argument( + "--id", + action="store", + type=str, + default="", + help="add identifier etching to each piece", + ) def render(self): + font = { + "fontsize": 12.5 * self.x / 100 if self.x < 81 else 10, + "align": "center", + "color": Color.ETCHING, + } + font_meta = font.copy() + font_meta["fontsize"] = font["fontsize"] * 0.75 + + today = date.today().strftime("%Y-%m-%d") + x, s = self.x, self.step t = self.thickness - fsize = 12.5 * self.x / 100 if self.x < 81 else 10 - self.moveTo(t, t) for cnt in range(self.pairs): - for i in range(4): - self.text("%.3fmm" % self.burn, x/2, t, fontsize = fsize, align="center", color=Color.ETCHING) + self.text("%.3fmm" % self.burn, x / 2, t, **font) + if self.date and i == 3: + self.text(today, x / 2, 20, **font_meta) + if self.id and i == 1: + self.text(self.id, x / 2, 20, **font_meta) self.edges["f"](x) self.corner(90) self.burn += s - self.burn -= 4*s + self.burn -= 4 * s + self.moveTo(x + 2 * t + self.spacing, -t) - self.moveTo(x+2*t+self.spacing, -t) for i in range(4): - self.text("%.3fmm" % self.burn, x/2, t, fontsize = fsize, align="center", color=Color.ETCHING) + self.text("%.3fmm" % self.burn, x / 2, t, **font) + if self.date and i == 3: + self.text(today, x / 2, 20, **font_meta) + if self.id and i == 1: + self.text(self.id, x / 2, 20, **font_meta) self.edges["F"](x) self.polyline(t, 90, t) self.burn += s - self.moveTo(x+2*t+self.spacing, t) + + self.moveTo(x + 2 * t + self.spacing, t)