summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmaan Bhojwani <me@armaanb.net>2021-01-08 23:39:53 -0500
committerArmaan Bhojwani <me@armaanb.net>2021-01-08 23:39:53 -0500
commitb5474dba71da6f66fcb89f8e91626c7577301575 (patch)
tree8d2d5d5c753d0af7026b01f60cf0d42cdc83c7e7
parent2b9c5579d244487f213f529c8117722794ee3974 (diff)
downloadlogo-b5474dba71da6f66fcb89f8e91626c7577301575.tar.gz
Clean up "svg2img"
* Use arrays to store repeated image sizes * Add verbose flag to rm * Add echoes throughout the program * Move whitespace in template/sed statements
-rwxr-xr-xsvg2img47
-rw-r--r--template/circle.svg2
-rw-r--r--template/square.svg2
3 files changed, 29 insertions, 22 deletions
diff --git a/svg2img b/svg2img
index e632960..56915d0 100755
--- a/svg2img
+++ b/svg2img
@@ -2,47 +2,51 @@
# Converts my logo to various formats from a template SVG
# Armaan Bhojwani 2021
+SIZES=(2048 1024 512 256 128 64)
+A_SIZES=(10 15 20 25 30 35 40 45 50 55 60)
+
[[ -z ${1} ]] && echo "Please provide an output format!" && exit 1
-[[ ${1} == "svg" ]] && find . -name *.svg -not -path "./template/*" -exec rm {} \;
+[[ ${1} == "svg" ]] && find . -name *.svg -not -path "./template/*" -exec rm -v {} \;
if [[ (! -d "square/svg" || ! -d "circle/svg") || (${1} == "svg") ]]; then
+ echo "Generating SVGs"
for SHAPE in square circle; do
mkdir -pv ${SHAPE}/svg
- sed -e 's/STROKE/stroke="#00ffbf" /g' \
+ sed -e 's/STROKE/stroke="#00ffbf"/g' \
-e 's/FILL/#212121/g' template/${SHAPE}.svg \
> ${SHAPE}/svg/logo-${SHAPE}-color-dark.svg
- sed -e 's/STROKE/stroke="#00ffbf" /g' \
+ sed -e 's/STROKE/stroke="#00ffbf"/g' \
-e 's/FILL/#fff/g' template/${SHAPE}.svg \
> ${SHAPE}/svg/logo-${SHAPE}-color-white.svg
- sed -e 's/STROKE/stroke="#00ffbf" /g' \
+ sed -e 's/STROKE/stroke="#00ffbf"/g' \
-e 's/FILL/none/g' template/${SHAPE}.svg \
> ${SHAPE}/svg/logo-${SHAPE}-color-trans.svg
- sed -e 's/STROKE/stroke="#212121" /g' \
+ sed -e 's/STROKE/stroke="#212121"/g' \
-e 's/FILL/#00ffbf/g' template/${SHAPE}.svg \
> ${SHAPE}/svg/logo-${SHAPE}-dark-color.svg
- sed -e 's/STROKE/stroke="#212121" /g' \
+ sed -e 's/STROKE/stroke="#212121"/g' \
-e 's/FILL/#fff/g' template/${SHAPE}.svg \
> ${SHAPE}/svg/logo-${SHAPE}-dark-white.svg
- sed -e 's/STROKE/stroke="#212121" /g' \
+ sed -e 's/STROKE/stroke="#212121"/g' \
-e 's/FILL/none/g' template/${SHAPE}.svg \
> ${SHAPE}/svg/logo-${SHAPE}-dark-trans.svg
- sed -e 's/STROKE/stroke="#fff" /g' \
+ sed -e 's/STROKE/stroke="#fff"/g' \
-e 's/FILL/#00ffbf/g' template/${SHAPE}.svg \
> ${SHAPE}/svg/logo-${SHAPE}-white-color.svg
- sed -e 's/STROKE/stroke="#fff" /g' \
+ sed -e 's/STROKE/stroke="#fff"/g' \
-e 's/FILL/#212121/g' template/${SHAPE}.svg \
> ${SHAPE}/svg/logo-${SHAPE}-white-dark.svg
- sed -e 's/STROKE/stroke="#fff" /g' \
+ sed -e 's/STROKE/stroke="#fff"/g' \
-e 's/FILL/none/g' template/${SHAPE}.svg \
> ${SHAPE}/svg/logo-${SHAPE}-white-trans.svg
done
@@ -50,15 +54,16 @@ fi
[[ ${1} == "svg" ]] && exit 0
-[[ ${1} == "png" ]] && find . -name *.png -exec rm {} \;
+[[ ${1} == "png" ]] && find . -name *.png -exec rm -v {} \;
if [[ (! -d "square/png" || ! -d "circle/png") || (${1} == "png") ]]; then
+ echo "Generating PNGs"
for SHAPE in square circle; do
- for i in 2048 1024 512 256 128; do
+ for i in ${SIZES[@]}; do
mkdir -pv ${SHAPE}/png/${i}
done
- for i in 2048 1024 512 256 128; do
+ for i in ${SIZES[@]}; do
for SVGIN in square/svg/*; do
BASE=$(basename ${SVGIN} | cut -d '.' -f 1)
inkscape -w ${i} -h ${i} ${SVGIN} --export-filename \
@@ -77,9 +82,10 @@ fi
[[ ${1} == "png" ]] && exit 0
if [[ ${1} == "ascii" ]]; then
- find . -name *ascii.txt -exec rm {} \;
+ echo "Generating ASCII art"
+ find . -name *ascii.txt -exec rm -v {} \;
for SHAPE in square circle; do
- for i in 10 15 20 25 30 35 40 45 50; do
+ for i in ${A_SIZES[@]}; do
mkdir -pv ${SHAPE}/ascii/${i}
for PNGIN in circle/png/2048/*; do
@@ -97,9 +103,10 @@ if [[ ${1} == "ascii" ]]; then
fi
if [[ ${1} == "unicode" ]]; then
- find . -name *unicode.txt -exec rm {} \;
+ echo "Generating Unicode"
+ find . -name *unicode.txt -exec rm -v {} \;
for SHAPE in square circle; do
- for i in 10 15 20 25 30 35 40 45 50; do
+ for i in ${A_SIZES[@]}; do
mkdir -pv ${SHAPE}/unicode/${i}
for PNGIN in circle/png/2048/*; do
@@ -119,14 +126,14 @@ if [[ ${1} == "unicode" ]]; then
fi
for SHAPE in square circle; do
- find . -name *.${1} -exec rm {} \;
+ find . -name *.${1} -exec rm -v {} \;
- for i in 2048 1024 512 256 128; do
+ for i in ${SIZES[@]}; do
mkdir -pv ${SHAPE}/${1}/${i}
done
- # for PAT in $(find -name *.png); do
while read PAT; do
+ echo "Generating ${1}s"
convert -verbose ${PAT} ${PAT//png/${1}}
done < <(find -name *.png)
done
diff --git a/template/circle.svg b/template/circle.svg
index 5210884..143a94e 100644
--- a/template/circle.svg
+++ b/template/circle.svg
@@ -1,5 +1,5 @@
<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
- <g STROKEstroke-width="6">
+ <g STROKE stroke-width="6">
<circle cx="50" cy="50" r="47" fill="FILL"/>
<line x1="17" y1="17" x2="50" y2="50"/>
<line x1="17" y1="83" x2="83" y2="17"/>
diff --git a/template/square.svg b/template/square.svg
index 8241d93..690acea 100644
--- a/template/square.svg
+++ b/template/square.svg
@@ -1,5 +1,5 @@
<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
- <g STROKEstroke-width="6">
+ <g STROKE stroke-width="6">
<rect x="3" y="3" width="94" height="94" fill="FILL"/>
<line x1="3" y1="3" x2="50" y2="50"/>
<line x1="97" y1="3" x2="3" y2="97"/>