javascriptcolorsless

Hex Code Difference


Is it possible to calculate the difference between two hex codes? I have been searching for hours and I'm starting to think it's not possible.

Example: Color #1: #c60f13 Color #2: #970b0e Difference: 25% Darker

Oh yeah, I came across a Javascript calculator, but it didn't work.

Thanks guys!


Solution

  • Separate them into (3) 2-byte groups, do the math for each group individually and apply that to the color that the group represents (Red / Green / Blue).

    C6 - 97 = red diff
    0F - 0B = green diff
    13 - 03 = blue diff