From daf49237f66981f70f8e797e8b0df91e9a2822fd Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Mon, 19 May 2025 02:24:39 -0600 Subject: [PATCH] Initial commit --- .gitignore | 4 ++ counters.py | 126 +++++++++++++++++++++++++++++++++++++++++ svg/charge.svg | 5 ++ svg/deathtouch.svg | 5 ++ svg/doublestrike.svg | 5 ++ svg/firststrike.svg | 5 ++ svg/flying.svg | 5 ++ svg/goad.svg | 5 ++ svg/haste.svg | 5 ++ svg/hexproof.svg | 6 ++ svg/indestructible.svg | 5 ++ svg/lifelink.svg | 5 ++ svg/lore.svg | 5 ++ svg/menace.svg | 5 ++ svg/reach.svg | 5 ++ svg/ringbearer.svg | 5 ++ svg/shield.svg | 5 ++ svg/stun.svg | 5 ++ svg/time.svg | 5 ++ svg/trample.svg | 5 ++ svg/vigilance.svg | 5 ++ 21 files changed, 226 insertions(+) create mode 100644 .gitignore create mode 100644 counters.py create mode 100644 svg/charge.svg create mode 100644 svg/deathtouch.svg create mode 100644 svg/doublestrike.svg create mode 100644 svg/firststrike.svg create mode 100644 svg/flying.svg create mode 100644 svg/goad.svg create mode 100644 svg/haste.svg create mode 100644 svg/hexproof.svg create mode 100644 svg/indestructible.svg create mode 100644 svg/lifelink.svg create mode 100644 svg/lore.svg create mode 100644 svg/menace.svg create mode 100644 svg/reach.svg create mode 100644 svg/ringbearer.svg create mode 100644 svg/shield.svg create mode 100644 svg/stun.svg create mode 100644 svg/time.svg create mode 100644 svg/trample.svg create mode 100644 svg/vigilance.svg diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0f1e252 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +* +!*/ +!*.svg +!counters.py diff --git a/counters.py b/counters.py new file mode 100644 index 0000000..3187ece --- /dev/null +++ b/counters.py @@ -0,0 +1,126 @@ +from ocp_vscode import * +from build123d import * +from math import tan, pi, radians + +def PG(x, y, angle): + return Polygon((x, 0), (x, y), (0, y + x * tan(radians(angle))), (0, x * tan(radians(angle))), align=Align.MIN) + +def CounterVal(val): + if val > 0: + return f"+{val}" + elif val < 0: + return f"-{val}" + else: + return f"{val}" + +def NumStr(val): + if val < 0: + return f"n{val}" + else: + return f"{val}" + +def Chevron(x, y, angle): + return PG(x/2, y, angle) + mirror(PG(x/2, y, angle), Plane.YZ) + +def Numerical(left, right, x, y, t, angle, base_z, text_z): + base = Chevron(x, y, angle) + counter = extrude(base, base_z + text_z, (0, 0, 1)) + + cutout = Pos(t/2, t + t*tan(radians(angle)), 0) * PG(x/2 - 1.5*t, y - 2*t, angle) + cutout += mirror(cutout, Plane.YZ) + cutout = Pos(0, 0, base_z + text_z) * cutout + + counter -= extrude(cutout, text_z, (0, 0, -1)) + + font_size = x/5 + + font = "Arial Rounded MT Bold" + top = Pos(-x/4, y/2 + (t/2+x/4)*tan(radians(angle))) * Rot(0, 0, angle) * Text(CounterVal(left), font_size, font=font) + top += Pos(x/4, y/2 + (t/2+x/4)*tan(radians(angle))) * Rot(0, 0, -angle) * Text(CounterVal(right), font_size, font=font) + + counter += extrude(Pos(0, 0, base_z) * top, text_z, (0, 0, 1)) + + return counter + +def Textual(text, image, image_yoff, x, y, t, angle, base_z, text_z): + counter = extrude(Chevron(x, y, angle), base_z + text_z, (0, 0, 1)) + counter -= extrude(Pos(0, t + t*tan(radians(angle)), base_z + text_z) * Chevron(x-2*t, y-2*t, angle), text_z, (0, 0, -1)) + + font = "Arial Rounded MT Bold" + font_size = x/8 + top = Pos(0, x/2*tan(radians(angle)) + 2*t) * Text(text, font_size, font=font, align=(Align.CENTER, Align.MIN)) + + svg = import_svg(image, align=(Align.CENTER, Align.MIN)) + svg_max_x = max([x.bounding_box().max.X for x in svg.faces()]) + svg_max_y = max([x.bounding_box().max.Y for x in svg.faces()]) + svg_min_x = min([x.bounding_box().min.X for x in svg.faces()]) + svg_min_y = min([x.bounding_box().min.Y for x in svg.faces()]) + svg_size = (svg_max_x - svg_min_x, svg_max_y - svg_min_y) + svg_scale = min(x/svg_size[0] * 0.6, y/svg_size[1] * 0.6) + + svg_obj = [Pos(0, y + t + image_yoff*svg_scale - svg_size[1]*svg_scale) * face for face in svg.faces()] + top += scale(svg_obj, (svg_scale, svg_scale, svg_scale)) + + counter += extrude(Pos(0, 0, base_z) * top, text_z, (0, 0, 1)) + + return counter + + +x = 25 * MM +y = 10 * MM +t = 1 * MM +base_z = 1 * MM +text_z = 1 * MM +angle = 22.5 + +number_counters = [ + (1, 1), + (5, 5), + (10, 10), + (-1, -1), + (-5, -5), + (1, 0), + (5, 0), + (10, 0), + (0, 1), + (0, 5), + (0, 10), + (1, -1), +] + +image_counters = { + "Deathtouch": 2, + "Doublestrike": 0, + "First Strike": 0, + "Flying": 0, + "Goad": 0, + "Haste": -3, + "Hexproof": 0, + "Indestructible": 0, + "Lifelink": -2, + "Lore": 0, + "Menace": -2, + "Reach": -3, + "Ringbearer": 2, + "Shield": -2, + "Stun": -2, + "Time": 0, + "Trample": 0, + "Vigilance": -1.5, + "Charge": 0, +} + +if True: + for numbers in number_counters: + counter = Numerical(numbers[0], numbers[1], x, y, t, angle, base_z, text_z) + export_step(counter, f"step/counter_{NumStr(numbers[0])}_{NumStr(numbers[1])}.step") + export_stl(counter, f"stl/counter_{NumStr(numbers[0])}_{NumStr(numbers[1])}.stl") + + for text, y_off in image_counters.items(): + counter = Textual(text, f"svg/{text.lower().replace(' ', '')}.svg", y_off, x, 2.5*y, t, angle, base_z, text_z) + export_step(counter, f"step/counter_{text.lower().replace(' ', '')}.step") + export_stl(counter, f"stl/counter_{text.lower().replace(' ', '')}.stl") +else: + text = "Charge" + counter = Textual(text, f"svg/{text.lower().replace(' ', '')}.svg", image_counters[text], x, 2.5*y, t, angle, base_z, text_z) + show(counter) \ No newline at end of file diff --git a/svg/charge.svg b/svg/charge.svg new file mode 100644 index 0000000..e710463 --- /dev/null +++ b/svg/charge.svg @@ -0,0 +1,5 @@ + + +counter-charge + + diff --git a/svg/deathtouch.svg b/svg/deathtouch.svg new file mode 100644 index 0000000..7815041 --- /dev/null +++ b/svg/deathtouch.svg @@ -0,0 +1,5 @@ + + +ability-deathtouch + + diff --git a/svg/doublestrike.svg b/svg/doublestrike.svg new file mode 100644 index 0000000..6e24787 --- /dev/null +++ b/svg/doublestrike.svg @@ -0,0 +1,5 @@ + + +ability-doublestrike + + diff --git a/svg/firststrike.svg b/svg/firststrike.svg new file mode 100644 index 0000000..c700903 --- /dev/null +++ b/svg/firststrike.svg @@ -0,0 +1,5 @@ + + +ability-firststrike + + diff --git a/svg/flying.svg b/svg/flying.svg new file mode 100644 index 0000000..6debb7b --- /dev/null +++ b/svg/flying.svg @@ -0,0 +1,5 @@ + + +ability-flying + + diff --git a/svg/goad.svg b/svg/goad.svg new file mode 100644 index 0000000..f3fc897 --- /dev/null +++ b/svg/goad.svg @@ -0,0 +1,5 @@ + + +ability-goad + + diff --git a/svg/haste.svg b/svg/haste.svg new file mode 100644 index 0000000..ebe14e8 --- /dev/null +++ b/svg/haste.svg @@ -0,0 +1,5 @@ + + +ability-haste + + diff --git a/svg/hexproof.svg b/svg/hexproof.svg new file mode 100644 index 0000000..7957a8a --- /dev/null +++ b/svg/hexproof.svg @@ -0,0 +1,6 @@ + + +ability-hexproof + + + diff --git a/svg/indestructible.svg b/svg/indestructible.svg new file mode 100644 index 0000000..c0750a8 --- /dev/null +++ b/svg/indestructible.svg @@ -0,0 +1,5 @@ + + +ability-indestructible + + diff --git a/svg/lifelink.svg b/svg/lifelink.svg new file mode 100644 index 0000000..a4a24cc --- /dev/null +++ b/svg/lifelink.svg @@ -0,0 +1,5 @@ + + +ability-lifelink + + diff --git a/svg/lore.svg b/svg/lore.svg new file mode 100644 index 0000000..a1de352 --- /dev/null +++ b/svg/lore.svg @@ -0,0 +1,5 @@ + + +counter-lore + + diff --git a/svg/menace.svg b/svg/menace.svg new file mode 100644 index 0000000..80d30ca --- /dev/null +++ b/svg/menace.svg @@ -0,0 +1,5 @@ + + +ability-menace + + diff --git a/svg/reach.svg b/svg/reach.svg new file mode 100644 index 0000000..90cbc0a --- /dev/null +++ b/svg/reach.svg @@ -0,0 +1,5 @@ + + +ability-reach + + diff --git a/svg/ringbearer.svg b/svg/ringbearer.svg new file mode 100644 index 0000000..2e88338 --- /dev/null +++ b/svg/ringbearer.svg @@ -0,0 +1,5 @@ + + +ability-ring-bearer + + diff --git a/svg/shield.svg b/svg/shield.svg new file mode 100644 index 0000000..f46d903 --- /dev/null +++ b/svg/shield.svg @@ -0,0 +1,5 @@ + + +counter-shield + + diff --git a/svg/stun.svg b/svg/stun.svg new file mode 100644 index 0000000..cfb1044 --- /dev/null +++ b/svg/stun.svg @@ -0,0 +1,5 @@ + + +counter-stun + + diff --git a/svg/time.svg b/svg/time.svg new file mode 100644 index 0000000..9ff64b0 --- /dev/null +++ b/svg/time.svg @@ -0,0 +1,5 @@ + + +counter-time + + diff --git a/svg/trample.svg b/svg/trample.svg new file mode 100644 index 0000000..6f2af64 --- /dev/null +++ b/svg/trample.svg @@ -0,0 +1,5 @@ + + +ability-trample + + diff --git a/svg/vigilance.svg b/svg/vigilance.svg new file mode 100644 index 0000000..5733cb2 --- /dev/null +++ b/svg/vigilance.svg @@ -0,0 +1,5 @@ + + +ability-vigilance + +