当前位置: 首页>>代码示例>>C#>>正文


C# RGB.asHSL方法代码示例

本文整理汇总了C#中RGB.asHSL方法的典型用法代码示例。如果您正苦于以下问题:C# RGB.asHSL方法的具体用法?C# RGB.asHSL怎么用?C# RGB.asHSL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RGB的用法示例。


在下文中一共展示了RGB.asHSL方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LeftClickXYZSpace

        /// <summary>
        /// this method performs all tasks done with a left mouse click in XYZ space
        /// </summary>
        /// <param name="x">the current x coordinate</param>
        /// <param name="y">the current y coordinate</param>
        /// <param name="showCircle">if true the selected Color circle will be shown</param>
        /// <author>Markus Strobel</author>
        private void LeftClickXYZSpace(float x, float y, bool showCircle)
        {
            // set trackbar values
            if (!(hoveredRGBColor.R < 0 || hoveredRGBColor.G < 0 || hoveredRGBColor.B < 0))
            {
                HSL hsl = hoveredRGBColor.asHSL();

                // normalize
                float maxV = Math.Max(hoveredRGBColor.R, Math.Max(hoveredRGBColor.G, hoveredRGBColor.B));
                hoveredRGBColor.R /= maxV;
                hoveredRGBColor.G /= maxV;
                hoveredRGBColor.B /= maxV;

                // set RGB tab values for trackbars
                labelTabRGB_R.Text = "R: " + hoveredRGBColor.R;
                labelTabRGB_G.Text = "G: " + hoveredRGBColor.G;
                labelTabRGB_B.Text = "B: " + hoveredRGBColor.B;
                trackBarR.Value = (int)(hoveredRGBColor.R * 255);
                trackBarG.Value = (int)(hoveredRGBColor.G * 255);
                trackBarB.Value = (int)(hoveredRGBColor.B * 255);

                //set HSL values for trackbars
                labelTabHSL_H.Text = "H: " + (hsl.H) + "°";
                labelTabHSL_S.Text = "S: " + (hsl.S * 100) + "%";
                labelTabHSL_L.Text = "L: " + (hsl.L * 100) + "%";
                trackBarH.Value = (int)hsl.H;
                trackBarS.Value = (int)(hsl.S * 100);
                trackBarL.Value = (int)(hsl.L * 100);

                selectedRGBColor = hoveredRGBColor;
                selectedXYZColor = hoveredXYZColor;
                selectedYxyColor = new Yxy(x, y);

                if (checkBoxRGB.Checked)
                {
                    showColorCircle = false;
                    createRGBPreviewLines(selectedRGBColor);
                }
                else if (checkBoxHSL.Checked)
                {
                    showColorCircle = false;
                    createHSLPreviewLines(selectedRGBColor.asHSL());
                    createHSLPreviewCircle(selectedRGBColor.asHSL());
                }
                else
                {
                    showColorCircle = showCircle;
                    createSelectedColorCircleVBO(x, y, 0.01f, 36); // computes color circle position
                }
            }
            else // (!(hoveredRGBColor.R < 0 || hoveredRGBColor.G < 0 || hoveredRGBColor.B < 0))
            {
                trackBarR.Value = 0;
                trackBarG.Value = 0;
                trackBarB.Value = 0;
                labelTabRGB_R.Text = "R: 0";
                labelTabRGB_G.Text = "G: 0";
                labelTabRGB_B.Text = "B: 0";
                trackBarH.Value = 1;
                trackBarS.Value = 100;
                trackBarL.Value = 50;
                labelTabHSL_H.Text = "H: 1°";
                labelTabHSL_S.Text = "S: 100%";
                labelTabHSL_L.Text = "L: 50%";

                selectedRGBColor = null;
                selectedXYZColor = null;
                showColorCircle = false;
            }

            // take current preview Color as selected Color
            // we dont need to compute it twice
            // set selectedColor Panel, label
            panelColorSelected.BackColor = panelColorPreview.BackColor;
            labelColorSelectedHex.Text = labelColorPreviewHex.Text;
            labelColSelectedXH.Text = labelColPreviewXH.Text;
            labelColSelectedYS.Text = labelColPreviewYS.Text;
        }
开发者ID:ArTc0re,项目名称:University,代码行数:85,代码来源:OpenGLForm.cs

示例2: trackBarRGB_Scroll

        /// <summary>
        /// Slidebar Event for RGB - allows to change the current selected point 
        /// </summary>
        /// <author> Markus Strobel, Justine Smyzek</author>
        private void trackBarRGB_Scroll(object sender, EventArgs e)
        {
            if (radioButtonXYZView.Checked)
            {
                //calculate values
                RGB rgb_slide = new RGB(trackBarR.Value / 255f, trackBarG.Value / 255f, trackBarB.Value / 255f);

                // here is a small computation error, TODO - fix to get and show the correct color from trackbarRGB

                HSL hsl_slide = rgb_slide.asHSL();

                //change labels of color
                labelTabRGB_R.Text = "R: " + rgb_slide.R;
                labelTabRGB_G.Text = "G: " + rgb_slide.G;
                labelTabRGB_B.Text = "B: " + rgb_slide.B;

                //change also HSL scroll
                trackBarH.Value = (int)hsl_slide.H;
                trackBarS.Value = (int)(hsl_slide.S * 100);
                trackBarL.Value = (int)(hsl_slide.L * 100);
                labelTabHSL_H.Text = "H: " + (trackBarH.Value) + "°";
                labelTabHSL_S.Text = "S: " + trackBarS.Value + "%";
                labelTabHSL_L.Text = "L: " + trackBarL.Value + "%";

                //set new selected Color
                panelColorSelected.BackColor = Color.FromArgb((int)(rgb_slide.R * 255), (int)(rgb_slide.G * 255), (int)(rgb_slide.B * 255));
                labelColorSelectedHex.Text = "#" + ((int)(rgb_slide.R * 255)).ToString("X") + ((int)(rgb_slide.G * 255)).ToString("X") + ((int)(rgb_slide.B * 255)).ToString("X");

                //calculate yxy room
                Yxy yxy = rgb_slide.asXYZ().asYxy();

                //control if Line prieview is wished - draw
                if (checkBoxRGB.Checked)
                {
                    createRGBPreviewLines(rgb_slide);
                    selectedRGBColor = rgb_slide;
                    showColorCircle = false;
                    checkBoxHSL.Enabled = false;
                }
                else
                {
                    showColorCircle = true;
                    checkBoxHSL.Enabled = true;
                }

                createSelectedColorCircleVBO(yxy.x, yxy.y, 0.01f, 36); // computes color circle position
            }
            glControl1.Invalidate();
        }
开发者ID:ArTc0re,项目名称:University,代码行数:53,代码来源:OpenGLForm.cs

示例3: KonvertierenButton_Click

        /// <summary>
        /// </summary>
        /// <author> Birthe Anne Wiegand</author>
        private void KonvertierenButton_Click(object sender, EventArgs e)
        {
            RadioButton checkedButton = this.tabFarbRechner.Controls.OfType<RadioButton>().FirstOrDefault(radioButton => radioButton.Checked);

            switch (checkedButton.Name)
            {
                case "customRGB":
                    // parse input to internal customRGBvalue
                    customRGBvalue.R = float.Parse(customRGB_R.Text, CultureInfo.InvariantCulture);
                    customRGBvalue.G = float.Parse(customRGB_G.Text, CultureInfo.InvariantCulture);
                    customRGBvalue.B = float.Parse(customRGB_B.Text, CultureInfo.InvariantCulture);

                    // update other internal values
                    XYZvalue = customRGBvalue.asXYZ();
                    RGBvalue = XYZvalue.asRGB();
                    sRGBvalue = RGBvalue.as_sRGB();
                    HSLvalue = RGBvalue.asHSL();
                    HSVvalue = RGBvalue.asHSV();
                    LUVvalue = XYZvalue.asLUV();
                    LABvalue = XYZvalue.asLAB();
                    break;
                case "sRGB":
                    // parse input to internal customRGBvalue
                    sRGBvalue.R = float.Parse(sRGB_R.Text, CultureInfo.InvariantCulture);
                    sRGBvalue.G = float.Parse(sRGB_G.Text, CultureInfo.InvariantCulture);
                    sRGBvalue.B = float.Parse(sRGB_B.Text, CultureInfo.InvariantCulture);

                    // update other internal values
                    RGBvalue = sRGBvalue.asRGB();
                    XYZvalue = RGBvalue.asXYZ();
                    customRGBvalue = XYZvalue.as_customRGB();
                    HSLvalue = RGBvalue.asHSL();
                    HSVvalue = RGBvalue.asHSV();
                    LUVvalue = XYZvalue.asLUV();
                    LABvalue = XYZvalue.asLAB();
                    break;
                case "HSL":
                    // parse input to internal HSLvalue
                    HSLvalue.H = float.Parse(HSL_H.Text, CultureInfo.InvariantCulture);
                    HSLvalue.S = float.Parse(HSL_S.Text, CultureInfo.InvariantCulture);
                    HSLvalue.L = float.Parse(HSL_L.Text, CultureInfo.InvariantCulture);

                    // update other internal values
                    RGBvalue = HSLvalue.asRGB();
                    XYZvalue = RGBvalue.asXYZ();
                    customRGBvalue = XYZvalue.as_customRGB();
                    sRGBvalue = RGBvalue.as_sRGB();
                    HSVvalue = RGBvalue.asHSV();
                    LUVvalue = XYZvalue.asLUV();
                    LABvalue = XYZvalue.asLAB();
                    break;
                case "HSV":
                    // parse input to internal HSVvalue
                    HSVvalue.H = float.Parse(HSV_H.Text, CultureInfo.InvariantCulture);
                    HSVvalue.S = float.Parse(HSV_S.Text, CultureInfo.InvariantCulture);
                    HSVvalue.V = float.Parse(HSV_V.Text, CultureInfo.InvariantCulture);

                    // update other internal values
                    RGBvalue = HSVvalue.asRGB();
                    XYZvalue = RGBvalue.asXYZ();
                    customRGBvalue = XYZvalue.as_customRGB();
                    sRGBvalue = RGBvalue.as_sRGB();
                    HSLvalue = RGBvalue.asHSL();
                    LUVvalue = XYZvalue.asLUV();
                    LABvalue = XYZvalue.asLAB();
                    break;
                case "XYZ":
                    // parse input to internal HSVvalue
                    XYZvalue.X = float.Parse(XYZ_X.Text, CultureInfo.InvariantCulture);
                    XYZvalue.Y = float.Parse(XYZ_Y.Text, CultureInfo.InvariantCulture);
                    XYZvalue.Z = float.Parse(XYZ_Z.Text, CultureInfo.InvariantCulture);

                    // update other internal values
                    RGBvalue = XYZvalue.asRGB();
                    customRGBvalue = XYZvalue.as_customRGB();
                    sRGBvalue = RGBvalue.as_sRGB();
                    HSLvalue = RGBvalue.asHSL();
                    HSVvalue = RGBvalue.asHSV();
                    LUVvalue = XYZvalue.asLUV(ColorHelper.WP_used);
                    LABvalue = XYZvalue.asLAB(ColorHelper.WP_used);
                    break;
                case "LUV":
                    // parse input to internal LUVvalue
                    LUVvalue.L = float.Parse(LUV_L.Text, CultureInfo.InvariantCulture);
                    LUVvalue.U = float.Parse(LUV_U.Text, CultureInfo.InvariantCulture);
                    LUVvalue.V = float.Parse(LUV_V.Text, CultureInfo.InvariantCulture);

                    // update other internal values
                    XYZvalue = LUVvalue.asXYZ(ColorHelper.WP_used);
                    RGBvalue = XYZvalue.asRGB();
                    customRGBvalue = XYZvalue.as_customRGB();
                    sRGBvalue = RGBvalue.as_sRGB();
                    HSLvalue = RGBvalue.asHSL();
                    HSVvalue = RGBvalue.asHSV();
                    LABvalue = XYZvalue.asLAB(ColorHelper.WP_used);
                    break;
                case "LAB":
//.........这里部分代码省略.........
开发者ID:ArTc0re,项目名称:University,代码行数:101,代码来源:OpenGLForm.cs


注:本文中的RGB.asHSL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。