コード例 #1
0
ファイル: HSLColorPicker.cs プロジェクト: q2git/VS
        private void GenerateImages()
        {
            Graphics g = Graphics.FromImage(saturation);

            float h = (float)hueSlider.Value;

            for (int i = 0; i < 360; ++i)
            {
                HSL hsl = new HSL(h, (360 - i) / 360.0f, .5f);

                g.DrawLine(new Pen(hsl.RGB), 0, i, satPicBox.Width, i);
            }

            satPicBox.Image = saturation;

            Graphics gl = Graphics.FromImage(luminance);

            float s = (float)satSlider.Value / 100.0f;

            for (int i = 0; i < 360; ++i)
            {
                HSL hsl = new HSL(h, s, (360 - i) / 360.0f);

                gl.DrawLine(new Pen(hsl.RGB), 0, i, lumPicBox.Width, i);
            }

            lumPicBox.Image = luminance;

            Graphics rgb = Graphics.FromImage(RGB);

            float l = (float)lumSlider.Value / 100.0f;

            Color rgbFinal = new HSL(h, s, l).RGB;

            rgb.FillRectangle(new SolidBrush(rgbFinal), 0, 0, RGBPicBox.Width, RGBPicBox.Height);

            RGBPicBox.Image = RGB;

            redLabel.Text   = String.Format("Red: {0}", rgbFinal.R.ToString());
            greenLabel.Text = String.Format("Green: {0}", rgbFinal.G.ToString());
            blueLabel.Text  = String.Format("Blue: {0}", rgbFinal.B.ToString());

            red   = rgbFinal.R;
            green = rgbFinal.G;
            blue  = rgbFinal.B;
        }