diff options
author | Mischa Untaga <99098079+MischaU8@users.noreply.github.com> | 2023-10-27 22:16:17 +0200 |
---|---|---|
committer | Mischa Untaga <99098079+MischaU8@users.noreply.github.com> | 2023-10-27 22:16:17 +0200 |
commit | b38e8565e9023adf5e0761a2102c2d1f275f67de (patch) | |
tree | a2ea86c8e8055301b51b55a6ba98063889aa3eba | |
parent | 400f3866eb7103243d5f52bcd17a0251dcc36304 (diff) | |
download | votes-for-women-b38e8565e9023adf5e0761a2102c2d1f275f67de.tar.gz |
generated layout for cubes & supporter placement
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | tools/genlayout.py | 32 | ||||
-rw-r--r-- | tools/layout.svg | 278 |
3 files changed, 311 insertions, 0 deletions
@@ -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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg width="100%" height="100%" viewBox="0 0 1100 850" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;"> + <g id="States"> + <g id="NJ"> + <g> + <rect x="936" y="253" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="CT"> + <g> + <rect x="995" y="213" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="RI"> + <g> + <rect x="1012" y="141" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="MA"> + <g> + <rect x="990" y="50" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="ME"> + <g> + <rect x="939" y="95" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="NH"> + <g> + <rect x="865" y="72" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="VT"> + <g> + <rect x="793" y="133" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="NY"> + <g> + <rect x="839" y="183" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="DE"> + <g> + <rect x="973" y="321" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="MD"> + <g> + <rect x="928" y="380" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="NC"> + <g> + <rect x="840" y="361" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="VA"> + <g> + <rect x="837" y="308" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="PA"> + <g> + <rect x="825" y="233" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="WV"> + <g> + <rect x="787" y="290" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="KY"> + <g> + <rect x="719" y="327" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="TN"> + <g> + <rect x="692" y="377" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="OH"> + <g> + <rect x="738" y="263" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="IN"> + <g> + <rect x="684" y="261" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="IL"> + <g> + <rect x="639" y="309" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="MI"> + <g> + <rect x="700" y="204" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="WI"> + <g> + <rect x="615" y="174" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="MO"> + <g> + <rect x="577" y="333" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="IA"> + <g> + <rect x="539" y="232" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="MN"> + <g> + <rect x="537" y="139" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="FL"> + <g> + <rect x="811" y="548" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="SC"> + <g> + <rect x="804" y="409" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="GA"> + <g> + <rect x="755" y="441" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="AL"> + <g> + <rect x="691" y="446" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="MS"> + <g> + <rect x="638" y="453" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="LA"> + <g> + <rect x="599" y="520" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="AR"> + <g> + <rect x="581" y="412" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="TX"> + <g> + <rect x="458" y="492" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="OK"> + <g> + <rect x="495" y="393" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="KS"> + <g> + <rect x="473" y="324" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="NE"> + <g> + <rect x="453" y="249" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="SD"> + <g> + <rect x="447" y="181" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="ND"> + <g> + <rect x="444" y="110" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="CO"> + <g> + <rect x="350" y="307" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="WY"> + <g> + <rect x="317" y="205" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="MT"> + <g> + <rect x="311" y="109" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="NM"> + <g> + <rect x="327" y="416" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="AZ"> + <g> + <rect x="221" y="408" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="UT"> + <g> + <rect x="240" y="286" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="NV"> + <g> + <rect x="156" y="266" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="ID"> + <g> + <rect x="209" y="179" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="CA"> + <g> + <rect x="102" y="343" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="OR"> + <g> + <rect x="111" y="149" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="WA"> + <g> + <rect x="134" y="73" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + </g> + <g id="Regions"> + <g id="NorthEast"> + <g> + <rect x="890" y="166" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="AtlanticAppalachia"> + <g> + <rect x="773" y="342" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="MidWest"> + <g> + <rect x="588" y="274" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="South"> + <g> + <rect x="550" y="481" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="Plains"> + <g> + <rect x="382" y="212" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + <g id="West"> + <g> + <rect x="103" y="276" width="48" height="48" style="fill:#f00;fill-opacity:0.5;"/> + </g> + </g> + </g> +</svg> |