thomasp85 / farver

High Performance Colourspace Manipulation in R
https://farver.data-imaginist.com
Other
125 stars 14 forks source link

Bug in compare_colour() with from_space="hcl" #44

Closed jmw86069 closed 2 months ago

jmw86069 commented 2 months ago

First, I love your R work, your generative artwork, overall it is quite inspiring. Much respect.

I have found a bug. It's simple but important.

In farver.cpp the function compare_dispatch_from() does not include an entry for Hcl. It should be the 13th entry, as with compare_dispatch_to(). As a result, the following example returns the first HCL color, which "should never happen" but unfortunately does:

farver::compare_colour(farver::decode_colour("#BB1133", to="hcl"),
   farver::decode_colour("#AA0011", to="hcl"),
   to_space="hcl",
   from_space="hcl")

Output:

        h   c    l
[1,] 7.93 117 39.9

(Expected output is a numeric distance.)

I have another issue - I will report separately. Thank you!