Skip to content

Wrong hue for #0A000A #165

@kamil-gwozdz

Description

@kamil-gwozdz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions