Skip to content

Commit 5bc875f

Browse files
committed
dash: use vector logo and minimize SVGs
1 parent a66152c commit 5bc875f

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

dashmin.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
3+
# Post-process gnuplot SVG output:
4+
# 1. replace bitmap logo with vector one (for smaller size and nicer look)
5+
# 2. losslessly compress it to minimize download size
6+
7+
# load svg logo without svg element, drop indent and newlines
8+
symbol_logo_bare="$(sed -E -e 's|</?svg.*>||g' -e 's/^ +//g' < ../logo/curl-symbol.svg | tr -d $'\n')"
9+
10+
# resize logo and move to center, set opacity
11+
logo_embed="$(printf \
12+
'<g id="logo" opacity=".07" transform="matrix(0.564,0,0,0.564,672,274)">%s</g>' \
13+
"${symbol_logo_bare}")"
14+
15+
# replace image element generated by gnuplot svg export, with svg logo
16+
cat stats.list | while read -r f; do
17+
# <image x='672.00' y='274.47' width='575.99' height='481.53' ...>
18+
sed -i.bak -E "s|\<image.+\>|${logo_embed}|g" "$f"
19+
done
20+
rm ./*.svg.bak
21+
22+
# compress losslessly
23+
svgo *.svg

updatedash.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ git shortlog -s > tmp/git-shortlog.txt 2>&1
3030
# generate us a bunch of updated SVG files
3131
sh stats/mksvg.sh ..
3232

33+
# post-process SVG
34+
../dashmin.sh
35+
3336
# back to base
3437
cd $orgdir
3538

0 commit comments

Comments
 (0)