diff options
author | Zach van Rijn <me@zv.io> | 2021-05-24 16:43:48 -0500 |
---|---|---|
committer | Zach van Rijn <me@zv.io> | 2021-05-24 16:43:48 -0500 |
commit | 0a5015eec26eeebb205e860c64b5472f1f16ab41 (patch) | |
tree | 9a80182a815538093d757aa08bff93d39cf0093a /assets/images/polyguin.sh | |
download | site-ng-0a5015eec26eeebb205e860c64b5472f1f16ab41.tar.gz site-ng-0a5015eec26eeebb205e860c64b5472f1f16ab41.tar.bz2 site-ng-0a5015eec26eeebb205e860c64b5472f1f16ab41.tar.xz site-ng-0a5015eec26eeebb205e860c64b5472f1f16ab41.zip |
Initial commit. Still missing pages/content.
Diffstat (limited to 'assets/images/polyguin.sh')
-rwxr-xr-x | assets/images/polyguin.sh | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/assets/images/polyguin.sh b/assets/images/polyguin.sh new file mode 100755 index 0000000..875ccee --- /dev/null +++ b/assets/images/polyguin.sh @@ -0,0 +1,79 @@ +#!/bin/sh -e + +## +# Target: color +# +# Optionally apply color transformations here. +# +cp polyguin.svg polyguin_color.svg + +## +# Target: black +# +# Convert color SVG to black SVG and maintain transparency. +# +cp polyguin.svg polyguin_black.svg +grep fill: polyguin.svg \ + | grep -v fill:none \ + | grep -E -o '\#[a-f0-9]*\w' \ + | sort \ + | uniq \ + | cut -d\# -f2 \ + | while read k; do + sed -i polyguin_black.svg \ + -e 's@'"$k"'@__BLACK_'"$k"'__@g' \ + ; + done \ + ; +grep fill: polyguin.svg \ + | grep -v fill:none \ + | grep -E -o '\#[a-f0-9]*\w' \ + | sort \ + | uniq \ + | cut -d\# -f2 \ + | sed 's/.\{2\}/& /g' \ + | awk '{ print "0x"$1,"0x"$2,"0x"$3, ($1 $2 $3) }' \ + | awk --non-decimal-data '{ print $4, (1 - (($1 + $2 + $3) / (3 * 256))) }' \ + | while read a b; do + sed -i polyguin_black.svg \ + -e '/'"$a"'/ s@-opacity:1@-opacity:'"$b"'@g' \ + -e '/'"$a"'/ s@__BLACK_[a-f0-9]*__@000000@g' \ + ; + done \ + ; + + +## +# Target: white +# +# Convert color SVG to white SVG and maintain transparency. +# +cp polyguin.svg polyguin_white.svg +grep fill: polyguin.svg \ + | grep -v fill:none \ + | grep -E -o '\#[a-f0-9]*\w' \ + | sort \ + | uniq \ + | cut -d\# -f2 \ + | while read k; do + sed -i polyguin_white.svg \ + -e 's@'"$k"'@__WHITE_'"$k"'__@g' \ + ; + done \ + ; +grep fill: polyguin.svg \ + | grep -v fill:none \ + | grep -E -o '\#[a-f0-9]*\w' \ + | sort \ + | uniq \ + | cut -d\# -f2 \ + | sed 's/.\{2\}/& /g' \ + | awk '{ print "0x"$1,"0x"$2,"0x"$3, ($1 $2 $3) }' \ + | awk --non-decimal-data '{ print $4, (($1 + $2 + $3) / (3 * 256)) }' \ + | while read a b; do + sed -i polyguin_white.svg \ + -e '/'"$a"'/ s@-opacity:1@-opacity:'"$b"'@g' \ + -e '/'"$a"'/ s@__WHITE_[a-f0-9]*__@ffffff@g' \ + ; + done \ + ; |