Example #1
0
        public override void Load()
        {
            //-----------------------------------------------
            FormTestWinGLControl form   = new FormTestWinGLControl();
            CanvasGL2d           canvas = new CanvasGL2d(this.Width, this.Height);
            var lionFill = new LionFillSprite();

            //-----------------------------------------------
            form.SetGLPaintHandler((o, s) =>
            {
                //canvas.Orientation = PixelFarm.Drawing.CanvasOrientation.LeftTop;
                canvas.Clear(PixelFarm.Drawing.Color.White);
                canvas.FillRect(PixelFarm.Drawing.Color.Blue, 0, 0, 400, 400);
                //draw vxs direct to GL surface
                //lionFill.Draw(canvas); //before offset

                canvas.EnableClipRect();
                canvas.SetClipRectRel(200, 250, 100, 100);

                lionFill.Draw(canvas);
                //offset
                canvas.SetCanvasOrigin(50, 50);
                //test clipping
                canvas.SetClipRectRel(200, 250, 100, 100);

                lionFill.Draw(canvas);
                canvas.DisableClipRect();


                canvas.SetCanvasOrigin(0, 0);
            });
            form.Show();
        }
        public override void Load()
        {
            //draw 1
            FormTestWinGLControl form = new FormTestWinGLControl();
            var canvas = PixelFarm.Drawing.DrawingGL.CanvasGLPortal.P.CreateCanvas(0, 0, 800, 600);

            form.SetGLPaintHandler((o, s) =>
            {
                //-----------------------------
                //see:  lazyfoo.net/tutorials/OpenGL/26_the_stencil_buffer/index.php
                //-----------------------------
                //test gradient brush
                //set value for clear color
                GLHelper.ClearColor(PixelFarm.Drawing.Color.White);
                GL.ClearStencil(0); //set value for clearing stencil buffer
                //actual clear here
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.StencilBufferBit);
                //-------------------
                //disable rendering to color buffer
                GL.ColorMask(false, false, false, false);
                //start using stencil
                GL.Enable(EnableCap.StencilTest);
                //place a 1 where rendered
                GL.StencilFunc(StencilFunction.Always, 1, 1);
                //replace where rendered
                GL.StencilOp(StencilOp.Replace, StencilOp.Replace, StencilOp.Replace);
                //render  to stencill buffer
                GL.Begin(BeginMode.Triangles);
                {
                    GL.Vertex2(20, 20);
                    GL.Vertex2(100, 20);
                    GL.Vertex2(60, 80);
                }
                GL.End();
                //-----------------
                //render color
                GL.ColorMask(true, true, true, true);
                //where a 1 was not rendered
                GL.StencilFunc(StencilFunction.Equal, 1, 1);
                //keep the pixel
                GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Keep);
                //draw
                GL.Begin(BeginMode.Quads);
                {
                    GL.Color3(1f, 0, 0);
                    GL.Vertex2(5, 5);
                    GL.Color3(1f, 1, 0);
                    GL.Vertex2(100, 5);
                    GL.Color3(1f, 0, 1);
                    GL.Vertex2(100, 100);
                    GL.Color3(1f, 1, 1);
                    GL.Vertex2(5, 100);
                }
                GL.End();
                GL.Disable(EnableCap.StencilTest);
            });
            form.Show();
        }
Example #3
0
        public override void Load()
        {
            //-----------------------------------------------
            FormTestWinGLControl form   = new FormTestWinGLControl();
            CanvasGL2d           canvas = new CanvasGL2d(this.Width, this.Height);
            var lionFill = new LionFillSprite();
            //-----------------------------------------------

            GLBitmap bmp1 = null;
            int      bmpW = 0;
            int      bmpH = 0;

            form.SetGLPaintHandler((o, s) =>
            {
                canvas.Clear(PixelFarm.Drawing.Color.White);

                //since OpenGL < 3 dose not have FrameBuffer
                //so we first draw it to backbuffer
                //then copy data from back buffer to texture
                if (bmp1 == null)
                {
                    lionFill.Draw(canvas);

                    GL.ReadBuffer(ReadBufferMode.Back);
                    Bitmap bmp           = new Bitmap(800, 600, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
                    byte[] buffer_output = new byte[800 * 4 * 600];
                    var bmpdata          = bmp.LockBits(
                        new Rectangle(0, 0, 800, 600),
                        System.Drawing.Imaging.ImageLockMode.ReadWrite,
                        bmp.PixelFormat);
                    GL.ReadPixels(0, 0, 800, 600, PixelFormat.Bgra, PixelType.Byte, bmpdata.Scan0);
                    unsafe
                    {
                        fixed(byte *outputH = &buffer_output[0])
                        {
                            GL.ReadPixels(0, 0, 800, 600, PixelFormat.Bgra, PixelType.Byte, (IntPtr)outputH);
                        }
                    }
                    bmp.UnlockBits(bmpdata);
                    //save
                    bmp.Save("d:\\WImageTest\\glLion.png");
                    //---------
                    //canvas.DrawImage(GLBitmapTexture.CreateBitmapTexture(bmp), 0, 0, bmp.Width, bmp.Height);
                    bmp1 = PixelFarm.Drawing.DrawingGL.GLBitmapTextureHelper.CreateBitmapTexture(bmp);
                    bmpW = bmp.Width;
                    bmpH = bmp.Height;

                    canvas.Clear(PixelFarm.Drawing.Color.White);
                }
                canvas.DrawImage(bmp1, 0, 0, bmpW, bmpH);

                //canvas.Clear(PixelFarm.Drawing.Color.White);
            });
            form.Show();
        }
Example #4
0
        public override void Load()
        {
            //draw 1
            FormTestWinGLControl form   = new FormTestWinGLControl();
            CanvasGL2d           canvas = new CanvasGL2d(this.Width, this.Height);

            form.SetGLPaintHandler((o, s) =>
            {
                canvas.Clear(PixelFarm.Drawing.Color.White);
            });
            form.Show();
        }
        public override void Load()
        {
            //lion fill test
            FormTestWinGLControl form   = new FormTestWinGLControl();
            CanvasGL2d           canvas = new CanvasGL2d(this.Width, this.Height);
            var lionFill = new LionFillSprite();
            //----------
            //draw lion on software layer
            ActualImage actualImage = new ActualImage(800, 600, PixelFarm.Agg.Image.PixelFormat.Rgba32);
            Graphics2D  g2d         = Graphics2D.CreateFromImage(actualImage);
            GLBitmap    bmp         = null;

            form.SetGLPaintHandler((o, s) =>
            {
                canvas.Clear(PixelFarm.Drawing.Color.White);
                //-------------------------------------
                // draw lion from bitmap to GL screen
                if (bmp == null)
                {
                    lionFill.OnDraw(g2d);
                    bmp = new GLBitmap(new LazyAggBitmapBufferProvider(actualImage));
                }
                //lion is inverted from software layer ,
                //so... we use DrawImageInvert()
                int xpos = 0;
                int w    = bmp.Width;
                int h    = bmp.Height;

                for (int i = 0; i < 3; ++i)
                {
                    canvas.DrawImage(bmp, xpos, 50, w, h);
                    w     = (int)(w * 1.2);
                    h     = (int)(h * 1.2);
                    xpos += 150;
                }
                w    = bmp.Width;
                h    = bmp.Height;
                xpos = 0;
                for (int i = 0; i < 2; ++i)
                {
                    w     = (int)(w * 0.75);
                    h     = (int)(h * 0.75);
                    xpos -= 50;
                    canvas.DrawImage(bmp, xpos, 50, w, h);
                }
            });

            form.Show();
        }
        public override void Load()
        {
            //-----------------------------------------------
            FormTestWinGLControl form   = new FormTestWinGLControl();
            CanvasGL2d           canvas = new CanvasGL2d(this.Width, this.Height);
            var lionFill = new LionFillSprite();

            //-----------------------------------------------
            form.SetGLPaintHandler((o, s) =>
            {
                canvas.Clear(PixelFarm.Drawing.Color.White);
                canvas.FillRect(PixelFarm.Drawing.Color.Blue, 0, 0, 400, 400);
                //draw vxs direct to GL surface
                lionFill.Draw(canvas);
            });
            form.Show();
        }
Example #7
0
        public override void Load()
        {
            //draw 1
            FormTestWinGLControl form = new FormTestWinGLControl();
            var          platform     = PixelFarm.Drawing.DrawingGL.CanvasGLPortal.P;
            var          canvas       = platform.CreateCanvas(0, 0, 800, 600);
            GraphicsPath path         = null;
            FontInfo     fontinfo     = platform.GetFont("tahoma", 24, PixelFarm.Drawing.FontStyle.Regular);

            canvas.CurrentFont = fontinfo.ResolvedFont;

            form.SetGLPaintHandler((o, s) =>
            {
                //if (fontinfo == null)
                //{
                //    fontinfo = platform.CreateNativeFontWrapper(new System.Drawing.Font("tahoma", 24));
                //    canvas.CurrentFont = fontinfo.ResolvedFont;
                //}
                canvas.ClearSurface(PixelFarm.Drawing.Color.White);
                canvas.FillRectangle(
                    PixelFarm.Drawing.Color.Blue,
                    100, 10, 200, 200);
                canvas.DrawRectangle(
                    PixelFarm.Drawing.Color.Black,
                    100, 10, 200, 200);

                //------------
                //graphics paths
                if (path == null)
                {
                    path = platform.CreateGraphicsPath();
                    //path.AddRectangle(new PixelFarm.Drawing.RectangleF(10, 10, 10, 10));
                    path.AddEllipse(30, 30, 25, 25);
                }
                //canvas.FillPath(path);
                canvas.DrawPath(path);
                //------------
                //test draw text
                canvas.DrawText("ABCD".ToCharArray(), 100, 500);
                //------------
            });
            form.Show();
        }
Example #8
0
        public override void Load()
        {
            //draw 1
            FormTestWinGLControl form = new FormTestWinGLControl();
            var canvas = PixelFarm.Drawing.DrawingGL.CanvasGLPortal.P.CreateCanvas(0, 0, 800, 600);

            form.SetOnDestroyHandler((o, s) =>
            {
                canvas.Dispose();
            });



            FontInfo fontinfo = null;

            form.SetGLPaintHandler((o, s) =>
            {
                canvas.Orientation = CanvasOrientation.LeftTop;
                if (fontinfo == null)
                {
                    fontinfo           = PixelFarm.Drawing.DrawingGL.CanvasGLPortal.GetFontInfo("tahoma", 10, PixelFarm.Drawing.DrawingGL.FontLoadTechnique.GdiBitmapFont);
                    canvas.CurrentFont = fontinfo.ResolvedFont;
                }
                canvas.ClearSurface(PixelFarm.Drawing.Color.White);
                canvas.FillRectangle(PixelFarm.Drawing.Color.Yellow, 3, 3, 200, 200);
                canvas.DrawRectangle(PixelFarm.Drawing.Color.Red, 0, 0, 400, 400);
                //test draw text

                canvas.DrawText("AaBbCc0123 +*/%$".ToCharArray(), 0, 0);

                canvas.CurrentTextColor = PixelFarm.Drawing.Color.Red;
                canvas.DrawText("AaBbCc0123 +*/%$".ToCharArray(), 0, 50);

                canvas.CurrentTextColor = PixelFarm.Drawing.Color.Green;
                canvas.DrawText("AaBbCc0123 +*/%$".ToCharArray(), 0, 100);

                canvas.CurrentTextColor = PixelFarm.Drawing.Color.Blue;
                canvas.DrawText("AaBbCc0123 +*/%$".ToCharArray(), 0, 150);

                canvas.CurrentTextColor = PixelFarm.Drawing.Color.Black;
            });
            form.Show();
        }
        public override void Load()
        {
            //draw 1

            FormTestWinGLControl form   = new FormTestWinGLControl();
            CanvasGL2d           canvas = new CanvasGL2d(this.Width, this.Height);
            GLBitmap             hwBmp  = null;

            form.SetGLPaintHandler((o, s) =>
            {
                canvas.Clear(PixelFarm.Drawing.Color.White);
                canvas.StrokeColor = PixelFarm.Drawing.Color.DeepPink;
                var polygonCoords  = new float[] {
                    5, 300,
                    40, 300,
                    50, 340
                };
                canvas.FillPolygon(PixelFarm.Drawing.Color.DeepPink, polygonCoords, 3);
            });
            form.Show();
        }
        public override void Load()
        {
            //draw 1
            FormTestWinGLControl form = new FormTestWinGLControl();
            var canvas = PixelFarm.Drawing.DrawingGL.CanvasGLPortal.P.CreateCanvas(0, 0, 800, 600);

            PixelFarm.Drawing.Bitmap       bmp    = null;
            PixelFarm.Drawing.TextureBrush tbrush = null;
            form.SetGLPaintHandler((o, s) =>
            {
                canvas.ClearSurface(PixelFarm.Drawing.Color.White);
                if (tbrush == null)
                {
                    var bitmap = new System.Drawing.Bitmap("../../../SampleImages/plain01.png");
                    bmp        = new PixelFarm.Drawing.Bitmap(bitmap.Width, bitmap.Height, bitmap);
                    tbrush     = new PixelFarm.Drawing.TextureBrush(bmp);
                }
                //2. fill polygon with gradient brush
                canvas.FillPolygon(
                    tbrush,
                    new PixelFarm.Drawing.PointF[] {
                    new PixelFarm.Drawing.PointF(60, 50),
                    new PixelFarm.Drawing.PointF(100, 50),
                    new PixelFarm.Drawing.PointF(70, 100)
                });

                canvas.Note1 = 1; //temp
                canvas.FillPolygon(
                    tbrush,
                    new PixelFarm.Drawing.PointF[] {
                    new PixelFarm.Drawing.PointF(0, 50),
                    new PixelFarm.Drawing.PointF(50, 50),
                    new PixelFarm.Drawing.PointF(10, 100)
                });

                canvas.Note1 = 0;
                //-------------------------------------------------------------------------
            });
            form.Show();
        }
Example #11
0
        public override void Load()
        {
            //----------------------------------------------------
            //test only
            TextureAtlas textureAtlas = new TextureAtlas(800, 600);
            int          areaId, x, y;

            for (int i = 0; i < 100; ++i)
            {
                var result2 = textureAtlas.AllocNewRectArea(100, 200, out areaId, out x, out y);
                if (result2 != TextureAtlasAllocResult.Ok)
                {
                }
            }
            //----------------------------------------------------
            FormTestWinGLControl form   = new FormTestWinGLControl();
            CanvasGL2d           canvas = new CanvasGL2d(this.Width, this.Height);

            form.SetGLPaintHandler((o, s) =>
            {
                canvas.Clear(PixelFarm.Drawing.Color.White);
            });
            form.Show();
        }
        public override void Load()
        {
            //draw 1
            FormTestWinGLControl form = new FormTestWinGLControl();
            var canvas = PixelFarm.Drawing.DrawingGL.CanvasGLPortal.P.CreateCanvas(0, 0, 800, 600);

            form.SetGLPaintHandler((o, s) =>
            {
                canvas.Orientation = CanvasOrientation.LeftTop;
                canvas.ClearSurface(PixelFarm.Drawing.Color.White);


                var linearGrBrush = new LinearGradientBrush(
                    new PixelFarm.Drawing.PointF(25, 25),
                    PixelFarm.Drawing.Color.Black,
                    new PixelFarm.Drawing.PointF(100, 100),
                    PixelFarm.Drawing.Color.Blue);

                ////fill rectangle is easy
                ////canvas.FillRectangle(linearGrBrush, 0, 0, 150, 150);
                canvas.FillRectangle(PixelFarm.Drawing.Color.Black, 0, 0, 150, 150);
                ////----------------------------------------------------

                var linearGrBrush2 = new LinearGradientBrush(
                    new PixelFarm.Drawing.PointF(0, 50),
                    PixelFarm.Drawing.Color.Red,
                    new PixelFarm.Drawing.PointF(25, 100),
                    PixelFarm.Drawing.Color.OrangeRed);
                //2. fill polygon with gradient brush

                canvas.Note1 = 1; //temp
                canvas.FillPolygon(
                    linearGrBrush2,
                    new PixelFarm.Drawing.PointF[] {
                    new PixelFarm.Drawing.PointF(0, 50),
                    new PixelFarm.Drawing.PointF(50, 50),
                    new PixelFarm.Drawing.PointF(10, 100)
                });
                canvas.Note1 = 0;
                ////-------------------------------------------------------------------------

                ////another  ...
                canvas.FillRectangle(PixelFarm.Drawing.Color.Yellow, 200, 0, 150, 150);

                canvas.Note1 = 1; //temp
                canvas.FillPolygon(
                    linearGrBrush2,
                    new PixelFarm.Drawing.PointF[] {
                    new PixelFarm.Drawing.PointF(200, 50),
                    new PixelFarm.Drawing.PointF(250, 50),
                    new PixelFarm.Drawing.PointF(210, 100)
                });
                canvas.Note1 = 0;
                //-------------------------------------------------------------------------

                canvas.FillRectangle(PixelFarm.Drawing.Color.White, 400, 0, 150, 150);

                canvas.Note1 = 1; //temp
                canvas.FillPolygon(
                    linearGrBrush2,
                    new PixelFarm.Drawing.PointF[] {
                    new PixelFarm.Drawing.PointF(400, 50),
                    new PixelFarm.Drawing.PointF(450, 50),
                    new PixelFarm.Drawing.PointF(410, 100)
                });
                canvas.Note1 = 0;
                //-------------------------------------------------------------------------
            });
            form.Show();
        }
Example #13
0
        public override void Load()
        {
            //draw 1

            FormTestWinGLControl form   = new FormTestWinGLControl();
            CanvasGL2d           canvas = new CanvasGL2d(this.Width, this.Height);
            GLBitmap             hwBmp  = null;

            form.SetGLPaintHandler((o, s) =>
            {
                canvas.Clear(PixelFarm.Drawing.Color.White);
                canvas.StrokeColor = PixelFarm.Drawing.Color.DeepPink;
                canvas.DrawLine(0, 300, 500, 300);
                //if (hwBmp == null)
                //{
                //    string app = Application.ExecutablePath;
                //    hwBmp = GLBitmapTextureHelper.CreateBitmapTexture(new Bitmap("../../../Data/Textures/logo-dark.jpg"));

                //}

                ////canvas.DrawImage(hwBmp, 10, 10);
                //canvas.DrawImage(hwBmp, 300, 300, hwBmp.Width / 4, hwBmp.Height / 4);
                //-----------------------------------------------------
                canvas.StrokeColor = PixelFarm.Drawing.Color.Magenta;
                //draw line test
                canvas.DrawLine(20, 20, 600, 200);
                //-----------------------------------------------------
                var color = new PixelFarm.Drawing.Color(50, 255, 0, 0);  //  PixelFarm.Drawing.Color.Red;
                //rect polygon
                var polygonCoords = new float[] {
                    5, 300,
                    40, 300,
                    50, 340,
                    10f, 340
                };
                canvas.DrawPolygon(polygonCoords, 4);
                //fill polygon test
                canvas.FillPolygon(color, polygonCoords);
                var polygonCoords2 = new float[] {
                    5 + 10, 300,
                    40 + 10, 300,
                    50 + 10, 340,
                    10f + 10, 340
                };
                canvas.SmoothMode  = CanvasSmoothMode.AggSmooth;
                canvas.StrokeColor = new PixelFarm.Drawing.Color(100, 0, 255, 0);  //  L
                canvas.DrawPolygon(polygonCoords2, 4);
                int strkW          = 10;
                canvas.StrokeColor = PixelFarm.Drawing.Color.LightGray;
                for (int i = 1; i < 90; i += 10)
                {
                    canvas.StrokeWidth = strkW;
                    double angle       = OpenTK.MathHelper.DegreesToRadians(i);
                    canvas.DrawLine(20, 400, (float)(600 * Math.Cos(angle)), (float)(600 * Math.Sin(angle)));
                    strkW--;
                    if (strkW < 1)
                    {
                        strkW = 1;
                    }
                }


                canvas.StrokeColor = PixelFarm.Drawing.Color.FromArgb(150, PixelFarm.Drawing.Color.Green);
                //////---------------------------------------------
                //////draw ellipse and circle

                canvas.StrokeWidth = 0.75f;
                canvas.DrawCircle(400, 500, 50);
                canvas.FillCircle(PixelFarm.Drawing.Color.FromArgb(150, PixelFarm.Drawing.Color.Green), 450, 550, 25);
                canvas.StrokeWidth = 3;
                canvas.DrawRoundRect(500, 450, 100, 100, 10, 10);
                canvas.StrokeWidth = 3;
                canvas.StrokeColor = PixelFarm.Drawing.Color.FromArgb(150, PixelFarm.Drawing.Color.Blue);
                //canvas.DrawBezierCurve(0, 0, 500, 500, 0, 250, 500, 250);
                canvas.DrawBezierCurve(120, 500 - 160, 220, 500 - 40, 35, 500 - 200, 220, 500 - 260);
                canvas.SmoothMode = CanvasSmoothMode.No;
                //canvas.DrawArc(150, 200, 300, 50, 0, 150, 150, SvgArcSize.Large, SvgArcSweep.Negative);
                canvas.DrawArc(100, 200, 300, 200, 30, 30, 50, SvgArcSize.Large, SvgArcSweep.Negative);
                canvas.StrokeColor = PixelFarm.Drawing.Color.FromArgb(150, PixelFarm.Drawing.Color.Green);
                // canvas.DrawArc(100, 200, 300, 200, 0, 100, 100, SvgArcSize.Large, SvgArcSweep.Negative);

                canvas.StrokeColor = PixelFarm.Drawing.Color.FromArgb(150, PixelFarm.Drawing.Color.Black);
                canvas.DrawLine(100, 200, 300, 200);
                //////load font data
                ////var font = PixelFarm.Agg.Fonts.NativeFontStore.LoadFont("c:\\Windows\\Fonts\\Tahoma.ttf", 64);
                ////var fontGlyph = font.GetGlyph('{');
                //////PixelFarm.Font2.MyFonts.SetShapingEngine();

                ////canvas.FillVxs(PixelFarm.Drawing.Color.FromArgb(150, PixelFarm.Drawing.Color.Black), fontGlyph.flattenVxs);

                ////canvas.StrokeColor = PixelFarm.Drawing.Color.White;
                ////canvas.CurrentFont = font;

                ////canvas.StrokeColor = PixelFarm.Drawing.Color.Black;
                ////canvas.DrawLine(0, 200, 500, 200);

                //////test Thai words
                ////canvas.DrawString("ดุดีดำด่าด่ำญญู", 80, 200);
                ////canvas.DrawString("1234567890", 80, 200);
                ////GLBitmap bmp = new GLBitmap(new LazyAggBitmapBufferProvider(fontGlyph.glyphImage32));
                ////canvas.DrawImage(bmp, 50, 50);
                ////bmp.Dispose();
            });
            form.Show();
        }
Example #14
0
        public override void Load()
        {
            //draw 1
            FormTestWinGLControl form = new FormTestWinGLControl();
            var canvas = PixelFarm.Drawing.DrawingGL.CanvasGLPortal.P.CreateCanvas(0, 0, 800, 600);

            PixelFarm.Drawing.Bitmap       bmp    = null;
            PixelFarm.Drawing.TextureBrush tbrush = null;
            form.SetGLPaintHandler((o, s) =>
            {
                canvas.ClearSurface(PixelFarm.Drawing.Color.White);
                //if (tbrush == null)
                //{
                //    var bitmap = new System.Drawing.Bitmap("../../../SampleImages/plain01.png");
                //    bmp = new PixelFarm.Drawing.Bitmap(bitmap.Width, bitmap.Height, bitmap);
                //    tbrush = new PixelFarm.Drawing.TextureBrush(bmp);
                //}

                //fill rectangle is easy
                //canvas.FillRectangle(linearGrBrush, 0, 0, 150, 150);
                //canvas.FillRectangle(PixelFarm.Drawing.Color.Blue, 0, 0, 150, 150);
                //----------------------------------------------------
                //2. fill polygon with gradient brush


                canvas.FillPolygon(
                    PixelFarm.Drawing.Color.Red,
                    new PixelFarm.Drawing.PointF[] {
                    new PixelFarm.Drawing.PointF(0, 50),
                    new PixelFarm.Drawing.PointF(50, 50),
                    new PixelFarm.Drawing.PointF(10, 100)
                });
                canvas.Note1      = 1; //temp
                var linearGrBrush = new LinearGradientBrush(
                    new PixelFarm.Drawing.PointF(25, 25),
                    PixelFarm.Drawing.Color.Black,
                    new PixelFarm.Drawing.PointF(100, 100),
                    PixelFarm.Drawing.Color.Blue);
                //canvas.FillPolygon(
                //    tbrush,
                //    new PixelFarm.Drawing.PointF[]{
                //            new PixelFarm.Drawing.PointF(60, 50),
                //            new PixelFarm.Drawing.PointF(100, 50),
                //            new PixelFarm.Drawing.PointF(70, 100)});

                //canvas.FillPolygon(
                //    linearGrBrush,
                //    new PixelFarm.Drawing.PointF[]{
                //            new PixelFarm.Drawing.PointF(60, 50),
                //            new PixelFarm.Drawing.PointF(100, 50),
                //            new PixelFarm.Drawing.PointF(70, 100)});
                canvas.FillPolygon(
                    linearGrBrush,
                    new PixelFarm.Drawing.PointF[] {
                    new PixelFarm.Drawing.PointF(60, 50),
                    new PixelFarm.Drawing.PointF(100, 50),
                    new PixelFarm.Drawing.PointF(70, 100)
                });
                canvas.Note1 = 0;
                //-------------------------------------------------------------------------
            });
            form.Show();
        }
Example #15
0
        public override void Load()
        {
            //draw 1
            FormTestWinGLControl form = new FormTestWinGLControl();
            //form.GetCanvasControl().Visible = false;
            //System.Windows.Forms.Panel pp = new Panel();
            //pp.Size = new System.Drawing.Size(500, 500);
            //pp.BackColor = System.Drawing.Color.Black;
            //form.Controls.Add(pp);
            //WinGdiPortal.P.CreateCanvas(0, 0, 800, 600);

            var canvas = PixelFarm.Drawing.DrawingGL.CanvasGLPortal.P.CreateCanvas(0, 0, 800, 600);

            PixelFarm.Drawing.Bitmap bmp = null;
            form.SetGLPaintHandler((o, s) =>
            {
                canvas.ClearSurface(PixelFarm.Drawing.Color.White);
                canvas.FillRectangle(
                    PixelFarm.Drawing.Color.Blue,
                    0, 0, 200, 200);

                canvas.SetCanvasOrigin(180, 180);
                //----------------------
                canvas.FillRectangle(
                    PixelFarm.Drawing.Color.Green,
                    0, 0, 100, 100);
                //----------------------
                canvas.SetCanvasOrigin(0, 0);
                //----------------------
                //drawimgage
                if (bmp == null)
                {
                    var bitmap = new System.Drawing.Bitmap("../../../SampleImages/plain01.png");
                    bmp        = new PixelFarm.Drawing.Bitmap(bitmap.Width, bitmap.Height, bitmap);
                }

                //draw full image to destination
                //canvas.DrawImage(bmp, GenRect(0, 0, bmp.Width / 2, bmp.Height / 2));
                canvas.DrawImage(bmp, new PixelFarm.Drawing.RectangleF(0, 0, bmp.Width / 2, bmp.Height / 2));
                //----------------------
                //1. draw from some part of src image to dest
                //canvas.DrawImage(bmp,
                //    //dest
                //    //new PixelFarm.Drawing.RectangleF(0, 350, bmp.Width, bmp.Height),
                //    new PixelFarm.Drawing.RectangleF(0, 350, bmp.Width, bmp.Height),
                //    //src
                //    new PixelFarm.Drawing.RectangleF(0, 0, 100, 100));
                canvas.DrawImage(bmp,
                                 //dest
                                 //new PixelFarm.Drawing.RectangleF(0, 350, bmp.Width, bmp.Height),
                                 new PixelFarm.Drawing.RectangleF(0, 350, bmp.Width / 2, bmp.Height / 2),
                                 //src
                                 new PixelFarm.Drawing.RectangleF(0, 0, bmp.Width, bmp.Height));

                ////----------------------
                canvas.DrawImage(bmp,
                                 //dest
                                 new PixelFarm.Drawing.RectangleF(350, 350, bmp.Width / 2, bmp.Height / 2),
                                 //src
                                 new PixelFarm.Drawing.RectangleF(100, 100, bmp.Width - 100, bmp.Height - 100));
                ////----------------------
                //2.
                {
                    var refBmp = new PixelFarm.Drawing.ReferenceBitmap(bmp, 50, 50, 100, 100);
                    canvas.DrawImage(refBmp,
                                     new PixelFarm.Drawing.RectangleF(300, 100, refBmp.Width, refBmp.Height));
                }
                ////----------------------
                //3. small glyph
                int startAt    = 50;
                int lineHeight = 20;
                int drawXPos   = 300;
                int drawYPos   = 50;
                for (int i = 0; i < 5; ++i)
                {
                    var refBmp = new PixelFarm.Drawing.ReferenceBitmap(bmp, 50, startAt, 50, 20);
                    canvas.DrawImage(refBmp,
                                     new PixelFarm.Drawing.RectangleF(drawXPos, drawYPos, refBmp.Width, refBmp.Height));
                    drawXPos += 50;
                    startAt  += lineHeight;
                }

                canvas.StrokeColor = PixelFarm.Drawing.Color.Blue;

                canvas.DrawLine(0, 0, 800, 800);
            });
            form.Show();
        }