HSL L slider gradient unlike others - does not represent the affect of L
tonyhallett opened this issue · 2 comments
tonyhallett commented
When the sliders for RGB / HSV and HSL H and S are moved to a new position the selected colour is the same as that under the thumb.
L has two gradient stops - black and white.
By increasing the gradient stops HSL L reflects the effect of moving the L slider on the resulting colour.
I have used 255 equally spaced stops.
New code required in here
I used
if (SliderHslType == "L")
{
var colorStart = GetColorForSelectedArgb(0);
var colorEnd = GetColorForSelectedArgb(255);
LeftCapColor.Color = colorStart;
RightCapColor.Color = colorEnd;
var backgroundGradient = new GradientStopCollection();
var numStops = 255;
for (var i = 0; i < numStops; i++)
{
var ratio = (double)i / numStops;
var value = 255 * ratio;
backgroundGradient.Add(new GradientStop(GetColorForSelectedArgb((int)value), ratio));
}
BackgroundGradient = backgroundGradient;
return;
}
Equbuxu commented
Good catch, fixing this in #23. Using just one additional GradientStop in the middle is enough for an accurate result, so I'm skipping the loop
tonyhallett commented
Using just one additional GradientStop in the middle is enough for an accurate result, so I'm skipping the loop
I didn't have time to do any Maths.