jQuery-xcolor icon indicating copy to clipboard operation
jQuery-xcolor copied to clipboard

complementary color don't work right

Open jcubic opened this issue 12 years ago • 2 comments

it pick black if you pick black or almost black instead of white

>>> $.xcolor.complementary('#131111').getHex()
"#111313" // different kind of black
>>> $.xcolor.complementary('#000000').getHex()
"#000000"
>>> $.xcolor.complementary('#ffffff').getHex()
"#ffffff"

jcubic avatar Feb 19 '13 08:02 jcubic

I found library that do this right http://matthewbj.github.com/Colors/

jcubic avatar Feb 21 '13 11:02 jcubic

Well, if you take a look into the project history, you'll see that I changed the behavior of the complementary function with version 1.6: https://github.com/infusion/jQuery-xcolor/commit/afe53c4d3c89da5303306a17a50b2b6a8d56acbf

I decided to change this, because a mathematical complement isn't really useful in practice. That's why I used a visual complement, like when you rotate the hue of the HSL spectrum.

If you really need the mathematical complement, use xcolor like so:

var tmp = $.xcolor.test('#111313').getInt(); if (tmp !== null) { $.xcolor.test(tmp ^ 0xffffff).getHex(); } else { // original color couldn't be parsed }

infusion avatar Jun 10 '14 12:06 infusion