// slider controls lightness // x = hue 0 -> 360 // y = saturation 100 -> 0 protected override void DrawHSLLightness() { using (Graphics g = Graphics.FromImage(bmp)) { HSL start = new HSL(0, 100, (int)selectedColor.hsl.Lightness100, selectedColor.argb.A); HSL end = new HSL(0, 0, (int)selectedColor.hsl.Lightness100, selectedColor.argb.A); for (int x = 0; x < clientWidth; x++) { start.Hue = end.Hue = (float)((double)x / (clientHeight)); using (LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, 1, clientHeight), start, end, LinearGradientMode.Vertical)) { g.FillRectangle(brush, new Rectangle(x, 0, 1, clientHeight)); } } } }
// slider controls hue // x = saturation 0 -> 100 // y = Lightness 100 -> 0 protected override void DrawHSLHue() { using (Graphics g = Graphics.FromImage(bmp)) { HSL start = new HSL((int)selectedColor.hsl.Hue360, 0, 0, selectedColor.argb.A); HSL end = new HSL((int)selectedColor.hsl.Hue360, 100, 0, selectedColor.argb.A); for (int y = 0; y < clientHeight; y++) { start.Lightness = end.Lightness = (float)(1.0 - ((double)y / (clientHeight))); using (LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, clientWidth, 1), start, end, LinearGradientMode.Horizontal)) { g.FillRectangle(brush, new Rectangle(0, y, clientWidth, 1)); } } } }