diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2011-09-16 14:36:28 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2011-09-16 14:36:28 +0200 |
| commit | 579ef7a535489d4aa632db11667a3b01deb6cafd (patch) | |
| tree | 55810021c02ac7d80d3a9702ef0b59e4af154b9c /main/project/attributes/makeicons1res.sh | |
| parent | 96ea21fd50334479c262da692038965d0e4d596a (diff) | |
| download | cgeo-579ef7a535489d4aa632db11667a3b01deb6cafd.zip cgeo-579ef7a535489d4aa632db11667a3b01deb6cafd.tar.gz cgeo-579ef7a535489d4aa632db11667a3b01deb6cafd.tar.bz2 | |
Move sources into the main directory
This prepares the inclusion of tests into the same repository.
Diffstat (limited to 'main/project/attributes/makeicons1res.sh')
| -rw-r--r-- | main/project/attributes/makeicons1res.sh | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/main/project/attributes/makeicons1res.sh b/main/project/attributes/makeicons1res.sh new file mode 100644 index 0000000..a6805ea --- /dev/null +++ b/main/project/attributes/makeicons1res.sh @@ -0,0 +1,85 @@ +#!/bin/bash +# +# creates attribute icons in one resolution only +# target dir: ./drawable + +require () { + hash $1 2>&- || { echo >&2 "I require $1 but it's not installed. Aborting."; exit 1; } +} + +require optipng +require convert +require composite +require sed + +# size of the image itself (inside border) +IMGSIZE=32 +# size of the whole icon +ICONSIZE=48 +# distance of border from edge of icon +BDIST=2 +# thickness of border +BSTROKE=2 +# size of the round edges +BROUND=8 +# color of the border +FCOL=white +# background color of the icon +BCOL=black +# thickness of the strikethru bar +SSTROKE=5 +# color of the strikethru bar +SCOL=\#c00000 +# file name of strike thru bar +SFNAME="drawable/attribute__strikethru.png" + +#calculated values +BNDIST=$(( ${ICONSIZE} - ${BDIST} )) +res=48 + +# create output directory if missing +[ -d drawable ] || mkdir drawable + +# create border +echo "drawing border" +convert -size ${ICONSIZE}x${ICONSIZE} xc:none -fill ${BCOL} -strokewidth 1 \ + -draw "roundrectangle ${BDIST},${BDIST} ${BNDIST},${BNDIST} ${BROUND},${BROUND}" \ + -strokewidth ${BSTROKE} -stroke ${FCOL} \ + -draw "roundrectangle ${BDIST},${BDIST} ${BNDIST},${BNDIST} ${BROUND},${BROUND}" \ + border.png + +# create strike-thru bar as overlay for _no images +echo "drawing ${SFNAME}" +convert -size ${ICONSIZE}x${ICONSIZE} xc:none -fill ${BCOL} -strokewidth 1 \ + -draw "roundrectangle ${BDIST},${BDIST} ${BNDIST},${BNDIST} ${BROUND},${BROUND}" \ + mask1.png +convert -size ${ICONSIZE}x${ICONSIZE} xc:none -fill none -strokewidth ${BSTROKE} -stroke ${FCOL} \ + -draw "roundrectangle ${BDIST},${BDIST} ${BNDIST},${BNDIST} ${BROUND},${BROUND}" \ + mask2.png +convert -size ${ICONSIZE}x${ICONSIZE} xc:none -stroke "${SCOL}" -strokewidth ${SSTROKE} \ + -draw "line 0,0 ${ICONSIZE},${ICONSIZE}" mask1.png -compose DstIn -composite tmp.png +convert tmp.png mask2.png -compose DstOut -composite -depth 8 ${SFNAME} +optipng -quiet ${SFNAME} + +if [ $# -gt 0 ]; then + svgs="$@" +else + svgs="svgs/*.svg" +fi +for s in $svgs; do + n=drawable/attribute_`basename "$s" | sed "s/\.svg//"` + + # don't draw icons if svg is older than icon + [ -f "${n}.png" ] && [ "$s" -ot "${n}.png" ] && continue + + echo "drawing $n" + + # draw icons + convert -density 200 -background none "$s" -resize ${IMGSIZE}x${IMGSIZE} tmp.png + composite -gravity center tmp.png border.png -depth 8 "${n}.png" + optipng -quiet "${n}.png" +done + + +rm tmp.png border.png mask1.png mask2.png + |
