Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It's 100% free, no registration required.

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

share|improve this question
1  
Semi-on-topic - Here is an online tool I just stumbled across that allows you to set increment shades of colors in hex code: hexcolortool.com Thought you might be interested as you're working in shades of the same color –  John Apr 4 '13 at 18:00
    
thanks @John I can look at their source code. –  Matt Apr 4 '13 at 18:16
    
HEX format colors are RGB in hexidecimal form: FFFFFF = FF FF FF = 255 255 255. So by your description, I would split the HEX into 3 pairs and calculate the difference. Your example does not appear to follow this, so I suspect that difference is being calculated via a different color model (HSB/HSV perhaps). –  horatio Sep 5 '13 at 16:59
add comment

1 Answer

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.

E_INVALID_ARGUMENTS=2;

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

if [ -f "${HOME}/bin/colors" ]; then . "${HOME}/bin/colors"; fi
OPTIONS="ibase=16;obase=10;";

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);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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