System.Drawing.Color.GetHue C# (CSharp) Method

GetHue() public method

public GetHue ( ) : Single
return Single
        public Single GetHue()
        {
            if (R == G && G == B)
                return 0; // 0 makes as good an UNDEFINED value as any

            float r = R / 255.0f;
            float g = G / 255.0f;
            float b = B / 255.0f;

            float max, min;
            float delta;
            float hue = 0.0f;

            max = r; min = r;

            if (g > max) max = g;
            if (b > max) max = b;

            if (g < min) min = g;
            if (b < min) min = b;

            delta = max - min;

            if (r == max)
            {
                hue = (g - b) / delta;
            }
            else if (g == max)
            {
                hue = 2 + (b - r) / delta;
            }
            else if (b == max)
            {
                hue = 4 + (r - g) / delta;
            }
            hue *= 60;

            if (hue < 0.0f)
            {
                hue += 360.0f;
            }
            return hue;
        }

Same methods

Color::GetHue ( ) : float

Usage Example

Beispiel #1
0
 public bool IsOldStar(Color pixelColor)
 {
     return ((pixelColor.GetHue() >= 150) &&
         (pixelColor.GetHue() <= 258) &&
         (pixelColor.GetSaturation() >= 0.10) &&
         (pixelColor.GetBrightness() <= 0.90));
 }
All Usage Examples Of System.Drawing.Color::GetHue