Exemplo n.º 1
0
        void UpdateHSVToRGBView()
        {
            Structs.HSV hsv = new Structs.HSV();

            hsv.h = (tb_h.Value / 255d);
            hsv.s = tb_s.Value / 255d;
            hsv.v = tb_v.Value / 255d;

            Structs.RGB rgb = ColorToolkit.hsv2rgb(hsv);

            Color c = ColorToolkit.rgb2color(rgb);

            if (!tb_r.Focused)
            {
                tb_r.Value = c.R;
            }
            if (!tb_g.Focused)
            {
                tb_g.Value = c.G;
            }
            if (!tb_b.Focused)
            {
                tb_b.Value = c.B;
            }

            UpdateTextBox();

            pnl_color_view.BackColor = c;
        }
Exemplo n.º 2
0
        void UpdateGradient(Structs.HSV start, Structs.HSV end)
        {
            using (Graphics g = Graphics.FromImage(bitmap)){
                using (SolidBrush brush = new SolidBrush(Color.Black)){
                    double h_step = (end.h - start.h) / (double)pnl_grad.Width;
                    double s_step = (end.s - start.s) / (double)pnl_grad.Width;
                    double v_step = (end.v - start.v) / (double)pnl_grad.Width;

                    Structs.HSV newhsv = new Structs.HSV();
                    newhsv.h = start.h;
                    newhsv.s = start.s;
                    newhsv.v = start.v;

                    for (int x = 0; x < bitmap.Width; x++)
                    {
                        brush.Color = ColorToolkit.rgb2color(ColorToolkit.hsv2rgb(newhsv));

                        g.FillRectangle(brush, x, 0, 1, 1);

                        newhsv.h += h_step;
                        newhsv.s += s_step;
                        newhsv.v += v_step;

                        if (newhsv.h < 0)
                        {
                            newhsv.h = 0;
                        }
                        if (newhsv.h > 1)
                        {
                            newhsv.h = 1;
                        }
                        if (newhsv.s < 0)
                        {
                            newhsv.s = 0;
                        }
                        if (newhsv.s > 1)
                        {
                            newhsv.s = 1;
                        }
                        if (newhsv.v < 0)
                        {
                            newhsv.v = 0;
                        }
                        if (newhsv.v > 1)
                        {
                            newhsv.v = 1;
                        }
                    }
                }
            }

            pnl_grad.Refresh();
        }
Exemplo n.º 3
0
        void UpdateRGBToHSVView()
        {
            Structs.RGB rgb = ColorToolkit.color2rgb(Color.FromArgb(tb_r.Value, tb_g.Value, tb_b.Value));

            Structs.HSV hsv = ColorToolkit.rgb2hsv(rgb);
            if (!tb_h.Focused)
            {
                tb_h.Value = (int)((hsv.h) * 255d);
            }
            if (!tb_s.Focused)
            {
                tb_s.Value = (int)((hsv.s) * 255d);
            }
            if (!tb_v.Focused)
            {
                tb_v.Value = (int)((hsv.v) * 255d);
            }

            Color c = ColorToolkit.rgb2color(ColorToolkit.hsv2rgb(hsv));

            UpdateTextBox();

            pnl_color_view.BackColor = Color.FromArgb(tb_r.Value, tb_g.Value, tb_b.Value);
        }