Exemplo n.º 1
0
        protected override async Task OnUpdate(CancellationToken token, TaskScheduler mainScheduler)
        {
            await Task.Delay(25, token);

            // step the rotation matrix
            rotationView.RotateYDegrees(5);
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            isCurrent = true;

            rotationView.RotateYDegrees(30);

            // set up a nice render loop
            Device.StartTimer(TimeSpan.FromSeconds(1.0 / 60.0), () =>
            {
                rotationView.RotateYDegrees(1);
                elevation += 0.05f;

                dynamicSurface?.InvalidateSurface();
                return(isCurrent);
            });
        }
Exemplo n.º 4
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);
        }