From ffa27860292b7337174cccd96554e3c8e1bf7d7c Mon Sep 17 00:00:00 2001
From: Elena ``of Valhalla'' Grandi <valhalla@trueelena.org>
Date: Tue, 5 Mar 2024 08:00:04 +0100
Subject: Add generating script for flat thimbles

---
 .../accessories/tools/leather_thimbles/thimbles.py | 54 ++++++++++++++++++++++
 1 file changed, 54 insertions(+)

(limited to 'source/accessories/tools/leather_thimbles/thimbles.py')

diff --git a/source/accessories/tools/leather_thimbles/thimbles.py b/source/accessories/tools/leather_thimbles/thimbles.py
index ef3bfdc..37586ca 100755
--- a/source/accessories/tools/leather_thimbles/thimbles.py
+++ b/source/accessories/tools/leather_thimbles/thimbles.py
@@ -167,6 +167,60 @@ class Flat(hazwaz.Command):
     """
     Draw the pattern for flat thimbles
     """
+    def draw_pattern(self, dest):
+        grp = dest.g()
+
+        sa = 2
+        r_min = 7
+        r_max = 13
+        h = 20
+
+        y = 20
+
+        for i, r in enumerate(range(r_min, r_max)):
+
+            size = dest.g()
+
+            # half the circumference plus 2 mm sewing allowance
+            w = r * math.pi + 4
+            h = 35
+
+            top_x = 20
+            top_y = (35 + 10) * i + 20
+
+            thimble = dest.path(
+                (
+                    "M", top_x * mm, top_y * mm,
+                    "c", 0, h / 2 * mm, 0, h * mm, w / 2 * mm, h * mm,
+                    "c", w / 2 * mm, 0,
+                         w / 2 * mm, - h / 2 * mm,
+                         w / 2 * mm, - h * mm,
+                    "L", top_x * mm, top_y * mm,
+                ),
+                ** LINE_STYLE,
+            )
+
+            size.add(thimble)
+
+            size.add(dest.text(
+                text="size: " + str(r * 2),
+                insert=((top_x + w / 2) * mm, (top_y + 1) * mm + 8),
+                text_anchor="middle",
+                ** TEXT_STYLE,
+            ))
+
+            grp.add(size)
+
+        dest.add(grp)
+
+    def main(self):
+        dest = svgwrite.Drawing(
+            filename="flat_thimbles.svg",
+            size=("210mm", "297mm"),
+            profile="full",
+        )
+        self.draw_pattern(dest)
+        dest.save()
 
 
 class Thimble(hazwaz.MainCommand):
-- 
cgit v1.2.3