PixiEditor/ColorPicker

HSL L slider gradient unlike others - does not represent the affect of L

tonyhallett opened this issue · 2 comments

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.

Given
image

image

image

L has two gradient stops - black and white.
image

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.

image

New code required in here

protected override void GenerateBackground()

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;
            }

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

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.