diff options
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 \ + ; |