十六进制颜色根据选择而变化

I'm creating an background color editor in my web site. Basically I would do match certain colors depending on the color chosen by the user it-self. For example, based on the color added... i would get two type of colors (lighter and darker).

So, with this hex #a5cedb the lighter color matching is this #f6fafb, while darker is this #739099.

Now, is there a script that finds the exact color match based on this example? Following this principle, I should be able to find #fafcf6(lighter) and #919a72(darker) by inserting this hex #d0dca4

I'm asking too much or is there already something that does this?

(...sorry for my bad english)

You can use thee following function to convert the hex to integer:

function hex2int(h) { 
       return parseInt(h, 16);
 }

alert(hex2int('dd66ab'))

than you can compare:

if(hex2int('dd66ab')>hex2int('fafcf6')){
       //do somethig
}