public override void Render(Graphics g)
        {
            var colorRect = new Rectangle(0, (Slider.Height / 2) - 3, Slider.Width - 6, 4);

            Color c1 = new ColorManager.HSVColor(CurrentColor.HSV.H, 0, CurrentColor.HSV.V).ToColor();
            Color c2 = new ColorManager.HSVColor(CurrentColor.HSV.H, 100, CurrentColor.HSV.V).ToColor();

            var brush = new LinearGradientBrush(colorRect, c1, c2, LinearGradientMode.Horizontal);

            //Draw color
            g.FillRectangle(brush, colorRect);
            //Draw border
            g.DrawRectangle(Pens.Black, colorRect);

            DrawThumb(g);
        }
        public override void Render(Graphics g)
        {
            var colorRect = new Rectangle(0, (Slider.Height / 2) - 3, Slider.Width - 6, 4);

            Color c1 = new ColorManager.HSVColor(CurrentColor.HSV.H, 0, CurrentColor.HSV.V).ToColor();
            Color c2 = new ColorManager.HSVColor(CurrentColor.HSV.H, 100, CurrentColor.HSV.V).ToColor();

            var brush = new LinearGradientBrush(colorRect, c1, c2, LinearGradientMode.Horizontal);

            //Draw color
            g.FillRectangle(brush, colorRect);
            //Draw border
            g.DrawRectangle(Pens.Black, colorRect);

            DrawThumb(g);
        }
Beispiel #3
0
        public static Bitmap ColorWheel(int size, int width, int multisampling)
        {
            if (width < 1 || size < 1)
                return null;

            int m = multisampling;
            size = size * m;
            width = width * m;

            using (var b = new Bitmap(size, size))
            {
                using (Graphics g = Graphics.FromImage(b))
                {
                    g.Clear(Color.Transparent);
                    var rect = new Rectangle(0, 0, size - m, size - m);
                    using (var wheel_path = new GraphicsPath())
                    {
                        wheel_path.AddEllipse(rect);
                        wheel_path.Flatten();

                        int num_pts = (wheel_path.PointCount - 1);
                        var surround_colors = new Color[wheel_path.PointCount];
                        for (int i = 0; i < wheel_path.PointCount; i++)
                            surround_colors[i] = new ColorManager.HSVColor((short) ((double) i / num_pts * 360), 100, 100).ToColor();

                        using (var brush = new PathGradientBrush(wheel_path))
                        {
                            brush.CenterColor = SystemColors.Window;
                            brush.SurroundColors = surround_colors;
                            brush.FocusScales = new PointF(100.0f, 100.0f);
                            g.FillEllipse(brush, rect);
                        }
                        using (var brush = new SolidBrush(Color.White))
                            g.FillEllipse(brush, new Rectangle(width, width, size - width * 2, size - width * 2));

                        //replace all the white with color.transparent :)
                        b.MakeTransparent(Color.White);
                    }
                }
                return ColorPickUtil.ResizeImage(b, size / m);
            }
        }