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));
        }
Example #2
0
 public CircleShape(string name, IAnimatableValue <Vector2?, Vector2?> position, AnimatablePointValue size, bool isReversed)
 {
     Name       = name;
     Position   = position;
     Size       = size;
     IsReversed = isReversed;
 }
Example #3
0
 public RectangleShape(string name, IAnimatableValue <Vector2?, Vector2?> position, AnimatablePointValue size, AnimatableFloatValue cornerRadius)
 {
     Name          = name;
     _position     = position;
     _size         = size;
     _cornerRadius = cornerRadius;
 }
Example #4
0
        internal static PolystarShape Parse(JsonReader reader, LottieComposition composition)
        {
            string name = null;
            var    type = PolystarShape.Type.Polygon;
            AnimatableFloatValue points = null;
            IAnimatableValue <Vector2?, Vector2?> position = null;
            AnimatableFloatValue rotation         = null;
            AnimatableFloatValue outerRadius      = null;
            AnimatableFloatValue outerRoundedness = null;
            AnimatableFloatValue innerRadius      = null;
            AnimatableFloatValue innerRoundedness = null;

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

                case "sy":
                    type = (PolystarShape.Type)reader.NextInt();
                    break;

                case "pt":
                    points = AnimatableValueParser.ParseFloat(reader, composition, false);
                    break;

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

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

                case "or":
                    outerRadius = AnimatableValueParser.ParseFloat(reader, composition);
                    break;

                case "os":
                    outerRoundedness = AnimatableValueParser.ParseFloat(reader, composition, false);
                    break;

                case "ir":
                    innerRadius = AnimatableValueParser.ParseFloat(reader, composition);
                    break;

                case "is":
                    innerRoundedness = AnimatableValueParser.ParseFloat(reader, composition, false);
                    break;

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

            return(new PolystarShape(name, type, points, position, rotation, innerRadius, outerRadius, innerRoundedness, outerRoundedness));
        }
 private RectangleShape(string name, IAnimatableValue <PointF> position, AnimatablePointValue size, AnimatableFloatValue cornerRadius)
 {
     Name          = name;
     _position     = position;
     _size         = size;
     _cornerRadius = cornerRadius;
 }
 private AnimatableTransform(AnimatablePathValue anchorPoint, IAnimatableValue <PointF> position, AnimatableScaleValue scale, AnimatableFloatValue rotation, AnimatableIntegerValue opacity)
 {
     AnchorPoint = anchorPoint;
     Position    = position;
     Scale       = scale;
     Rotation    = rotation;
     Opacity     = opacity;
 }
Example #7
0
 public RectangleShape(string name, IAnimatableValue <Vector2?, Vector2?> position, AnimatablePointValue size, AnimatableFloatValue cornerRadius)
 {
     Name         = name;
     Position     = position;
     Size         = size;
     CornerRadius = cornerRadius;
     IsHidden     = hidden;
 }
 public AnimatableTransform(AnimatablePathValue anchorPoint, IAnimatableValue <Vector2?, Vector2?> position, AnimatableScaleValue scale, AnimatableFloatValue rotation, AnimatableIntegerValue opacity, AnimatableFloatValue startOpacity, AnimatableFloatValue endOpacity)
 {
     AnchorPoint  = anchorPoint;
     Position     = position;
     Scale        = scale;
     Rotation     = rotation;
     Opacity      = opacity;
     StartOpacity = startOpacity;
     EndOpacity   = endOpacity;
 }
Example #9
0
 public PolystarShape(string name, Type type, AnimatableFloatValue points, IAnimatableValue <Vector2?, Vector2?> position, AnimatableFloatValue rotation, AnimatableFloatValue innerRadius, AnimatableFloatValue outerRadius, AnimatableFloatValue innerRoundedness, AnimatableFloatValue outerRoundedness)
 {
     Name             = name;
     _type            = type;
     Points           = points;
     Position         = position;
     Rotation         = rotation;
     InnerRadius      = innerRadius;
     OuterRadius      = outerRadius;
     InnerRoundedness = innerRoundedness;
     OuterRoundedness = outerRoundedness;
 }
        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 AnimatableTransform NewInstance(JsonObject json, LottieComposition composition)
            {
                AnimatablePathValue       anchorPoint;
                IAnimatableValue <PointF> position = null;
                AnimatableScaleValue      scale;
                AnimatableFloatValue      rotation = null;
                AnimatableIntegerValue    opacity;
                var anchorJson = json.GetNamedObject("a", null);

                if (anchorJson != null)
                {
                    anchorPoint = new AnimatablePathValue(anchorJson["k"], composition);
                }
                else
                {
                    // Cameras don't have an anchor point property. Although we don't support them, at least
                    // we won't crash.
                    Debug.WriteLine("Layer has no transform property. You may be using an unsupported " + "layer type such as a camera.", "LOTTIE");
                    anchorPoint = new AnimatablePathValue();
                }

                var positionJson = json.GetNamedObject("p", null);

                if (positionJson != null)
                {
                    position = AnimatablePathValue.CreateAnimatablePathOrSplitDimensionPath(positionJson, composition);
                }
                else
                {
                    ThrowMissingTransform("position");
                }

                var scaleJson = json.GetNamedObject("s", null);

                if (scaleJson != null)
                {
                    scale = AnimatableScaleValue.Factory.NewInstance(scaleJson, composition);
                }
                else
                {
                    // Somehow some community animations don't have scale in the transform.
                    scale = new AnimatableScaleValue(new List <IKeyframe <ScaleXy> >(), new ScaleXy());
                }

                var rotationJson = json.GetNamedObject("r", null);

                if (rotationJson == null)
                {
                    rotationJson = json.GetNamedObject("rz", null);
                }
                if (rotationJson != null)
                {
                    rotation = AnimatableFloatValue.Factory.NewInstance(rotationJson, composition, false);
                }
                else
                {
                    ThrowMissingTransform("rotation");
                }

                var opacityJson = json.GetNamedObject("o", null);

                if (opacityJson != null)
                {
                    opacity = AnimatableIntegerValue.Factory.NewInstance(opacityJson, composition);
                }
                else
                {
                    // Somehow some community animations don't have opacity in the transform.
                    opacity = new AnimatableIntegerValue(new List <IKeyframe <int?> >(), 100);
                }
                return(new AnimatableTransform(anchorPoint, position, scale, rotation, opacity));
            }
Example #12
0
 private CircleShape(string name, IAnimatableValue<Vector2?, Vector2?> position, AnimatablePointValue size)
 {
     Name = name;
     Position = position;
     Size = size;
 }
        public static AnimatableTransform Parse(JsonReader reader, LottieComposition composition)
        {
            AnimatablePathValue anchorPoint = null;
            IAnimatableValue <Vector2?, Vector2?> position = null;
            AnimatableScaleValue   scale        = null;
            AnimatableFloatValue   rotation     = null;
            AnimatableIntegerValue opacity      = null;
            AnimatableFloatValue   startOpacity = null;
            AnimatableFloatValue   endOpacity   = null;

            bool isObject = reader.Peek() == JsonToken.StartObject;

            if (isObject)
            {
                reader.BeginObject();
            }
            while (reader.HasNext())
            {
                switch (reader.NextName())
                {
                case "a":
                    reader.BeginObject();
                    while (reader.HasNext())
                    {
                        if (reader.NextName().Equals("k"))
                        {
                            anchorPoint = AnimatablePathValueParser.Parse(reader, composition);
                        }
                        else
                        {
                            reader.SkipValue();
                        }
                    }
                    reader.EndObject();
                    break;

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

                case "s":
                    scale = AnimatableValueParser.ParseScale(reader, composition);
                    break;

                case "rz":
                    composition.AddWarning("Lottie doesn't support 3D layers.");
                    rotation = AnimatableValueParser.ParseFloat(reader, composition, false);
                    break;

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

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

                case "so":
                    startOpacity = AnimatableValueParser.ParseFloat(reader, composition, false);
                    break;

                case "eo":
                    endOpacity = AnimatableValueParser.ParseFloat(reader, composition, false);
                    break;

                default:
                    reader.SkipValue();
                    break;
                }
            }
            if (isObject)
            {
                reader.EndObject();
            }

            if (anchorPoint == null)
            {
                // Cameras don't have an anchor point property. Although we don't support them, at least
                // we won't crash.
                Debug.WriteLine("Layer has no transform property. You may be using an unsupported layer type such as a camera.", LottieLog.Tag);
                anchorPoint = new AnimatablePathValue();
            }

            if (scale == null)
            {
                // Somehow some community animations don't have scale in the transform.
                scale = new AnimatableScaleValue(new ScaleXy(1f, 1f));
            }

            if (opacity == null)
            {
                // Repeaters have start/end opacity instead of opacity
                opacity = new AnimatableIntegerValue();
            }

            return(new AnimatableTransform(
                       anchorPoint, position, scale, rotation, opacity, startOpacity, endOpacity));
        }