You are modifying the L
property of an HSL colour - that's correct.
The error is in the range of L
. It should have a nominal value of 0.5, with a range of 0 to 1.0.
Hence your slider value to be added to L
should run from -1
to +1
, but you need to clamp the resulting value in the range 0 .. 1
, e.g:
hsl[2] += ui.value;
hsl[2] = Math.min(hsl[2], 1);
hsl[2] = Math.max(hsl[2], 0);