From 8c35bef60c7da9c6cb762b7ae147ea3d6c7615d8 Mon Sep 17 00:00:00 2001 From: Daniel Ruiz de Alegría Date: Sun, 2 Dec 2018 04:19:24 +0100 Subject: Add Flat-Remix palette --- tools/_colorFixer.sh | 53 +- tools/flat-remix-palette.svg | 2818 ++++++++++++++++++++++++++++++++++++++++++ tools/paletteColors | 45 +- 3 files changed, 2874 insertions(+), 42 deletions(-) create mode 100644 tools/flat-remix-palette.svg (limited to 'tools') diff --git a/tools/_colorFixer.sh b/tools/_colorFixer.sh index 467f57d34..932b7ca90 100755 --- a/tools/_colorFixer.sh +++ b/tools/_colorFixer.sh @@ -1,8 +1,19 @@ #!/bin/bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PALETTE_FILE="${DIR}/paletteColors" -paletteColors=($(cat "$DIR/paletteColors")) +function hexToRgb { + color=$1 + if [ $(echo $color | wc -c) = 5 ] + then + color="#${color:1:1}${color:1:1}${color:2:1}${color:2:1}${color:3:1}${color:3:1}" + fi + printf "rgb(%s%%,%s%%,%s%%)" \ + $(echo "scale=3;$((0x${color:1:2}))*100/255" | bc) \ + $(echo "scale=3;$((0x${color:3:2}))*100/255" | bc) \ + $(echo "scale=3;$((0x${color:5:2}))*100/255" | bc) +} function findNearestColor { rgb1=($(grep -o -P '(\d+(.\d+)?)(?=%)' <<< $1)) @@ -10,39 +21,49 @@ function findNearestColor { g1=${rgb1[1]} b1=${rgb1[2]} - smallerDistance=173 + smallestDistance=173 bestColor='' - for paletteColor in ${paletteColors[@]} + while read -r paletteColor 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) )) + if (( $(echo $distance'<'$smallestDistance | bc) )) then - smallerDistance=$distance + smallestDistance=$distance bestColor=$paletteColor fi - done + done <<< $paletteColors echo $bestColor } + +paletteColors=$(for color in $(cat "$PALETTE_FILE") + do + echo $(hexToRgb $color) + done) + 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 | sort -u) - 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 + svg=$(cat $file) + file_colors=$(grep -o -P -i 'rgb\((\d+(.\d+)?%,?){3}\)|#((\d|[abcdef]){3}){1,2}' $file | sort -u) + for file_color in $file_colors + do + if [ ${file_color:0:1} = '#' ] + then + file_color_rgb=$(hexToRgb $file_color) + fi + new_color=$(findNearestColor $file_color_rgb) + echo $file_color '->' $new_color + + svg=$(sed "s/$file_color/$new_color/g" <<< $svg) + done + echo $svg > $file done diff --git a/tools/flat-remix-palette.svg b/tools/flat-remix-palette.svg new file mode 100644 index 000000000..8b67948e0 --- /dev/null +++ b/tools/flat-remix-palette.svg @@ -0,0 +1,2818 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/paletteColors b/tools/paletteColors index ed824a696..a77d03cfa 100644 --- a/tools/paletteColors +++ b/tools/paletteColors @@ -1,26 +1,19 @@ -rgb(0%,0%,0%) -rgb(100%,100%,100%) -rgb(90.196078%,90.196078%,90.196078%) -rgb(71.764706%,76.470588%,80.392157%) -rgb(64.705882%,64.705882%,64.705882%) -rgb(29.803922%,29.803922%,29.803922%) -rgb(97.647059%,87.058824%,41.176471%) -rgb(100%,78.431373%,19.215686%) -rgb(99.215686%,49.411765%,0%) -rgb(96.470588%,27.843137%,27.843137%) -rgb(83.137255%,10.196078%,10.196078%) -rgb(72.941176%,9.019608%,30.588235%) -rgb(55.686275%,26.666667%,67.843137%) -rgb(80.392157%,61.176471%,42.745098%) -rgb(41.568627%,30.196078%,21.960784%) -rgb(10.588235%,63.921569%,53.72549%) -rgb(5.882353%,63.137255%,37.254902%) -rgb(13.333333%,21.176471%,33.72549%) -rgb(24.313725%,80.392157%,96.470588%) -rgb(29.019608%,68.235294%,90.980392%) -rgb(0%,41.568627%,72.54902%) -rgb(16.078431%,50.196078%,72.54902%) -rgb(21.176471%,48.235294%,94.117647%) -rgb(14.117647%,36.470588%,76.862745%) -rgb(32.156863%,70.196078%,85.098039%) -rgb(31.764706%,72.54902%,76.470588%) + #0f2751 #112d5c #133368 #153873 #2c4c81 #44608f #5b739d + #1b3f7c #1e488e #2251a0 #265ab1 #3b6ab9 #517bc1 #678bc8 + #2656a8 #2b62c0 #316fd8 #367bf0 #4a88f1 #5e95f3 #72a2f4 + #347aa1 #3b8bb8 #439dcf #4aaee6 #5cb6e8 #6ebeeb #80c6ed + #198388 #1c959b #20a8af #23bac2 #39c1c8 #4fc8ce #65cfd4 + #12715f #14816c #17917a #19a187 #30aa93 #47b49f #5ebdab + #087142 #0a814b #0b9155 #0ca15e #24aa6e #3db47e #54bd8e + #493525 #533d2a #5e4530 #684c35 #775e49 #86705d #958171 + #714b2b #815631 #916137 #a16b3d #aa7a50 #b48964 #bd9777 + #622e78 #703589 #7e3c9a #8c42ab #9755b3 #a368bc #ae7ac4 + #811035 #93123d #a61545 #b8174c #bf2e5e #c64570 #cd5c81 + #951212 #aa1414 #bf1717 #d41919 #d83030 #dd4747 #e15e5e + #b22525 #ca2a2a #e43030 #fd3535 #fd4949 #fd5d5d #fe7171 + #b25800 #ca6400 #e47100 #fd7d00 #fd8a19 #fd9733 #fea44c + #b38c22 #cc9f26 #e6b32b #ffc730 #ffcc44 #ffd259 #ffd86e + #ae9c49 #c6b253 #e0c85e #f8de68 #f9e177 #f9e586 #fae895 + #272a34 #2d303b #333643 #383c4a #4c4f5c #60636e #737680 + #000000 #191919 #333333 #4c4c4c + #ffffff -- cgit v1.2.3