Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option in scripts to generate colored svg icons #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions tools/generatepng.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

# Usage: generatepng.sh type outputformat
# type can be 'all', default is 'all'
# outputformat can be 'png' or 'svg', default is 'png'

pushd . > /dev/null
cd `dirname $BASH_SOURCE` > /dev/null
BASEFOLDER=`pwd`;
Expand All @@ -12,27 +16,37 @@ FORGROUND_COLOURS=( '#0092DA' '#734A08' '#666666' '#39AC39' '#734A08' '#
SIZES=(64 48 32 24 20 16 12)

SVGFOLDER=${BASEFOLDER}/svg/
OUTPUTFOLDER=${BASEFOLDER}/png/
OUTPUTFOLDER=${BASEFOLDER}/out/

if [ ! -d "${OUTPUTFOLDER}" ]; then
mkdir ${OUTPUTFOLDER}
fi

for (( i = 0 ; i < ${#TYPES[@]} ; i++ )) do
if [ "$2" == "" ]; then
OUTPUTFORMAT="png"
else
OUTPUTFORMAT="$2"
fi

if [ "$1" == "" -o "$1" == "${TYPES[i]}" ]; then
if [ "$OUTPUTFORMAT" == "svg" ]; then
SIZES=(12)
fi

for (( i = 0 ; i < ${#TYPES[@]} ; i++ )) do

echo "On: ${TYPES[i]}"
if [ "$1" == "" -o "$1" == "${TYPES[i]}" -o "$1" == "all" ]; then

for FILE in $SVGFOLDER${TYPES[i]}/*.svg; do

BASENAME=${FILE##/*/}
BASENAME=${OUTPUTFOLDER}${TYPES[i]}_${BASENAME%.*}

for (( j = 0 ; j < ${#SIZES[@]} ; j++ )) do
${BASEFOLDER}/tools/recolourtopng.sh ${FILE} 'none' 'none' ${FORGROUND_COLOURS[i]} ${SIZES[j]} ${BASENAME}.p.${SIZES[j]}
${BASEFOLDER}/tools/recolourtopng.sh ${FILE} ${FORGROUND_COLOURS[i]} ${FORGROUND_COLOURS[i]} '#ffffff' ${SIZES[j]} ${BASENAME}.n.${SIZES[j]}
convert ${BASENAME}.p.${SIZES[j]}.png \( +clone -background "#ffffff" -shadow 8000x2-0+0 \) +swap -background none -layers merge +repage -trim ${BASENAME}.glow.${SIZES[j]}.png
${BASEFOLDER}/tools/recolourtopng.sh ${FILE} 'none' 'none' ${FORGROUND_COLOURS[i]} ${SIZES[j]} ${BASENAME}.p.${SIZES[j]} $OUTPUTFORMAT
${BASEFOLDER}/tools/recolourtopng.sh ${FILE} ${FORGROUND_COLOURS[i]} ${FORGROUND_COLOURS[i]} '#ffffff' ${SIZES[j]} ${BASENAME}.n.${SIZES[j]} $OUTPUTFORMAT
if [ "$OUTPUTFORMAT" == "png" ]; then
convert ${BASENAME}.p.${SIZES[j]}.png \( +clone -background "#ffffff" -shadow 8000x2-0+0 \) +swap -background none -layers merge +repage -trim ${BASENAME}.glow.${SIZES[j]}.png
fi
done

done
Expand Down
9 changes: 8 additions & 1 deletion tools/recolourtopng.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
# $4 forground
# $5 png size
# $6 output filename
# $7 output format ('svg' or 'png')

pushd . > /dev/null
cd `dirname $BASH_SOURCE` > /dev/null
BASEFOLDER=`pwd`;
popd > /dev/null
BASEFOLDER=`dirname $BASEFOLDER`

${BASEFOLDER}/tools/recolour.sh $1 $2 $3 $4 | rsvg -f png -w ${5} -h ${5} /dev/stdin ${6}.png
if [ "${7}" == "png" ]; then
${BASEFOLDER}/tools/recolour.sh $1 $2 $3 $4 | rsvg -f png -w ${5} -h ${5} /dev/stdin ${6}.png
elif [ "${7}" == "svg" ]; then
${BASEFOLDER}/tools/recolour.sh $1 $2 $3 $4 > ${6}.svg
else
echo "Unknown output format"
fi