示例#1
0
        public override void Draw(Painter p)
        {
            p.Clear(Drawing.Color.Yellow);

            ////
            ////---reference line--
            p.StrokeColor = Color.Black;
            p.DrawLine(0, 400, 800, 400); //draw reference line
            p.DrawImage(_lionImg, 300, 0);

            int _imgW = _lionImg.Width;
            int _imgH = _lionImg.Height;


            int x_pos = 0;
            for (int i = 0; i < 360; i += 30)
            {

                AffineMat aff = AffineMat.Iden();
                aff.Translate(-_imgW / 2f, -_imgH / 2f);
                aff.Scale(0.5, 0.5);
                aff.RotateDeg(i);
                aff.Translate((_imgW / 2f) + x_pos, _imgH / 2f);

                p.DrawImage(_lionImg, aff);

                x_pos += _imgW / 3;
            }


            using (Tools.BorrowVxs(out var vxs1, out var vxs2))
            using (Tools.BorrowRect(out var rect))
            {
                int x = 5, y = 5, w = 100, h = 100;
                rect.SetRect(x, y, x + w, y + h);
                rect.MakeVxs(vxs1);
                p.Fill(vxs1, Color.Blue);
                //-------------------
                AffineMat af = AffineMat.GetRotateDegMat(30, w / 2f, h / 2f);

                af.TransformToVxs(vxs1, vxs2);
                p.Fill(vxs2, Color.Red);
                //-------------------
            }

        }
示例#2
0
        public override void Draw(Painter p)
        {
            AggPainter painter = p as AggPainter;

            if (painter == null)
            {
                return;
            }

            painter.Clear(Color.White);

            switch (FilterName)
            {
            case FilterName.Unknown:
                painter.RenderSurface.CustomImgSpanGen = null;
                break;

            case FilterName.NearestNeighbor:
                painter.RenderSurface.CustomImgSpanGen = _imgSpanGenNN;
                break;

            default:
                DrawWeightDistributionGraph(p, _lut.WeightArray);
                painter.RenderSurface.CustomImgSpanGen = _imgSpanGenCustom;
                break;
            }

            AffineMat mat = AffineMat.Iden();

            mat.RotateDeg(_rotationDeg, _imgW / 2.0, _imgH / 2.0);
            p.DrawImage(_orgImg, mat);

            if (_thumbnailScaleDown > 0 && _thumbnailScaleDown < 1)
            {
                using (MemBitmap thumbnail = _orgImg.CreateThumbnailWithSuperSamplingTechnique(_thumbnailScaleDown))
                {
                    painter.DrawImage(thumbnail, 400, 300);
                }
            }

            base.Draw(p);
        }
示例#3
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
        }
示例#4
0
        protected override void CreateCustomNotation(EncloseNotation notation,
                                                     float thickness, float w, float h,
                                                     HorizontalStackBox hbox, float maxLeft, float maxTop, float extend, float over,
                                                     EncloseBox encloseBox)
        {
            //notations that only custom lines

            using (Tools.BorrowVxs(out VertexStore vsx1, out VertexStore vsx2))
                using (Tools.BorrowStroke(out Stroke stroke))
                    using (Tools.BorrowPathWriter(vsx1, out PathWriter pathWriter))
                    {
                        var customVsxBox = new MyCustomNotationVsxBox();
                        stroke.LineJoin = LineJoin.Bevel;
                        stroke.Width    = thickness;
                        int useVxs = 1;//default = vxs1
                        switch (notation)
                        {
                        default:
                            useVxs = 0;//not match only lines notation
                            break;

                        case EncloseNotation.actuarial:
                            pathWriter.MoveTo(0, 0);
                            pathWriter.LineTo(w, 0);
                            pathWriter.LineTo(w, h);
                            break;

                        case EncloseNotation.box:
                            pathWriter.MoveTo(0, 0);
                            pathWriter.LineTo(0, h);
                            pathWriter.LineTo(w, h);
                            pathWriter.LineTo(w, 0);
                            pathWriter.LineTo(0, 0);
                            break;

                        case EncloseNotation.left:
                            pathWriter.MoveTo(0, 0);
                            pathWriter.LineTo(0, h);
                            break;

                        case EncloseNotation.right:
                            pathWriter.MoveTo(w, 0);
                            pathWriter.LineTo(w, h);
                            break;

                        case EncloseNotation.top:
                            pathWriter.MoveTo(0, 0);
                            pathWriter.LineTo(w, 0);
                            break;

                        case EncloseNotation.bottom:
                            pathWriter.MoveTo(0, h);
                            pathWriter.LineTo(w, h);
                            break;

                        case EncloseNotation.updiagonalstrike:
                            pathWriter.MoveTo(0, h);
                            pathWriter.LineTo(w, 0);
                            break;

                        case EncloseNotation.downdiagonalstrike:
                            pathWriter.MoveTo(0, 0);
                            pathWriter.LineTo(w, h);
                            break;

                        case EncloseNotation.verticalstrike:
                            pathWriter.MoveTo(w / 2f, 0);
                            pathWriter.LineTo(w / 2f, h);
                            break;

                        case EncloseNotation.horizontalstrike:
                            pathWriter.MoveTo(0, h / 2f);
                            pathWriter.LineTo(w, h / 2f);
                            break;

                        case EncloseNotation.madruwb:
                            pathWriter.MoveTo(w, 0);
                            pathWriter.LineTo(w, h);
                            pathWriter.LineTo(0, h);
                            break;

                        case EncloseNotation.updiagonalarrow:
                            double arrowAngleDegree = Math.Atan(h / w) * 180.0 / Math.PI;
                            double arrowLength      = Math.Sqrt(Math.Pow(h, 2) + Math.Pow(w, 2));//pythagoras

                            float arrowWing = GetPixelScale() * 150;
                            pathWriter.MoveTo(0, 0);
                            pathWriter.LineTo(arrowLength, 0);
                            pathWriter.LineTo(arrowLength - arrowWing, -arrowWing);
                            pathWriter.LineTo(arrowLength - arrowWing, arrowWing);
                            pathWriter.LineTo(arrowLength, 0);

                            AffineMat mat = AffineMat.Iden();
                            mat.RotateDeg(-arrowAngleDegree);
                            mat.Translate(0, h);
                            mat.TransformToVxs(vsx1, vsx2);

                            useVxs = 2;
                            break;

                        case EncloseNotation.phasorangle:
                            float angleWidth  = 640 * GetPixelScale();  //x 637.5
                            float angleHeight = 1160 * GetPixelScale(); //y 1162.5
                            float shiftH      = h - angleHeight;
                            pathWriter.MoveTo(angleWidth, shiftH);
                            pathWriter.LineTo(0, angleHeight + shiftH);
                            pathWriter.LineTo(maxLeft - angleWidth + w, angleHeight + shiftH);

                            customVsxBox.BeforeBaseBox = angleWidth;
                            break;

                        case EncloseNotation.longdiv:
                            GlyphBox ldiv = NewGlyphBox();
                            ldiv.Character = ')';
                            AssignGlyphVxs(ldiv);
                            ldiv.Layout();

                            Box actualDiv = StretchHeightIfStretchable(ldiv, hbox.Height + over);
                            actualDiv.Layout();
                            customVsxBox.NotationBox = actualDiv;
                            float shiftLeft = maxLeft - actualDiv.Width;
                            float shiftTop  = maxTop - over;
                            actualDiv.SetLocation(shiftLeft, -shiftTop - over);
                            pathWriter.MoveTo(shiftLeft, shiftTop);
                            pathWriter.LineTo(shiftLeft + hbox.Width + actualDiv.Width + extend, shiftTop);
                            pathWriter.Stop();

                            customVsxBox.BeforeBaseBox = actualDiv.Width + extend;
                            break;

                        case EncloseNotation.radical:
                            GlyphBox radical = NewGlyphBox();
                            radical.Character = (char)0x221A;
                            AssignGlyphVxs(radical);
                            radical.Layout();

                            Box actualRadical = StretchHeightIfStretchable(radical, hbox.Height + over);
                            actualRadical.Layout();
                            float shiftLeft1 = maxLeft - actualRadical.Width;
                            float shiftTop1  = maxTop - over;
                            actualRadical.SetLocation(shiftLeft1, -shiftTop1 - over);
                            customVsxBox.NotationBox = actualRadical;

                            pathWriter.MoveTo(shiftLeft1 + actualRadical.Width, shiftTop1);
                            pathWriter.LineTo(shiftLeft1 + actualRadical.Width + hbox.Width + extend, shiftTop1);
                            pathWriter.Stop();

                            customVsxBox.BeforeBaseBox = actualRadical.Width + extend;
                            break;

                        case EncloseNotation.roundedbox:
                            using (Tools.BorrowRoundedRect(out var roundedRect))
                            {
                                roundedRect.SetRadius(over, over, over, over, over, over, over, over);
                                roundedRect.SetRect(0, 0, w, h);
                                roundedRect.MakeVxs(vsx1);
                                customVsxBox.CustomVxs = stroke.CreateTrim(vsx1);
                            }
                            customVsxBox.BeforeBaseBox = over;
                            break;

                        case EncloseNotation.circle:
                            using (Tools.BorrowEllipse(out Ellipse ellipse))
                            {
                                float xLength = hbox.Width / 2 + maxLeft;
                                float yLength = hbox.Height / 2 + maxTop;

                                ellipse.Set(xLength, yLength, xLength, yLength);
                                ellipse.MakeVxs(vsx1);
                                customVsxBox.CustomVxs     = stroke.CreateTrim(vsx1);
                                customVsxBox.BeforeBaseBox = maxLeft;
                            }
                            break;
                        }
                        if (useVxs > 0)
                        {
                            if (useVxs == 1)
                            {
                                customVsxBox.CustomVxs = stroke.CreateTrim(vsx1);
                            }
                            else if (useVxs == 2)
                            {
                                customVsxBox.CustomVxs = stroke.CreateTrim(vsx2);
                            }
                            encloseBox.NotationBoxs.Add(customVsxBox);
                        }
                    }
        }
示例#5
0
        public override void Draw(Painter p)
        {


            p.Clear(Drawing.Color.White);
            p.UseLcdEffectSubPixelRendering = false;

            //---red reference line--
            p.StrokeColor = Color.Black;
            p.DrawLine(0, 400, 800, 400); //draw reference line
            p.DrawImage(_lionImg, 300, 0);
            //p.DrawImage(lionImg, 0, 0, 10, 10, 100, 100);

            //
            //p.DrawImage(halfLion, 50, 0);

            int _imgW = _lionImg.Width;
            int _imgH = _lionImg.Height;
            int x_pos = 0;
            int y_pos = 0;


            //1. create new half-size lion image 

            //for (int i = 0; i < 360; i += 30)
            //{
            //    affPlans[0] = AffinePlan.Translate(-_imgW / 2f, -_imgH / 2f);
            //    affPlans[1] = AffinePlan.Scale(1, 1);
            //    affPlans[2] = AffinePlan.Rotate(AggMath.deg2rad(i));
            //    affPlans[3] = AffinePlan.Translate((_imgW / 2f) + x_pos, (_imgH / 2f) + y_pos);
            //    p.DrawImage(halfLion, affPlans);

            //    x_pos += _imgW / 3;
            //}


            x_pos = 0;
            y_pos = 100;


            for (int i = 0; i < 360; i += 30)
            {

                AffineMat aff = AffineMat.Iden();
                aff.Translate(-_imgW / 2f, -_imgH / 2f);
                aff.Scale(0.5, 0.5);
                aff.RotateDeg(i);
                aff.Translate((_imgW / 2f) + x_pos, (_imgH / 2f) + y_pos);

                p.DrawImage(_lionImg, aff);
                x_pos += _imgW / 3;
            }




            //----
            //

            using (Tools.BorrowVxs(out var vxs1, out var vxs2))
            using (Tools.BorrowRect(out var rect))
            {
               
                int x = 5, y = 5, w = 100, h = 100;
                rect.SetRect(x, y, x + w, y + h);
                rect.MakeVxs(vxs1);
                p.Fill(vxs1, Color.Blue);
                //-------------------

                AffineMat mat = AffineMat.GetRotateDegMat(30, w / 2f, h / 2f);

                mat.TransformToVxs(vxs1, vxs2);
                p.Fill(vxs2, Color.Red);
            }
        }
示例#6
0
        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();
        }
示例#7
0
        public override void Draw(Painter p)
        {
            if (UseBitmapExt)
            {
                p.RenderQuality = RenderQuality.Fast;
            }
            else
            {
                p.RenderQuality = RenderQuality.HighQuality;
            }

            int width  = 800;
            int height = 600;

            //clear the image to white
            // draw a circle
            p.Clear(Drawing.Color.White);

            //Ellipse ellipseVxsGen = new Ellipse(0, 0, 100, 50);
            using (Tools.BorrowEllipse(out var ellipseVxsGen))
                using (Tools.BorrowStroke(out var stroke))
                {
                    ellipseVxsGen.Set(0, 0, 100, 50);
                    stroke.Width = 3;



                    for (double angleDegrees = 0; angleDegrees < 180; angleDegrees += 22.5)
                    {
                        //TODO: use AffineMat (stack-base matrix)
                        //var mat = Affine.New(
                        //    AffinePlan.Rotate(MathHelper.DegreesToRadians(angleDegrees)),
                        //    AffinePlan.Translate(width / 2, 150));

                        AffineMat mat = AffineMat.Iden();
                        mat.RotateDeg(angleDegrees);
                        mat.Translate(width / 2, 150);
                        _reusableAff.SetElems(mat);

                        using (Tools.BorrowVxs(out var v1, out var v2, out var v3))
                        {
                            //ellipseVxsGen.MakeVxs(mat, v2);
                            //p.FillColor = Drawing.Color.Yellow;
                            //p.Fill(v2);
                            ////------------------------------------
                            //p.FillColor = Drawing.Color.Blue;
                            //p.Fill(stroke.MakeVxs(v2, v3));
                        }
                    }
                }


            // and a little polygon
            using (Tools.BorrowVxs(out var v1))
                using (Tools.BorrowPathWriter(v1, out PathWriter littlePoly))
                {
                    littlePoly.MoveTo(50, 50);
                    littlePoly.LineTo(150, 50);
                    littlePoly.LineTo(200, 200);
                    littlePoly.LineTo(50, 150);
                    littlePoly.LineTo(50, 50);
                    p.FillColor = Drawing.Color.Blue;
                    p.Fill(v1);
                }
            //---



            //----
            //test draw img



            //
            //g.Render(littlePoly.MakeVertexSnap(), ColorRGBA.Cyan);
            // draw some text
            // draw some text

            //var textPrinter = new TextPrinter();
            //textPrinter.CurrentActualFont = svgFontStore.LoadFont(SvgFontStore.DEFAULT_SVG_FONTNAME, 30);
            //new TypeFacePrinter("Printing from a printer", 30, justification: Justification.Center);

            //VertexStore vxs = textPrinter.CreateVxs("Printing from a printer".ToCharArray());
            //var affTx = Affine.NewTranslation(width / 2, height / 4 * 3);
            //VertexStore s1 = affTx.TransformToVxs(vxs);
            //p.FillColor = Drawing.Color.Black;
            //p.Fill(s1);
            ////g.Render(s1, ColorRGBA.Black);
            //p.FillColor = Drawing.Color.Red;
            //p.Fill(StrokeHelp.MakeVxs(s1, 1));
            ////g.Render(StrokeHelp.MakeVxs(s1, 1), ColorRGBA.Red);
            //var aff2 = Affine.NewMatix(
            //    AffinePlan.Rotate(MathHelper.DegreesToRadians(90)),
            //    AffinePlan.Translate(40, height / 2));
            //p.FillColor = Drawing.Color.Black;
            //p.Fill(aff2.TransformToVertexSnap(vxs));
            ////g.Render(aff2.TransformToVertexSnap(vxs), ColorRGBA.Black);
        }