Replies: 4 comments 2 replies
-
Well, something is up. In my library, it handles these cases fine. I'll compare with a working example that runs fine in both, and then the problematic cases for comparison. In the first example, the results are pretty much the same (ignoring floating point error differences likely due to floating point rounding differences when I generated my inverse matrix vs when Color.js generated theirs. Also, these can slightly differ at times depending on the platform they are done on. The point though, is that they are pretty much the same. The next two examples mine converts and roundtrips fine while Color.js breaks down. >>> Color("color(--lchuv 86.8 42.9 230)").convert('jzazbz').coords()
[0.19080045711600463, -0.02312030486839481, -0.03784299301779337]
>>> Color("color(--lchuv 86.8 429 230)").convert('jzazbz').coords()
[-0.8341670378101103, 213.87469579919897, 11.783872317426832]
>>> Color("color(--lchuv 86.8 429 230)").convert('jzazbz').convert('lchuv').coords()
[86.80000000000435, 429.0000000000131, 229.99999999999966] And then color.js > new Color("color(--lchuv 86.8 42.9 230)").to('jzazbz').coords
[ 0.19080045711600463, -0.02312030486839503, -0.037842993017793425 ]
> new Color("color(--lchuv 86.8 429 230)").to('jzazbz').coords
[ NaN, NaN, NaN ]
> new Color("color(--lchuv 86.8 429 230)").to('jzazbz').to('lchuv').coords
[ 0, 0, null ] There's a couple differences for sure. I put in a few more protections for certain, non-ideal cases, so I have some signed power calls to account for powers on negative values. This provides sane results when some negative LMS values are generated due to the massive chroma being applied. |
Beta Was this translation helpful? Give feedback.
-
So I should submit this as a bug? Or maybe better that you do it with all the detail. Great that you could locate it so quickly. It caused me to put a third level of validation in the |
Beta Was this translation helpful? Give feedback.
-
I submitted issue #613 - same title as here. I kept it simple, essentially a copy/paste/edit of this original question. You can add what you see fit. Thanks! |
Beta Was this translation helpful? Give feedback.
-
I have my extra validation step regardless. So I'm set. Hard to imagine more validation than checking the coordinates in every available space. With Color.js still in a 0.N version a little extra validation might be expected. |
Beta Was this translation helpful? Give feedback.
-
I'm asking here before presuming: Is this a bug? See this codepen: https://codepen.io/sidewayss/pen/JoPGdQy
Open the console and you'll see a list of space ids followed by coordinates. The only
NaN
coordinates are in the jzczhz and jzazbz spaces.This is a bad set of coordinates to begin with, but the fact that it's just these two spaces makes me think that it's a bug.
I'm testing invalid color strings of different types to see how they get processed. Removing the decimal place in this original color string's 2nd parameter, but not the 1st, causes an error to get thrown in my code. I just happen to be defaulting to jzczhz as one of my two color spaces.
Beta Was this translation helpful? Give feedback.
All reactions