예제 #1
0
        // 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));
                    }
                }
            }
        }
예제 #2
0
        // 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));
                    }
                }
            }
        }
예제 #3
0
 /// <summary>
 /// Convert the current color to a HSL color.
 /// </summary>
 /// <returns>An HSL representation of this color.</returns>
 public HSL ToHSL()
 {
     return(HSL.FromARGB(A, R, G, B));
 }