Пример #1
0
        public static string WrapUOHtmlGradient(this string str, params Color[] colors)
        {
            if (colors == null || colors.Length == 0)
            {
                return(str ?? String.Empty);
            }

            using (var g = new ColorGradient(colors))
            {
                var t = new StringBuilder(str.Length * g.Count);

                g.ForEachSegment(
                    str.Length,
                    (o, s, c) =>
                {
                    if (o >= str.Length)
                    {
                        return;
                    }

                    if (o + s > str.Length)
                    {
                        s = str.Length - o;
                    }

                    t.AppendFormat(str.Substring(o, s).WrapUOHtmlColor(c, false));
                });

                return(t.ToString());
            }
        }