コード例 #1
0
        protected override async Task OnInit()
        {
            // create the base and step 3D rotation matrices (around the y-axis)
            rotationView = new SK3dView();
            rotationView.RotateYDegrees(30);

            await base.OnInit();
        }
コード例 #2
0
        protected override void OnDrawSample(SKCanvas canvas, int width, int height)
        {
            canvas.Translate(width / 2, height / 2);

            var length = Math.Min(width / 6, height / 6);
            var rect   = new SKRect(-length, -length, length, length);
            var side   = rotation > 90 && rotation < 270;

            canvas.Clear(SampleMedia.Colors.XamarinLightBlue);

            var view = new SK3dView();

            view.RotateYDegrees(rotation);
            view.ApplyToCanvas(canvas);

            var paint = new SKPaint
            {
                Color       = side ? SampleMedia.Colors.XamarinPurple : SampleMedia.Colors.XamarinGreen,
                Style       = SKPaintStyle.Fill,
                IsAntialias = true
            };

            canvas.DrawRoundRect(rect, 30, 30, paint);

            var shadow = SKShader.CreateLinearGradient(
                new SKPoint(0, 0), new SKPoint(0, length * 2),
                new[] { paint.Color.WithAlpha(127), paint.Color.WithAlpha(0) },
                null,
                SKShaderTileMode.Clamp);

            paint = new SKPaint
            {
                Shader      = shadow,
                Style       = SKPaintStyle.Fill,
                IsAntialias = true
            };

            rect.Offset(0, length * 2 + 5);
            canvas.DrawRoundRect(rect, 30, 30, paint);
        }