Beispiel #1
0
        private static byte[] GetColorBytes(string color)
        {
            byte[] bytes = null;

            if (HtmlColorCodeParser.TryParse(color, out var red, out var green, out var blue))
            {
                bytes = new[] { red, green, blue, byte.MaxValue };
            }

            return(bytes);
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new color based on the supplied HTML color code.
        /// </summary>
        /// <param name="code">The HTML color code to parse</param>
        /// <returns><see cref="ChartColor"/></returns>
        public static ChartColor FromHtmlColorCode(string code)
        {
            if (code == null)
            {
                throw new ArgumentNullException(nameof(code));
            }

            if (HtmlColorCodeParser.TryParse(code, out var red, out var green, out var blue))
            {
                return(new ChartColor(red, green, blue));
            }

            throw new ArgumentException($"The \"{code}\" doesn't represent a valid HTML color code.", nameof(code));
        }