Calculating color shades

Posted by matejv on Stack Overflow See other posts from Stack Overflow or by matejv
Published on 2012-10-05T17:51:29Z Indexed on 2012/10/07 3:38 UTC
Read the original article Hit count: 110

Filed under:
|
|

I have the next problem.
I have a base color with couple of different shades of that color.

Example:

  • Base color: #4085c5
  • Shade: #005cb1

Now, I have a different color (let's say #d60620), but no shades of it. From the color I would like to calculate shades, that have similar difference as colors mentioned in first paragraph.

First I tried calculating difference of RGB elements and applying them to second color, but the result was not like I expected to be.
Than I tried with converting color to HSV, reading saturation value and applying the difference to second color, but again the resulting color was still weird.

The formula was something like: (HSV(BaseColor)[S] - HSV(Shade)[S]) + HSV(SecondColor)[H]

Does anyone know how this problem could be solved? I know I am doing something wrong, but I don't know what. :)

© Stack Overflow or respective owner

Related posts about php

Related posts about algorithm