示例#1
0
        internal static PathKeyframe Parse(JsonReader reader, LottieComposition composition)
        {
            bool animated = reader.Peek() == JsonToken.StartObject;
            Keyframe <Vector2?> keyframe = KeyframeParser.Parse(reader, composition, Utils.Utils.DpScale(), PathParser.Instance, animated);

            return(new PathKeyframe(composition, keyframe));
        }
        internal static List <Keyframe <T> > Parse <T>(JsonReader reader, LottieComposition composition, float scale, IValueParser <T> valueParser)
        {
            List <Keyframe <T> > 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, scale, valueParser, false));
                        }
                        else
                        {
                            while (reader.HasNext())
                            {
                                keyframes.Add(KeyframeParser.Parse(reader, composition, scale, valueParser, true));
                            }
                        }
                        reader.EndArray();
                    }
                    else
                    {
                        keyframes.Add(KeyframeParser.Parse(reader, composition, scale, valueParser, false));
                    }
                    break;

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

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