From ee9d9ca6ede595710b8f072ea8e620ca1d876c85 Mon Sep 17 00:00:00 2001 From: Oliver Akins Date: Sun, 25 Dec 2022 17:41:03 -0600 Subject: [PATCH] Add python script to generate a hex SVG points --- hex.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 hex.py diff --git a/hex.py b/hex.py new file mode 100644 index 0000000..bc0ef9d --- /dev/null +++ b/hex.py @@ -0,0 +1,19 @@ +from math import cos, sin, radians + +h = int(input("Total hexagon height allowed: ")) +canvas_size = int(input("SVG size: ")) +move_by = abs(canvas_size - h) / 2 + +m = h // 2 +p = { + "x": 0, + "y": m +} + +print("\nPoints: ") +for _ in range(6): + print(f"{round(p['x'] + m + move_by)},{round(p['y'] + m + move_by)}", end=" ") + x, y = p["x"], p["y"] + p["x"] = round(x*cos(radians(60)) - y*sin(radians(60)), 5) + p["y"] = round(x*sin(radians(60)) + y*cos(radians(60)), 5) +print() \ No newline at end of file