]> git.armaanb.net Git - logo.git/commitdiff
Complete repo restructure
authorArmaan Bhojwani <me@armaanb.net>
Sat, 9 Jan 2021 03:08:27 +0000 (22:08 -0500)
committerArmaan Bhojwani <me@armaanb.net>
Sat, 9 Jan 2021 03:08:27 +0000 (22:08 -0500)
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
template/circle.svg [new file with mode: 0644]
template/square.svg [new file with mode: 0644]

diff --git a/svg2img b/svg2img
index af2e242bf73d12a4cbc3caf1c4998d8d3d4f1c60..9c1eba6ddd9d62f384c224088c345e8b31c4b045 100755 (executable)
--- a/svg2img
+++ b/svg2img
 #!/usr/bin/env bash
 #!/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
 
   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
 done
diff --git a/template/circle.svg b/template/circle.svg
new file mode 100644 (file)
index 0000000..7eaab61
--- /dev/null
@@ -0,0 +1,8 @@
+<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
+ <g STROKEstroke-width="6">
+   <circle cx="50" cy="50" r="47"FILL/>
+   <line x1="17" y1="17" x2="50" y2="50"/>
+   <line x1="17" y1="83" x2="83" y2="17"/>
+   <line x1="50" y1="97" x2="88" y2="22"/>
+ </g>
+</svg>
diff --git a/template/square.svg b/template/square.svg
new file mode 100644 (file)
index 0000000..2f254cb
--- /dev/null
@@ -0,0 +1,8 @@
+<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
+ <g STROKEstroke-width="6">
+   <rect x="3" y="3" width="94" height="94"FILL/>
+   <line x1="3" y1="3" x2="50" y2="50"/>
+   <line x1="97" y1="3" x2="3" y2="97"/>
+   <line x1="50" y1="97" x2="97" y2="3"/>
+ </g>
+</svg>