示例#1
0
            internal static GradientFill NewInstance(JsonObject json, LottieComposition composition)
            {
                var name = json.GetNamedString("nm");

                var jsonColor = json.GetNamedObject("g", null);

                if (jsonColor != null && jsonColor.ContainsKey("k"))
                {
                    // This is a hack because the "p" value which contains the number of color points is outside
                    // of "k" which contains the useful data.
                    var points = (int)jsonColor.GetNamedNumber("p");
                    jsonColor = jsonColor.GetNamedObject("k");
                    try
                    {
                        jsonColor["p"] = JsonValue.CreateNumberValue(points);
                    }
                    catch (Exception)
                    {
                        // Do nothing. This shouldn't fail.
                    }
                }
                AnimatableGradientColorValue color = null;

                if (jsonColor != null)
                {
                    color = AnimatableGradientColorValue.Factory.NewInstance(jsonColor, composition);
                }

                var jsonOpacity = json.GetNamedObject("o", null);
                AnimatableIntegerValue opacity = null;

                if (jsonOpacity != null)
                {
                    opacity = AnimatableIntegerValue.Factory.NewInstance(jsonOpacity, composition);
                }

                var fillTypeInt = (int)json.GetNamedNumber("r", 1);
                var fillType    = fillTypeInt == 1 ? PathFillType.Winding : PathFillType.EvenOdd;

                var gradientTypeInt = (int)json.GetNamedNumber("t", 1);
                var gradientType    = gradientTypeInt == 1 ? GradientType.Linear : GradientType.Radial;

                var jsonStartPoint = json.GetNamedObject("s", null);
                AnimatablePointValue startPoint = null;

                if (jsonStartPoint != null)
                {
                    startPoint = AnimatablePointValue.Factory.NewInstance(jsonStartPoint, composition);
                }

                var jsonEndPoint = json.GetNamedObject("e", null);
                AnimatablePointValue endPoint = null;

                if (jsonEndPoint != null)
                {
                    endPoint = AnimatablePointValue.Factory.NewInstance(jsonEndPoint, composition);
                }

                return(new GradientFill(name, gradientType, fillType, color, opacity, startPoint, endPoint, null, null));
            }
示例#2
0
 public CircleShape(string name, IAnimatableValue <Vector2?, Vector2?> position, AnimatablePointValue size, bool isReversed)
 {
     Name       = name;
     Position   = position;
     Size       = size;
     IsReversed = isReversed;
 }
        internal static RectangleShape Parse(JsonReader reader, LottieComposition composition)
        {
            string name = null;
            IAnimatableValue <Vector2?, Vector2?> position = null;
            AnimatablePointValue size        = null;
            AnimatableFloatValue roundedness = null;

            while (reader.HasNext())
            {
                switch (reader.NextName())
                {
                case "nm":
                    name = reader.NextString();
                    break;

                case "p":
                    position = AnimatablePathValueParser.ParseSplitPath(reader, composition);
                    break;

                case "s":
                    size = AnimatableValueParser.ParsePoint(reader, composition);
                    break;

                case "r":
                    roundedness = AnimatableValueParser.ParseFloat(reader, composition);
                    break;

                default:
                    reader.SkipValue();
                    break;
                }
            }

            return(new RectangleShape(name, position, size, roundedness));
        }
示例#4
0
 public RectangleShape(string name, IAnimatableValue <Vector2?, Vector2?> position, AnimatablePointValue size, AnimatableFloatValue cornerRadius)
 {
     Name          = name;
     _position     = position;
     _size         = size;
     _cornerRadius = cornerRadius;
 }
示例#5
0
 public RectangleShape(string name, IAnimatableValue <Vector2?, Vector2?> position, AnimatablePointValue size, AnimatableFloatValue cornerRadius)
 {
     Name         = name;
     Position     = position;
     Size         = size;
     CornerRadius = cornerRadius;
     IsHidden     = hidden;
 }
示例#6
0
 private GradientFill(string name, GradientType gradientType, PathFillType fillType, AnimatableGradientColorValue gradientColor, AnimatableIntegerValue opacity, AnimatablePointValue startPoint, AnimatablePointValue endPoint, AnimatableFloatValue highlightLength, AnimatableFloatValue highlightAngle)
 {
     GradientType    = gradientType;
     FillType        = fillType;
     GradientColor   = gradientColor;
     Opacity         = opacity;
     StartPoint      = startPoint;
     EndPoint        = endPoint;
     Name            = name;
     HighlightLength = highlightLength;
     HighlightAngle  = highlightAngle;
 }
示例#7
0
 public GradientStroke(string name, GradientType gradientType, AnimatableGradientColorValue gradientColor, AnimatableIntegerValue opacity, AnimatablePointValue startPoint, AnimatablePointValue endPoint, AnimatableFloatValue width, ShapeStroke.LineCapType capType, ShapeStroke.LineJoinType joinType, List <AnimatableFloatValue> lineDashPattern, AnimatableFloatValue dashOffset)
 {
     Name            = name;
     GradientType    = gradientType;
     GradientColor   = gradientColor;
     Opacity         = opacity;
     StartPoint      = startPoint;
     EndPoint        = endPoint;
     Width           = width;
     CapType         = capType;
     JoinType        = joinType;
     LineDashPattern = lineDashPattern;
     DashOffset      = dashOffset;
 }
        internal static CircleShape Parse(JsonReader reader, LottieComposition composition, int d)
        {
            string name = null;
            IAnimatableValue <Vector2?, Vector2?> position = null;
            AnimatablePointValue size = null;
            bool reversed             = d == 3;
            bool hidden = false;

            while (reader.HasNext())
            {
                switch (reader.NextName())
                {
                case "nm":
                    name = reader.NextString();
                    break;

                case "p":
                    position = AnimatablePathValueParser.ParseSplitPath(reader, composition);
                    break;

                case "s":
                    size = AnimatableValueParser.ParsePoint(reader, composition);
                    break;

                case "hd":
                    hidden = reader.NextBoolean();
                    break;

                case "d":
                    // "d" is 2 for normal and 3 for reversed.
                    reversed = reader.NextInt() == 3;
                    break;

                default:
                    reader.SkipValue();
                    break;
                }
            }

            return(new CircleShape(name, position, size, reversed, hidden));
        }
        internal static GradientStroke Parse(JsonReader reader, LottieComposition composition)
        {
            string name = null;
            AnimatableGradientColorValue color   = null;
            AnimatableIntegerValue       opacity = null;
            GradientType         gradientType    = GradientType.Linear;
            AnimatablePointValue startPoint      = null;
            AnimatablePointValue endPoint        = null;
            AnimatableFloatValue width           = null;

            ShapeStroke.LineCapType  capType  = ShapeStroke.LineCapType.Unknown;
            ShapeStroke.LineJoinType joinType = ShapeStroke.LineJoinType.Round;
            AnimatableFloatValue     offset   = null;
            float miterLimit = 0f;
            bool  hidden     = false;

            List <AnimatableFloatValue> lineDashPattern = new List <AnimatableFloatValue>();

            while (reader.HasNext())
            {
                switch (reader.NextName())
                {
                case "nm":
                    name = reader.NextString();
                    break;

                case "g":
                    int points = -1;
                    reader.BeginObject();
                    while (reader.HasNext())
                    {
                        switch (reader.NextName())
                        {
                        case "p":
                            points = reader.NextInt();
                            break;

                        case "k":
                            color = AnimatableValueParser.ParseGradientColor(reader, composition, points);
                            break;

                        default:
                            reader.SkipValue();
                            break;
                        }
                    }
                    reader.EndObject();
                    break;

                case "o":
                    opacity = AnimatableValueParser.ParseInteger(reader, composition);
                    break;

                case "t":
                    gradientType = reader.NextInt() == 1 ? GradientType.Linear : GradientType.Radial;
                    break;

                case "s":
                    startPoint = AnimatableValueParser.ParsePoint(reader, composition);
                    break;

                case "e":
                    endPoint = AnimatableValueParser.ParsePoint(reader, composition);
                    break;

                case "w":
                    width = AnimatableValueParser.ParseFloat(reader, composition);
                    break;

                case "lc":
                    capType = (ShapeStroke.LineCapType)(reader.NextInt() - 1);
                    break;

                case "lj":
                    joinType = (ShapeStroke.LineJoinType)(reader.NextInt() - 1);
                    break;

                case "ml":
                    miterLimit = reader.NextDouble();
                    break;

                case "hd":
                    hidden = reader.NextBoolean();
                    break;

                case "d":
                    reader.BeginArray();
                    while (reader.HasNext())
                    {
                        String n = null;
                        AnimatableFloatValue val = null;
                        reader.BeginObject();
                        while (reader.HasNext())
                        {
                            switch (reader.NextName())
                            {
                            case "n":
                                n = reader.NextString();
                                break;

                            case "v":
                                val = AnimatableValueParser.ParseFloat(reader, composition);
                                break;

                            default:
                                reader.SkipValue();
                                break;
                            }
                        }
                        reader.EndObject();

                        if (n.Equals("o"))
                        {
                            offset = val;
                        }
                        else if (n.Equals("d") || n.Equals("g"))
                        {
                            lineDashPattern.Add(val);
                        }
                    }
                    reader.EndArray();
                    if (lineDashPattern.Count == 1)
                    {
                        // If there is only 1 value then it is assumed to be equal parts on and off.
                        lineDashPattern.Add(lineDashPattern[0]);
                    }
                    break;

                default:
                    reader.SkipValue();
                    break;
                }
            }

            return(new GradientStroke(
                       name, gradientType, color, opacity, startPoint, endPoint, width, capType, joinType,
                       miterLimit, lineDashPattern, offset, hidden));
        }
示例#10
0
 private CircleShape(string name, IAnimatableValue<Vector2?, Vector2?> position, AnimatablePointValue size)
 {
     Name = name;
     Position = position;
     Size = size;
 }
        internal static GradientFill Parse(JsonReader reader, LottieComposition composition)
        {
            string name = null;
            AnimatableGradientColorValue color   = null;
            AnimatableIntegerValue       opacity = null;
            var gradientType = GradientType.Linear;
            AnimatablePointValue startPoint = null;
            AnimatablePointValue endPoint   = null;
            var fillType = PathFillType.EvenOdd;
            AnimatableFloatValue highlightAngle  = null;
            AnimatableFloatValue highlightLength = null;

            while (reader.HasNext())
            {
                switch (reader.NextName())
                {
                case "nm":
                    name = reader.NextString();
                    break;

                case "g":
                    var points = -1;
                    reader.BeginObject();
                    while (reader.HasNext())
                    {
                        switch (reader.NextName())
                        {
                        case "p":
                            points = reader.NextInt();
                            break;

                        case "k":
                            color = AnimatableValueParser.ParseGradientColor(reader, composition, points);
                            break;

                        default:
                            reader.SkipValue();
                            break;
                        }
                    }

                    reader.EndObject();
                    break;

                case "o":
                    opacity = AnimatableValueParser.ParseInteger(reader, composition);
                    break;

                case "t":
                    gradientType = reader.NextInt() == 1 ? GradientType.Linear : GradientType.Radial;
                    break;

                case "s":
                    startPoint = AnimatableValueParser.ParsePoint(reader, composition);
                    break;

                case "e":
                    endPoint = AnimatableValueParser.ParsePoint(reader, composition);
                    break;

                case "r":
                    fillType = reader.NextInt() == 1 ? PathFillType.Winding : PathFillType.EvenOdd;
                    break;

                case "h":
                    highlightLength = AnimatableValueParser.ParseFloat(reader, composition);
                    break;

                case "a":
                    highlightAngle = AnimatableValueParser.ParseFloat(reader, composition);
                    break;

                default:
                    reader.SkipValue();
                    break;
                }
            }

            return(new GradientFill(
                       name, gradientType, fillType, color, opacity, startPoint, endPoint, highlightLength, highlightAngle));
        }
        internal static GradientFill Parse(JsonReader reader, LottieComposition composition)
        {
            string name = null;
            AnimatableGradientColorValue color   = null;
            AnimatableIntegerValue       opacity = null;
            GradientType         gradientType    = GradientType.Linear;
            AnimatablePointValue startPoint      = null;
            AnimatablePointValue endPoint        = null;
            SKPathFillType       fillType        = SKPathFillType.EvenOdd;


            bool hidden = false;

            while (reader.HasNext())
            {
                switch (reader.NextName())
                {
                case "nm":
                    name = reader.NextString();
                    break;

                case "g":
                    int points = -1;
                    reader.BeginObject();
                    while (reader.HasNext())
                    {
                        switch (reader.NextName())
                        {
                        case "p":
                            points = reader.NextInt();
                            break;

                        case "k":
                            color = AnimatableValueParser.ParseGradientColor(reader, composition, points);
                            break;

                        default:
                            reader.SkipValue();
                            break;
                        }
                    }
                    reader.EndObject();
                    break;

                case "o":
                    opacity = AnimatableValueParser.ParseInteger(reader, composition);
                    break;

                case "t":
                    gradientType = reader.NextInt() == 1 ? GradientType.Linear : GradientType.Radial;
                    break;

                case "s":
                    startPoint = AnimatableValueParser.ParsePoint(reader, composition);
                    break;

                case "e":
                    endPoint = AnimatableValueParser.ParsePoint(reader, composition);
                    break;

                case "r":
                    fillType = reader.NextInt() == 1 ? SKPathFillType.Winding : SKPathFillType.EvenOdd;
                    break;

                case "hd":
                    hidden = reader.NextBoolean();
                    break;

                default:
                    reader.SkipValue();
                    break;
                }
            }

            return(new GradientFill(
                       name, gradientType, fillType, color, opacity, startPoint, endPoint, null, null, hidden));
        }