aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLibravatar Daniel Ruiz de Alegría <daniruizdealegria@gmail.com>2018-03-15 22:01:01 +0100
committerLibravatar Daniel Ruiz de Alegría <daniruizdealegria@gmail.com>2018-03-15 22:01:01 +0100
commit09d3a8ef23e41ac907dd0e146791c49c956570f8 (patch)
treee5d3b7bc3de2a7d3b1f83b3caca9b43f16824b19 /tools
parent4802449a64d78fca71c77cab8ca007c23ea9eb86 (diff)
downloadflat-remix-09d3a8ef23e41ac907dd0e146791c49c956570f8.tar.gz
flat-remix-09d3a8ef23e41ac907dd0e146791c49c956570f8.zip
Update colorFixer.sh for multiple threads
Diffstat (limited to 'tools')
-rwxr-xr-xtools/_colorFixer.sh48
-rwxr-xr-xtools/colorFixer.sh44
2 files changed, 50 insertions, 42 deletions
diff --git a/tools/_colorFixer.sh b/tools/_colorFixer.sh
new file mode 100755
index 000000000..30ff1efa8
--- /dev/null
+++ b/tools/_colorFixer.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+paletteColors=($(cat "$DIR/paletteColors"))
+
+function findNearestColor {
+ rgb1=($(grep -o -P '(\d+(.\d+)?)(?=%)' <<< $1))
+ r1=${rgb1[0]}
+ g1=${rgb1[1]}
+ b1=${rgb1[2]}
+
+ smallerDistance=173
+ bestColor=''
+
+ for paletteColor in ${paletteColors[@]}
+ do
+ rgb2=($(grep -o -P '(\d+(.\d+)?)(?=%)' <<< $paletteColor))
+ r2=${rgb2[0]}
+ g2=${rgb2[1]}
+ b2=${rgb2[2]}
+ distance=$(echo "scale=3;sqrt(($r2-$r1)^2 + ($g2-$g1)^2 + ($b2-$b1)^2)" | bc)
+ if (( $(echo $distance'<'$smallerDistance | bc) ))
+ then
+ smallerDistance=$distance
+ bestColor=$paletteColor
+ fi
+ done
+
+ echo $bestColor
+}
+
+
+for file in $(find -name "$1" -maxdepth 1 -type f -printf "%f\n")
+do
+ echo ===================================================
+ echo $file
+ svg=$(cat $file)
+ file_colors=$(grep -o -P 'rgb\((\d+(.\d+)?%,?){3}\)' $file)
+ for file_color in $file_colors
+ do
+ new_color=$(findNearestColor $file_color)
+ echo $file_color '->' $new_color
+
+ svg=$(sed "s/$file_color/$new_color/g" <<< $svg)
+ done
+ echo $svg > $file
+done
diff --git a/tools/colorFixer.sh b/tools/colorFixer.sh
index 427715f37..1addf9ac8 100755
--- a/tools/colorFixer.sh
+++ b/tools/colorFixer.sh
@@ -2,47 +2,7 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-paletteColors=($(cat "$DIR/paletteColors"))
-
-function findNearestColor {
- rgb1=($(grep -o -P '(\d+(.\d+)?)(?=%)' <<< $1))
- r1=${rgb1[0]}
- g1=${rgb1[1]}
- b1=${rgb1[2]}
-
- smallerDistance=173
- bestColor=''
-
- for paletteColor in ${paletteColors[@]}
- do
- rgb2=($(grep -o -P '(\d+(.\d+)?)(?=%)' <<< $paletteColor))
- r2=${rgb2[0]}
- g2=${rgb2[1]}
- b2=${rgb2[2]}
- distance=$(echo "scale=3;sqrt(($r2-$r1)^2 + ($g2-$g1)^2 + ($b2-$b1)^2)" | bc)
- if (( $(echo $distance'<'$smallerDistance | bc) ))
- then
- smallerDistance=$distance
- bestColor=$paletteColor
- fi
- done
-
- echo $bestColor
-}
-
-
-for file in $(find -maxdepth 1 -type f -printf "%f\n")
+for i in {a..z}
do
- echo ===================================================
- echo $file
- svg=$(cat $file)
- file_colors=$(grep -o -P 'rgb\((\d+(.\d+)?%,?){3}\)' $file)
- for file_color in $file_colors
- do
- new_color=$(findNearestColor $file_color)
- echo $file_color '->' $new_color
-
- svg=$(sed "s/$file_color/$new_color/g" <<< $svg)
- done
- echo $svg > $file
+ "$DIR"/_colorFixer.sh "${i}*"
done