public override void Fill(VertexStore vxs)
 {
     _canvas.FillGfxPath(
         _fillColor,
         InternalGraphicsPath.CreateGraphicsPath(new VertexStoreSnap(vxs))
         );
 }
 public override void Draw(VertexStoreSnap snap)
 {
     _canvas.DrawGfxPath(
         this._strokeColor,
         InternalGraphicsPath.CreateGraphicsPath(snap)
         );
 }
Beispiel #3
0
        //-----------------------------------------------------------------------------------------------------------------
        public override RenderVx CreateRenderVx(VertexStoreSnap snap)
        {
            //store internal gfx path inside render vx

            //1.
            InternalGraphicsPath p = _igfxPathBuilder.CreateGraphicsPathForRenderVx(snap);

            return(new GLRenderVx(p));
        }
 public override void PaintSeries(VertexStore vxs, Color[] colors, int[] pathIndexs, int numPath)
 {
     //TODO: review here.
     //
     for (int i = 0; i < numPath; ++i)
     {
         _canvas.FillGfxPath(colors[i], InternalGraphicsPath.CreateGraphicsPath(new VertexStoreSnap(vxs, pathIndexs[i])));
     }
 }
        public void FillRoundRect(Color color, float x, float y, float w, float h, float rx, float ry)
        {
            roundRect.SetRect(x, y, x + w, y + h);
            roundRect.SetRadius(rx, ry);
            //create round rect vxs

            var vxs = roundRect.MakeVxs(GetFreeVxs());

            _canvas.FillGfxPath(_fillColor, InternalGraphicsPath.CreateGraphicsPath(new VertexStoreSnap(vxs)));
            ReleaseVxs(ref vxs);
        }
        public override void DrawEllipse(double left, double bottom, double right, double top)
        {
            double x  = (left + right) / 2;
            double y  = (bottom + top) / 2;
            double rx = Math.Abs(right - x);
            double ry = Math.Abs(top - y);

            ellipse.Reset(x, y, rx, ry);
            VertexStore vxs = ellipse.MakeVxs(GetFreeVxs());

            _canvas.DrawGfxPath(_strokeColor, InternalGraphicsPath.CreateGraphicsPath(new VertexStoreSnap(vxs)));
            ReleaseVxs(ref vxs);
        }
        public void DrawRoundRect(float x, float y, float w, float h, float rx, float ry)
        {
            roundRect.SetRect(x, y, x + w, y + h);
            roundRect.SetRadius(rx, ry);
            _aggStroke.Width = this.StrokeWidth;

            var v1 = GetFreeVxs();
            var v2 = GetFreeVxs();

            _aggStroke.MakeVxs(roundRect.MakeVxs(v1), v2);
            _canvas.DrawGfxPath(_strokeColor, InternalGraphicsPath.CreateGraphicsPath(new VertexStoreSnap(v2)));
            ReleaseVxs(ref v2);
            ReleaseVxs(ref v1);
        }
        public override void DrawBezierCurve(float startX, float startY, float endX, float endY, float controlX1, float controlY1, float controlX2, float controlY2)
        {
            var v1 = GetFreeVxs();

            BezierCurve.CreateBezierVxs4(v1,
                                         new PixelFarm.VectorMath.Vector2(startX, startY),
                                         new PixelFarm.VectorMath.Vector2(endX, endY),
                                         new PixelFarm.VectorMath.Vector2(controlX1, controlY1),
                                         new PixelFarm.VectorMath.Vector2(controlY2, controlY2));
            _aggStroke.Width = this.StrokeWidth;

            var v2 = GetFreeVxs();

            _canvas.DrawGfxPath(_canvas.StrokeColor, InternalGraphicsPath.CreateGraphicsPath(new VertexStoreSnap(_aggStroke.MakeVxs(v1, v2))));
            ReleaseVxs(ref v2);
            ReleaseVxs(ref v1);
        }
Beispiel #9
0
        //-------------------------------------------------------------------------------
        public void FillGfxPath(Drawing.Color color, InternalGraphicsPath igpth)
        {
            switch (SmoothMode)
            {
            case CanvasSmoothMode.No:
            {
                List <Figure> figures      = igpth.figures;
                int           subPathCount = figures.Count;
                for (int i = 0; i < subPathCount; ++i)
                {
                    Figure  f        = figures[i];
                    float[] tessArea = f.GetAreaTess(ref this.tessTool);
                    if (tessArea != null)
                    {
                        this.basicFillShader.FillTriangles(tessArea, f.TessAreaTriangleCount, color);
                    }
                }
            }
            break;

            case CanvasSmoothMode.Smooth:
            {
                List <Figure> figures      = igpth.figures;
                int           subPathCount = figures.Count;
                float         prevWidth    = StrokeWidth;

                StrokeColor = color;
                StrokeWidth = 0.5f;
                for (int i = 0; i < subPathCount; ++i)
                {
                    Figure  f        = figures[i];
                    float[] tessArea = f.GetAreaTess(ref this.tessTool);
                    if (tessArea != null)
                    {
                        basicFillShader.FillTriangles(tessArea, f.TessAreaTriangleCount, color);
                        smoothLineShader.DrawTriangleStrips(f.GetSmoothBorders(), f.BorderTriangleStripCount);
                    }
                }
                StrokeWidth = prevWidth;
            }
            break;
            }
        }
        public void DrawGfxPath(Drawing.Color color, InternalGraphicsPath igpth)
        {
            switch (SmoothMode)
            {
            case SmoothMode.No:
            {
                int subPathCount = igpth.FigCount;
                for (int i = 0; i < subPathCount; ++i)
                {
                    Figure  f        = igpth.GetFig(i);
                    float[] coordXYs = f.coordXYs;
                    unsafe
                    {
                        fixed(float *head = &coordXYs[0])
                        {
                            basicFillShader.DrawLineLoopWithVertexBuffer(head, coordXYs.Length / 2, StrokeColor);
                        }
                    }
                }
            }
            break;

            case SmoothMode.Smooth:
            {
                StrokeColor = color;
                StrokeWidth = 1f;

                int subPathCount = igpth.FigCount;
                for (int i = 0; i < subPathCount; ++i)
                {
                    Figure f = igpth.GetFig(i);
                    smoothLineShader.DrawTriangleStrips(f.GetSmoothBorders(smoothBorderBuilder), f.BorderTriangleStripCount);
                }

                //restore back
            }
            break;
            }
        }
Beispiel #11
0
        public void DrawGfxPath(Drawing.Color color, InternalGraphicsPath igpth)
        {
            switch (SmoothMode)
            {
            case CanvasSmoothMode.No:
            {
                List <Figure> figures      = igpth.figures;
                int           subPathCount = figures.Count;
                for (int i = 0; i < subPathCount; ++i)
                {
                    Figure  f        = figures[i];
                    float[] coordXYs = f.coordXYs;
                    unsafe
                    {
                        fixed(float *head = &coordXYs[0])
                        {
                            basicFillShader.DrawLineLoopWithVertexBuffer(head, coordXYs.Length / 2, StrokeColor);
                        }
                    }
                }
            }
            break;

            case CanvasSmoothMode.Smooth:
            {
                StrokeColor = color;
                StrokeWidth = 1f;
                List <Figure> figures      = igpth.figures;
                int           subPathCount = figures.Count;
                for (int i = 0; i < subPathCount; ++i)
                {
                    Figure f = figures[i];
                    smoothLineShader.DrawTriangleStrips(f.GetSmoothBorders(), f.BorderTriangleStripCount);
                }
            }
            break;
            }
        }
 public GLRenderVx(InternalGraphicsPath gxpth)
 {
     this.gxpth = gxpth;
 }
Beispiel #13
0
        //-------------------------------------------------------------------------------
        public void FillGfxPath(Drawing.Color color, InternalGraphicsPath igpth)
        {
            switch (SmoothMode)
            {
                case CanvasSmoothMode.No:
                    {
                        List<Figure> figures = igpth.figures;
                        int subPathCount = figures.Count;
                        for (int i = 0; i < subPathCount; ++i)
                        {
                            Figure f = figures[i];
                            this.basicFillShader.FillTriangles(f.GetAreaTess(ref this.tessTool), f.TessAreaTriangleCount, color);
                        }
                    }
                    break;
                case CanvasSmoothMode.Smooth:
                    {

                        List<Figure> figures = igpth.figures;
                        int subPathCount = figures.Count;
                        float prevWidth = StrokeWidth;
                        StrokeColor = color;
                        StrokeWidth = 0.5f;
                        for (int i = 0; i < subPathCount; ++i)
                        {
                            Figure f = figures[i];
                            basicFillShader.FillTriangles(f.GetAreaTess(ref this.tessTool), f.TessAreaTriangleCount, color);
                            smoothLineShader.DrawTriangleStrips(f.GetSmoothBorders(), f.BorderTriangleStripCount);
                        }
                        StrokeWidth = prevWidth;
                    }
                    break;
            }
        }
Beispiel #14
0
        public void FillGfxPath(Drawing.Brush brush, InternalGraphicsPath igpth)
        {
            switch (brush.BrushKind)
            {
            case Drawing.BrushKind.Solid:
            {
                var solidBrush = brush as PixelFarm.Drawing.SolidBrush;
                FillGfxPath(solidBrush.Color, igpth);
            }
            break;

            case Drawing.BrushKind.LinearGradient:
            case Drawing.BrushKind.Texture:
            {
                List <Figure> figures = igpth.figures;
                int           m       = figures.Count;
                for (int b = 0; b < m; ++b)
                {
                    Figure fig = figures[b];
                    GL.ClearStencil(0);         //set value for clearing stencil buffer
                    //actual clear here
                    GL.Clear(ClearBufferMask.StencilBufferBit);
                    //-------------------
                    //disable rendering to color buffer
                    GL.ColorMask(false, false, false, false);
                    //start using stencil
                    GL.Enable(EnableCap.StencilTest);
                    //place a 1 where rendered
                    GL.StencilFunc(StencilFunction.Always, 1, 1);
                    //replace where rendered
                    GL.StencilOp(StencilOp.Replace, StencilOp.Replace, StencilOp.Replace);
                    //render  to stencill buffer
                    //-----------------

                    float[] tessArea = fig.GetAreaTess(ref this.tessTool);
                    //-------------------------------------
                    if (tessArea != null)
                    {
                        this.basicFillShader.FillTriangles(tessArea, fig.TessAreaTriangleCount, PixelFarm.Drawing.Color.Black);
                    }
                    //--------------------------------------
                    //render color
                    //--------------------------------------
                    //reenable color buffer
                    GL.ColorMask(true, true, true, true);
                    //where a 1 was not rendered
                    GL.StencilFunc(StencilFunction.Equal, 1, 1);
                    //freeze stencill buffer
                    GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Keep);
                    //------------------------------------------
                    //we already have valid ps from stencil step
                    //------------------------------------------

                    //-------------------------------------------------------------------------------------
                    //1.  we draw only alpha chanel of this black color to destination color
                    //so we use  BlendFuncSeparate  as follow ...
                    //-------------------------------------------------------------------------------------
                    //1.  we draw only alpha channel of this black color to destination color
                    //so we use  BlendFuncSeparate  as follow ...
                    GL.ColorMask(false, false, false, true);
                    //GL.BlendFuncSeparate(
                    //     BlendingFactorSrc.DstColor, BlendingFactorDest.DstColor, //the same
                    //     BlendingFactorSrc.One, BlendingFactorDest.Zero);

                    //use alpha chanel from source***
                    GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.Zero);
                    float[] smoothBorder = fig.GetSmoothBorders();
                    invertAlphaFragmentShader.DrawTriangleStrips(smoothBorder, fig.BorderTriangleStripCount);
                    //at this point alpha component is fill in to destination
                    //-------------------------------------------------------------------------------------
                    //2. then fill again!,
                    //we use alpha information from dest,
                    //so we set blend func to ... GL.BlendFunc(BlendingFactorSrc.DstAlpha, BlendingFactorDest.OneMinusDstAlpha)
                    GL.ColorMask(true, true, true, true);
                    GL.BlendFunc(BlendingFactorSrc.DstAlpha, BlendingFactorDest.OneMinusDstAlpha);
                    {
                        //draw box*** of gradient color
                        switch (brush.BrushKind)
                        {
                        case Drawing.BrushKind.LinearGradient:
                        {
                            var     linearGradientBrush = brush as PixelFarm.Drawing.LinearGradientBrush;
                            var     colors = linearGradientBrush.GetColors();
                            var     points = linearGradientBrush.GetStopPoints();
                            float[] v2f, color4f;
                            GLGradientColorProvider.CalculateLinearGradientVxs2(
                                points[0].X, points[0].Y,
                                points[1].X, points[1].Y,
                                colors[0],
                                colors[1], out v2f, out color4f);
                            rectFillShader.Render(v2f, color4f);
                        }
                        break;

                        case Drawing.BrushKind.Texture:
                        {
                            //draw texture image ***
                            PixelFarm.Drawing.TextureBrush tbrush = (PixelFarm.Drawing.TextureBrush)brush;
                            GLBitmap bmpTexture = PixelFarm.Drawing.Image.GetCacheInnerImage(tbrush.TextureImage) as GLBitmap;
                            //TODO: review here
                            //where text start?
                            this.DrawImage(bmpTexture, 0, 300);
                        }
                        break;
                        }
                    }
                    //restore back
                    //3. switch to normal blending mode
                    GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
                    GL.Disable(EnableCap.StencilTest);
                }
            }
            break;
            }
        }
 public RenderVx CreatePolygonRenderVx(float[] xycoords)
 {
     //store internal gfx path inside render vx
     return(new GLRenderVx(InternalGraphicsPath.CreatePolygonGraphicsPath(xycoords)));
 }
        //---------------------------------------------------------------------
        public void DrawArc(float fromX, float fromY, float endX, float endY,
                            float xaxisRotationAngleDec, float rx, float ry,
                            SvgArcSize arcSize, SvgArcSweep arcSweep)
        {
            //------------------
            //SVG Elliptical arc ...
            //from Apache Batik
            //-----------------

            CenterFormArc centerFormArc = new CenterFormArc();

            ComputeArc2(fromX, fromY, rx, ry,
                        DegToRad(xaxisRotationAngleDec),
                        arcSize == SvgArcSize.Large,
                        arcSweep == SvgArcSweep.Negative,
                        endX, endY, ref centerFormArc);
            arcTool.Init(centerFormArc.cx, centerFormArc.cy, rx, ry,
                         centerFormArc.radStartAngle,
                         (centerFormArc.radStartAngle + centerFormArc.radSweepDiff));

            VertexStore v1       = GetFreeVxs();
            bool        stopLoop = false;

            foreach (VertexData vertexData in arcTool.GetVertexIter())
            {
                switch (vertexData.command)
                {
                case VertexCmd.NoMore:
                    stopLoop = true;
                    break;

                default:
                    v1.AddVertex(vertexData.x, vertexData.y, vertexData.command);
                    //yield return vertexData;
                    break;
                }
                //------------------------------
                if (stopLoop)
                {
                    break;
                }
            }

            double scaleRatio = 1;

            if (centerFormArc.scaleUp)
            {
                int    vxs_count = v1.Count;
                double px0, py0, px_last, py_last;
                v1.GetVertex(0, out px0, out py0);
                v1.GetVertex(vxs_count - 1, out px_last, out py_last);
                double distance1 = Math.Sqrt((px_last - px0) * (px_last - px0) + (py_last - py0) * (py_last - py0));
                double distance2 = Math.Sqrt((endX - fromX) * (endX - fromX) + (endY - fromY) * (endY - fromY));
                if (distance1 < distance2)
                {
                    scaleRatio = distance2 / distance1;
                }
                else
                {
                }
            }

            if (xaxisRotationAngleDec != 0)
            {
                //also  rotate
                if (centerFormArc.scaleUp)
                {
                    var mat = PixelFarm.Agg.Transform.Affine.NewMatix(
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Translate, -centerFormArc.cx, -centerFormArc.cy),
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Scale, scaleRatio, scaleRatio),
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Rotate, DegToRad(xaxisRotationAngleDec)),
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Translate, centerFormArc.cx, centerFormArc.cy));
                    var v2 = GetFreeVxs();
                    mat.TransformToVxs(v1, v2);
                    ReleaseVxs(ref v1);
                    v1 = v2;
                }
                else
                {
                    //not scalue
                    var mat = PixelFarm.Agg.Transform.Affine.NewMatix(
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Translate, -centerFormArc.cx, -centerFormArc.cy),
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Rotate, DegToRad(xaxisRotationAngleDec)),
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Translate, centerFormArc.cx, centerFormArc.cy));
                    var v2 = GetFreeVxs();
                    mat.TransformToVxs(v1, v2);
                    ReleaseVxs(ref v1);
                    v1 = v2;
                }
            }
            else
            {
                //no rotate
                if (centerFormArc.scaleUp)
                {
                    var mat = PixelFarm.Agg.Transform.Affine.NewMatix(
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Translate, -centerFormArc.cx, -centerFormArc.cy),
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Scale, scaleRatio, scaleRatio),
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Translate, centerFormArc.cx, centerFormArc.cy));
                    var v2 = GetFreeVxs();
                    mat.TransformToVxs(v1, v2);
                    ReleaseVxs(ref v1);
                    v1 = v2;
                }
            }

            _aggStroke.Width = this.StrokeWidth;


            var v3 = _aggStroke.MakeVxs(v1, GetFreeVxs());

            _canvas.DrawGfxPath(_canvas.StrokeColor, InternalGraphicsPath.CreateGraphicsPath(new VertexStoreSnap(v3)));

            ReleaseVxs(ref v3);
            ReleaseVxs(ref v1);
        }
 //-----------------------------------------------------------------------------------------------------------------
 public override RenderVx CreateRenderVx(VertexStoreSnap snap)
 {
     //store internal gfx path inside render vx
     return(new GLRenderVx(InternalGraphicsPath.CreateGraphicsPath(snap)));
 }
Beispiel #18
0
        public void FillGfxPath(Drawing.Brush brush, InternalGraphicsPath igpth)
        {
            switch (brush.BrushKind)
            {
                case Drawing.BrushKind.Solid:
                    {
                        var solidBrush = brush as PixelFarm.Drawing.SolidBrush;
                        FillGfxPath(solidBrush.Color, igpth);
                    }
                    break;
                case Drawing.BrushKind.LinearGradient:
                case Drawing.BrushKind.Texture:
                    {
                        List<Figure> figures = igpth.figures;
                        int m = figures.Count;
                        for (int b = 0; b < m; ++b)
                        {
                            Figure fig = figures[b];
                            GL.ClearStencil(0); //set value for clearing stencil buffer 
                            //actual clear here
                            GL.Clear(ClearBufferMask.StencilBufferBit);
                            //-------------------
                            //disable rendering to color buffer
                            GL.ColorMask(false, false, false, false);
                            //start using stencil
                            GL.Enable(EnableCap.StencilTest);
                            //place a 1 where rendered
                            GL.StencilFunc(StencilFunction.Always, 1, 1);
                            //replace where rendered
                            GL.StencilOp(StencilOp.Replace, StencilOp.Replace, StencilOp.Replace);
                            //render  to stencill buffer
                            //-----------------

                            float[] tessArea = fig.GetAreaTess(ref this.tessTool);
                            //-------------------------------------   
                            this.basicFillShader.FillTriangles(tessArea, fig.TessAreaTriangleCount, PixelFarm.Drawing.Color.Black);
                            //-------------------------------------- 
                            //render color
                            //--------------------------------------  
                            //reenable color buffer 
                            GL.ColorMask(true, true, true, true);
                            //where a 1 was not rendered
                            GL.StencilFunc(StencilFunction.Equal, 1, 1);
                            //freeze stencill buffer
                            GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Keep);
                            //------------------------------------------
                            //we already have valid ps from stencil step
                            //------------------------------------------

                            //-------------------------------------------------------------------------------------
                            //1.  we draw only alpha chanel of this black color to destination color
                            //so we use  BlendFuncSeparate  as follow ... 
                            //-------------------------------------------------------------------------------------
                            //1.  we draw only alpha channel of this black color to destination color
                            //so we use  BlendFuncSeparate  as follow ... 
                            GL.ColorMask(false, false, false, true);
                            //GL.BlendFuncSeparate(
                            //     BlendingFactorSrc.DstColor, BlendingFactorDest.DstColor, //the same
                            //     BlendingFactorSrc.One, BlendingFactorDest.Zero);

                            //use alpha chanel from source***
                            GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.Zero);
                            float[] smoothBorder = fig.GetSmoothBorders();
                            invertAlphaFragmentShader.DrawTriangleStrips(smoothBorder, fig.BorderTriangleStripCount);
                            //at this point alpha component is fill in to destination 
                            //-------------------------------------------------------------------------------------
                            //2. then fill again!, 
                            //we use alpha information from dest, 
                            //so we set blend func to ... GL.BlendFunc(BlendingFactorSrc.DstAlpha, BlendingFactorDest.OneMinusDstAlpha)    
                            GL.ColorMask(true, true, true, true);
                            GL.BlendFunc(BlendingFactorSrc.DstAlpha, BlendingFactorDest.OneMinusDstAlpha);
                            {
                                //draw box*** of gradient color
                                switch (brush.BrushKind)
                                {
                                    case Drawing.BrushKind.LinearGradient:
                                        {
                                            var linearGradientBrush = brush as PixelFarm.Drawing.LinearGradientBrush;
                                            var colors = linearGradientBrush.GetColors();
                                            var points = linearGradientBrush.GetStopPoints();
                                            float[] v2f, color4f;
                                            GLGradientColorProvider.CalculateLinearGradientVxs2(
                                                 points[0].X, points[0].Y,
                                                 points[1].X, points[1].Y,
                                                 colors[0],
                                                 colors[1], out v2f, out color4f);
                                            rectFillShader.Render(v2f, color4f);
                                        }
                                        break;
                                    case Drawing.BrushKind.Texture:
                                        {
                                            //draw texture image ***
                                            PixelFarm.Drawing.TextureBrush tbrush = (PixelFarm.Drawing.TextureBrush)brush;
                                            GLBitmap bmpTexture = PixelFarm.Drawing.Image.GetCacheInnerImage(tbrush.TextureImage) as GLBitmap;
                                            //TODO: review here 
                                            //where text start?
                                            this.DrawImage(bmpTexture, 0, 300);
                                        }
                                        break;
                                }
                            }
                            //restore back 
                            //3. switch to normal blending mode 
                            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
                            GL.Disable(EnableCap.StencilTest);
                        }
                    }
                    break;
            }
        }
Beispiel #19
0
 public void DrawGfxPath(Drawing.Color color, InternalGraphicsPath igpth)
 {
     switch (SmoothMode)
     {
         case CanvasSmoothMode.No:
             {
                 List<Figure> figures = igpth.figures;
                 int subPathCount = figures.Count;
                 for (int i = 0; i < subPathCount; ++i)
                 {
                     Figure f = figures[i];
                     float[] coordXYs = f.coordXYs;
                     unsafe
                     {
                         fixed (float* head = &coordXYs[0])
                         {
                             basicFillShader.DrawLineLoopWithVertexBuffer(head, coordXYs.Length / 2, StrokeColor);
                         }
                     }
                 }
             }
             break;
         case CanvasSmoothMode.Smooth:
             {
                 StrokeColor = color;
                 StrokeWidth = 1f;
                 List<Figure> figures = igpth.figures;
                 int subPathCount = figures.Count;
                 for (int i = 0; i < subPathCount; ++i)
                 {
                     Figure f = figures[i];
                     smoothLineShader.DrawTriangleStrips(f.GetSmoothBorders(), f.BorderTriangleStripCount);
                 }
             }
             break;
     }
 }
Beispiel #20
0
 public GLRenderVx(InternalGraphicsPath gxpth)
 {
     this.gxpth = gxpth;
 }
        public void FillGfxPath(Drawing.Color color, InternalGraphicsPath igpth)
        {
            switch (SmoothMode)
            {
            case SmoothMode.No:
            {
                int subPathCount = igpth.FigCount;

                for (int i = 0; i < subPathCount; ++i)
                {
                    Figure f = igpth.GetFig(i);
                    if (f.SupportVertexBuffer)
                    {
                        basicFillShader.FillTriangles(
                            f.GetAreaTessAsVBO(tessTool),
                            f.TessAreaVertexCount,
                            color);
                    }
                    else
                    {
                        float[] tessArea = f.GetAreaTess(this.tessTool);
                        if (tessArea != null)
                        {
                            this.basicFillShader.FillTriangles(tessArea, f.TessAreaVertexCount, color);
                        }
                    }
                }
            }
            break;

            case SmoothMode.Smooth:
            {
                int           subPathCount = igpth.FigCount;
                float         saved_Width  = StrokeWidth;
                Drawing.Color saved_Color  = StrokeColor;
                //temp set stroke width to 2 amd stroke color
                //to the same as bg color (for smooth border).
                //and it will be set back later.
                //
                StrokeColor = color;
                StrokeWidth = 1.5f;         //TODO: review this ***
                //
                float[] tessArea;
                for (int i = 0; i < subPathCount; ++i)
                {
                    //draw each sub-path
                    Figure f = igpth.GetFig(i);
                    if (f.SupportVertexBuffer)
                    {
                        //TODO: review here again
                        //draw area
                        basicFillShader.FillTriangles(
                            f.GetAreaTessAsVBO(tessTool),
                            f.TessAreaVertexCount,
                            color);
                        //draw smooth border
                        smoothLineShader.DrawTriangleStrips(
                            f.GetSmoothBorders(smoothBorderBuilder),
                            f.BorderTriangleStripCount);
                    }
                    else
                    {
                        if ((tessArea = f.GetAreaTess(this.tessTool)) != null)
                        {
                            //draw area
                            basicFillShader.FillTriangles(tessArea, f.TessAreaVertexCount, color);
                            //draw smooth border
                            smoothLineShader.DrawTriangleStrips(
                                f.GetSmoothBorders(smoothBorderBuilder),
                                f.BorderTriangleStripCount);
                        }
                    }
                }
                //restore stroke width and color
                StrokeWidth = saved_Width;         //restore back
                StrokeColor = saved_Color;
            }
            break;
            }
        }