Ejemplo n.º 1
0
        internal FillContent(LottieDrawable lottieDrawable, BaseLayer layer, ShapeFill fill)
        {
            Name            = fill.Name;
            _lottieDrawable = lottieDrawable;
            if (fill.Color == null || fill.Opacity == null)
            {
                _colorAnimation   = null;
                _opacityAnimation = null;
                return;
            }

            _path.FillType = fill.FillType;

            _colorAnimation = fill.Color.CreateAnimation();
            _colorAnimation.ValueChanged += (sender, args) =>
            {
                _lottieDrawable.InvalidateSelf();
            };
            layer.AddAnimation(_colorAnimation);
            _opacityAnimation = (KeyframeAnimation <int?>)fill.Opacity.CreateAnimation();
            _opacityAnimation.ValueChanged += (sender, args) =>
            {
                _lottieDrawable.InvalidateSelf();
            };
            layer.AddAnimation(_opacityAnimation);
        }
 internal virtual void AddAnimationsToLayer(BaseLayer layer)
 {
     layer.AddAnimation(_anchorPoint);
     layer.AddAnimation(_position);
     layer.AddAnimation(_scale);
     layer.AddAnimation(_rotation);
     layer.AddAnimation(_opacity);
 }
Ejemplo n.º 3
0
        internal EllipseContent(LottieDrawable lottieDrawable, BaseLayer layer, CircleShape circleShape)
        {
            Name               = circleShape.Name;
            _lottieDrawable    = lottieDrawable;
            _sizeAnimation     = circleShape.Size.CreateAnimation();
            _positionAnimation = circleShape.Position.CreateAnimation();

            layer.AddAnimation(_sizeAnimation);
            layer.AddAnimation(_positionAnimation);

            _sizeAnimation.ValueChanged     += OnValueChanged;
            _positionAnimation.ValueChanged += OnValueChanged;
        }
Ejemplo n.º 4
0
        internal BaseStrokeContent(LottieDrawable lottieDrawable, BaseLayer layer, PenLineCap cap, PenLineJoin join, AnimatableIntegerValue opacity, AnimatableFloatValue width, IList <AnimatableFloatValue> dashPattern, AnimatableFloatValue offset)
        {
            _lottieDrawable = lottieDrawable;

            Paint.Style      = Paint.PaintStyle.Stroke;
            Paint.StrokeCap  = cap;
            Paint.StrokeJoin = join;

            _opacityAnimation = opacity.CreateAnimation();
            _widthAnimation   = width.CreateAnimation();

            if (offset == null)
            {
                _dashPatternOffsetAnimation = null;
            }
            else
            {
                _dashPatternOffsetAnimation = offset.CreateAnimation();
            }
            _dashPatternAnimations = new List <IBaseKeyframeAnimation <float?> >(dashPattern.Count);
            _dashPatternValues     = new double[dashPattern.Count];

            for (var i = 0; i < dashPattern.Count; i++)
            {
                _dashPatternAnimations.Add(dashPattern[i].CreateAnimation());
            }

            layer.AddAnimation(_opacityAnimation);
            layer.AddAnimation(_widthAnimation);
            for (var i = 0; i < _dashPatternAnimations.Count; i++)
            {
                layer.AddAnimation(_dashPatternAnimations[i]);
            }
            if (_dashPatternOffsetAnimation != null)
            {
                layer.AddAnimation(_dashPatternOffsetAnimation);
            }

            _opacityAnimation.ValueChanged += OnValueChanged;
            _widthAnimation.ValueChanged   += OnValueChanged;

            for (var i = 0; i < dashPattern.Count; i++)
            {
                _dashPatternAnimations[i].ValueChanged += OnValueChanged;
            }
            if (_dashPatternOffsetAnimation != null)
            {
                _dashPatternOffsetAnimation.ValueChanged += OnValueChanged;
            }
        }
Ejemplo n.º 5
0
 internal StrokeContent(LottieDrawable lottieDrawable, BaseLayer layer, ShapeStroke stroke) : base(lottieDrawable, layer, ShapeStroke.LineCapTypeToPaintCap(stroke.CapType), ShapeStroke.LineJoinTypeToPaintLineJoin(stroke.JoinType), stroke.Opacity, stroke.Width, stroke.LineDashPattern, stroke.DashOffset)
 {
     Name            = stroke.Name;
     _colorAnimation = (KeyframeAnimation <Color>)stroke.Color.CreateAnimation();
     _colorAnimation.ValueChanged += OnValueChanged;
     layer.AddAnimation(_colorAnimation);
 }
Ejemplo n.º 6
0
        internal RectangleContent(LottieDrawable lottieDrawable, BaseLayer layer, RectangleShape rectShape)
        {
            Name                   = rectShape.Name;
            _lottieDrawable        = lottieDrawable;
            _positionAnimation     = rectShape.Position.CreateAnimation();
            _sizeAnimation         = rectShape.Size.CreateAnimation();
            _cornerRadiusAnimation = rectShape.CornerRadius.CreateAnimation();

            layer.AddAnimation(_positionAnimation);
            layer.AddAnimation(_sizeAnimation);
            layer.AddAnimation(_cornerRadiusAnimation);

            _positionAnimation.ValueChanged     += OnValueChanged;
            _sizeAnimation.ValueChanged         += OnValueChanged;
            _cornerRadiusAnimation.ValueChanged += OnValueChanged;
        }
Ejemplo n.º 7
0
        internal TrimPathContent(BaseLayer layer, ShapeTrimPath trimPath)
        {
            Name             = trimPath.Name;
            Type             = trimPath.GetType();
            _startAnimation  = trimPath.Start.CreateAnimation();
            _endAnimation    = trimPath.End.CreateAnimation();
            _offsetAnimation = trimPath.Offset.CreateAnimation();

            layer.AddAnimation(_startAnimation);
            layer.AddAnimation(_endAnimation);
            layer.AddAnimation(_offsetAnimation);

            _startAnimation.ValueChanged  += OnValueChanged;
            _endAnimation.ValueChanged    += OnValueChanged;
            _offsetAnimation.ValueChanged += OnValueChanged;
        }
Ejemplo n.º 8
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;
        }
Ejemplo n.º 9
0
 internal ShapeContent(LottieDrawable lottieDrawable, BaseLayer layer, ShapePath shape)
 {
     Name            = shape.Name;
     _lottieDrawable = lottieDrawable;
     _shapeAnimation = shape.GetShapePath().CreateAnimation();
     layer.AddAnimation(_shapeAnimation);
     _shapeAnimation.ValueChanged += OnValueChanged;
 }
        internal GradientStrokeContent(LottieDrawable lottieDrawable, BaseLayer layer, GradientStroke stroke) : base(lottieDrawable, layer, ShapeStroke.LineCapTypeToPaintCap(stroke.CapType), ShapeStroke.LineJoinTypeToPaintLineJoin(stroke.JoinType), stroke.Opacity, stroke.Width, stroke.LineDashPattern, stroke.DashOffset)
        {
            Name        = stroke.Name;
            _type       = stroke.GradientType;
            _cacheSteps = (int)(lottieDrawable.Composition.Duration / CacheStepsMs);

            _colorAnimation = (KeyframeAnimation <GradientColor>)stroke.GradientColor.CreateAnimation();
            _colorAnimation.ValueChanged += OnValueChanged;
            layer.AddAnimation(_colorAnimation);

            _startPointAnimation = (KeyframeAnimation <PointF>)stroke.StartPoint.CreateAnimation();
            _startPointAnimation.ValueChanged += OnValueChanged;
            layer.AddAnimation(_startPointAnimation);

            _endPointAnimation = (KeyframeAnimation <PointF>)stroke.EndPoint.CreateAnimation();
            _endPointAnimation.ValueChanged += OnValueChanged;
            layer.AddAnimation(_endPointAnimation);
        }
Ejemplo n.º 11
0
        internal GradientFillContent(LottieDrawable lottieDrawable, BaseLayer layer, GradientFill fill)
        {
            Name            = fill.Name;
            _lottieDrawable = lottieDrawable;
            _type           = fill.GradientType;
            _path.FillType  = fill.FillType;
            _cacheSteps     = (int)(lottieDrawable.Composition.Duration / CacheStepsMs);

            _colorAnimation = (KeyframeAnimation <GradientColor>)fill.GradientColor.CreateAnimation();
            _colorAnimation.ValueChanged += OnValueChanged;
            layer.AddAnimation(_colorAnimation);

            _opacityAnimation = (KeyframeAnimation <int?>)fill.Opacity.CreateAnimation();
            _opacityAnimation.ValueChanged += OnValueChanged;
            layer.AddAnimation(_opacityAnimation);

            _startPointAnimation = (KeyframeAnimation <PointF>)fill.StartPoint.CreateAnimation();
            _startPointAnimation.ValueChanged += OnValueChanged;
            layer.AddAnimation(_startPointAnimation);

            _endPointAnimation = (KeyframeAnimation <PointF>)fill.EndPoint.CreateAnimation();
            _endPointAnimation.ValueChanged += OnValueChanged;
            layer.AddAnimation(_endPointAnimation);
        }
Ejemplo n.º 12
0
 internal virtual void AddAnimationsToLayer(BaseLayer layer)
 {
     layer.AddAnimation(_anchorPoint);
     layer.AddAnimation(_position);
     layer.AddAnimation(_scale);
     layer.AddAnimation(_rotation);
     layer.AddAnimation(_opacity);
     if (_startOpacity != null)
     {
         layer.AddAnimation(_startOpacity);
     }
     if (_endOpacity != null)
     {
         layer.AddAnimation(_endOpacity);
     }
 }
Ejemplo n.º 13
0
        internal PolystarContent(LottieDrawable lottieDrawable, BaseLayer layer, PolystarShape polystarShape)
        {
            _lottieDrawable = lottieDrawable;

            Name                       = polystarShape.Name;
            _type                      = polystarShape.GetType();
            _pointsAnimation           = polystarShape.Points.CreateAnimation();
            _positionAnimation         = polystarShape.Position.CreateAnimation();
            _rotationAnimation         = polystarShape.Rotation.CreateAnimation();
            _outerRadiusAnimation      = polystarShape.OuterRadius.CreateAnimation();
            _outerRoundednessAnimation = polystarShape.OuterRoundedness.CreateAnimation();
            if (_type == PolystarShape.Type.Star)
            {
                _innerRadiusAnimation      = polystarShape.InnerRadius.CreateAnimation();
                _innerRoundednessAnimation = polystarShape.InnerRoundedness.CreateAnimation();
            }
            else
            {
                _innerRadiusAnimation      = null;
                _innerRoundednessAnimation = null;
            }

            layer.AddAnimation(_pointsAnimation);
            layer.AddAnimation(_positionAnimation);
            layer.AddAnimation(_rotationAnimation);
            layer.AddAnimation(_outerRadiusAnimation);
            layer.AddAnimation(_outerRoundednessAnimation);
            if (_type == PolystarShape.Type.Star)
            {
                layer.AddAnimation(_innerRadiusAnimation);
                layer.AddAnimation(_innerRoundednessAnimation);
            }

            _pointsAnimation.ValueChanged           += OnValueChanged;
            _positionAnimation.ValueChanged         += OnValueChanged;
            _rotationAnimation.ValueChanged         += OnValueChanged;
            _outerRadiusAnimation.ValueChanged      += OnValueChanged;
            _outerRoundednessAnimation.ValueChanged += OnValueChanged;
            if (_type == PolystarShape.Type.Star)
            {
                _outerRadiusAnimation.ValueChanged      += OnValueChanged;
                _outerRoundednessAnimation.ValueChanged += OnValueChanged;
            }
        }