Closed meyer closed 9 years ago
Can you show correct limits for this model? At http://en.wikipedia.org/wiki/Lab_color_space or another places.
I dont' remember where I found those -52.
Fix should be applied here https://github.com/garex/nodejs-color-model/blob/master/lib/lab.js#L18
Also if you will add test for this case — it will be good.
According to colourphil.co.uk there is no theoretical min/max for a
and b
but -128 to +127 seems to be a standard range. I’m still digging though.
@meyer What if we then set those min/max to real min/max that we will get by translating from other color models?
Another options is to remove min/max if it can be any and just throw exceptions when translating to another models, thta can't receive translated values.
According to http://en.wikipedia.org/wiki/Lab_color_space LAB include sRGB.
3rd option will be to try to find nearest value of target color model. What do you think?
Hmm. Well LAB allows for colours that can’t be represented with either RGB or CMYK. Throwing an error seems to be a reasonable solution. It’s definitely an edge case. It’d be nice if there was a config option that allowed colour approximation on error.
I might be wrong, but I think the a
and b
range of -128 to +127 is directly related to the limitations of RGB, so locking those down might not be a terrible idea.
Colormine’s CMYK-to-LAB and RGB-to-LAB converters lock a
and b
down to a range of -128 to +128. I think 127 is more correct, though.
Ok, let's then lock it in -127 +127. Can you create pull request with some test? Let's test 1st create Lab and convert to RGB. Another case should create LaB that will throw error during conversion.
Regarding config option. I dont' see it anywhere in current implementation — we dont' have here any CI or similar stuff.
In our case range inclusive:
https://github.com/garex/nodejs-color-model/blob/master/lib/component.js#L36
Stop, I dont' understand.. What range do we need?
[-127, +128] ? So -127 and +128 will be min/max allowed?
-128 to +127, and that range is inclusive. I’ll start the PR now and finish tomorrow.
I’m running into an issue using
color-difference
.cd.compare("00FF7F", "BADA55")
seems to cause issues. Apparently#00FF7F
’s value fora
is not between -52 and 100—it’s -76.9009. I’d propose a fix if I knew more about colour math. Seems like this is the source of the issue. Cana
go below -52?