Beispiel #1
0
        internal static ShapePath Parse(JsonReader reader, LottieComposition composition)
        {
            string name = null;
            var    ind  = 0;
            AnimatableShapeValue shape = null;

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

                case "ind":
                    ind = reader.NextInt();
                    break;

                case "ks":
                    shape = AnimatableValueParser.ParseShapeData(reader, composition);
                    break;

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

            return(new ShapePath(name, ind, shape));
        }
Beispiel #2
0
        internal static Mask Parse(JsonReader reader, LottieComposition composition)
        {
            var maskMode = Mask.MaskMode.MaskModeAdd;
            AnimatableShapeValue   maskPath = null;
            AnimatableIntegerValue opacity  = null;

            reader.BeginObject();
            while (reader.HasNext())
            {
                var mode = reader.NextName();
                switch (mode)
                {
                case "mode":
                    switch (reader.NextString())
                    {
                    case "a":
                        maskMode = Mask.MaskMode.MaskModeAdd;
                        break;

                    case "s":
                        maskMode = Mask.MaskMode.MaskModeSubtract;
                        break;

                    case "i":
                        composition.AddWarning(
                            "Animation contains intersect masks. They are not supported but will be treated like add masks.");
                        maskMode = Mask.MaskMode.MaskModeIntersect;
                        break;

                    default:
                        Debug.WriteLine($"Unknown mask mode {mode}. Defaulting to Add.", LottieLog.Tag);
                        maskMode = Mask.MaskMode.MaskModeAdd;
                        break;
                    }

                    break;

                case "pt":
                    maskPath = AnimatableValueParser.ParseShapeData(reader, composition);
                    break;

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

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

            reader.EndObject();

            return(new Mask(maskMode, maskPath, opacity));
        }