예제 #1
0
 void Test2()
 {
     canvas2d.ClearColorBuffer();
     canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
     canvas2d.StrokeColor = PixelFarm.Drawing.Color.Blue;
     canvas2d.StrokeWidth = 1;
     painter.StrokeWidth  = 1;
     ////line
     painter.FillColor = PixelFarm.Drawing.Color.Green;
     painter.FillRectLBWH(100, 100, 50, 50);
     canvas2d.DrawLine(50, 50, 200, 200);
     canvas2d.DrawRect(10, 10, 50, 50);
     painter.FillRenderVx(polygon2);
     painter.StrokeColor = PixelFarm.Drawing.Color.Blue;
     painter.DrawRenderVx(polygon2);
     //-------------------------------------------
     ////polygon
     painter.DrawRenderVx(polygon1);
     canvas2d.StrokeColor = PixelFarm.Drawing.Color.Green;
     ////--------------------------------------------
     painter.DrawCircle(100, 100, 25);
     painter.DrawEllipse(200, 200, 225, 250);
     ////
     painter.FillColor = PixelFarm.Drawing.Color.OrangeRed;
     painter.FillCircle(100, 400, 25);
     canvas2d.StrokeColor = PixelFarm.Drawing.Color.OrangeRed;
     painter.DrawCircle(100, 400, 25);
     ////
     painter.FillColor = PixelFarm.Drawing.Color.OrangeRed;
     painter.FillEllipse(200, 400, 225, 450);
     canvas2d.StrokeColor = PixelFarm.Drawing.Color.OrangeRed;
     painter.DrawEllipse(200, 400, 225, 450);
     //-------------------------------------------
     SwapBuffer();
 }
예제 #2
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
            canvas2d.StrokeColor = PixelFarm.Drawing.Color.Blue;
            canvas2d.ClearColorBuffer();
            if (!resInit)
            {
                msdf_bmp = LoadTexture(RootDemoPath.Path + @"\msdf_75.png");
                //msdf_bmp = LoadTexture(@"d:\\WImageTest\\a001_x1.png");
                //msdf_bmp = LoadTexture(@"d:\\WImageTest\\msdf_65.png");
                resInit = true;
            }
            canvas2d.Clear(PixelFarm.Drawing.Color.White);

            //canvas2d.DrawImageWithMsdf(msdf_bmp, 0, 400, 6);
            //canvas2d.DrawImageWithMsdf(msdf_bmp, 100, 500, 0.5f);
            //canvas2d.DrawImageWithMsdf(msdf_bmp, 100, 520, 0.4f);
            //canvas2d.DrawImageWithMsdf(msdf_bmp, 100, 550, 0.3f);
            //canvas2d.DrawImage(msdf_bmp, 150, 400);

            canvas2d.DrawImageWithSubPixelRenderingMsdf(msdf_bmp, 200, 500, 15f);
            //canvas2d.DrawImageWithSubPixelRenderingMsdf(msdf_bmp, 300, 500, 0.5f);
            //canvas2d.DrawImageWithSubPixelRenderingMsdf(msdf_bmp, 300, 520, 0.4f);
            //canvas2d.DrawImageWithSubPixelRenderingMsdf(msdf_bmp, 300, 550, 0.3f);

            ////
            //canvas2d.DrawImageWithMsdf(sdf_bmp, 400, 400, 6);
            //canvas2d.DrawImageWithMsdf(sdf_bmp, 400, 500, 0.5f);
            //canvas2d.DrawImageWithMsdf(sdf_bmp, 400, 520, 0.4f);
            //canvas2d.DrawImageWithMsdf(sdf_bmp, 400, 550, 0.3f);
            canvas2d.DrawImage(msdf_bmp, 100, 300);

            miniGLControl.SwapBuffers();
        }
예제 #3
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
            canvas2d.StrokeColor = PixelFarm.Drawing.Color.Blue;
            canvas2d.ClearColorBuffer();
            painter.FillColor = PixelFarm.Drawing.Color.Black;
            painter.FillRectLBWH(0, 0, 150, 150);
            GLBitmap glBmp        = LoadTexture(RootDemoPath.Path + "\\logo-dark.jpg");
            var      textureBrush = new TextureBrush(glBmp);

            painter.FillRenderVx(textureBrush, polygon1);
            //-------------------------------------------------------------------------
            var linearGrBrush2 = new LinearGradientBrush(
                new PointF(0, 50), Color.Red,
                new PointF(400, 100), Color.White);

            //fill polygon with gradient brush
            painter.FillColor = Color.Yellow;
            painter.FillRectLBWH(200, 0, 150, 150);
            painter.FillRenderVx(linearGrBrush2, polygon2);
            painter.FillColor = Color.Black;
            painter.FillRectLBWH(400, 0, 150, 150);
            //-------------------------------------------------------------------------

            //another  ...

            painter.FillRenderVx(linearGrBrush2, polygon3);
            //-------------------------------------------------------------------------


            SwapBuffer();
        }
 protected override void OnGLRender(object sender, EventArgs args)
 {
     canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
     canvas2d.StrokeColor = PixelFarm.Drawing.Color.Blue;
     canvas2d.ClearColorBuffer();
     //-------------------------------
     canvas2d.DrawImage(glBmp, 0, 600);
     miniGLControl.SwapBuffers();
 }
예제 #5
0
 protected override void OnGLRender(object sender, EventArgs args)
 {
     canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
     canvas2d.StrokeColor = PixelFarm.Drawing.Color.Blue;
     canvas2d.ClearColorBuffer();
     canvas2d.Clear(PixelFarm.Drawing.Color.Red);
     //-------------------------------
     painter.DrawString("OK", 0, 17);
     painter.DrawString("1234567890", 0, 17 * 3);
     //-------------------------------
     SwapBuffer();
 }
예제 #6
0
 void HandleGLPaint(object sender, System.EventArgs e)
 {
     canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
     canvas2d.StrokeColor = PixelFarm.Drawing.Color.Black;
     canvas2d.ClearColorBuffer();
     //example
     canvasPainter.FillColor = PixelFarm.Drawing.Color.Black;
     canvasPainter.FillRectLBWH(20, 20, 150, 150);
     //load bmp image
     //-------------------------------------------------------------------------
     if (exampleBase != null)
     {
         exampleBase.Draw(canvasPainter);
     }
     miniGLControl.SwapBuffers();
 }
예제 #7
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
            canvas2d.StrokeColor = PixelFarm.Drawing.Color.Blue;
            canvas2d.ClearColorBuffer();
            if (!resInit)
            {
                //glbmp = LoadTexture(@"..\logo-dark.jpg");
                glbmp   = LoadTexture(RootDemoPath.Path + @"\logo-dark.jpg");
                resInit = true;
            }

            canvas2d.DrawSubImage(glbmp, 10, 10, 100, 100, 200, 400);
            canvas2d.DrawImage(glbmp, 0, 300);
            canvas2d.DrawImageWithBlurX(glbmp, 0, 600);
            miniGLControl.SwapBuffers();
        }
예제 #8
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
            canvas2d.StrokeColor = PixelFarm.Drawing.Color.Blue;
            canvas2d.ClearColorBuffer();
            //-------------------------------

            int j = lionRenderVxList.Count;

            Color[] colors = lionShape.Colors;
            for (int i = 0; i < j; ++i)
            {
                canvas2d.FillRenderVx(colors[i], lionRenderVxList[i]);
            }
            //-------------------------------
            SwapBuffer();
        }
 protected override void OnGLRender(object sender, EventArgs args)
 {
     canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
     canvas2d.StrokeColor = PixelFarm.Drawing.Color.Blue;
     canvas2d.Clear(PixelFarm.Drawing.Color.White);
     canvas2d.ClearColorBuffer();
     //-------------------------------
     if (!isInit)
     {
         glbmp  = LoadTexture(RootDemoPath.Path + @"\logo-dark.jpg");
         isInit = true;
     }
     if (frameBuffer.FrameBufferId > 0)
     {
         if (frameBufferNeedUpdate)
         {
             //------------------------------------------------------------------------------------
             //framebuffer
             canvas2d.AttachFrameBuffer(frameBuffer);
             //after make the frameBuffer current
             //then all drawing command will apply to frameBuffer
             //do draw to frame buffer here
             canvas2d.Clear(PixelFarm.Drawing.Color.Red);
             canvas2d.DrawImageWithBlurX(glbmp, 0, 300);
             canvas2d.DetachFrameBuffer();
             //------------------------------------------------------------------------------------
             //framebuffer2
             canvas2d.AttachFrameBuffer(frameBuffer2);
             GLBitmap bmp2 = new GLBitmap(frameBuffer.TextureId, frameBuffer.Width, frameBuffer.Height);
             bmp2.IsBigEndianPixel = true;
             canvas2d.DrawImageWithBlurY(bmp2, 0, 300);
             canvas2d.DetachFrameBuffer();
             //------------------------------------------------------------------------------------
             //after release current, we move back to default frame buffer again***
             frameBufferNeedUpdate = false;
         }
         canvas2d.DrawFrameBuffer(frameBuffer2, 15, 300);
     }
     else
     {
         canvas2d.Clear(PixelFarm.Drawing.Color.Blue);
     }
     //-------------------------------
     miniGLControl.SwapBuffers();
 }
예제 #10
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
            canvas2d.StrokeColor = PixelFarm.Drawing.Color.Blue;
            canvas2d.ClearColorBuffer();
            if (!resInit)
            {
                resInit = true;
            }
            painter.Clear(PixelFarm.Drawing.Color.White);
            //painter.DrawString("hello world!", 100, 100);
            //painter.DrawString("กิ่น", 100, 100);
            string test_str = "อูญูอุบ่ป่กินกิ่นก็โก้";

            //string test_str = "กิน";
            painter.DrawString(test_str, 100, 100);
            //painter.DrawString("hello world! กิ่น", 100, 100);
            miniGLControl.SwapBuffers();
        }
예제 #11
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
            canvas2d.StrokeColor = PixelFarm.Drawing.Color.Blue;
            canvas2d.Clear(PixelFarm.Drawing.Color.White);
            canvas2d.ClearColorBuffer();
            //-------------------------------
            if (!isInit)
            {
                isInit = true;
            }
            if (frameBuffer.FrameBufferId > 0)
            {
                //------------------------------------------------------------------------------------
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, frameBuffer.FrameBufferId);
                //--------
                //do draw to frame buffer here
                GL.ClearColor(OpenTK.Graphics.Color4.Red);
                GL.Clear(ClearBufferMask.ColorBufferBit);
                //------------------------------------------------------------------------------------



                //------------------------------------------------------------------------------------
                GL.BindTexture(TextureTarget.Texture2D, frameBuffer.TextureId);
                GL.GenerateMipmap(TextureTarget.Texture2D);
                GL.BindTexture(TextureTarget.Texture2D, 0);
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
                //------------------------------------------------------------------------------------

                GLBitmap bmp = new GLBitmap(frameBuffer.TextureId, frameBuffer.Width, frameBuffer.Height);
                bmp.IsBigEndianPixel = true;
                canvas2d.DrawImage(bmp, 15, 300);
            }
            else
            {
                canvas2d.Clear(PixelFarm.Drawing.Color.Blue);
            }
            //-------------------------------
            SwapBuffer();
        }
예제 #12
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
            canvas2d.StrokeColor = PixelFarm.Drawing.Color.Blue;
            canvas2d.ClearColorBuffer();
            painter.FillColor = PixelFarm.Drawing.Color.Black;
            //painter.FillRectLBWH(0, 0, 150, 150);
            //GLBitmap glBmp = LoadTexture("..\\logo-dark.jpg");
            //var textureBrush = new TextureBrush(new GLImage(glBmp));
            //painter.FillRenderVx(textureBrush, polygon1);
            ////-------------------------------------------------------------------------

            //fill
            painter.FillColor = PixelFarm.Drawing.Color.Black;
            painter.FillRenderVx(linearGrBrush2, glyph_vx);
            //painter.FillRenderVx(glyph_vx);
            //-------------------------------------------------------------------------


            miniGLControl.SwapBuffers();
        }
예제 #13
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
            canvas2d.StrokeColor = PixelFarm.Drawing.Color.Blue;
            canvas2d.ClearColorBuffer();
            //-------------------------------

            int j = lionShape.NumPaths;

            int[]       pathList = lionShape.PathIndexList;
            Color[]     colors   = lionShape.Colors;
            VertexStore myvxs    = lionVxs;

            for (int i = 0; i < j; ++i)
            {
                painter.FillColor = colors[i];
                painter.Fill(new VertexStoreSnap(myvxs, pathList[i]));
            }
            //-------------------------------
            miniGLControl.SwapBuffers();
        }
예제 #14
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
            canvas2d.StrokeColor = PixelFarm.Drawing.Color.Blue;
            canvas2d.Clear(PixelFarm.Drawing.Color.White);
            canvas2d.ClearColorBuffer();
            //-------------------------------
            if (!isInit)
            {
                glbmp  = LoadTexture(RootDemoPath.Path + @"\leaves.jpg");
                isInit = true;
            }
            if (frameBuffer.FrameBufferId > 0)
            {
                if (frameBufferNeedUpdate)
                {
                    //------------------------------------------------------------------------------------
                    //framebuffer
                    canvas2d.AttachFrameBuffer(frameBuffer);
                    //after make the frameBuffer current
                    //then all drawing command will apply to frameBuffer
                    //do draw to frame buffer here
                    canvas2d.Clear(PixelFarm.Drawing.Color.Red);
                    canvas2d.DrawImageWithConv3x3(glbmp, Mat3x3ConvGen.emboss, 0, 300);
                    canvas2d.DetachFrameBuffer();

                    //after release current, we move back to default frame buffer again***
                    frameBufferNeedUpdate = false;
                }
                canvas2d.DrawFrameBuffer(frameBuffer, 15, 300);
            }
            else
            {
                canvas2d.Clear(PixelFarm.Drawing.Color.Blue);
            }
            //-------------------------------
            miniGLControl.SwapBuffers();
        }
예제 #15
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            canvas2d.SmoothMode  = CanvasSmoothMode.Smooth;
            canvas2d.StrokeColor = PixelFarm.Drawing.Color.Blue;
            canvas2d.ClearColorBuffer();
            if (!resInit)
            {
                // msdf_bmp = LoadTexture(@"..\msdf_75.png");
                //msdf_bmp = LoadTexture(@"d:\\WImageTest\\a001_x1_66.png");
                msdf_bmp = LoadTexture(totalImg);
                //msdf_bmp = LoadTexture(@"d:\\WImageTest\\a001_x1.png");
                //msdf_bmp = LoadTexture(@"d:\\WImageTest\\msdf_65.png");

                resInit = true;
            }

            painter.Clear(PixelFarm.Drawing.Color.White);
            //var f = painter.CurrentFont;

            //painter.DrawString("hello!", 0, 20);
            //canvas2d.DrawImageWithSubPixelRenderingMsdf(msdf_bmp, 200, 500, 15f);

            Typography.Rendering.TextureFontGlyphData glyphData;

            byte[] codepoint = System.Text.Encoding.UTF8.GetBytes("AB");
            fontAtlas.GetRectByCodePoint(codepoint[0], out glyphData);
            PixelFarm.Drawing.Rectangle r = ConvToRect(glyphData.Rect);
            //canvas2d.DrawSubImageWithMsdf(msdf_bmp, ref r, 100, 500);
            canvas2d.DrawSubImageWithMsdf(msdf_bmp, ref r, 100, 500);

            fontAtlas.GetRectByCodePoint(codepoint[1], out glyphData);
            PixelFarm.Drawing.Rectangle r2 = ConvToRect(glyphData.Rect);
            canvas2d.DrawSubImageWithMsdf(msdf_bmp, ref r2, 100 + r.Width - 10, 500);

            //full image
            canvas2d.DrawImage(msdf_bmp, 100, 300);
            miniGLControl.SwapBuffers();
        }
예제 #16
0
 protected override void OnGLRender(object sender, EventArgs args)
 {
     canvas2d.ClearColorBuffer();
     miniGLControl.SwapBuffers();
 }