Exemple #1
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.ClearColorBuffer();
            if (!_resInit)
            {
                _msdf_bmp = DemoHelper.LoadTexture(RootDemoPath.Path + @"\msdf_75.png");
                _resInit  = true;
            }
            _pcx.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);

            //_pcx.draw(_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);

            _pcx.DrawImageWithMsdf(_msdf_bmp, 300, 500, 0.5f, PixelFarm.Drawing.Color.Black);
            ////
            //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);
            _pcx.DrawImage(_msdf_bmp, 100, 300);

            SwapBuffers();
        }
Exemple #2
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.ClearColorBuffer();
            if (!_resInit)
            {
                _msdf_bmp = DemoHelper.LoadTexture(_fontAtlas.MainBitmap);
                _resInit  = true;
            }

            _painter.Clear(PixelFarm.Drawing.Color.White);


            _fontAtlas.TryGetItem(_glyphIndex_0, out AtlasItem glyphData);
            PixelFarm.Drawing.Rectangle r =
                new PixelFarm.Drawing.Rectangle(glyphData.Left,
                                                glyphData.Top,
                                                glyphData.Width,
                                                glyphData.Height);

            _pcx.DrawSubImageWithMsdf(_msdf_bmp, ref r, 100, 40);

            _fontAtlas.TryGetItem(_glyphIndex_1, out glyphData);
            PixelFarm.Drawing.Rectangle r2 = new PixelFarm.Drawing.Rectangle(glyphData.Left,
                                                                             glyphData.Top,
                                                                             glyphData.Width,
                                                                             glyphData.Height);
            _pcx.DrawSubImageWithMsdf(_msdf_bmp, ref r2, 100 + r.Width, 40);

            //full image
            _pcx.DrawImage(_msdf_bmp, 0, 100);
            SwapBuffers();
        }
Exemple #3
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.ClearColorBuffer();
            _painter.FillColor = PixelFarm.Drawing.Color.Black;
            _painter.FillRect(0, 0, 150, 150);

            //-------------------------------------------------------------------------
            _painter.FillRenderVx(_textureBrush, _polygon1);
            //_painter.FillRenderVx(_linearGradient, _polygon1);
            ////-------------------------------------------------------------------------


            //fill polygon with gradient brush
            _painter.FillColor = Color.Yellow;
            _painter.FillRect(200, 0, 150, 150);
            //_painter.FillRenderVx(_textureBrush2, _polygon2);
            _painter.FillRenderVx(_linearGradient, _polygon2);


            ////-------------------------------------------------------------------------
            _painter.FillColor = Color.Black;
            _painter.FillRect(400, 0, 150, 150);
            //another  ...
            _painter.FillRenderVx(_textureBrush2, _polygon3);
            ////-------------------------------------------------------------------------


            SwapBuffers();
        }
Exemple #4
0
 protected override void OnGLRender(object sender, EventArgs args)
 {
     _pcx.SmoothMode  = SmoothMode.Smooth;
     _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
     _pcx.Clear(PixelFarm.Drawing.Color.White);
     _pcx.ClearColorBuffer();
     //-------------------------------
     if (!_isInit)
     {
         _isInit = true;
     }
     _pcx.Clear(PixelFarm.Drawing.Color.Blue);
     _painter.StrokeColor = PixelFarm.Drawing.Color.Black;
     _painter.StrokeWidth = 2;
     //-------------------------------
     //painter.FillColor = PixelFarm.Drawing.Color.Yellow;
     //painter.FillRenderVx(polygon1);
     //-------------------------------
     //painter.FillColor = PixelFarm.Drawing.Color.Red;
     //painter.FillRenderVx(polygon2);
     //////-------------------------------
     _painter.FillColor = PixelFarm.Drawing.Color.Magenta;
     try
     {
         _painter.FillRenderVx(_polygon3);
         SwapBuffers();
     }
     catch (Exception ex)
     {
     }
 }
Exemple #5
0
        void Test2()
        {
            _pcx.ClearColorBuffer();
            _pcx.SmoothMode      = SmoothMode.Smooth;
            _pcx.StrokeColor     = PixelFarm.Drawing.Color.Blue;
            _pcx.StrokeWidth     = 1;
            _painter.StrokeWidth = 1;
            ////line
            _painter.FillColor = PixelFarm.Drawing.Color.Green;
            _painter.FillRect(100, 100, 50, 50);
            _pcx.DrawLine(50, 50, 200, 200);

            _painter.FillRenderVx(_polygon2);
            _painter.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _painter.DrawRenderVx(_polygon2);
            //-------------------------------------------
            ////polygon
            _painter.DrawRenderVx(_polygon1);
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Green;
            ////--------------------------------------------
            _painter.DrawCircle(100, 100, 25);
            _painter.DrawEllipse(200, 200, 225, 250);
            ////
            _painter.FillColor = PixelFarm.Drawing.KnownColors.OrangeRed;
            _painter.FillCircle(100, 400, 25);
            _pcx.StrokeColor = PixelFarm.Drawing.KnownColors.OrangeRed;
            _painter.DrawCircle(100, 400, 25);
            ////
            _painter.FillColor = PixelFarm.Drawing.KnownColors.OrangeRed;
            _painter.FillEllipse(200, 400, 225, 450);
            _pcx.StrokeColor = PixelFarm.Drawing.KnownColors.OrangeRed;
            _painter.DrawEllipse(200, 400, 225, 450);
            //-------------------------------------------
            SwapBuffers();
        }
Exemple #6
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.Clear(PixelFarm.Drawing.Color.White); //set clear color and clear all buffer
            _pcx.ClearColorBuffer();                   //test , clear only color buffer
            //-------------------------------
            if (!_isInit)
            {
                _glbmp  = ConvertFromBGRA_To_RGBA(DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.jpg"));
                _isInit = true;
            }

            PixelFarm.Drawing.RenderSurfaceOriginKind prevOrgKind = _pcx.OriginKind; //save
            _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;

            _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
            //_pcx.DrawFrameBuffer(_frameBuffer, 0, 0, true);
            for (int i = 0; i < 1; ++i)
            {
                _pcx.DrawImage(_glbmp, 100 + (i * 30), 200 + (i * 30));
            }

            //-------------------------------
            _pcx.OriginKind = prevOrgKind;//restore
        }
Exemple #7
0
 protected override void OnGLRender(object sender, EventArgs args)
 {
     _pcx.SmoothMode  = SmoothMode.Smooth;
     _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
     _pcx.ClearColorBuffer();
     //-------------------------------
     _pcx.DrawImage(_glBmp, 0, 600);
     SwapBuffers();
 }
Exemple #8
0
 protected override void OnGLRender(object sender, EventArgs args)
 {
     _pcx.SmoothMode  = SmoothMode.Smooth;
     _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
     _pcx.ClearColorBuffer();
     //-------------------------------
     _spriteShape.Paint(_painter);
     //-------------------------------
     SwapBuffers();
 }
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.Clear(PixelFarm.Drawing.Color.White);
            _pcx.ClearColorBuffer();
            //-------------------------------
            _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
            if (!_isInit)
            {
                _glbmp  = DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.png");
                _isInit = true;
            }
            if (_surface1.IsValid)
            {
                if (_frameBufferNeedUpdate)
                {
                    //------------------------------------------------------------------------------------
                    //framebuffer
                    _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                    _pcx.AttachToRenderSurface(_surface1);
                    //after make the frameBuffer current
                    //then all drawing command will apply to frameBuffer
                    //do draw to frame buffer here
                    _pcx.Clear(PixelFarm.Drawing.Color.Red);
                    _pcx.DrawImageWithBlurX(_glbmp, 0, 0);
                    _pcx.AttachToRenderSurface(null);//switch to primary render surface
                    //------------------------------------------------------------------------------------
                    //framebuffer2

                    _pcx.AttachToRenderSurface(_surface2);
                    _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;

                    //GLBitmap bmp2 = new GLBitmap(_frameBuffer.TextureId, _frameBuffer.Width, _frameBuffer.Height);
                    //bmp2.IsYFlipped = true;
                    //bmp2.IsBigEndianPixel = true;

                    _pcx.DrawImageWithBlurY(_surface1.GetGLBitmap(), 0, 0);
                    _pcx.AttachToRenderSurface(null);
                    //------------------------------------------------------------------------------------
                    //after release current, we move back to default frame buffer again***
                    _frameBufferNeedUpdate = false;
                }
                _pcx.DrawImage(_surface2.GetGLBitmap(), 0, 0);

                //_pcx.DrawFrameBuffer(_frameBuffer2, 0, 0, true);
            }
            else
            {
                _pcx.Clear(PixelFarm.Drawing.Color.Blue);
            }
            //-------------------------------
            SwapBuffers();
        }
Exemple #10
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.Clear(PixelFarm.Drawing.Color.White); //set clear color and clear all buffer
            _pcx.ClearColorBuffer();                   //test , clear only color buffer
            //-------------------------------
            if (!_isInit)
            {
                _glbmp  = DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.jpg");
                _isInit = true;
            }

            PixelFarm.Drawing.RenderSurfaceOriginKind prevOrgKind = _pcx.OriginKind; //save
            _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;

            if (_surface1.IsValid)
            {
                if (_frameBufferNeedUpdate)
                {
                    _pcx.AttachToRenderSurface(_surface1);

                    _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                    //------------------------------------------------------------------------------------
                    //after make the frameBuffer current
                    //then all drawing command will apply to frameBuffer
                    //do draw to frame buffer here
                    _pcx.Clear(PixelFarm.Drawing.Color.Black);
                    _pcx.DrawImage(_glbmp, 5, 5);
                    //------------------------------------------------------------------------------------
                    _pcx.AttachToRenderSurface(null);
                    //after release current, we move back to default frame buffer again***
                    _frameBufferNeedUpdate = false;
                }
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                //_pcx.DrawFrameBuffer(_frameBuffer, 0, 0, true);

                for (int i = 0; i < 1; ++i)
                {
                    _pcx.DrawImage(_surface1.GetGLBitmap(), 100 + (i * 30), 200 + (i * 30));
                }
            }
            else
            {
                _pcx.Clear(PixelFarm.Drawing.Color.Blue);
            }
            //-------------------------------
            _pcx.OriginKind = prevOrgKind;//restore
        }
Exemple #11
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.ClearColorBuffer();
            _painter.FillColor = PixelFarm.Drawing.Color.Black;

            _painter.Clear(Color.Blue);

            PixelFarm.Drawing.RectangleF maskSrc = new RectangleF(0, 0, _maskBmp.Width, _maskBmp.Height);
            _pcx.DrawImageWithMask(_maskGLBmp, _colorGLBmp, maskSrc, 5, 3, 0, 0);
            _pcx.DrawImageWithMask(_maskGLBmp, _colorGLBmp, maskSrc, 5, 3, 30, 30);

            SwapBuffers();
        }
 protected override void OnGLRender(object sender, EventArgs args)
 {
     _pcx.SmoothMode  = SmoothMode.Smooth;
     _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
     _pcx.ClearColorBuffer();
     //-------------------------------
     if (_tmpDrawVersion == 2)
     {
         //TODO: impl this again
         //2018-08-01
     }
     else
     {
         //TODO: impl this again
         //2018-08-01
     }
     //-------------------------------
     SwapBuffers();
 }
Exemple #13
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode = SmoothMode.Smooth;
            _pcx.ClearColorBuffer();

            for (int y = 0; y < 10; ++y)
            {
                int x_pos = 0;
                for (int x = 0; x < 10; ++x)
                {
                    _painter.DrawImage(_chk_checked, x_pos, y * 20);
                    _painter.DrawImage(_chk_unchecked, x_pos + 20, y * 20);
                    x_pos += 40;
                }
            }


            SwapBuffers();
        }
Exemple #14
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.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);
            //-------------------------------------------------------------------------


            SwapBuffers();
        }
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.Clear(PixelFarm.Drawing.Color.White);
            _pcx.ClearColorBuffer();
            //-------------------------------
            if (!_isInit)
            {
                _glbmp  = DemoHelper.LoadTexture(RootDemoPath.Path + @"\leaves.jpg");
                _isInit = true;
            }
            if (_surface1.IsValid)
            {
                if (_frameBufferNeedUpdate)
                {
                    //------------------------------------------------------------------------------------
                    //framebuffer
                    _pcx.AttachToRenderSurface(_surface1);
                    //after make the frameBuffer current
                    //then all drawing command will apply to frameBuffer
                    //do draw to frame buffer here
                    _pcx.Clear(PixelFarm.Drawing.Color.Red);
                    _pcx.DrawImageWithConv3x3(_glbmp, Mat3x3ConvGen.emboss, 0, 0);
                    _pcx.AttachToRenderSurface(null);

                    //after release current, we move back to default frame buffer again***
                    _frameBufferNeedUpdate = false;
                }
                //_pcx.DrawFrameBuffer(_frameBuffer, 0, 0, true);
                _pcx.DrawImage(_surface1.GetGLBitmap(), 0, 0);
            }
            else
            {
                _pcx.Clear(PixelFarm.Drawing.Color.Blue);
            }
            //-------------------------------
            SwapBuffers();
        }
Exemple #16
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode      = SmoothMode.Smooth;
            _painter.StrokeColor = _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;

            _pcx.Clear(PixelFarm.Drawing.Color.White); //set clear color and clear all buffer
            _pcx.ClearColorBuffer();                   //test , clear only color buffer
                                                       //-------------------------------

            float prevStrokeW = _pcx.StrokeWidth;

            switch (T102_1_StrokeWidth)
            {
            default: throw new NotSupportedException();

            case T102_1_StrokeWidth.HalfPx:
                _pcx.StrokeWidth = 0.5f;
                break;

            case T102_1_StrokeWidth.OnePx:
                _pcx.StrokeWidth = 1;
                break;

            case T102_1_StrokeWidth.TwoPx:
                _pcx.StrokeWidth = 2;
                break;

            case T102_1_StrokeWidth.ThreePx:
                _pcx.StrokeWidth = 3;
                break;

            case T102_1_StrokeWidth.FourPx:
                _pcx.StrokeWidth = 4;
                break;

            case T102_1_StrokeWidth.FivePx:
                _pcx.StrokeWidth = 5;
                break;
            }
            PixelFarm.Drawing.RenderSurfaceOriginKind prevOrgKind = _pcx.OriginKind; //save
            switch (DrawSet)
            {
            default:
            case T102_1_Set.Lines:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawLine(i + 10, i + 10, i + 30, i + 50);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawLine(i + 10, i + 10, i + 30, i + 50);
                    i += 50;
                }
            }
            break;

            case T102_1_Set.FillRect:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                for (int i = 0; i < 400;)
                {
                    _pcx.FillRect(PixelFarm.Drawing.Color.Red, i, i, 50, 50);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.FillRect(PixelFarm.Drawing.Color.Red, i, i, 50, 50);
                    i += 50;
                }
            }
            break;

            case T102_1_Set.DrawRect:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                for (int i = 0; i < 400;)
                {
                    _painter.DrawRect(i, i, 50, 50);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _painter.DrawRect(i, i, 50, 50);
                    i += 50;
                }
            }
            break;
            }
            _pcx.OriginKind = prevOrgKind;//restore


            _pcx.StrokeWidth = prevStrokeW;
        }
Exemple #17
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.ClearColorBuffer();
            _pcx.Clear(PixelFarm.Drawing.Color.White);


#if DEBUG
            //test only
            GLBitmapGlyphTextPrinter.s_dbugDrawTechnique    = DrawTextTechnique;
            GLBitmapGlyphTextPrinter.s_dbugUseVBO           = UseVbo;
            GLBitmapGlyphTextPrinter.s_dbugShowGlyphTexture = ShowGlyphTexture;
            GLBitmapGlyphTextPrinter.s_dbugShowMarkers      = ShowMarkers;
#endif

            //-------------------------------

            PixelFarm.Drawing.Color fillColor = PixelFarm.Drawing.Color.Black;
            switch (DrawTextColor)
            {
            case T110_DrawTextColor.Blue:
                fillColor = PixelFarm.Drawing.Color.Blue;
                break;

            case T110_DrawTextColor.Green:
                fillColor = PixelFarm.Drawing.Color.Green;
                break;

            case T110_DrawTextColor.Magenta:
                fillColor = PixelFarm.Drawing.Color.Magenta;
                break;

            case T110_DrawTextColor.Red:
                fillColor = PixelFarm.Drawing.Color.Red;
                break;

            case T110_DrawTextColor.Yellow:
                fillColor = PixelFarm.Drawing.Color.Yellow;
                break;
            }


            int line_top = 500;
            _painter.FontFillColor = fillColor;


            _painter.DrawString("aftjypqkx", 0, line_top);

            //
            line_top = 550;
            _painter.DrawString("1234567890 ABCD", 0, line_top);
            //-------------------------------
            line_top = 570;
            if (!string.IsNullOrEmpty(UserText))
            {
                _painter.DrawString(UserText, 0, line_top);
            }

            SwapBuffers();
        }
        protected override void OnGLRender(object sender, EventArgs args)
        {
            //reset
            _pcx.SmoothMode = SmoothMode.Smooth;
            _pcx.ClearColorBuffer();
            _painter.Clear(Color.Yellow);

            switch (DrawSet)
            {
            case T408_DrawSet.A:
            {
                //draw msdf bitmap to mask surface
                if (_maskRenderSurface == null)
                {
                    GLRenderSurface currentSurface = _pcx.CurrentRenderSurface;
                    _maskRenderSurface = new GLRenderSurface(100, 100);
                    _pcx.AttachToRenderSurface(_maskRenderSurface);
                    //draw mask
                    _pcx.Clear(Color.Black);
                    _pcx.DrawImageWithMsdf(_msdfMaskGLBmp, 0, 0, 5, Color.White);
                    //switch back to normal surface
                    _pcx.AttachToRenderSurface(currentSurface);
                }

                //render with simple mask
                _pcx.DrawImageWithMask(
                    _maskRenderSurface.GetInnerGLData().GLBmp,
                    _colorGLBmp, 0, 0);
            }
            break;

            case T408_DrawSet.B:
            {
                RectangleF maskSrc = new RectangleF(0, 0, _msdfMaskBmp.Width, _msdfMaskBmp.Height);

                Rectangle rect = new Rectangle(10, 10, 120, 120);
                Quad2f    quad = new Quad2f();
                quad.SetCornersFromRect(rect);

                AffineMat mat1 = AffineMat.Iden();
                mat1.Translate(-rect.Width / 2, -rect.Height / 2);
                mat1.RotateDeg(45);
                mat1.Translate(rect.Width / 2, rect.Height / 2);
                quad.Transform(mat1);        //***test transform

                //-----------------------
                //create mask surface, this quite low leve step.
                //user should use this through drawboard
                //-----------------------

                if (_maskRenderSurface2 == null)
                {
                    //before we switch to another GLRenderSurface.
                    //we save current setting of current GLRenderSurface


                    _pcx.SaveStates(out GLPainterStatesData saveData1);

                    _maskRenderSurface2 = new GLRenderSurface(100, 100);

                    _pcx.AttachToRenderSurface(_maskRenderSurface2);
                    _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;


                    //draw mask
                    _pcx.Clear(Color.Black);
                    //draw image to specific quad
                    _pcx.DrawImageWithMsdf(_msdfMaskGLBmp, quad, Color.White);

                    //switch back to normal surface
                    _pcx.RestoreStates(saveData1);
                }


                _pcx.DrawImageWithMask(
                    _maskRenderSurface2.GetInnerGLData().GLBmp,
                    _colorGLBmp, 20, 20);
            }
            break;
            }

            SwapBuffers();
        }
Exemple #19
0
        protected override void OnGLRender(object sender, EventArgs args)
        {
            _pcx.SmoothMode  = SmoothMode.Smooth;
            _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue;
            _pcx.Clear(PixelFarm.Drawing.Color.White); //set clear color and clear all buffer
            _pcx.ClearColorBuffer();                   //test , clear only color buffer
            //-------------------------------
            if (!_isInit)
            {
                _glbmp  = DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.jpg");
                _isInit = true;
            }

            PixelFarm.Drawing.RenderSurfaceOriginKind prevOrgKind = _pcx.OriginKind; //save
            switch (DrawSet)
            {
            default:
            case T107_1_DrawImageSet.Full:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImage(_glbmp, i, i);         //left,top (NOT x,y)
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImage(_glbmp, i, i);         //left,top (NOT x,y)
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.Half:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawImage(_glbmp, i, i, _glbmp.Width / 2, _glbmp.Height / 2);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImage(_glbmp, i, i, _glbmp.Width / 2, _glbmp.Height / 2);         //left,top (NOT x,y)
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.ToRect:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    //PixelFarm.Drawing.RectangleF srcRect = new PixelFarm.Drawing.RectangleF(i, i, _glbmp.Width, _glbmp.Height);
                    _pcx.DrawImage(_glbmp, i, i, _glbmp.Width / 2, _glbmp.Height / 2);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    //PixelFarm.Drawing.RectangleF srcRect = new PixelFarm.Drawing.RectangleF(i, i, _glbmp.Width, _glbmp.Height);
                    _pcx.DrawImage(_glbmp, i, i, _glbmp.Width / 2, _glbmp.Height / 2);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.ToQuad1:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;

                Quad2f quad = new Quad2f();
                quad.SetCornersFromRect(0, 0, _glbmp.Width / 2, _glbmp.Height / 2);        //half size

                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)

                    _pcx.DrawImageToQuad(_glbmp, quad);

                    quad.Offset(50, 50);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                quad.SetCornersFromRect(0, 0, _glbmp.Width / 2, _glbmp.Height / 2);        //half size
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImageToQuad(_glbmp, quad);
                    quad.Offset(50, 50);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.ToQuad2:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;

                float rotateDegree = 20;

                //float[] quad = new float[8];

                Quad2f quad = new Quad2f();

                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    quad.SetCornersFromRect(0, 0, _glbmp.Width, _glbmp.Height);

                    AffineMat aff = AffineMat.Iden();
                    aff.Translate(-_glbmp.Width / 2, -_glbmp.Height / 2);        //move to bitmap's center
                    aff.RotateDeg(rotateDegree);
                    aff.Translate(i + _glbmp.Width / 2, i + _glbmp.Height / 2);

                    quad.Transform(aff);

                    _pcx.DrawImageToQuad(_glbmp, quad);

                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;


                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    quad.SetCornersFromRect(0, 0, _glbmp.Width, -_glbmp.Height);

                    AffineMat aff = AffineMat.Iden();
                    aff.Translate(-_glbmp.Width / 2, -_glbmp.Height / 2);        //move to bitmap's center
                    aff.RotateDeg(rotateDegree);
                    aff.Translate(i + _glbmp.Width / 2, i + _glbmp.Height / 2);

                    quad.Transform(aff);

                    _pcx.DrawImageToQuad(_glbmp, quad);

                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.ToQuad3:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;

                float rotateDegree = 60;

                for (int i = 0; i < 400;)
                {
                    AffineMat aff = AffineMat.Iden();
                    aff.Translate(-_glbmp.Width / 2, -_glbmp.Height / 2);        //move to bitmap's center
                    aff.RotateDeg(rotateDegree);
                    aff.Translate(i + _glbmp.Width / 2, i + _glbmp.Height / 2);

                    _pcx.DrawImageToQuad(_glbmp, aff);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    AffineMat aff = AffineMat.Iden();
                    aff.Translate(-_glbmp.Width / 2, -_glbmp.Height / 2);        //move to bitmap's center
                    aff.RotateDeg(rotateDegree);
                    aff.Translate(i + _glbmp.Width / 2, i + _glbmp.Height / 2);

                    _pcx.DrawImageToQuad(_glbmp, aff);


                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImages0:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                PixelFarm.Drawing.Rectangle srcRect = new PixelFarm.Drawing.Rectangle(0, 0, _glbmp.Width, _glbmp.Height);
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawSubImage(_glbmp, srcRect, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawSubImage(_glbmp, srcRect, i, i);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImages1:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                PixelFarm.Drawing.Rectangle srcRect = new PixelFarm.Drawing.Rectangle(0, 0, _glbmp.Width / 2, _glbmp.Height / 2);

                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)

                    _pcx.DrawSubImage(_glbmp, srcRect, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawSubImage(_glbmp, srcRect, i, i);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImages2:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                PixelFarm.Drawing.Rectangle srcRect = new PixelFarm.Drawing.Rectangle(20, 20, 50, 50);

                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)

                    _pcx.DrawSubImage(_glbmp, srcRect, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawSubImage(_glbmp, srcRect, i, i);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImagesWithScale:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                PixelFarm.Drawing.Rectangle srcRect = new PixelFarm.Drawing.Rectangle(20, 20, 50, 50);

                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawSubImage(_glbmp, srcRect, i, i, 2f);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawSubImage(_glbmp, srcRect, i, i, 2f);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImageWithBlurX:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawImageWithBlurX(_glbmp, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImageWithBlurX(_glbmp, i, i);
                    i += 50;
                }
            }
            break;

            case T107_1_DrawImageSet.SubImageWithBlurY:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawImageWithBlurY(_glbmp, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImageWithBlurY(_glbmp, i, i);
                    i += 50;
                }

                //
            }
            break;

            case T107_1_DrawImageSet.DrawWithConv3x3:
            {
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop;
                for (int i = 0; i < 400;)
                {
                    //left,top (NOT x,y)
                    _pcx.DrawImageWithConv3x3(_glbmp, Mat3x3ConvGen.sobelHorizontal, i, i);
                    i += 50;
                }
                //
                _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftBottom;
                for (int i = 0; i < 400;)
                {
                    _pcx.DrawImageWithConv3x3(_glbmp, Mat3x3ConvGen.emboss, i, i);
                    i += 50;
                }
            }
            break;
            }
            _pcx.OriginKind = prevOrgKind;//restore
        }