Esempio n. 1
0
            internal static ShapeFill NewInstance(JsonObject json, LottieComposition composition)
            {
                AnimatableColorValue color = null;
                bool fillEnabled;
                AnimatableIntegerValue opacity = null;
                var name = json.GetNamedString("nm");

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

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

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

                if (jsonOpacity != null)
                {
                    opacity = AnimatableIntegerValue.Factory.NewInstance(jsonOpacity, composition);
                }
                fillEnabled = json.GetNamedBoolean("fillEnabled", false);

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

                return(new ShapeFill(name, fillEnabled, fillType, color, opacity));
            }
 public AnimatableTextProperties(AnimatableColorValue color, AnimatableColorValue stroke, AnimatableFloatValue strokeWidth, AnimatableFloatValue tracking)
 {
     _color       = color;
     _stroke      = stroke;
     _strokeWidth = strokeWidth;
     _tracking    = tracking;
 }
Esempio n. 3
0
 private ShapeFill(string name, bool fillEnabled, PathFillType fillType, AnimatableColorValue color, AnimatableIntegerValue opacity)
 {
     Name         = name;
     _fillEnabled = fillEnabled;
     FillType     = fillType;
     _color       = color;
     _opacity     = opacity;
 }
Esempio n. 4
0
 public ShapeFill(string name, bool fillEnabled, PathFillType fillType, AnimatableColorValue color, AnimatableIntegerValue opacity, bool hidden)
 {
     Name         = name;
     _fillEnabled = fillEnabled;
     FillType     = fillType;
     Color        = color;
     Opacity      = opacity;
     IsHidden     = hidden;
 }
Esempio n. 5
0
 public ShapeStroke(string name, AnimatableFloatValue offset, List <AnimatableFloatValue> lineDashPattern, AnimatableColorValue color, AnimatableIntegerValue opacity, AnimatableFloatValue width, LineCapType capType, LineJoinType joinType)
 {
     Name            = name;
     DashOffset      = offset;
     LineDashPattern = lineDashPattern;
     Color           = color;
     Opacity         = opacity;
     Width           = width;
     CapType         = capType;
     JoinType        = joinType;
 }
Esempio n. 6
0
        internal static ShapeFill Parse(JsonReader reader, LottieComposition composition)
        {
            AnimatableColorValue color     = null;
            bool fillEnabled               = false;
            AnimatableIntegerValue opacity = null;
            string name        = null;
            int    fillTypeInt = 1;

            bool hidden = false;

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

                case "c":
                    color = AnimatableValueParser.ParseColor(reader, composition);
                    break;

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

                case "fillEnabled":
                    fillEnabled = reader.NextBoolean();
                    break;

                case "r":
                    fillTypeInt = reader.NextInt();
                    break;

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

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

            var fillType = fillTypeInt == 1 ? SKPathFillType.Winding : SKPathFillType.EvenOdd;

            return(new ShapeFill(name, fillEnabled, fillType, color, opacity, hidden));
        }
Esempio n. 7
0
        private static AnimatableTextProperties ParseAnimatableTextProperties(JsonReader reader,
                                                                              LottieComposition composition)
        {
            AnimatableColorValue color       = null;
            AnimatableColorValue stroke      = null;
            AnimatableFloatValue strokeWidth = null;
            AnimatableFloatValue tracking    = null;

            reader.BeginObject();
            while (reader.HasNext())
            {
                switch (reader.NextName())
                {
                case "fc":
                    color = AnimatableValueParser.ParseColor(reader, composition);
                    break;

                case "sc":
                    stroke = AnimatableValueParser.ParseColor(reader, composition);
                    break;

                case "sw":
                    strokeWidth = AnimatableValueParser.ParseFloat(reader, composition);
                    break;

                case "t":
                    tracking = AnimatableValueParser.ParseFloat(reader, composition);
                    break;

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

            reader.EndObject();

            return(new AnimatableTextProperties(color, stroke, strokeWidth, tracking));
        }
Esempio n. 8
0
        internal static ShapeStroke Parse(JsonReader reader, LottieComposition composition)
        {
            string name = null;
            AnimatableColorValue   color   = null;
            AnimatableFloatValue   width   = null;
            AnimatableIntegerValue opacity = null;

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

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


            bool hidden = false;

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

                case "c":
                    color = AnimatableValueParser.ParseColor(reader, composition);
                    break;

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

                case "o":
                    opacity = AnimatableValueParser.ParseInteger(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 "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();

                        switch (n)
                        {
                        case "o":
                            offset = val;
                            break;

                        case "d":
                        case "g":
                            lineDashPattern.Add(val);
                            break;
                        }
                    }
                    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;

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

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

            return(new ShapeStroke(name, offset, lineDashPattern, color, opacity, width, capType, joinType, miterLimit, hidden));
        }