How can I calculate
- the luminosity contrast ratio,
- the difference in brightness, and
- the difference in color
between two given colors?
Example:
Input
- color 1 : #99ccff
- color 2: #225588
Output
- luminosity contrast ratio : 4.57 : 1
- difference in brightness : 119
- difference in color : 357
Convert each colour from (R, G, B) to (H, S, V) [or (H, S, L)] coordinates. You can find formulae at Wikipedia.
I have written Pascal functions for this: