Closed OEvgeny closed 8 years ago
Not sure why I'm just seeing this (Usually on top of issues; sorry!)
I'm not entirely sure how this would be fixed if it's a rounding issue. Floating point math is rather dodgy in computer science given the standard's nature (IEEE Std 754-2008 is a beast). I can look into it a bit further.
Keep in mind not all conversions are lossless!
I think it can be.. This function produces:
rgb2hsl([ 223, 240, 216 ])
>[102.5, 44.444444444444436, 89.41176470588235]
But:
var converter = require("color-convert")();
converter.rgb(223, 240, 216).hsl()
Returns to me:
[103, 44, 89]
I can't seem to reproduce this now that I look at it.
What version of color-convert are you using? Have you tried using rgb2hslRaw()
?
I simply copied This function to my devtools. and call it.
Because the library wraps functions with a rounding operation because decimal numbers in most color values don't usually work. For instance, you can't specify a decimal 256-based RGB color in most technologies (only exception I can think of is with Apple technologies, which use a 0.0
-1.0
floating point number for color since the retina screens support it).
The hash right now doesn't have the xRaw()
variations I don't think; not that I can see anyway. Use rgb2hslRaw()
instead.
Thanks. Didn't know about that.
I'll think about adding in something like rgb.hsl.raw()
. Might be helpful. :+1: Thanks for the report!
rgb.hsl.raw()
is added in #27. :+1:
Thnks a lot! :+1:
Just try this:
It returns
I think it is because
hsl
values are integers.