Esempio n. 1
0
        /// <summary>
        /// Converts a web color string to a Color.
        /// </summary>
        /// <returns>
        /// The color.
        /// </returns>
        /// <param name='colorCode'>
        /// A web RGB-format color code of the format "\#rrggbb", where rr, gg, and bb are
        /// hexadecimal values (e.g., \#ff0000 for red).
        /// </param>
        public static Color WebColor(string colorCode)
        {
            byte r = (colorCode.Length > 2) ? Tools.HexToByte(colorCode.Substring(1, 2)) : (byte)0;
            byte g = (colorCode.Length > 4) ? Tools.HexToByte(colorCode.Substring(3, 2)) : (byte)0;
            byte b = (colorCode.Length > 6) ? Tools.HexToByte(colorCode.Substring(5, 2)) : (byte)0;

            return(new Color32(r, g, b, 255));
        }