* Use arrays to store repeated image sizes
* Add verbose flag to rm
* Add echoes throughout the program
* Move whitespace in template/sed statements
# Converts my logo to various formats from a template SVG
# Armaan Bhojwani 2021
# 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
[[ -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
if [[ (! -d "square/svg" || ! -d "circle/svg") || (${1} == "svg") ]]; then
for SHAPE in square circle; do
mkdir -pv ${SHAPE}/svg
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
-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
-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
-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
-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
-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
-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
-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
-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
-e 's/FILL/none/g' template/${SHAPE}.svg \
> ${SHAPE}/svg/logo-${SHAPE}-white-trans.svg
done
[[ ${1} == "svg" ]] && exit 0
[[ ${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
if [[ (! -d "square/png" || ! -d "circle/png") || (${1} == "png") ]]; then
for SHAPE in square circle; do
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
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 \
for SVGIN in square/svg/*; do
BASE=$(basename ${SVGIN} | cut -d '.' -f 1)
inkscape -w ${i} -h ${i} ${SVGIN} --export-filename \
[[ ${1} == "png" ]] && exit 0
if [[ ${1} == "ascii" ]]; then
[[ ${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 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
mkdir -pv ${SHAPE}/ascii/${i}
for PNGIN in circle/png/2048/*; do
fi
if [[ ${1} == "unicode" ]]; 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 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
mkdir -pv ${SHAPE}/unicode/${i}
for PNGIN in circle/png/2048/*; do
fi
for SHAPE in square circle; do
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
mkdir -pv ${SHAPE}/${1}/${i}
done
- # for PAT in $(find -name *.png); do
+ echo "Generating ${1}s"
convert -verbose ${PAT} ${PAT//png/${1}}
done < <(find -name *.png)
done
convert -verbose ${PAT} ${PAT//png/${1}}
done < <(find -name *.png)
done
<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
<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"/>
<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"/>
<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
<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"/>
<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"/>