Пример #1
0
        Picture _buildPicture(_InspectorOverlayRenderState state)
        {
            PictureRecorder recorder = new PictureRecorder();
            Canvas          canvas   = new RecorderCanvas(recorder);
            Size            size     = state.overlayRect.size;

            var fillPaint = new Paint()
            {
                color = _kHighlightedRenderObjectFillColor
            };
            var borderPaint = new Paint()
            {
                color       = _kHighlightedRenderObjectBorderColor, style = PaintingStyle.stroke,
                strokeWidth = 1
            };
            Rect selectedPaintRect = state.selected.rect.deflate(0.5f);

            canvas.save();
            canvas.setMatrix(state.selected.transform);
            canvas.drawRect(selectedPaintRect, fillPaint);
            canvas.drawRect(selectedPaintRect, borderPaint);
            canvas.restore();

            foreach (var transformedRect in state.candidates)
            {
                canvas.save();
                canvas.setMatrix(transformedRect.transform);
                canvas.drawRect(transformedRect.rect.deflate(0.5f), borderPaint);
                canvas.restore();
            }

            // todo paint descipion
            return(recorder.endRecording());
        }
Пример #2
0
        void clipRRect()
        {
            var pictureRecorder = new PictureRecorder();
            var canvas          = new RecorderCanvas(pictureRecorder);

            var paint = new Paint {
                color = new Color(0xFFFF0000),
            };

            var path = new Path();

            path.moveTo(10, 10);
            path.lineTo(10, 110);
            path.lineTo(90, 110);
            path.lineTo(110, 10);
            path.close();

            canvas.drawPath(path, paint);

            paint = new Paint {
                color = new Color(0xFFFFFF00),
            };

            var rect   = Unity.UIWidgets.ui.Rect.fromLTWH(10, 150, 100, 100);
            var rrect  = RRect.fromRectAndCorners(rect, 0, 4, 8, 16);
            var rect1  = Unity.UIWidgets.ui.Rect.fromLTWH(18, 152, 88, 92);
            var rrect1 = RRect.fromRectAndCorners(rect1, 0, 4, 8, 16);

            canvas.drawDRRect(rrect, rrect1, paint);

            canvas.rotate(-45 * Mathf.PI / 180.0f, new Offset(150, 150));

//            paint = new Paint {
//                color = new Color(0xFF00FFFF),
//                blurSigma = 3,
//            };
//            canvas.drawRectShadow(
//                Rect.fromLTWH(150, 150, 110, 120),
//                paint);

            var picture = pictureRecorder.endRecording();

            Debug.Log("picture.paintBounds: " + picture.paintBounds);

            var editorCanvas = new CommandBufferCanvas(this._renderTexture, Window.instance.devicePixelRatio,
                                                       this._meshPool);

            editorCanvas.rotate(-5 * Mathf.PI / 180);
            editorCanvas.clipRRect(RRect.fromRectAndRadius(Unity.UIWidgets.ui.Rect.fromLTWH(25, 15, 250, 250), 50));
            editorCanvas.rotate(5 * Mathf.PI / 180);

            editorCanvas.drawPicture(picture);

            editorCanvas.rotate(-15 * Mathf.PI / 180);
            editorCanvas.translate(100, 100);

            editorCanvas.drawPicture(picture);

            editorCanvas.flush();
        }
Пример #3
0
        void drawPicture()
        {
            var pictureRecorder = new PictureRecorder();
            var canvas          = new RecorderCanvas(pictureRecorder);

            var paint = new Paint {
                color = new Color(0xFFFF0000),
            };

            var path = new Path();

            path.moveTo(10, 10);
            path.lineTo(10, 110);
            path.lineTo(90, 110);
            path.lineTo(100, 10);
            path.close();
            canvas.drawPath(path, paint);

            paint = new Paint {
                color = new Color(0xFFFFFF00),
            };

            var rect   = Unity.UIWidgets.ui.Rect.fromLTWH(10, 150, 100, 100);
            var rrect  = RRect.fromRectAndCorners(rect, 0, 4, 8, 16);
            var rect1  = Unity.UIWidgets.ui.Rect.fromLTWH(18, 152, 88, 92);
            var rrect1 = RRect.fromRectAndCorners(rect1, 0, 4, 8, 16);

            canvas.drawDRRect(rrect, rrect1, paint);

            canvas.rotate(-45 * Mathf.PI / 180, new Offset(150, 150));

            paint = new Paint {
                color      = new Color(0xFF00FFFF),
                maskFilter = MaskFilter.blur(BlurStyle.normal, 3),
            };
            canvas.drawRect(
                Unity.UIWidgets.ui.Rect.fromLTWH(150, 150, 110, 120),
                paint);

            var picture = pictureRecorder.endRecording();

            Debug.Log("picture.paintBounds: " + picture.paintBounds);

            var editorCanvas = new CommandBufferCanvas(this._renderTexture, Window.instance.devicePixelRatio,
                                                       this._meshPool);

            editorCanvas.drawPicture(picture);

            editorCanvas.rotate(-15 * Mathf.PI / 180);
            editorCanvas.translate(100, 100);
            editorCanvas.drawPicture(picture);
            editorCanvas.flush();
        }
Пример #4
0
        PictureLayer _highlightConflictingLayer(PhysicalModelLayer child)
        {
            PictureRecorder recorder = new PictureRecorder();
            var             canvas   = new RecorderCanvas(recorder);

            canvas.drawPath(child.clipPath, new Paint()
            {
                color       = new Color(0xFFAA0000),
                style       = PaintingStyle.stroke,
                strokeWidth = child.elevation + 10.0f,
            });
            PictureLayer pictureLayer = new PictureLayer(child.clipPath.getBounds());

            pictureLayer.picture      = recorder.endRecording();
            pictureLayer.debugCreator = child;
            child.append(pictureLayer);
            return(pictureLayer);
        }
Пример #5
0
        void saveLayer()
        {
            var pictureRecorder = new PictureRecorder();
            var canvas          = new RecorderCanvas(pictureRecorder);
            var paint1          = new Paint {
                color = new Color(0xFFFFFFFF),
            };

            var path1 = new Path();

            path1.moveTo(0, 0);
            path1.lineTo(0, 90);
            path1.lineTo(90, 90);
            path1.lineTo(90, 0);
            path1.close();
            canvas.drawPath(path1, paint1);


            var paint = new Paint {
                color = new Color(0xFFFF0000),
            };

            var path = new Path();

            path.moveTo(20, 20);
            path.lineTo(20, 70);
            path.lineTo(70, 70);
            path.lineTo(70, 20);
            path.close();

            canvas.drawPath(path, paint);

            var paint2 = new Paint {
                color = new Color(0xFFFFFF00),
            };

            var path2 = new Path();

            path2.moveTo(30, 30);
            path2.lineTo(30, 60);
            path2.lineTo(60, 60);
            path2.lineTo(60, 30);
            path2.close();

            canvas.drawPath(path2, paint2);

            var picture = pictureRecorder.endRecording();

            var editorCanvas = new CommandBufferCanvas(this._renderTexture, Window.instance.devicePixelRatio,
                                                       this._meshPool);

            editorCanvas.saveLayer(
                picture.paintBounds, new Paint {
                color = new Color(0xFFFFFFFF),
            });
            editorCanvas.drawPicture(picture);
            editorCanvas.restore();

            editorCanvas.saveLayer(Unity.UIWidgets.ui.Rect.fromLTWH(45, 45, 90, 90), new Paint {
                color    = new Color(0xFFFFFFFF),
                backdrop = ImageFilter.blur(3f, 3f)
            });
            editorCanvas.restore();

            editorCanvas.flush();
        }