From 483da9bc95b54f9ce8bf7ffb165d66a7fdab93f9 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Fri, 8 Jan 2021 22:08:27 -0500 Subject: [PATCH] Complete repo restructure SVG with easily regex-able placeholders for fill and stroke put in template folder, which `svg2img` generates into all the color variants of the logo. `svg2img` revamped to support this new system, as well as ASCII (via jp2a), and Unicode (via chafa) --- svg2img | 138 +++++++++++++++++++++++++++++++++++++++----- template/circle.svg | 8 +++ template/square.svg | 8 +++ 3 files changed, 138 insertions(+), 16 deletions(-) create mode 100644 template/circle.svg create mode 100644 template/square.svg diff --git a/svg2img b/svg2img index af2e242..9c1eba6 100755 --- a/svg2img +++ b/svg2img @@ -1,26 +1,132 @@ #!/usr/bin/env bash +# Converts my logo to various formats from a template SVG +# Armaan Bhojwani 2021 -if [[ (! -d "png") || (${1} == "png") ]]; then - mkdir -p png/1024 png/512 png/256 png/128 - - for PHOTO in svg/*; do - BASE=$(basename $PHOTO | cut -d '.' -f 1) - inkscape -w 1024 -h 1024 "$PHOTO" --export-filename png/1024/${BASE}.png - inkscape -w 512 -h 512 "$PHOTO" --export-filename png/512/${BASE}.png - inkscape -w 256 -h 256 "$PHOTO" --export-filename png/256/${BASE}.png - inkscape -w 128 -h 128 "$PHOTO" --export-filename png/128/${BASE}.png +[[ -z ${1} ]] && echo "Please provide an output format!" && exit 1 + +[[ ${1} == "svg" ]] && find . -name *.svg -not -path "./template/*" -exec rm {} \; + +if [[ (! -d "square/svg" || ! -d "circle/svg") || (${1} == "svg") ]]; then + for SHAPE in square circle; do + mkdir -pv ${SHAPE}/svg + + sed -e 's/STROKE/stroke="#00ffbf" /g' \ + -e 's/FILL/ fill="#212121"/g' template/${SHAPE}.svg \ + > ${SHAPE}/svg/logo-${SHAPE}-color-dark.svg + + sed -e 's/STROKE/stroke="#00ffbf" /g' \ + -e 's/FILL/ fill="#fff"/g' template/${SHAPE}.svg \ + > ${SHAPE}/svg/logo-${SHAPE}-color-white.svg + + sed -e 's/STROKE/stroke="#00ffbf" /g' \ + -e 's/FILL//g' template/${SHAPE}.svg \ + > ${SHAPE}/svg/logo-${SHAPE}-color-trans.svg + + sed -e 's/STROKE/stroke="#212121" /g' \ + -e 's/FILL/ fill="#00ffbf"/g' template/${SHAPE}.svg \ + > ${SHAPE}/svg/logo-${SHAPE}-dark-color.svg + + sed -e 's/STROKE/stroke="#212121" /g' \ + -e 's/FILL/ fill="#fff"/g' template/${SHAPE}.svg \ + > ${SHAPE}/svg/logo-${SHAPE}-dark-white.svg + + sed -e 's/STROKE/stroke="#212121" /g' \ + -e 's/FILL//g' template/${SHAPE}.svg \ + > ${SHAPE}/svg/logo-${SHAPE}-dark-trans.svg + + sed -e 's/STROKE/stroke="#fff" /g' \ + -e 's/FILL/ fill="#00ffbf"/g' template/${SHAPE}.svg \ + > ${SHAPE}/svg/logo-${SHAPE}-white-color.svg + + sed -e 's/STROKE/stroke="#fff" /g' \ + -e 's/FILL/ fill="#212121"/g' template/${SHAPE}.svg \ + > ${SHAPE}/svg/logo-${SHAPE}-white-dark.svg + + sed -e 's/STROKE/stroke="#fff" /g' \ + -e 's/FILL//g' template/${SHAPE}.svg \ + > ${SHAPE}/svg/logo-${SHAPE}-white-trans.svg + done +fi + +[[ ${1} == "svg" ]] && exit 0 + +[[ ${1} == "png" ]] && find . -name *.png -exec rm {} \; + +if [[ (! -d "square/png" || ! -d "circle/png") || (${1} == "png") ]]; then + for SHAPE in square circle; do + for i in 2048 1024 512 256 128; do + mkdir -pv ${SHAPE}/png/${i} + done + + for i in 2048 1024 512 256 128; do + for SVGIN in square/svg/*; do + BASE=$(basename ${SVGIN} | cut -d '.' -f 1) + inkscape -w ${i} -h ${i} ${SVGIN} --export-filename \ + square/png/${i}/${BASE}-${i}.png + done + + for SVGIN in circle/svg/*; do + BASE=$(basename ${SVGIN} | cut -d '.' -f 1) + inkscape -w ${i} -h ${i} ${SVGIN} --export-filename \ + circle/png/${i}/${BASE}-${i}.png + done + done done fi [[ ${1} == "png" ]] && exit 0 -rm -rf ${1} +if [[ ${1} == "ascii" ]]; then + find . -name *ascii.txt -exec rm {} \; + for SHAPE in square circle; do + for i in 10 15 20 25 30 35 40 45 50; do + mkdir -pv ${SHAPE}/ascii/${i} -for PAT in $(find "png" -type d); do - mkdir $(echo $PAT | sed "s/png/${1}/g") -done + for PNGIN in circle/png/2048/*; do + BASE=$(basename ${PNGIN} | cut -d '.' -f 1) + jp2a --height=${i} ${PNGIN} > circle/ascii/${i}/${BASE}-${i}.ascii.txt + done + + for PNGIN in square/png/2048/*; do + BASE=$(basename ${PNGIN} | cut -d '.' -f 1) + jp2a --height=${i} ${PNGIN} > square/ascii/${i}/${BASE}-${i}.ascii.txt + done + done + done + exit 0 +fi + +if [[ ${1} == "unicode" ]]; then + find . -name *unicode.txt -exec rm {} \; + for SHAPE in square circle; do + for i in 10 15 20 25 30 35 40 45 50; do + mkdir -pv ${SHAPE}/unicode/${i} + + for PNGIN in circle/png/2048/*; do + BASE=$(basename ${PNGIN} | cut -d '-' -f -4) + chafa -c none -s ${i}x${i} ${PNGIN} \ + > circle/unicode/${i}/${BASE}-${i}.unicode.txt + done + + for PNGIN in square/png/2048/*; do + BASE=$(basename ${PNGIN} | cut -d '-' -f -4) + chafa -c none -s ${i}x${i} ${PNGIN} \ + > square/unicode/${i}/${BASE}-${i}.unicode.txt + done + done + done + exit 0 +fi + +for SHAPE in square circle; do + find . -name *.${1} -exec rm {} \; + + for i in 2048 1024 512 256 128; do + mkdir -pv ${SHAPE}/${1}/${i} + done -for PAT in $(find "png" -type f); do - BASE=$(echo $PAT | sed "s/png/${1}/g") - convert -verbose $PAT $BASE + # for PAT in $(find -name *.png); do + while read PAT; do + convert -verbose ${PAT} ${PAT//png/${1}} + done < <(find -name *.png) done diff --git a/template/circle.svg b/template/circle.svg new file mode 100644 index 0000000..7eaab61 --- /dev/null +++ b/template/circle.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/template/square.svg b/template/square.svg new file mode 100644 index 0000000..2f254cb --- /dev/null +++ b/template/square.svg @@ -0,0 +1,8 @@ + + + + + + + + -- 2.39.2