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

Specific hue hex colors not working #123

Closed
HannesDeMets opened this issue Apr 29, 2019 · 8 comments
Closed

Specific hue hex colors not working #123

HannesDeMets opened this issue Apr 29, 2019 · 8 comments
Labels

Comments

@HannesDeMets
Copy link

When i pass the hexadecimal #fec300 value to the hue key, i get the following error:

var randomColor = randomColor({ hue: '#fec300' });

Screenshot 2019-04-29 at 14 56 20

I had the same result when testing with: #fec200, #fec400, #fec500 and #fec600

@davidmerfield
Copy link
Owner

Cannot reproduce with the latest version of the library. Please send me a link to a page which demonstrates the issue

@maximtmartin
Copy link

maximtmartin commented Apr 30, 2019

@davidmerfield
This problem happens when you set count option to 1; randomColor({hue: '#fec300', count: 1})

hexToHSB returns hue: 46.06299212598425

Inside getColorInfo you test every color inside the colorDictionary. But orange doesn't match because 46.06299212598425 <= 46 is false. (same for yellow).

 if (color.hueRange && hue >= color.hueRange[0] && hue <= color.hueRange[1]) {
    return colorDictionary[colorName];
 }

@kylefoley
Copy link

Having the exact same issue with the color #FF00DB

@davidmerfield
Copy link
Owner

Understood, will fix

@SethPaulM
Copy link

Is there any update on the status of this fix?

@davidmerfield
Copy link
Owner

@SethPaulM No, but if you subscribe to this issue you will be notified when it's closed

@msd7manoj
Copy link

Is this bug fixed? Facing the same issue

davidmerfield added a commit that referenced this issue Jul 14, 2020
Because hue ranges previously did not overlap, it was possible to generate
hue values without a corresponding color definition. Fixes issue #123
@davidmerfield
Copy link
Owner

Should now be fixed in 0.6.1, available from npm right now!

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

No branches or pull requests

6 participants