Ejemplo n.º 1
0
        static IPropertyValue ToGradientStop(List <CssToken> value)
        {
            var color    = default(IPropertyValue);
            var position = default(IPropertyValue);
            var items    = value.ToItems();

            if (items.Count != 0)
            {
                position = LengthOrPercentConverter.Convert(items[items.Count - 1]);

                if (position != null)
                {
                    items.RemoveAt(items.Count - 1);
                }
            }

            if (items.Count != 0)
            {
                color = ColorConverter.Convert(items[items.Count - 1]);

                if (color != null)
                {
                    items.RemoveAt(items.Count - 1);
                }
            }

            return(items.Count == 0 ? new StopValue(color, position, value) : null);
        }
Ejemplo n.º 2
0
        public RadialGradientConverter()
        {
            var position = PointConverter.StartsWithKeyword(Keywords.At).Option(Point.Center);
            var circle   = WithOrder(WithAny(Assign(Keywords.Circle, true).Option(true),
                                             LengthConverter.Option()),
                                     position);

            var ellipse = WithOrder(WithAny(Assign(Keywords.Ellipse, false).Option(false),
                                            LengthOrPercentConverter.Many(2, 2).Option()),
                                    position);

            var extents = WithOrder(WithAny(Toggle(Keywords.Circle, Keywords.Ellipse).Option(false),
                                            Map.RadialGradientSizeModes.ToConverter()), position);

            _converter = circle.Or(ellipse.Or(extents));
        }