示例#1
0
        public void OnPaintSurface(SKCanvas canvas, double widthDp, double heightDp)
        {
            _scene.Update();
            _drawPending = false;

            if (widthDp == 0 || widthDp == 0)
            {
                return;
            }

            var widthPixels  = canvas.DeviceClipBounds.Width;
            var heightPixels = canvas.DeviceClipBounds.Height;

            var dpScale = (float)(widthPixels / widthDp);
            var scale   = new SKPoint(dpScale, dpScale);

            UiComponent.Node.RelativeScale = scale;

            UiComponent.Size           = new SKSize((float)widthDp, (float)heightDp);
            _camera.Node.RelativePoint = new SKPoint(widthPixels / 2f, heightPixels / 2f);

            canvas.Clear(BackgroundColor);
            _canvasComponent.StartDraw(canvas, widthDp, heightDp);

            _cameraGroup.Draw(canvas, DrawOptions);
        }
示例#2
0
        private void OnPaintSurface2(object sender, SKPaintGLSurfaceEventArgs args)
        {
            var canvas = args.Surface.Canvas;

            canvas.Clear(SKColors.Black);
            _scene.Draw(() => {
                _canvasComponent2.StartDraw(canvas, SkGlView2.Width, SkGlView2.Height);
                _cameraGroup2.Draw(canvas);
            });
            canvas.Flush();
        }