internal ContentGroup(LottieDrawable lottieDrawable, BaseLayer layer, string name, List <IContent> contents, AnimatableTransform transform)
        {
            Name      = name;
            _contents = contents;

            if (transform != null)
            {
                _transformAnimation = transform.CreateAnimation();

                _transformAnimation.AddAnimationsToLayer(layer);
                _transformAnimation.ValueChanged += (sender, args) =>
                {
                    lottieDrawable.InvalidateSelf();
                };
            }

            var greedyContents = new List <IGreedyContent>();

            for (var i = contents.Count - 1; i >= 0; i--)
            {
                var content = contents[i];
                if (content is IGreedyContent greedyContent)
                {
                    greedyContents.Add(greedyContent);
                }
            }

            for (var i = greedyContents.Count - 1; i >= 0; i--)
            {
                greedyContents[i].AbsorbContent(_contents);
            }
        }
Beispiel #2
0
        internal RepeaterContent(LottieDrawable lottieDrawable, BaseLayer layer, Repeater repeater)
        {
            _lottieDrawable = lottieDrawable;
            _layer          = layer;
            Name            = repeater.Name;
            _copies         = repeater.Copies.CreateAnimation();
            layer.AddAnimation(_copies);
            _copies.ValueChanged += OnValueChanged;

            _offset = repeater.Offset.CreateAnimation();
            layer.AddAnimation(_offset);
            _offset.ValueChanged += OnValueChanged;

            _transform = repeater.Transform.CreateAnimation();
            _transform.AddAnimationsToLayer(layer);
            _transform.ValueChanged += OnValueChanged;
        }
Beispiel #3
0
        internal BaseLayer(LottieDrawable lottieDrawable, Layer layerModel)
        {
            LottieDrawable       = lottieDrawable;
            LayerModel           = layerModel;
            _drawTraceName       = layerModel.Name + ".Draw";
            _clearPaint.Xfermode = new PorterDuffXfermode(PorterDuff.Mode.Clear);
            _maskPaint.Xfermode  = new PorterDuffXfermode(PorterDuff.Mode.DstIn);
            if (layerModel.GetMatteType() == Layer.MatteType.Invert)
            {
                _mattePaint.Xfermode = new PorterDuffXfermode(PorterDuff.Mode.DstOut);
            }
            else
            {
                _mattePaint.Xfermode = new PorterDuffXfermode(PorterDuff.Mode.DstIn);
            }

            Transform = layerModel.Transform.CreateAnimation();
            Transform.ValueChanged += OnValueChanged;
            Transform.AddAnimationsToLayer(this);

            if (layerModel.Masks != null && layerModel.Masks.Count > 0)
            {
                _mask = new MaskKeyframeAnimation(layerModel.Masks);
                foreach (var animation in _mask.MaskAnimations)
                {
                    AddAnimation(animation);
                    animation.ValueChanged += OnValueChanged;
                }
                foreach (var animation in _mask.OpacityAnimations)
                {
                    AddAnimation(animation);
                    animation.ValueChanged += OnValueChanged;
                }
            }
            SetupInOutAnimations();
        }