Returns the hue of a colour in RGB format - CSharp System.Drawing

CSharp examples for System.Drawing:Color RGB

Description

Returns the hue of a colour in RGB format

Demo Code


using Microsoft.Xna.Framework;
using System;//from   w  w w. j a  v  a 2  s  . co m

public class Main{
        /// <summary>
        /// Returns the hue of a colour in RGB format
        /// </summary>
        /// <param name="R">Red</param>
        /// <param name="G">Green</param>
        /// <param name="B">Blue</param>
        /// <returns>Hue as a double</returns>
        public static double getHue(int R, int G, int B)
        {
            double alph;
            double beta;
            
            alph = 0.5*(2*R-(G+B));
            beta = Math.Sqrt(3)*0.5*(G-B);
            
            return Math.Atan2(beta,alph);
        }
}

Related Tutorials