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

Wrong hue for #0A000A #165

Open
kamil-gwozdz opened this issue May 6, 2022 · 0 comments
Open

Wrong hue for #0A000A #165

kamil-gwozdz opened this issue May 6, 2022 · 0 comments

Comments

@kamil-gwozdz
Copy link

Hi,
i believe that the ChunkyPNG::Color.to_hsl method returns a wrong hue for certain colours.

Example:

  • gem version: 1.3.15
require "chunky_png"

irb(main):002:0> ChunkyPNG::Color.to_hsl ChunkyPNG::Color.from_hex("#0A000A")
=> [-60, 1.0000000000000007, 0.0196078431372549]

Afaik the hue should be between 0 and 360 so -60 is wrong. I'd expect to get 300 in this case, which happen to be equal to -60 % 360. So maybe a fix could look like this:

in the ChunkyPNG::Color#hue_and_chroma

hue = hue.between?(0, 360) ? hue : hue % 360
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

1 participant