Add python script to generate a hex SVG points
This commit is contained in:
parent
4991f0eac8
commit
ee9d9ca6ed
1 changed files with 19 additions and 0 deletions
19
hex.py
Normal file
19
hex.py
Normal 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()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue