Add python script to generate a hex SVG points

This commit is contained in:
Oliver Akins 2022-12-25 17:41:03 -06:00
parent 4991f0eac8
commit ee9d9ca6ed
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99

19
hex.py Normal file
View file

@ -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()