Ejemplo n.º 1
0
        internal static PathKeyframe Parse(JsonReader reader, LottieComposition composition)
        {
            var animated = reader.Peek() == JsonToken.StartObject;
            var keyframe = KeyframeParser.Parse(reader, composition, Utils.Utils.DpScale(), PathParser.Instance, animated);

            return(new PathKeyframe(composition, keyframe));
        }
Ejemplo n.º 2
0
        internal static List <Keyframe <T> > Parse <T>(JsonReader reader, LottieComposition composition,
                                                       IValueParser <T> valueParser)
        {
            var keyframes = new List <Keyframe <T> >();

            if (reader.Peek() == JsonToken.String)
            {
                composition.AddWarning("Lottie doesn't support expressions.");
                return(keyframes);
            }

            reader.BeginObject();
            while (reader.HasNext())
            {
                switch (reader.NextName())
                {
                case "k":
                    if (reader.Peek() == JsonToken.StartArray)
                    {
                        reader.BeginArray();

                        if (reader.Peek() == JsonToken.Integer || reader.Peek() == JsonToken.Float)
                        {
                            // For properties in which the static value is an array of numbers.
                            keyframes.Add(KeyframeParser.Parse(reader, composition, valueParser, false));
                        }
                        else
                        {
                            while (reader.HasNext())
                            {
                                keyframes.Add(KeyframeParser.Parse(reader, composition, valueParser, true));
                            }
                        }
                        reader.EndArray();
                    }
                    else
                    {
                        keyframes.Add(KeyframeParser.Parse(reader, composition, valueParser, false));
                    }

                    break;

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

            reader.EndObject();

            SetEndFrames <Keyframe <T>, T>(keyframes);
            return(keyframes);
        }