HSVtoRGB() публичный статический Метод

The hs vto rgb.
HSV contains values scaled as in the color wheel: that is, all from 0 to 255. for ( this code to work, HSV.Hue needs to be scaled from 0 to 360 (it//s the angle of the selected point within the circle). HSV.Saturation and HSV.value must be scaled to be between 0 and 1.
public static HSVtoRGB ( HSV HSV ) : RGB
HSV HSV The hsv.
Результат RGB
Пример #1
0
        /// <summary>
        /// The update box.
        /// </summary>
        public void updateBox()
        {
            colorBox.BackColor = ColorHandler.HSVtoColor(hsvColor);
            ColorHandler.RGB tempRGB = ColorHandler.HSVtoRGB(hsvColor);
            updatingColors = true;
            if (alphaText != null)
            {
                alphaText.Text = (this.color.Alpha / 255f).ToString();
            }

            redText.Text   = (tempRGB.Red / 255f).ToString();
            greenText.Text = (tempRGB.Green / 255f).ToString();
            blueText.Text  = (tempRGB.Blue / 255f).ToString();
            updatingColors = false;
        }
Пример #2
0
        private void GrabColor(object sender, Point mouseXY)
        {
            int cntlNum = this.Controls.IndexOf((Control)sender);
            int cx      = mouseXY.X;
            int cy      = mouseXY.Y;

            switch (cntlNum)
            {
            case 0:
                // center our coordinate system so the middle is (0,0), and positive Y is facing up
                cx -= (this.Controls[cntlNum].Width / 2);
                cy -= (this.Controls[cntlNum].Height / 2);
                if (cx < this.Controls[cntlNum].Width / 2)
                {
                    double theta = Math.Atan2(cy, cx);

                    if (theta < 0)
                    {
                        theta += 2 * Math.PI;
                    }

                    double alpha = Math.Sqrt((cx * cx) + (cy * cy));

                    int h = (int)((theta / (Math.PI * 2)) * 360.0);
                    int s = (int)Math.Min(100.0, (alpha / (double)(this.Controls[0].Width / 2)) * 100);
                    int v = hsvColor.value;

                    hsvColor = new ColorHandler.HSV(h, s, v);

                    OnColorChanged();
                    updateBar();
                }
                break;

            case 1:
                if (cx < this.Controls[cntlNum].Width)
                {
                    hsvColor.value = Math.Max(0, Math.Min(100, 100 - (cy * 100 / this.Controls[cntlNum].Height)));
                    updateBox();
                }
                break;
            }
            this.color = ColorHandler.HSVtoRGB(hsvColor);
            Invalidate(true);
        }