Ejemplo n.º 1
0
            internal static void Check(Point center, double radiusX, double radiusY, Brush brush, Pen pen, int width, int height,
                                       [CallerMemberName] string methodName = "unknown")
            {
                Application.EnableMSAA = false;

                MeshBuffer meshBuffer            = new MeshBuffer();
                MeshList   meshList              = new MeshList();
                BuiltinGeometryRenderer renderer = new BuiltinGeometryRenderer();

                byte[] bytes;

                using (var context = new RenderContextForTest(width, height))
                {
                    renderer.OnBeforeRead();
                    renderer.DrawEllipse(brush, pen, center, radiusX, radiusY);//This must be called after the RenderContextForTest is created, for uploading textures to GPU via OpenGL.
                    renderer.OnAfterRead(meshList);

                    //rebuild mesh buffer
                    meshBuffer.Clear();
                    meshBuffer.Init();
                    meshBuffer.Append(meshList);

                    //draw mesh buffer to screen
                    context.Clear();
                    context.DrawMeshes(meshBuffer);

                    bytes = context.GetRenderedRawBytes();
                }

                Util.CheckExpectedImage(bytes, width, height, $"{RootDir}{nameof(DrawEllipse)}\\{methodName}.png");
            }
Ejemplo n.º 2
0
        public static byte[] DrawAsOpenGLPixelBytes(FormattedText formattedText,
                                                    Brush brush, int width, int height, Rect clipRect)
        {
            BuiltinGeometryRenderer renderer = new BuiltinGeometryRenderer();

            renderer.PushClipRect(clipRect);
            renderer.OnBeforeRead();
            renderer.DrawEllipse(null, new Pen(Color.DarkSeaGreen, 1),
                                 formattedText.OriginPoint, 2, 2);
            renderer.DrawLine(new Pen(Color.Gray, 1), formattedText.OriginPoint,
                              formattedText.OriginPoint + new Vector(width, 0));
            renderer.DrawText(brush, formattedText);
            var mesh     = renderer.ShapeMesh;
            var textMesh = renderer.TextMesh;
            var bytes    = Util.DrawAsOpenGLPixelBytes(mesh, textMesh, width, height);

            return(bytes);
        }