예제 #1
0
        public static RectInt GetBoundingRect(VertexStoreSnap vs)
        {
            int  x1, y1, x2, y2;
            bool rValue = GetBoundingRect(vs, out x1, out y1, out x2, out y2);

            return(new RectInt(x1, y1, x2, y2));
        }
예제 #2
0
        public void Render(VertexStoreSnap vertexSource, double x, double y, ColorRGBA color)
        {
            var inputVxs = vertexSource.GetInternalVxs();
            var vxs      = Affine.TranslateTransformToVxs(vertexSource, x, y);//Affine.NewTranslation(x, y).TransformToVxs (inputVxs);

            Render(vxs, color);
        }
예제 #3
0
        /// <summary>
        /// we do NOT store vxs/vxsSnap
        /// </summary>
        /// <param name="vxsSnap"></param>
        /// <param name="color"></param>
        public override void Render(VertexStoreSnap vxsSnap, Drawing.Color color)
        {
            //reset rasterizer before render each vertextSnap
            //-----------------------------
            sclineRas.Reset();
            Affine transform = this.CurrentTransformMatrix;

            if (!transform.IsIdentity())
            {
                var v1 = transform.TransformToVxs(vxsSnap, GetFreeVxs());
                sclineRas.AddPath(v1);
                ReleaseVxs(ref v1);
                //-------------------------
                //since sclineRas do NOT store vxs
                //then we can reuse the vxs***
                //-------------------------
            }
            else
            {
                sclineRas.AddPath(vxsSnap);
            }
            sclineRasToBmp.RenderWithColor(destImageReaderWriter, sclineRas, sclinePack8, color);
            unchecked { destImageChanged++; };
            //-----------------------------
        }
예제 #4
0
        public static void Fill(this CanvasPainter p, VertexStoreSnap snap, Color color)
        {
            Color prevColor = p.FillColor;

            p.FillColor = color;
            p.Fill(snap);
            p.FillColor = prevColor;
        }
예제 #5
0
        public static void Draw(this CanvasPainter p, VertexStoreSnap vxs, Color color)
        {
            Color prevColor = p.StrokeColor;

            p.StrokeColor = color;
            p.Draw(vxs);
            p.StrokeColor = prevColor;
        }
예제 #6
0
        //-----------------------------------------------------bounding_rect_single
        //template<class VertexSource, class CoordT>
        static bool GetBoundingRect(
            VertexStoreSnap vs,
            out int x1, out int y1,
            out int x2, out int y2)
        {
            double x_d = 0;
            double y_d = 0;

            int  x     = 0;
            int  y     = 0;
            bool first = true;

            x1 = 1;
            y1 = 1;
            x2 = 0;
            y2 = 0;

            var vsnapIter = vs.GetVertexSnapIter();

            VertexCmd PathAndFlags;

            while (!VertexHelper.IsEmpty(PathAndFlags = vsnapIter.GetNextVertex(out x_d, out y_d)))
            {
                x = (int)x_d;
                y = (int)y_d;
                if (VertexHelper.IsVertextCommand(PathAndFlags))
                {
                    if (first)
                    {
                        x1    = x;
                        y1    = y;
                        x2    = x;
                        y2    = y;
                        first = false;
                    }
                    else
                    {
                        if (x < x1)
                        {
                            x1 = x;
                        }
                        if (y < y1)
                        {
                            y1 = y;
                        }
                        if (x > x2)
                        {
                            x2 = x;
                        }
                        if (y > y2)
                        {
                            y2 = y;
                        }
                    }
                }
            }
            return(x1 <= x2 && y1 <= y2);
        }
예제 #7
0
        public static bool GetBoundingRect(VertexStoreSnap vs, ref RectD rect)
        {
            double x1, y1, x2, y2;
            bool   rValue = GetBoundingRectSingle(vs, out x1, out y1, out x2, out y2);

            rect.Left   = x1;
            rect.Bottom = y1;
            rect.Right  = x2;
            rect.Top    = y2;
            return(rValue);
        }
        /// <summary>
        /// we do NOT store vxs, return original outputVxs
        /// </summary>
        /// <param name="src"></param>
        /// <param name="outputVxs"></param>
        /// <returns></returns>
        public static VertexStore TransformToVxs(this Affine aff, VertexStoreSnap src, VertexStore outputVxs)
        {
            var       snapIter = src.GetVertexSnapIter();
            VertexCmd cmd;
            double    x, y;

            while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.NoMore)
            {
                aff.Transform(ref x, ref y);
                outputVxs.AddVertex(x, y, cmd);
            }
            return(outputVxs);
        }
예제 #9
0
        /// <summary>
        /// fill vertex store, we do NOT store snap
        /// </summary>
        /// <param name="vxs"></param>
        /// <param name="c"></param>
        public override void Fill(VertexStoreSnap snap)
        {
            //BitmapExt
            if (this._renderQuality == RenderQualtity.Fast)
            {
                FillWithBxt(snap);
                return;
            }

            //Agg
            sclineRas.AddPath(snap);
            sclineRasToBmp.RenderWithColor(this._aggsx.DestImage, sclineRas, scline, fillColor);
        }
        public static VertexStore TransformToVxs(this Perspective perspecitveTx, VertexStoreSnap snap, VertexStore vxs)
        {
            var       vsnapIter = snap.GetVertexSnapIter();
            double    x, y;
            VertexCmd cmd;

            do
            {
                cmd = vsnapIter.GetNextVertex(out x, out y);
                perspecitveTx.Transform(ref x, ref y);
                vxs.AddVertex(x, y, cmd);
            } while (!VertexHelper.IsEmpty(cmd));
            return(vxs);
        }
예제 #11
0
 /// <summary>
 /// we do NOT store vxsSnap
 /// </summary>
 /// <param name="vxsSnap"></param>
 /// <returns></returns>
 public static SKPath CreateGraphicsPath(VertexStoreSnap vxsSnap)
 {
     VertexSnapIter vxsIter = vxsSnap.GetVertexSnapIter();
     double prevX = 0;
     double prevY = 0;
     double prevMoveToX = 0;
     double prevMoveToY = 0;
     //var brush_path = new System.Drawing.Drawing2D.GraphicsPath(FillMode.Winding);//*** winding for overlapped path  
     var brushPath = new SKPath();
     for (;;)
     {
         double x, y;
         VertexCmd cmd = vxsIter.GetNextVertex(out x, out y);
         switch (cmd)
         {
             case PixelFarm.Agg.VertexCmd.MoveTo:
                 prevMoveToX = prevX = x;
                 prevMoveToY = prevY = y;
                 brushPath.MoveTo((float)x, (float)y);
                 break;
             case PixelFarm.Agg.VertexCmd.LineTo:
                 //brushPath.AddLine((float)prevX, (float)prevY, (float)x, (float)y);
                 brushPath.LineTo((float)x, (float)y);
                 prevX = x;
                 prevY = y;
                 break;
             case PixelFarm.Agg.VertexCmd.CloseAndEndFigure:
                 //from current point                         
                 //brushPath.AddLine((float)prevX, (float)prevY, (float)prevMoveToX, (float)prevMoveToY);
                 brushPath.LineTo((float)prevMoveToX, (float)prevMoveToY);
                 prevX = prevMoveToX;
                 prevY = prevMoveToY;
                 //brushPath.CloseFigure();
                 brushPath.Close();
                 break;
             case PixelFarm.Agg.VertexCmd.EndFigure:
                 goto EXIT_LOOP;
             case PixelFarm.Agg.VertexCmd.Stop:
                 goto EXIT_LOOP;
             default:
                 throw new NotSupportedException();
         }
     }
     EXIT_LOOP:
     return brushPath;
 }
예제 #12
0
        public override void Render(VertexStoreSnap vertextSnap, ColorRGBA color)
        {
            //reset rasterizer before render each vertextSnap
            //-----------------------------
            sclineRas.Reset();
            Affine transform = this.CurrentTransformMatrix;

            if (!transform.IsIdentity())
            {
                sclineRas.AddPath(transform.TransformToVxs(vertextSnap));
            }
            else
            {
                sclineRas.AddPath(vertextSnap);
            }
            sclineRasToBmp.RenderWithColor(destImageReaderWriter, sclineRas, sclinePack8, color);
            unchecked { destImageChanged++; };
            //-----------------------------
        }
예제 #13
0
        public void AddPath(VertexStoreSnap snap)
        {
            double x = 0;
            double y = 0;

            if (m_cellAARas.Sorted)
            {
                Reset();
            }

            if (snap.VxsHasMoreThanOnePart)
            {
                //****
                //render all parts
                VertexStore vxs = snap.GetInternalVxs();
                int         j   = vxs.Count;

                for (int i = 0; i < j; ++i)
                {
                    var cmd = vxs.GetVertex(i, out x, out y);
                    if (cmd != VertexCmd.Stop)
                    {
                        AddVertex(cmd, x, y);
                    }
                }
            }
            else
            {
                VertexSnapIter snapIter = snap.GetVertexSnapIter();
                VertexCmd      cmd;
                int            dbugVertexCount = 0;

                while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
                {
                    dbugVertexCount++;
                    AddVertex(cmd, x, y);
                }
            }
        }
예제 #14
0
 //------------------------------------------------------------------------
 /// <summary>
 /// we do NOT store vxs
 /// </summary>
 /// <param name="vertexSource"></param>
 /// <param name="c"></param>
 public abstract void Render(VertexStoreSnap vertexSource, Drawing.Color c);
예제 #15
0
 //------------------------------------------------------------------------
 /// <summary>
 /// we do NOT store vxs
 /// </summary>
 /// <param name="vertexSource"></param>
 /// <param name="c"></param>
 public abstract void Render(VertexStoreSnap vertexSource, Drawing.Color c);
예제 #16
0
 public override RenderVx CreateRenderVx(VertexStoreSnap snap)
 {
     return(new AggRenderVx(snap));
 }
예제 #17
0
 internal VertexSnapIter(VertexStoreSnap vsnap)
 {
     this.vxs = vsnap.GetInternalVxs();
     this.currentIterIndex = vsnap.StartAt;
 }
예제 #18
0
 public static void DrawVxsSnap(SKCanvas g, VertexStoreSnap vxsSnap, SKPaint stroke)
 {
     using (var p = CreateGraphicsPath(vxsSnap))
     {
         g.DrawPath(p, stroke);
     }
 }
예제 #19
0
        /// <summary>
        /// we do NOT store snap ***
        /// </summary>
        /// <param name="snap"></param>
        public void AddPath(VertexStoreSnap snap)
        {
            //-----------------------------------------------------
            //*** we extract vertext command and coord(x,y) from
            //the snap but not store the snap inside rasterizer
            //-----------------------------------------------------

            double x = 0;
            double y = 0;

            if (m_cellAARas.Sorted)
            {
                Reset();
            }
            float offsetOrgX = OffsetOriginX;
            float offsetOrgY = OffsetOriginY;


            VertexSnapIter snapIter = snap.GetVertexSnapIter();
            VertexCmd      cmd;

#if DEBUG
            int dbugVertexCount = 0;
#endif

            if (ExtendX3ForSubPixelRendering)
            {
                while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.NoMore)
                {
#if DEBUG
                    dbugVertexCount++;
#endif
                    //---------------------------------------------
                    //NOTE: we scale horizontal 3 times.
                    //subpixel renderer will shrink it to 1
                    //---------------------------------------------
                    AddVertex(cmd, (x + offsetOrgX) * 3, y + offsetOrgY);
                }
            }
            else
            {
                while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.NoMore)
                {
#if DEBUG
                    dbugVertexCount++;
#endif

                    AddVertex(cmd, x + offsetOrgX, y + offsetOrgY);
                }
            }


            //            if (snap.VxsHasMoreThanOnePart)
            //            {
            //                //****

            //                //render all parts
            //                VertexStore vxs = snap.GetInternalVxs();
            //                int j = vxs.Count;

            //                if (UseSubPixelRendering)
            //                {
            //                    for (int i = 0; i < j; ++i)
            //                    {
            //                        var cmd = vxs.GetVertex(i, out x, out y);
            //                        if (cmd != VertexCmd.Stop)
            //                        {
            //                            //AddVertext 1 of 4
            //                            AddVertex(cmd, (x + offsetOrgX) * 3, y + offsetOrgY);
            //                        }
            //                    }
            //                }
            //                else
            //                {
            //                    for (int i = 0; i < j; ++i)
            //                    {
            //                        var cmd = vxs.GetVertex(i, out x, out y);
            //                        if (cmd != VertexCmd.Stop)
            //                        {
            //                            //AddVertext 2 of 4
            //                            AddVertex(cmd, x + offsetOrgX, y + offsetOrgY);
            //                        }
            //                    }
            //                }
            //            }
            //            else
            //            {
            //                VertexSnapIter snapIter = snap.GetVertexSnapIter();
            //                VertexCmd cmd;
            //#if DEBUG
            //                int dbugVertexCount = 0;
            //#endif
            //                if (UseSubPixelRendering)
            //                {
            //                    while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
            //                    {
            //#if DEBUG
            //                        dbugVertexCount++;
            //#endif
            //                        //AddVertext 3 of 4
            //                        AddVertex(cmd, (x + offsetOrgX) * 3, y + offsetOrgY);
            //                    }

            //                }
            //                else
            //                {

            //                    while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
            //                    {
            //#if DEBUG
            //                        dbugVertexCount++;
            //#endif
            //                        //AddVertext 4 of 4
            //                        AddVertex(cmd, x + offsetOrgX, y + offsetOrgY);
            //                    }
            //                }
            //            }
        }
예제 #20
0
 //------------------------------------------------------------------------
 //render vertices
 public abstract void Render(VertexStoreSnap vertexSource, ColorRGBA colorBytes);
        /// <summary>
        /// we do NOT store snap ***
        /// </summary>
        /// <param name="snap"></param>
        public void AddPath(VertexStoreSnap snap)
        {
            //-----------------------------------------------------
            //*** we extract vertext command and coord(x,y) from
            //the snap but not store the snap inside rasterizer
            //-----------------------------------------------------

            double x = 0;
            double y = 0;
            if (m_cellAARas.Sorted) { Reset(); }
            float offsetOrgX = OffsetOriginX;
            float offsetOrgY = OffsetOriginY;

            if (snap.VxsHasMoreThanOnePart)
            {
                //****
                //render all parts
                VertexStore vxs = snap.GetInternalVxs();
                int j = vxs.Count;
                for (int i = 0; i < j; ++i)
                {
                    var cmd = vxs.GetVertex(i, out x, out y);
                    if (cmd != VertexCmd.Stop)
                    {
                        AddVertex(cmd, x + offsetOrgX, y + offsetOrgY);
                    }
                }
            }
            else
            {
                VertexSnapIter snapIter = snap.GetVertexSnapIter();
                VertexCmd cmd;
#if DEBUG
                int dbugVertexCount = 0;
#endif
                while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
                {
#if DEBUG
                    dbugVertexCount++;
#endif
                    AddVertex(cmd, x + offsetOrgX, y + offsetOrgY);
                }
            }
        }
예제 #22
0
        /// <summary>
        /// we do NOT store vxs/vxsSnap
        /// </summary>
        /// <param name="vxsSnap"></param>
        /// <param name="color"></param>
        public override void Render(VertexStoreSnap vxsSnap, Drawing.Color color)
        {
            //reset rasterizer before render each vertextSnap 
            //-----------------------------
            sclineRas.Reset();
            Affine transform = this.CurrentTransformMatrix;
            if (!transform.IsIdentity())
            {

                var v1 = transform.TransformToVxs(vxsSnap, GetFreeVxs());
                sclineRas.AddPath(v1);
                ReleaseVxs(ref v1);
                //-------------------------
                //since sclineRas do NOT store vxs
                //then we can reuse the vxs***
                //-------------------------
            }
            else
            {
                sclineRas.AddPath(vxsSnap);
            }
            sclineRasToBmp.RenderWithColor(destImageReaderWriter, sclineRas, sclinePack8, color);
            unchecked { destImageChanged++; };
            //-----------------------------
        }
예제 #23
0
 public override RenderVx CreateRenderVx(VertexStoreSnap snap)
 {
     return new AggRenderVx(snap);
 }
예제 #24
0
 internal VertexSnapIter(VertexStoreSnap vsnap)
 {
     this.vxs = vsnap.GetInternalVxs();
     this.currentIterIndex = vsnap.StartAt;
 }
예제 #25
0
 /// <summary>
 /// fill vertex store, we do NOT store snap
 /// </summary>
 /// <param name="vxs"></param>
 /// <param name="c"></param>
 public override void Fill(VertexStoreSnap snap)
 {
     sclineRas.AddPath(snap);
     sclineRasToBmp.RenderWithColor(this.gx.DestImage, sclineRas, scline, fillColor);
 }
예제 #26
0
 public abstract RenderVx CreateRenderVx(VertexStoreSnap snap);
예제 #27
0
 public abstract void Draw(VertexStoreSnap vxs);
예제 #28
0
        //-------------------------------------------------------

        /// <summary>
        /// fill vertex store
        /// </summary>
        /// <param name="vxs"></param>
        /// <param name="c"></param>
        public void Fill(VertexStoreSnap snap)
        {
            sclineRas.AddPath(snap);
            sclineRasToBmp.RenderWithColor(this.gx.DestImage, sclineRas, scline, fillColor);
        }
예제 #29
0
        public static InternalGraphicsPath CreateGraphicsPath(VertexStoreSnap vxsSnap)
        {
            VertexSnapIter vxsIter = vxsSnap.GetVertexSnapIter();
            double prevX = 0;
            double prevY = 0;
            double prevMoveToX = 0;
            double prevMoveToY = 0;
            //TODO: reivew here 
            //about how to reuse this list
            List<List<float>> allXYlist = new List<List<float>>(); //all include sub path
            List<float> xylist = new List<float>();
            allXYlist.Add(xylist);
            bool isAddToList = true;
            for (; ; )
            {
                double x, y;
                VertexCmd cmd = vxsIter.GetNextVertex(out x, out y);
                switch (cmd)
                {
                    case PixelFarm.Agg.VertexCmd.MoveTo:
                        if (!isAddToList)
                        {
                            allXYlist.Add(xylist);
                            isAddToList = true;
                        }
                        prevMoveToX = prevX = x;
                        prevMoveToY = prevY = y;
                        xylist.Add((float)x);
                        xylist.Add((float)y);
                        break;
                    case PixelFarm.Agg.VertexCmd.LineTo:
                        xylist.Add((float)x);
                        xylist.Add((float)y);
                        prevX = x;
                        prevY = y;
                        break;
                    case PixelFarm.Agg.VertexCmd.CloseAndEndFigure:
                        //from current point 
                        xylist.Add((float)prevMoveToX);
                        xylist.Add((float)prevMoveToY);
                        prevX = prevMoveToX;
                        prevY = prevMoveToY;
                        //start the new one
                        xylist = new List<float>();
                        isAddToList = false;
                        break;
                    case PixelFarm.Agg.VertexCmd.EndFigure:
                        break;
                    case PixelFarm.Agg.VertexCmd.Stop:
                        goto EXIT_LOOP;
                    default:
                        throw new System.NotSupportedException();
                }
            }
        EXIT_LOOP:

            int j = allXYlist.Count;
            List<Figure> figures = new List<Figure>(j);
            for (int i = 0; i < j; ++i)
            {
                figures.Add(new Figure(allXYlist[i].ToArray()));
            }
            return new InternalGraphicsPath(figures);
        }
예제 #30
0
        //-------------------------------------------------------
      

        ////////////////////////////////////////////////////////////////////////////
        //vertext store/snap/rendervx
        public abstract void Fill(VertexStoreSnap snap);
예제 #31
0
 public abstract RenderVx CreateRenderVx(VertexStoreSnap snap);
예제 #32
0
 public static VertexStore GetInternalVxs(VertexStoreSnap snap)
 {
     return(snap.vxs);
 }
예제 #33
0
 public override void Fill(VertexStoreSnap snap)
 {
     _canvas.FillGfxPath(
         _fillColor,
        InternalGraphicsPath.CreateGraphicsPath(snap));
 }
예제 #34
0
 //-----------------------------------------------------------------------------------------------------------------
 public override RenderVx CreateRenderVx(VertexStoreSnap snap)
 {
     //store internal gfx path inside render vx
     return new GLRenderVx(InternalGraphicsPath.CreateGraphicsPath(snap));
 }
예제 #35
0
 /// <summary>
 /// we do NOT store snap/vxs
 /// </summary>
 /// <param name="snap"></param>
 public override void Fill(VertexStoreSnap snap)
 {
     VxsHelper.FillVxsSnap(_gfx, snap, _fillColor);
 }
예제 #36
0
 public static void FillVxsSnap(SKCanvas g, VertexStoreSnap vxsSnap, SKPaint fill)
 {
     using (var p = CreateGraphicsPath(vxsSnap))
     {
         g.DrawPath(p, fill);
     }
 }
예제 #37
0
 public override RenderVx CreateRenderVx(VertexStoreSnap snap)
 {
     var renderVx = new WinGdiRenderVx(snap);
     renderVx.path = VxsHelper.CreateGraphicsPath(snap);
     return renderVx;
 }
예제 #38
0
 public override void Draw(VertexStoreSnap snap)
 {
     _canvas.DrawGfxPath(
      this._fillColor,
      InternalGraphicsPath.CreateGraphicsPath(snap)
      );
 }
예제 #39
0
 public override void Draw(VertexStoreSnap vxs)
 {
     this.Fill(vxs);
 }
예제 #40
0
 public override void Draw(VertexStoreSnap vxs)
 {
     this.Fill(vxs);
 }
예제 #41
0
 public static void FillVxsSnap(Graphics g, VertexStoreSnap vxsSnap, Color c)
 {
     using (System.Drawing.Drawing2D.GraphicsPath p = CreateGraphicsPath(vxsSnap))
     {
         _br.Color = ToDrawingColor(c);
         g.FillPath(_br, p);
     }
 }
예제 #42
0
 public WinGdiRenderVx(VertexStoreSnap snap)
 {
     this.snap = snap;
 }
예제 #43
0
 public static void DrawVxsSnap(Graphics g, VertexStoreSnap vxsSnap, Color c)
 {
     using (System.Drawing.Drawing2D.GraphicsPath p = CreateGraphicsPath(vxsSnap))
     {
         _pen.Color = ToDrawingColor(c);
         g.DrawPath(_pen, p);
     }
 }
예제 #44
0
        public void AddPath(VertexStoreSnap snap)
        {

            double x = 0;
            double y = 0;

            if (m_cellAARas.Sorted) { Reset(); }
            //--------------------------------------------
            if (snap.VxsHasMoreThanOnePart)
            {
                var vxs = snap.GetInternalVxs();
                int j = vxs.Count;
                for (int i = 0; i < j; ++i)
                {
                    var cmd = vxs.GetVertex(i, out x, out y);
                    switch (cmd)
                    {
                        case VertexCmd.Stop:
                            {
                                //stop 
                            } break;
                        case VertexCmd.MoveTo:
                            {
                                MoveTo(x, y);
                            } break;
                        case VertexCmd.LineTo: 
                        case VertexCmd.P2c: 
                        case VertexCmd.P3c:
                            { 
                                //curve must be flatten before using here
                                LineTo(x, y);
                            } break;
                        default:
                            {
                                if (VertexHelper.IsClose(cmd))
                                {
                                    ClosePolygon();
                                }
                            } break;
                    }
                }
            }
            else
            {
                var snapIter = snap.GetVertexSnapIter();
                VertexCmd cmd;
                bool stop = false;
                while (!stop)
                {
                    cmd = snapIter.GetNextVertex(out x, out y);
                    switch (cmd)
                    {
                        case VertexCmd.Stop:
                            {
                                stop = true;
                            } break;
                        case VertexCmd.MoveTo:
                            {
                                MoveTo(x, y);
                            } break;
                        case VertexCmd.LineTo: 
                        case VertexCmd.P2c: 
                        case VertexCmd.P3c:
                            {
                                LineTo(x, y);
                            } break;
                        default:
                            {
                                if (VertexHelper.IsClose(cmd))
                                {
                                    ClosePolygon();
                                }
                            } break;
                    }
                }
            }

        }
예제 #45
0
 public AggRenderVx(VertexStoreSnap snap)
 {
     this.snap = snap;
 }
예제 #46
0
 public abstract void Draw(VertexStoreSnap vxs);
예제 #47
0
        /// <summary>
        /// fill with BitmapBufferExtension lib
        /// </summary>
        void FillWithBxt(VertexStoreSnap snap)
        {
            //transate the vxs/snap to command
            double x          = 0;
            double y          = 0;
            double offsetOrgX = this.OriginX;
            double offsetOrgY = this.OriginY;

            VertexSnapIter snapIter = snap.GetVertexSnapIter();
            VertexCmd      cmd;

            int latestMoveToX = 0, latestMoveToY = 0;
            int latestX = 0, latestY = 0;


            bool closed = false;

            _reusablePolygonList.Clear();

            while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.NoMore)
            {
                x += offsetOrgX;
                y += offsetOrgY;

                switch (cmd)
                {
                case VertexCmd.MoveTo:
                {
                    if (_reusablePolygonList.Count > 0)
                    {
                        //no drawline
                        _reusablePolygonList.Clear();
                    }

                    closed = false;
                    _reusablePolygonList.Add(latestMoveToX = latestX = (int)Math.Round(x));
                    _reusablePolygonList.Add(latestMoveToY = latestY = (int)Math.Round(y));
                }
                break;

                case VertexCmd.LineTo:
                case VertexCmd.P2c:
                case VertexCmd.P3c:
                {
                    //collect to the polygon
                    _reusablePolygonList.Add(latestX = (int)Math.Round(x));
                    _reusablePolygonList.Add(latestY = (int)Math.Round(y));
                }
                break;

                case VertexCmd.Close:
                case VertexCmd.CloseAndEndFigure:
                {
                    if (_reusablePolygonList.Count > 0)
                    {
                        //flush by draw line
                        _reusablePolygonList.Add(latestX = latestMoveToX);
                        _reusablePolygonList.Add(latestY = latestMoveToY);

                        _bxt.FillPolygon(_reusablePolygonList.ToArray(),
                                         this.fillColor.ToARGB());
                    }

                    _reusablePolygonList.Clear();
                    closed = true;
                }
                break;

                default:
                    break;
                }
            }
            //---------------
            if (!closed && (_reusablePolygonList.Count > 0) &&
                (latestX == latestMoveToX) && (latestY == latestMoveToY))
            {
                //flush by draw line
                _reusablePolygonList.Add(latestMoveToX);
                _reusablePolygonList.Add(latestMoveToY);

                _bxt.FillPolygon(_reusablePolygonList.ToArray(),
                                 this.fillColor.ToARGB());
            }
        }
예제 #48
0
        //-------------------------------------------------------


        ////////////////////////////////////////////////////////////////////////////
        //vertext store/snap/rendervx
        public abstract void Fill(VertexStoreSnap snap);
예제 #49
0
 /// <summary>
 /// we do NOT store snap/vxs
 /// </summary>
 /// <param name="snap"></param>
 public override void Fill(VertexStoreSnap snap)
 {
     VxsHelper.FillVxsSnap(_skCanvas, snap, _fill);
 }