skratchdot / color-harmony

Create color scales by rotating hue
MIT License
84 stars 9 forks source link

Not working with black #2

Open rlancer opened 8 years ago

rlancer commented 8 years ago
var Harmonizer = require('color-harmony').Harmonizer;
var harmonizer = new Harmonizer();
harmonizer.harmonize('#000', 'complementary');  
// returns  ["#000000", "#000000"] and not  ['#000000', '#ffffff']
skratchdot commented 8 years ago

This is an odd behavior, but it's due to the way I am treating the hue rotation. For instance, harmonies are working similar to the "mudcube" sphere here. Notice, that the edge of that sphere is black, and the middle is white. So the complementary color of black is still black, and white is still white.

I know this is not intuitive. I don't know a lot about color theory, so this issue is probably solved already (I just need to look it up- and potentially change my code). I might be able to add multiple "modes" of harmonization, so '#000000' returns '#ffffff' in one mode while it behaves like it does now in another.

I see that the Adobe Kuler color wheel/sphere does not have super high/low lightness values shown, so the outside is not black (hence their "complementary" feature works intuitively).

Anyways, if you have ideas on how to fix, let me know. I'll look into it when I get a bit of time...

rlancer commented 8 years ago

It's fine if its not supposed to work with black.

But then maybe update the readme to use a different color in the example.

skratchdot commented 8 years ago

The way I calculate hue rotation currently is on this line: https://github.com/skratchdot/color-harmony/blob/fa7b923fa151775a14a1dd3f2a0367a378994013/lib/color-harmony.js#L56

onecolor normalizes all values between 0 and 1, so I am just doing some stuff to rotate, then normalize.

skratchdot commented 8 years ago

@rlancer - good point. I'll update the README. Didn't realize I was using black as an example there :)

skratchdot commented 8 years ago

Might be cool to actually show screenshots of what it calculates too