I was curious to know if anyone has used or seen code to measure colors between two hex values. Any language will do but I did see the JavaScript source to determine what HEX value is in RGB.

Example: between #44aaee and #0088ee would result in #2199ee

enter image description here


I use a shell script to handle it. I quickly type the alias to my script followed by the two colors in question (without the hash mark) and it spits out the result.


  echo -e "Usage: ${COLOR_BRIGHT_WHITE}$(basename $0)${COLOR_END} color color"
  exit $1

if [ -f "${HOME}/bin/colors" ]; then . "${HOME}/bin/colors"; fi

if [ -z "$1" ]; then usage $E_INVALID_ARGUMENTS; fi
if [ -z "$2" ]; then usage $E_INVALID_ARGUMENTS; fi

CA=$(echo "$1" | tr [:lower:] [:upper:]);
CB=$(echo "$2" | tr [:lower:] [:upper:]);

C1=$(echo "${OPTIONS}(${CA:0:2}+${CB:0:2})/2" | bc);
C2=$(echo "${OPTIONS}(${CA:2:2}+${CB:2:2})/2" | bc);
C3=$(echo "${OPTIONS}(${CA:4:2}+${CB:4:2})/2" | bc);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.