internal static Hsl ToColor(Rgb rgb)
        {
            Color color      = System.Drawing.Color.FromArgb(rgb.R, rgb.G, rgb.B);
            float hue        = color.GetHue();
            float saturation = color.GetSaturation();
            float lightness  = color.GetBrightness();

            Hsl hsl = new Hsl();

            hsl.H = (int)hue;
            hsl.S = (int)(saturation * 100);
            hsl.L = (int)(lightness * 100);

            return(hsl);
        }
Exemple #2
0
        /// <summary>
        /// RGBカラーからHSL文字列へ変換する
        /// </summary>
        /// <param name="rgb">RGBカラー</param>
        /// <returns>HSL文字列</returns>
        public string getHslString(Rgb rgb)
        {
            Hsl hsl = HslConverter.ToColor(rgb);

            return(hsl.H.ToString() + "," + hsl.S.ToString() + "%," + hsl.L.ToString() + "%");
        }