Exemplo n.º 1
0
 public override void GetBounds(out Rect outBounds, Matrix3X3 parentMatrix)
 {
     base.GetBounds(out outBounds, parentMatrix);
     _contentGroup.GetBounds(out outBounds, BoundsMatrix);
 }
Exemplo n.º 2
0
 public void GetBounds(out Rect outBounds, Matrix3X3 parentMatrix)
 {
     _contentGroup.GetBounds(out outBounds, parentMatrix);
 }
Exemplo n.º 3
0
 public override void DrawLayer(BitmapCanvas canvas, Matrix3X3 parentMatrix, byte parentAlpha)
 {
     _contentGroup.Draw(canvas, parentMatrix, parentAlpha);
 }
Exemplo n.º 4
0
 public override void GetBounds(out Rect outBounds, Matrix3X3 parentMatrix)
 {
     base.GetBounds(out outBounds, parentMatrix);
     RectExt.Set(ref outBounds, 0, 0, 0, 0);
 }
Exemplo n.º 5
0
        private static void Draw(SKSurface bitmapCanvas, CompositionLayer compositionLayer, SKRect bounds, float scale, byte alpha, Matrix3X3 matrix, double width, double height)
        {
            bitmapCanvas.Canvas.Clear(SKColors.Transparent);
            LottieLog.BeginSection("Drawable.Draw");
            if (compositionLayer == null)
            {
                return;
            }

            var   localScale = scale;
            float extraScale = 1f;

            float maxScale = GetMaxScale(bitmapCanvas.Canvas, bounds);

            if (localScale > maxScale)
            {
                localScale = maxScale;
                extraScale = scale / localScale;
            }

            if (extraScale > 1)
            {
                // This is a bit tricky...
                // We can't draw on a canvas larger than ViewConfiguration.get(context).getScaledMaximumDrawingCacheSize()
                // which works out to be roughly the size of the screen because Android can't generate a
                // bitmap large enough to render to.
                // As a result, we cap the scale such that it will never be wider/taller than the screen
                // and then only render in the top left corner of the canvas. We then use extraScale
                // to scale up the rest of the scale. However, since we rendered the animation to the top
                // left corner, we need to scale up and translate the canvas to zoom in on the top left
                // corner.
                bitmapCanvas.Canvas.Save();
                float halfWidth        = (float)bounds.Width / 2f;
                float halfHeight       = (float)bounds.Height / 2f;
                float scaledHalfWidth  = halfWidth * localScale;
                float scaledHalfHeight = halfHeight * localScale;
                bitmapCanvas.Canvas.Translate(
                    scale * halfWidth - scaledHalfWidth,
                    scale * halfHeight - scaledHalfHeight);
                bitmapCanvas.Canvas.Scale(extraScale, extraScale, scaledHalfWidth, scaledHalfHeight);
            }

            matrix.Reset();
            matrix = MatrixExt.PreScale(matrix, localScale, localScale);
            compositionLayer.Draw(bitmapCanvas.Canvas, matrix, alpha);
            LottieLog.EndSection("Drawable.Draw");

            if (extraScale > 1)
            {
                bitmapCanvas.Canvas.Restore();
            }
        }
Exemplo n.º 6
0
        //public int Opacity
        //{
        //    get
        //    {
        //        return PixelFormat.TRANSLUCENT;
        //    }
        //}

        private void CanvasControlOnDraw(ICanvasAnimatedControl canvasControl, CanvasAnimatedDrawEventArgs args)
        {
            lock (this)
            {
                if (_bitmapCanvas == null)
                {
                    return;
                }

                using (_bitmapCanvas.CreateSession(canvasControl.Device, canvasControl.Size.Width, canvasControl.Size.Height, args.DrawingSession))
                {
                    _bitmapCanvas.Clear(Colors.Transparent);
                    LottieLog.BeginSection("Drawable.Draw");
                    if (_compositionLayer == null)
                    {
                        return;
                    }

                    var   scale      = _scale;
                    float extraScale = 1f;

                    float maxScale = GetMaxScale(_bitmapCanvas);
                    if (scale > maxScale)
                    {
                        scale      = maxScale;
                        extraScale = _scale / scale;
                    }

                    if (extraScale > 1)
                    {
                        // This is a bit tricky...
                        // We can't draw on a canvas larger than ViewConfiguration.get(context).getScaledMaximumDrawingCacheSize()
                        // which works out to be roughly the size of the screen because Android can't generate a
                        // bitmap large enough to render to.
                        // As a result, we cap the scale such that it will never be wider/taller than the screen
                        // and then only render in the top left corner of the canvas. We then use extraScale
                        // to scale up the rest of the scale. However, since we rendered the animation to the top
                        // left corner, we need to scale up and translate the canvas to zoom in on the top left
                        // corner.
                        _bitmapCanvas.Save();
                        float halfWidth        = (float)_composition.Bounds.Width / 2f;
                        float halfHeight       = (float)_composition.Bounds.Height / 2f;
                        float scaledHalfWidth  = halfWidth * scale;
                        float scaledHalfHeight = halfHeight * scale;
                        _bitmapCanvas.Translate(
                            Scale * halfWidth - scaledHalfWidth,
                            Scale * halfHeight - scaledHalfHeight);
                        _bitmapCanvas.Scale(extraScale, extraScale, scaledHalfWidth, scaledHalfHeight);
                    }

                    _matrix.Reset();
                    _matrix = MatrixExt.PreScale(_matrix, scale, scale);
                    _compositionLayer.Draw(_bitmapCanvas, _matrix, _alpha);
                    LottieLog.EndSection("Drawable.Draw");

                    if (extraScale > 1)
                    {
                        _bitmapCanvas.Restore();
                    }
                }
            }
        }
Exemplo n.º 7
0
 public void Transform(Matrix3X3 matrix)
 {
 }
Exemplo n.º 8
0
 public static Matrix3X3 PreTranslate(Matrix3X3 matrix, float dx, float dy)
 {
     return(matrix * GetTranslate(dx, dy));
 }
Exemplo n.º 9
0
 public static Matrix3X3 PreScale(Matrix3X3 matrix, float scaleX, float scaleY)
 {
     return(matrix * GetScale(scaleX, scaleY));
 }
Exemplo n.º 10
0
 public void SetMatrix(Matrix3X3 matrix)
 {
     _matrix.Set(matrix);
 }
Exemplo n.º 11
0
 public static Matrix3X3 PreConcat(Matrix3X3 matrix, Matrix3X3 transformAnimationMatrix)
 {
     return(matrix * transformAnimationMatrix);
 }
Exemplo n.º 12
0
 public void Scale(float sx, float sy, float px, float py)
 {
     _matrix = MatrixExt.PreScale(_matrix, sx, sy, px, py);
 }
Exemplo n.º 13
0
 public void Translate(float dx, float dy)
 {
     _matrix = MatrixExt.PreTranslate(_matrix, dx, dy);
 }
Exemplo n.º 14
0
 public void Concat(Matrix3X3 parentMatrix)
 {
     _matrix = MatrixExt.PreConcat(_matrix, parentMatrix);
 }
Exemplo n.º 15
0
 public void Transform(Matrix3X3 matrix)
 {
     path1.Transform(matrix);
     path2.Transform(matrix);
 }
Exemplo n.º 16
0
        public static Matrix3X3 PreScale(Matrix3X3 matrix, float scaleX, float scaleY, float px, float py)
        {
            var tmp = GetTranslate(-px, -py) * GetScale(scaleX, scaleY) * GetTranslate(px, py);

            return(matrix * tmp);
        }
Exemplo n.º 17
0
 public override void Draw(BitmapCanvas canvas, Matrix3X3 parentMatrix, byte parentAlpha)
 {
     Paint.Color = _colorAnimation.Value;
     base.Draw(canvas, parentMatrix, parentAlpha);
 }
Exemplo n.º 18
0
 public override void GetBounds(out Rect outBounds, Matrix3X3 parentMatrix)
 {
     base.GetBounds(out outBounds, parentMatrix);
     UpdateRect(BoundsMatrix);
     RectExt.Set(ref outBounds, Rect);
 }
Exemplo n.º 19
0
 public void Transform(Matrix3X3 matrix)
 {
     _control1 = matrix.Transform(_control1);
     _control2 = matrix.Transform(_control2);
     _vertex   = matrix.Transform(_vertex);
 }
Exemplo n.º 20
0
 private void UpdateRect(Matrix3X3 matrix)
 {
     RectExt.Set(ref Rect, 0, 0, LayerModel.SolidWidth, LayerModel.SolidHeight);
     matrix.MapRect(ref Rect);
 }
Exemplo n.º 21
0
 public void Transform(Matrix3X3 matrix)
 {
     _startPoint = matrix.Transform(_startPoint);
     _endPoint   = matrix.Transform(_endPoint);
 }
Exemplo n.º 22
0
 public override void DrawLayer(BitmapCanvas canvas, Matrix3X3 parentMatrix, byte parentAlpha)
 {
     // Do nothing.
 }