diff --git a/generate_svgs.py b/generate_svgs.py new file mode 100644 index 0000000..49cd233 --- /dev/null +++ b/generate_svgs.py @@ -0,0 +1,46 @@ +import xml.etree.ElementTree as ET +import re + +pattern = re.compile("table_(.)(.*)") +pattern_text = re.compile("label_(.)") + + +def letters_to_numbers(group_string, number_string): + out1 = ord(group_string) - ord('a') + if len(number_string) == 1: + # only one letter + out2 = ord(number_string) - ord('a') + elif len(number_string) == 2: + # its an umlaut + out2 = {"ae": 26, "oe": 27, "ue": 28}[number_string] + return out1, out2 + +def draw_only_group(group_id): + tree = ET.parse("mensa.svg") + root = tree.getroot() + + rects = root.findall(".//{http://www.w3.org/2000/svg}rect") + rects = list(filter(lambda rect: pattern.match(rect.attrib["id"]), rects)) + + texts = root.findall(".//{http://www.w3.org/2000/svg}text") + texts = list(filter(lambda text: pattern_text.match(text.attrib["id"]), texts)) + for text in texts: + match = pattern_text.match(text.attrib["id"]) + group = ord(match.group(1)) - ord('a') + if group != group_id: + # color the child spans text white + span = list(text)[0] + style_span="font-size:3.17499995px;fill:#ffffff;fill-opacity:1;stroke-width:0.26458332;" + span.attrib["style"] = style_span + + for rect in rects: + match = pattern.match(rect.attrib["id"]) + group, number = letters_to_numbers(match.group(1), match.group(2)) + if group != group_id: + # other group, color grey + rect.attrib["style"] = "fill:#808080;stroke-width:0.26458332" + groupstring = chr(ord('a') + group_id) + tree.write(f"mensamap_highlight_group_{groupstring}.svg") + +for i in range(9): + draw_only_group(i) diff --git a/mensa.svg b/mensa.svg index 62ca701..e8422f6 100644 --- a/mensa.svg +++ b/mensa.svg @@ -28,18 +28,18 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="4" - inkscape:cx="336.09929" - inkscape:cy="700.11768" + inkscape:zoom="2.828427" + inkscape:cx="348.36714" + inkscape:cy="672.26215" inkscape:document-units="mm" inkscape:current-layer="layer1" showgrid="true" inkscape:measure-start="0,0" inkscape:measure-end="0,0" inkscape:window-width="1366" - inkscape:window-height="744" + inkscape:window-height="768" inkscape:window-x="0" - inkscape:window-y="24" + inkscape:window-y="0" inkscape:window-maximized="0"> + inkscape:export-ydpi="698.18164" + inkscape:label="#rect3771-53-3" /> + inkscape:export-ydpi="698.18164" + inkscape:label="#rect3769-31-3" /> - - - - - - + y="104.64171" + style="font-size:3.88055563px;stroke-width:0.26458332" /> + y="105.72691" + style="font-size:2.11666656px;stroke-width:0.26458332" /> + style="font-size:3.52777767px;stroke-width:0.26458332" /> A + style="font-size:1.76388896px;stroke-width:0.26458332">A L - - - - F + C + d i - i + style="font-size:3.17499995px;fill:#cc00ff;fill-opacity:1;stroke-width:0.26458332">i L + +