by jbverschoor · 4y ago · 0 comments
A better example would be to use HSL or LAB for the gradients (Red->Green):
background: linear-gradient(to right, hsl(0, 100%, 50%), hsl(120, 100%, 50%));
background: linear-gradient(to right, lab(50% 128 128), lab(50% -128 128));
background: linear-gradient(to right, lab(50% 128 128), lab(100% -128 128));
The two different LAB values for "green" show that if you're just changing Lightness, you'll get a darker share of green. The RGB green needs 100% Lightness.HSL produces the same output as an RGB gradient, which is wrong, as only L should be modified.
LAB works only in safari, and although the result is slightly different, it's still incorrect, probably due to my conversion
My ad hoc expectation would be that I get a linear interpolation of perceived brightness, saturation, and color independent of how I specified the color to interpolate. Or maybe even better a path of minimal perceived color difference with uniform perceived color difference along the path which is probably at least slightly different from interpolating brightness, saturation, and color independently.
Some values don’t exist. Some might have multiple values in another space
So yes, LAB will produce more perceptually uniform gradients than RGB, but browsers are exacerbating the problems of RGB gradients by not implementing them properly.