當前位置: 首頁>>代碼示例>>C#>>正文


C# Color.ToHSV方法代碼示例

本文整理匯總了C#中Color.ToHSV方法的典型用法代碼示例。如果您正苦於以下問題:C# Color.ToHSV方法的具體用法?C# Color.ToHSV怎麽用?C# Color.ToHSV使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Color的用法示例。


在下文中一共展示了Color.ToHSV方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Contains

        public override bool Contains(Color colour)
        {
            bool hsv = false;
            bool rgb = false;

            HSV h = colour.ToHSV();
            if ((h.H > 0 & h.H < 35 & h.S > 0.23d & h.S < 0.68) | Contains(h))
                hsv = true;

            rgb = skinColourLabels[colour.R, colour.G, colour.B];

            return rgb | hsv;
        }
開發者ID:paveltimofeev,項目名稱:Skin-analize,代碼行數:13,代碼來源:FileTrainee.cs

示例2: SetColor

        /// <summary>
        /// Sets the selected color.
        /// </summary>
        /// <param name="value">Value to set.</param>
        /// <param name="onlyHue">Deetrmines whether to only set H value (not SV).</param>
        public void SetColor(Color value, bool onlyHue) /*true*/
        {
            HSV hsv = value.ToHSV();
            m_Hue = hsv.h;

            if (!onlyHue)
            {
                m_CursorPos.X = (int)(hsv.s * Width);
                m_CursorPos.Y = (int)((1 - hsv.v) * Height);
            }
            Invalidate();

            if (ColorChanged != null)
                ColorChanged.Invoke(this);
        }
開發者ID:petya2164,項目名稱:ZsharpGameEditor,代碼行數:20,代碼來源:ColorLerpBox.cs

示例3: SetColor

        private void SetColor(Color color)
        {
            HSV hsv = color.ToHSV();

            m_SelectedDist = (int)(hsv.h / 360 * Height);

            if (ColorChanged != null)
                ColorChanged.Invoke(this, EventArgs.Empty);
        }
開發者ID:LawlietRyuuzaki,項目名稱:gwen-dotnet,代碼行數:9,代碼來源:ColorSlider.cs

示例4: HSV

 public HSV(Color c)
 {
     this = c.ToHSV();
 }
開發者ID:paveltimofeev,項目名稱:Skin-analize,代碼行數:4,代碼來源:Exstensions.cs

示例5: GetLightColors

        /// <summary>
        /// This is a helper method that sets the light's colors based on the color passed in
        /// </summary>
        public static void GetLightColors(out Color ambient, out Color front, out Color back, Color color)
        {
            ColorHSV hsv = color.ToHSV();

            //<AmbientLight x:Name="ambientLight" Color="#696969" />
            //<DirectionalLight x:Name="frontDirectional" Color="#FFFFFF" Direction="-1,-1,-1" />
            //<DirectionalLight x:Name="backDirectional" Color="#303030" Direction="1,1,1" />

            ambient = UtilityWPF.HSVtoRGB(color.A, hsv.H, hsv.S, hsv.V * .41d);
            front = color;
            back = UtilityWPF.HSVtoRGB(color.A, hsv.H, hsv.S, hsv.V * .19d);
        }
開發者ID:charlierix,項目名稱:AsteroidMiner,代碼行數:15,代碼來源:InventoryItem.xaml.cs

示例6: Rainbowify

 /// <summary>
 /// Make a rainbow from the start color, shifting the hue until it reaches the end hue. (Returns a list of Colors).
 /// </summary>
 /// <param name="startColor">Start color.</param>
 /// <param name="endColor">Hue to stop shifting at (will only use the hue of this color, not value or saturation).</param>
 /// <param name="length">Desired length of the list.</param>
 public static List<Color> Rainbowify(Color startColor, Color endColor, int length)
 {
     List<Color> rainbow = new List<Color>();
     float startHue = startColor.ToHSV().h;
     float endHue = endColor.ToHSV().h;
     if (endHue < startHue) {
         endHue += 360f;
     }
     float degreesPerStep = (endHue - startHue);
     degreesPerStep /= (float)length - 1;
     rainbow.Add(startColor);
     ColorHSV colorHSV = startColor.ToHSV();
     for (int i = 0; i < length - 1; i++) {
         colorHSV.ShiftHue(degreesPerStep);
         rainbow.Add(colorHSV.ToColor());
     }
     return rainbow;
 }
開發者ID:dimmondslice,項目名稱:GraphicsFinalProject,代碼行數:24,代碼來源:JBirdColorLibrary.cs

示例7: MakeGradientHSV

 /// <summary>
 /// Make a gradient between two colors using HSV (Returns a list of colors blended from startColor to endColor).
 /// </summary>
 /// <returns>A list of colors blended from startColor to endColor.</returns>
 /// <param name="startColor">Start color.</param>
 /// <param name="endColor">End color.</param>
 /// <param name="blendColors>Number of blended colors in the middle (returned list's length will be this value plus two).</param>
 public static List<Color> MakeGradientHSV(Color startColor, Color endColor, int blendColors)
 {
     List<Color> gradient = new List<Color>();
     float startHue = startColor.ToHSV().h;
     float endHue = endColor.ToHSV().h;
     float startSat = startColor.ToHSV().s;
     float endSat = endColor.ToHSV().s;
     float startVal = startColor.ToHSV().v;
     float endVal = endColor.ToHSV().v;
     float degreesPerStep = (endHue - startHue);
     if (degreesPerStep > 180f) {
         degreesPerStep = degreesPerStep - 360f;
     }
     if (degreesPerStep < -180f) {
         degreesPerStep = degreesPerStep + 360f;
     }
     float saturationPerStep = (endSat - startSat);
     float valuePerStep = (endVal - startVal);
     degreesPerStep /= (float)(blendColors + 1);
     saturationPerStep /= (float)(blendColors + 1);
     valuePerStep /= (float)(blendColors + 1);
     gradient.Add(startColor);
     ColorHSV colorHSV = startColor.ToHSV();
     for (int i = 0; i < blendColors; i++) {
         colorHSV.ShiftHue(degreesPerStep);
         colorHSV.s += saturationPerStep;
         colorHSV.v += valuePerStep;
         gradient.Add(colorHSV.ToColor());
     }
     gradient.Add(endColor);
     return gradient;
 }
開發者ID:dimmondslice,項目名稱:GraphicsFinalProject,代碼行數:39,代碼來源:JBirdColorLibrary.cs

示例8: SetColor

        /// <summary>
        /// Sets the selected color.
        /// </summary>
        /// <param name="value">Value to set.</param>
        /// <param name="onlyHue">Deetrmines whether to only set H value (not SV).</param>
        public void SetColor(Color value, bool onlyHue = true)
        {
            HSV hsv = value.ToHSV();
            m_Hue = hsv.h;

            if (!onlyHue)
            {
                m_CursorPos.X = (int)(hsv.s * Width);
                m_CursorPos.Y = (int)((1 - hsv.v) * Height);
            }
            Invalidate();

            ColorChanged?.Invoke(this, EventArgs.Empty);
        }
開發者ID:Sprunth,項目名稱:gwen-dotnet,代碼行數:19,代碼來源:ColorLerpBox.cs


注:本文中的Color.ToHSV方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。