Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

complementary color don't work right #4

Open
jcubic opened this issue Feb 19, 2013 · 2 comments
Open

complementary color don't work right #4

jcubic opened this issue Feb 19, 2013 · 2 comments

Comments

@jcubic
Copy link

jcubic commented Feb 19, 2013

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
Copy link
Author

jcubic commented Feb 21, 2013

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

@infusion
Copy link
Owner

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:
afe53c4

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants