From b38e8565e9023adf5e0761a2102c2d1f275f67de Mon Sep 17 00:00:00 2001 From: Mischa Untaga <99098079+MischaU8@users.noreply.github.com> Date: Fri, 27 Oct 2023 22:16:17 +0200 Subject: generated layout for cubes & supporter placement --- .gitignore | 1 + tools/genlayout.py | 32 ++++++ tools/layout.svg | 278 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 311 insertions(+) create mode 100644 tools/genlayout.py create mode 100644 tools/layout.svg diff --git a/.gitignore b/.gitignore index 8d87097..3e3dbf9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +HIRES/ node_modules/ .vscode/ diff --git a/tools/genlayout.py b/tools/genlayout.py new file mode 100644 index 0000000..8782af3 --- /dev/null +++ b/tools/genlayout.py @@ -0,0 +1,32 @@ +from bs4 import BeautifulSoup + +SCALE = 1.0 + +def readsvg(filename): + with open(filename) as fp: + soup = BeautifulSoup(fp, features="xml") + + result = [] + for group in ['Regions', 'States']: + boxes = soup.find('g', id=group) + for box in boxes.find_all('g', recursive=False): + name = box.attrs['id'] + rect = box.find('rect') + x = float(rect.attrs['x']) + y = float(rect.attrs['y']) + w = float(rect.attrs['width']) + h = float(rect.attrs['height']) + xc = round((x+w/2.0)*SCALE) + yc = round((y+h/2.0)*SCALE) + result.append([name, xc, yc]) + + return result + +def print_list(data): + print("const LAYOUT = {") + for (name, x, y) in data: + print(f'\t"{name}": [{x}, {y}],') + print("}") + +result = readsvg("tools/layout.svg") +print_list(result) diff --git a/tools/layout.svg b/tools/layout.svg new file mode 100644 index 0000000..722125e --- /dev/null +++ b/tools/layout.svg @@ -0,0 +1,278 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3