コード例 #1
0
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            int max = Math.Max(this.Width, this.Height);

            canvas2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max);
            painter  = new GLCanvasPainter(canvas2d, max, max);

            //---------------------
            string fontfilename = "d:\\WImageTest\\a_total.xml";
            var    atlasBuilder = new Typography.Rendering.SimpleFontAtlasBuilder();

            fontAtlas = atlasBuilder.LoadFontInfo(fontfilename);

            totalImg = new System.Drawing.Bitmap("d:\\WImageTest\\a_total.png");

            var bmpdata = totalImg.LockBits(new System.Drawing.Rectangle(0, 0, totalImg.Width, totalImg.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, totalImg.PixelFormat);
            var buffer  = new int[totalImg.Width * totalImg.Height];

            System.Runtime.InteropServices.Marshal.Copy(bmpdata.Scan0, buffer, 0, buffer.Length);
            totalImg.UnlockBits(bmpdata);
            var glyph = new Typography.Rendering.GlyphImage(totalImg.Width, totalImg.Height);

            glyph.SetImageBuffer(buffer, false);
            fontAtlas.TotalGlyph = glyph;



            //---------------------
        }
コード例 #2
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();
        }
コード例 #3
0
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            int max = Math.Max(this.Width, this.Height);

            canvas2d = CreateCanvasGL2d(max, max);
            painter  = new GLCanvasPainter(canvas2d, max, max);
            polygon1 = painter.CreatePolygonRenderVx(new float[]
            {
                0, 50,
                50, 50,
                10, 100
            });
            polygon2 = painter.CreatePolygonRenderVx(new float[]
            {
                200, 50,
                250, 50,
                210, 100
            });
            polygon3 = painter.CreatePolygonRenderVx(new float[]
            {
                400, 50,
                450, 50,
                410, 100
            });
        }
コード例 #4
0
 public static Canvas CreateCanvas2(int left,
                                    int top, int width, int height,
                                    CanvasGL2d canvas,
                                    GLCanvasPainter painter1,
                                    CanvasInitParameters reqPars = new CanvasInitParameters())
 {
     return(new MyGLCanvas(painter1, 0, 0, width, height));
 }
コード例 #5
0
ファイル: T110_Text.cs プロジェクト: cs-phillips/PixelFarm
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            int max = Math.Max(this.Width, this.Height);

            canvas2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max);
            painter  = new GLCanvasPainter(canvas2d, max, max);
            //convert lion vxs to renderVx
        }
コード例 #6
0
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            int max = Math.Max(this.Width, this.Height);

            canvas2d              = CreateCanvasGL2d(max, max);
            frameBuffer           = canvas2d.CreateFrameBuffer(this.Width, this.Height);
            frameBufferNeedUpdate = true;
            //------------
        }
コード例 #7
0
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            int max = Math.Max(this.Width, this.Height);

            canvas2d    = CreateCanvasGL2d(max, max);
            painter     = new GLCanvasPainter(canvas2d, max, max);
            frameBuffer = canvas2d.CreateFrameBuffer(max, max);
            //------------
        }
コード例 #8
0
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            int max = Math.Max(this.Width, this.Height);

            canvas2d              = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max);
            painter               = new GLCanvasPainter(canvas2d, max, max);
            frameBuffer           = canvas2d.CreateFrameBuffer(this.Width, this.Height);
            frameBufferNeedUpdate = true;
            //------------
        }
コード例 #9
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();
        }
コード例 #10
0
 public override void CloseCanvas()
 {
     if (isDisposed)
     {
         return;
     }
     this.isDisposed = true;
     this.canvasGL2d.Dispose();
     ReleaseUnManagedResource();
     this.canvasGL2d = null;
 }
コード例 #11
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();
        }
コード例 #12
0
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            //--------------------------------------------------------------------------------
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.ClearColor(1, 1, 1, 1);
            //setup viewport size
            int max = Math.Max(this.Width, this.Height);

            canvas2d = new CanvasGL2d(max, max);
            //square viewport
            GL.Viewport(0, 0, max, max);
        }
コード例 #13
0
        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();
        }
コード例 #14
0
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            int max = Math.Max(this.Width, this.Height);

            canvas2d  = CreateCanvasGL2d(max, max);
            lionShape = new SpriteShape();
            lionShape.ParseLion();
            //flip this lion vertically before use with openGL
            PixelFarm.Agg.Transform.Affine aff = PixelFarm.Agg.Transform.Affine.NewMatix(
                PixelFarm.Agg.Transform.AffinePlan.Scale(1, -1),
                PixelFarm.Agg.Transform.AffinePlan.Translate(0, 600));
            lionVxs = new VertexStore();
            aff.TransformToVxs(lionShape.Path.Vxs, lionVxs);
            painter = new GLCanvasPainter(canvas2d, max, max);
        }
コード例 #15
0
        public void Init2(CanvasGL2d canvas2d)
        {
            int max = 800;

            this.canvas2d = canvas2d;
            lionShape     = new SpriteShape();
            lionShape.ParseLion();
            //flip this lion vertically before use with openGL
            PixelFarm.Agg.Transform.Affine aff = PixelFarm.Agg.Transform.Affine.NewMatix(
                PixelFarm.Agg.Transform.AffinePlan.Scale(1, -1),
                PixelFarm.Agg.Transform.AffinePlan.Translate(0, 600));
            lionVxs = new VertexStore();
            aff.TransformToVxs(lionShape.Path.Vxs, lionVxs);
            painter = new GLCanvasPainter(canvas2d, max, max);
            SetPrinter(painter);
        }
コード例 #16
0
        //  PixelFarm.Drawing.Fonts.SvgFontStore svgFontStore = new PixelFarm.Drawing.Fonts.SvgFontStore();
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            //temp***
            int max = Math.Max(this.Width, this.Height);

            canvas2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max);
            painter  = new GLCanvasPainter(canvas2d, max, max);

            //----------------------
            var win32InstallFontProvider       = new PixelFarm.Drawing.InstallFontsProviderWin32();
            InstalledFontCollection collection = new InstalledFontCollection();

            collection.LoadInstalledFont(win32InstallFontProvider.GetInstalledFontIter());
            InstalledFont tahomaFont = collection.GetFont("tahoma", InstalledFontStyle.Regular);
            FontFace      tahomaFace = OpenFontLoader.LoadFont(tahomaFont.FontPath, ScriptLangs.Latin);
            ActualFont    actualFont = tahomaFace.GetFontAtPointsSize(72);
            FontGlyph     glyph      = actualFont.GetGlyph('K');

            //var svgFont = svgFontStore.LoadFont("svg-LiberationSansFont", 300);
            ////PathWriter p01 = new PathWriter();
            ////p01.MoveTo(0, 0);
            ////p01.LineTo(50, 100);
            ////p01.LineTo(100, 0);
            //////-
            ////p01.MoveTo(220, 10);
            ////p01.LineTo(50, 75);
            ////p01.LineTo(25, 15);
            ////p01.CloseFigure();
            ////p01.Stop();
            ////m_pathVxs = p01.Vxs;

            //var m_pathVxs = svgFont.GetGlyph('K').originalVxs;// typeFaceForLargeA.GetGlyphForCharacter('a');
            ////m_pathVxs = MergeFontSubFigures(m_pathVxs);

            //Affine shape_mtx = Affine.NewMatix(AffinePlan.Translate(150, 100));
            //m_pathVxs = shape_mtx.TransformToVxs(m_pathVxs);
            //var curveFlattener = new CurveFlattener();
            //var m_pathVxs2 = curveFlattener.MakeVxs(m_pathVxs);

            glyph_vx = painter.CreateRenderVx(tempSnap1 = new PixelFarm.Agg.VertexStoreSnap(glyph.flattenVxs));

            linearGrBrush2 = new LinearGradientBrush(
                new PointF(0, 0), Color.Red,
                new PointF(100, 100), Color.Black);
            //----------------------
        }
コード例 #17
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.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();
        }
コード例 #18
0
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            int max = Math.Max(this.Width, this.Height);

            canvas2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max);
            painter  = new GLCanvasPainter(canvas2d, max, max);
            polygon1 = painter.CreatePolygonRenderVx(new float[]
            {
                50, 200,
                250, 200,
                125, 350
            });
            polygon2 = painter.CreatePolygonRenderVx(new float[]
            {
                250, 400,
                450, 400,
                325, 550
            });
        }
コード例 #19
0
        public MyCanvasGL(GraphicsPlatform platform, int hPageNum, int vPageNum, int left, int top, int width, int height)
        {
            canvasGL2d = new CanvasGL2d(width, height);
            //--------------------------------------------
            this.platform = platform;
            this.left     = left;
            this.top      = top;
            this.right    = left + width;
            this.bottom   = top + height;
            //--------------------------------------------

            this.CurrentFont      = defaultFontInfo.ResolvedFont;
            this.CurrentTextColor = Color.Black;
#if DEBUG
            debug_canvas_id   = dbug_canvasCount + 1;
            dbug_canvasCount += 1;
#endif
            this.StrokeWidth     = 1;
            this.currentClipRect = new System.Drawing.Rectangle(0, 0, width, height);
        }
コード例 #20
0
ファイル: T105_Stencil.cs プロジェクト: cs-phillips/PixelFarm
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            int max = Math.Max(this.Width, this.Height);

            canvas2d       = CreateCanvasGL2d(max, max);
            painter        = new GLCanvasPainter(canvas2d, max, max);
            stencilPolygon = painter.CreatePolygonRenderVx(new float[]
            {
                20, 20,
                100, 20,
                60, 80
            });
            rectPolygon = painter.CreatePolygonRenderVx(new float[]
            {
                5, 5,
                100, 5,
                100, 100,
                5, 100
            });
        }
コード例 #21
0
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            lionShape = new SpriteShape();
            lionShape.ParseLion();
            RectD lionBounds = lionShape.Bounds;

            //-------------
            aggImage   = new ActualImage((int)lionBounds.Width, (int)lionBounds.Height, PixelFarm.Agg.PixelFormat.ARGB32);
            imgGfx2d   = new ImageGraphics2D(aggImage);
            aggPainter = new AggCanvasPainter(imgGfx2d);

            DrawLion(aggPainter, lionShape, lionShape.Path.Vxs);
            //convert affImage to texture
            glBmp = LoadTexture(aggImage);

            int max = Math.Max(this.Width, this.Height);

            canvas2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max);
            //-------------------------
            painter = new GLCanvasPainter(canvas2d, max, max);
        }
コード例 #22
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;
                var polygonCoords  = new float[] {
                    5, 300,
                    40, 300,
                    50, 340
                };
                canvas.FillPolygon(PixelFarm.Drawing.Color.DeepPink, polygonCoords, 3);
            });
            form.Show();
        }
コード例 #23
0
        MyMiniGLES2Control InitMiniGLControl(int w, int h)
        {
            if (miniGLControl == null)
            {
                miniGLControl            = new MyMiniGLES2Control();
                miniGLControl.Width      = w;
                miniGLControl.Height     = h;
                miniGLControl.ClearColor = PixelFarm.Drawing.Color.Blue;
                this.Controls.Add(miniGLControl);
                miniGLControl.SetGLPaintHandler(HandleGLPaint);
                hh1 = miniGLControl.Handle;
                miniGLControl.MakeCurrent();
                int max = Math.Max(this.Width, this.Height);
                canvas2d      = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max);
                canvasPainter = new GLCanvasPainter(canvas2d, max, max);
                //create text printer for opengl
                //----------------------
                //1. win gdi based
                //var printer = new WinGdiFontPrinter(canvas2d, w, h);
                //canvasPainter.TextPrinter = printer;
                //----------------------
                //2. raw vxs
                //var printer = new PixelFarm.Drawing.Fonts.VxsTextPrinter(canvasPainter);
                //canvasPainter.TextPrinter = printer;
                //----------------------
                //3. agg texture based font texture
                //var printer = new AggFontPrinter(canvasPainter, w, h);
                //canvasPainter.TextPrinter = printer;
                //----------------------
                //4. texture atlas based font texture

                //------------
                //resolve request font


                var printer = new GLBmpGlyphTextPrinter(canvasPainter, YourImplementation.BootStrapWinGdi.myFontLoader);
                canvasPainter.TextPrinter = printer;
            }
            return(miniGLControl);
        }
コード例 #24
0
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            int max = Math.Max(this.Width, this.Height);

            canvas2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max);

            PixelFarm.Drawing.GLES2.GLES2Platform.AddTextureFont("tahoma",
                                                                 "d:\\WImageTest\\a_total.xml",
                                                                 "d:\\WImageTest\\a_total.png");
            //temp comment
            ////------------------------------------------------
            hbShapingService = new HarfBuzzShapingService();
            hbShapingService.SetAsCurrentImplementation();

            painter             = new GLCanvasPainter(canvas2d, max, max);
            painter.CurrentFont = new PixelFarm.Drawing.RequestFont("tahoma", 24);
            //------------------------------------------------

            //string fontName = "tahoma";
            //float fontSize = 24;
            //GlyphImage glypImage = null;
            //using (var nativeImg = new PixelFarm.Drawing.Imaging.NativeImage("d:\\WImageTest\\a_total.png"))
            //{
            //    glypImage = new GlyphImage(nativeImg.Width, nativeImg.Height);
            //    var buffer = new int[nativeImg.Width * nativeImg.Height];
            //    System.Runtime.InteropServices.Marshal.Copy(nativeImg.GetNativeImageHandle(), buffer, 0, buffer.Length);
            //    glypImage.SetImageBuffer(buffer, true);
            //}

            //textureFont = TextureFont.CreateFont(fontName, fontSize,
            //    "d:\\WImageTest\\a_total.xml",
            //    glypImage);

            ////PixelFarm.Drawing.RequestFont f = new PixelFarm.Drawing.RequestFont(fontName, fontSize);
            ////canvas2d.TextureFontStore = textureFonts;
            ////painter.CurrentFont = textureFont;
            //painter.ActualFont = textureFont;
        }
コード例 #25
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();
        }
コード例 #26
0
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            int max = Math.Max(this.Width, this.Height);

            canvas2d  = CreateCanvasGL2d(max, max);
            lionShape = new SpriteShape();
            lionShape.ParseLion();
            //flip this lion vertically before use with openGL
            PixelFarm.Agg.Transform.Affine aff = PixelFarm.Agg.Transform.Affine.NewMatix(
                PixelFarm.Agg.Transform.AffinePlan.Scale(1, -1),
                PixelFarm.Agg.Transform.AffinePlan.Translate(0, 600));
            lionVxs = new VertexStore();
            aff.TransformToVxs(lionShape.Path.Vxs, lionVxs);
            painter = new GLCanvasPainter(canvas2d, max, max);
            //convert lion vxs to renderVx

            int j = lionShape.NumPaths;

            int[] pathList = lionShape.PathIndexList;
            for (int i = 0; i < j; ++i)
            {
                lionRenderVxList.Add(painter.CreateRenderVx(new VertexStoreSnap(lionVxs, pathList[i])));
            }
        }
コード例 #27
0
        public override void Init()
        {
            FormTestWinGLControl2 form          = new FormTestWinGLControl2();
            CanvasGL2d            canvas        = new CanvasGL2d(this.Width, this.Height);
            GLTextPrinter         glTextPrinter = new GLTextPrinter(canvas);

            form.SetGLPaintHandler((o, s) =>
            {
                canvas.Clear(PixelFarm.Drawing.Color.White);
                if (hwBmp == null)
                {
                    hwBmp = PixelFarm.Drawing.DrawingGL.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.DeepPink;
                canvas.DrawLine(0, 300, 500, 300);

                //-----------------------------------------------------
                canvas.StrokeColor = PixelFarm.Drawing.Color.Magenta;
                //draw line test
                canvas.DrawLine(20, 20, 600, 200);
                //-----------------------------------------------------
                //smooth with agg

                canvas.SmoothMode = CanvasSmoothMode.AggSmooth;
                var fillColor     = 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);
                //fill polygon test
                canvas.FillPolygon(fillColor, polygonCoords);

                var polygonCoords2 = new float[] {
                    5 + 10, 300,
                    40 + 10, 300,
                    50 + 10, 340,
                    10f + 10, 340
                };
                canvas.StrokeColor = new PixelFarm.Drawing.Color(100, 0, 255, 0);  //  L
                canvas.DrawPolygon(polygonCoords2, polygonCoords2.Length / 2);

                int strokeW        = 10;
                canvas.StrokeColor = PixelFarm.Drawing.Color.LightGray;

                for (int i = 1; i < 90; i += 10)
                {
                    canvas.StrokeWidth = strokeW;
                    double angle       = OpenTK.MathHelper.DegreesToRadians(i);
                    canvas.DrawLine(20, 400, (float)(600 * Math.Cos(angle)), (float)(600 * Math.Sin(angle)));

                    strokeW--;
                    if (strokeW < 1)
                    {
                        strokeW = 1;
                    }
                }



                var color          = PixelFarm.Drawing.Color.FromArgb(150, PixelFarm.Drawing.Color.Green);
                canvas.StrokeColor = color;

                ////---------------------------------------------
                ////draw ellipse and circle

                canvas.StrokeWidth = 0.75f;
                canvas.DrawCircle(400, 500, 50);
                canvas.FillCircle(color, 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.DrawArc(100, 200, 300, 200, 0, 100, 100, SvgArcSize.Large, SvgArcSweep.Negative);

                fillColor          = PixelFarm.Drawing.Color.FromArgb(150, PixelFarm.Drawing.Color.Black);
                canvas.StrokeColor = fillColor;
                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(fillColor, fontGlyph.flattenVxs);

                glTextPrinter.CurrentFont = font;


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

                //test Thai words
                glTextPrinter.Print("ดุดีดำด่าด่ำญญู", 80, 200);
                //number
                glTextPrinter.Print("1234567890", 80, 200);
                GLBitmap bmp = PixelFarm.Drawing.DrawingGL.GLBitmapTextureHelper.CreateBitmapTexture(fontGlyph.glyphImage32);

                canvas.DrawImage(bmp, 50, 50);
                bmp.Dispose();
            });
            form.Show();
        }
コード例 #28
0
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            int max = Math.Max(this.Width, this.Height);

            canvas2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max);
        }
コード例 #29
0
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            int max = Math.Max(this.Width, this.Height);

            canvas2d = CreateCanvasGL2d(max, max);
        }
コード例 #30
0
ファイル: GLTextPrinter.cs プロジェクト: asmboom/PixelFarm
 public GLTextPrinter(CanvasGL2d canvas2d)
 {
     this.canvas2d = canvas2d;
 }