Skip to content

Commit

Permalink
refactor: create combined SVG by nesting, rather than embedding base64
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcur committed Jul 20, 2024
1 parent a354cc5 commit ecd4b77
Show file tree
Hide file tree
Showing 3 changed files with 2,468 additions and 38 deletions.
2,462 changes: 2,446 additions & 16 deletions media/combined-embedded.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 4 additions & 16 deletions media/combined.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 18 additions & 6 deletions scripts/screenshots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,21 @@ done
wait

# prepare combined SVG from template
sed \
-e "s~./highlow.svg~data:image/svg+xml;base64,$(base64 -w 0 ./media/highlow.svg)~" \
-e "s~./twocolor.svg~data:image/svg+xml;base64,$(base64 -w 0 ./media/twocolor.svg)~" \
-e "s~./verf.svg~data:image/svg+xml;base64,$(base64 -w 0 ./media/verf.svg)~" \
"./media/combined.svg" \
>./media/combined-embedded.svg
python3 <<EOF
from pathlib import Path
def set_dimensions(svg: str, x: int, y: int, width: int, height: int) -> str:
return svg.replace("<svg", f"""<svg x="{x}" y="{y}" width="{width}" height="{height}" """)
template = Path("./media/combined.svg").read_text()
img1 = set_dimensions(Path("./media/highlow.svg").read_text(), 5, 5, 120, 70)
img2 = set_dimensions(Path("./media/twocolor.svg").read_text(), 35, 35, 120, 70)
img3 = set_dimensions(Path("./media/verf.svg").read_text(), 65, 65, 120, 70)
template = template.replace("{img1}", img1)
template = template.replace("{img2}", img2)
template = template.replace("{img3}", img3)
Path("./media/combined-embedded.svg").write_text(template)
EOF

0 comments on commit ecd4b77

Please sign in to comment.