예제 #1
0
        conv_poly_counter(VertexStoreSnap src)
        {
            m_contours = 0;
            m_points   = 0;
            var       snapIter = src.GetVertexSnapIter();
            VertexCmd cmd;
            double    x, y;

            do
            {
                cmd = snapIter.GetNextVertex(out x, out y);
                if (VertexHelper.IsVertextCommand(cmd))
                {
                    ++m_points;
                }

                if (VertexHelper.IsMoveTo(cmd))
                {
                    ++m_contours;
                }
            } while (cmd != VertexCmd.Stop);
            //foreach (VertexData vertexData in src.GetVertexIter())
            //{
            //    if (ShapePath.IsVertextCommand(vertexData.command))
            //    {
            //        ++m_points;
            //    }

            //    if (ShapePath.IsMoveTo(vertexData.command))
            //    {
            //        ++m_contours;
            //    }
            //}
        }
예제 #2
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;

            VertexSnapIter 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);
        }
예제 #3
0
        public static System.Drawing.Drawing2D.GraphicsPath 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

            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;
                    brush_path.StartFigure();
                    break;

                case PixelFarm.Agg.VertexCmd.LineTo:

                    brush_path.AddLine((float)prevX, (float)prevY, (float)x, (float)y);
                    prevX = x;
                    prevY = y;
                    break;

                case PixelFarm.Agg.VertexCmd.CloseAndEndFigure:
                    //from current point
                    //
                    brush_path.AddLine((float)prevX, (float)prevY, (float)prevMoveToX, (float)prevMoveToY);
                    prevX = prevMoveToX;
                    prevY = prevMoveToY;
                    brush_path.CloseFigure();
                    break;

                case PixelFarm.Agg.VertexCmd.EndFigure:
                    goto EXIT_LOOP;
                    break;

                case PixelFarm.Agg.VertexCmd.HasMore:
                    break;

                case PixelFarm.Agg.VertexCmd.Stop:
                    goto EXIT_LOOP;

                default:
                    throw new NotSupportedException();
                }
            }
EXIT_LOOP:
            return(brush_path);
        }
예제 #4
0
        //// Concatenate path. The path is added as is.
        public void ConcatPath(VertexStoreSnap s)
        {
            double         x, y;
            VertexCmd      cmd_flags;
            VertexSnapIter snapIter = s.GetVertexSnapIter();

            while ((cmd_flags = snapIter.GetNextVertex(out x, out y)) != VertexCmd.NoMore)
            {
                myvxs.AddVertex(x, y, cmd_flags);
            }
        }
예제 #5
0
        /// <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);
        }
예제 #6
0
        public VertexStore TransformToVxs(VertexStoreSnap src)
        {
            var       vxs      = new VertexStore();
            var       snapIter = src.GetVertexSnapIter();
            VertexCmd cmd;
            double    x, y;

            while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
            {
                this.Transform(ref x, ref y);
                vxs.AddVertex(x, y, cmd);
            }
            return(vxs);
        }
예제 #7
0
        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);
        }
예제 #8
0
        //--------------------------------------------------------------------
        // Join path. The path is joined with the existing one, that is,
        // it behaves as if the pen of a plotter was always down (drawing)
        //template<class VertexSource>
        public void JoinPath(VertexStoreSnap s)
        {
            double    x, y;
            var       snapIter = s.GetVertexSnapIter();
            VertexCmd cmd      = snapIter.GetNextVertex(out x, out y);

            if (cmd == VertexCmd.Stop)
            {
                return;
            }

            if (VertexHelper.IsVertextCommand(cmd))
            {
                double    x0, y0;
                VertexCmd flags0 = GetLastVertex(out x0, out y0);

                if (VertexHelper.IsVertextCommand(flags0))
                {
                    if (AggMath.calc_distance(x, y, x0, y0) > AggMath.VERTEX_DISTANCE_EPSILON)
                    {
                        if (VertexHelper.IsMoveTo(cmd))
                        {
                            cmd = VertexCmd.LineTo;
                        }
                        myvxs.AddVertex(x, y, cmd);
                    }
                }
                else
                {
                    if (VertexHelper.IsEmpty(flags0))
                    {
                        cmd = VertexCmd.MoveTo;
                    }
                    else
                    {
                        if (VertexHelper.IsMoveTo(cmd))
                        {
                            cmd = VertexCmd.LineTo;
                        }
                    }
                    myvxs.AddVertex(x, y, cmd);
                }
            }

            while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
            {
                myvxs.AddVertex(x, y, VertexHelper.IsMoveTo(cmd) ? VertexCmd.LineTo : cmd);
            }
        }
예제 #9
0
        public VertexStore TransformToVxs(VertexStoreSnap snap)
        {
            var       vxs = new VertexStore();
            var       vsnapIter = snap.GetVertexSnapIter();
            double    x, y;
            VertexCmd cmd;

            do
            {
                cmd = vsnapIter.GetNextVertex(out x, out y);
                this.Transform(ref x, ref y);
                vxs.AddVertex(x, y, cmd);
            } while (!VertexHelper.IsEmpty(cmd));
            return(vxs);
        }
예제 #10
0
        public static VertexStore TranslateTransformToVxs(VertexStoreSnap src, double dx, double dy)
        {
            var       vxs      = new VertexStore();
            var       snapIter = src.GetVertexSnapIter();
            VertexCmd cmd;
            double    x, y;

            while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
            {
                x += dx;
                y += dy;
                vxs.AddVertex(x, y, cmd);
            }
            return(vxs);
        }
예제 #11
0
        void AddPath(VertexStoreSnap s)
        {
            double    x;
            double    y;
            VertexCmd cmd;
            var       snapIter = s.GetVertexSnapIter();

            while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.NoMore)
            {
                AddVertex(x, y, cmd);
            }



            Render(false);
        }
예제 #12
0
        static List <List <IntPoint> > CreatePolygons(VertexStoreSnap a)
        {
            List <List <IntPoint> > allPolys    = new List <List <IntPoint> >();
            List <IntPoint>         currentPoly = null;
            VertexData last       = new VertexData();
            VertexData first      = new VertexData();
            bool       addedFirst = false;

            var       snapIter = a.GetVertexSnapIter();
            VertexCmd cmd;
            double    x, y;

            cmd = snapIter.GetNextVertex(out x, out y);
            do
            {
                if (cmd == VertexCmd.LineTo)
                {
                    if (!addedFirst)
                    {
                        currentPoly.Add(new IntPoint((long)(last.x * 1000), (long)(last.y * 1000)));
                        addedFirst = true;
                        first      = last;
                    }
                    currentPoly.Add(new IntPoint((long)(x * 1000), (long)(y * 1000)));
                    last = new VertexData(cmd, x, y);
                }
                else
                {
                    addedFirst  = false;
                    currentPoly = new List <IntPoint>();
                    allPolys.Add(currentPoly);
                    if (cmd == VertexCmd.MoveTo)
                    {
                        last = new VertexData(cmd, x, y);
                    }
                    else
                    {
                        last = first;
                    }
                }
                cmd = snapIter.GetNextVertex(out x, out y);
            } while (cmd != VertexCmd.Stop);

            return(allPolys);
        }
예제 #13
0
        //-----------------------------------------------------bounding_rect_single
        //template<class VertexSource, class CoordT>
        static bool GetBoundingRectSingle(
            VertexStoreSnap vs,
            out double x1, out double y1,
            out double x2, out double y2)
        {
            double x = 0;
            double y = 0;

            x1 = double.MaxValue;
            y1 = double.MaxValue;
            x2 = double.MinValue;
            y2 = double.MinValue;

            var       vsnapIter = vs.GetVertexSnapIter();
            VertexCmd PathAndFlags;

            while (!VertexHelper.IsEmpty(PathAndFlags = vsnapIter.GetNextVertex(out x, out y)))
            {
                if (VertexHelper.IsVertextCommand(PathAndFlags))
                {
                    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);
        }
예제 #14
0
        conv_poly_counter(VertexStoreSnap src)
        {
            m_contours = 0;
            m_points   = 0;
            var       snapIter = src.GetVertexSnapIter();
            VertexCmd cmd;
            double    x, y;

            do
            {
                cmd = snapIter.GetNextVertex(out x, out y);
                if (VertexHelper.IsVertextCommand(cmd))
                {
                    ++m_points;
                }

                if (VertexHelper.IsMoveTo(cmd))
                {
                    ++m_contours;
                }
            } while (cmd != VertexCmd.NoMore);
        }
예제 #15
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 (ExtendWidthX3ForSubPixelLcdEffect)
            {
                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);
            //                    }
            //                }
            //            }
        }
예제 #16
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;
 }
예제 #17
0
 static List<List<IntPoint>> CreatePolygons(VertexStoreSnap a)
 {
     List<List<IntPoint>> allPolys = new List<List<IntPoint>>();
     List<IntPoint> currentPoly = null;
     VertexData last = new VertexData();
     VertexData first = new VertexData();
     bool addedFirst = false;
     var snapIter = a.GetVertexSnapIter();
     double x, y;
     VertexCmd cmd = snapIter.GetNextVertex(out x, out y);
     do
     {
         if (cmd == VertexCmd.LineTo)
         {
             if (!addedFirst)
             {
                 currentPoly.Add(new IntPoint((long)(last.x * 1000), (long)(last.y * 1000)));
                 addedFirst = true;
                 first = last;
             }
             currentPoly.Add(new IntPoint((long)(x * 1000), (long)(y * 1000)));
             last = new VertexData(cmd, x, y);
         }
         else
         {
             addedFirst = false;
             currentPoly = new List<IntPoint>();
             allPolys.Add(currentPoly);
             if (cmd == VertexCmd.MoveTo)
             {
                 last = new VertexData(cmd, x, y);
             }
             else
             {
                 last = first;
             }
         }
         cmd = snapIter.GetNextVertex(out x, out y);
     } while (cmd != VertexCmd.Stop);
     return allPolys;
 }
예제 #18
0
        void AddPath(VertexStoreSnap s)
        {
            double x;
            double y;
            VertexCmd cmd;
            var snapIter = s.GetVertexSnapIter();
            while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
            {
                AddVertex(x, y, cmd);
            }



            Render(false);
        }
예제 #19
0
        public void MakeVxs(VertexStoreSnap vsnap, VertexStore vxs)
        {
            m_curve3.Reset();
            m_curve4.Reset();
            var snapIter = vsnap.GetVertexSnapIter();
            CurvePointMode latestCurveMode = CurvePointMode.NotCurve;
            double x, y;
            VertexCmd cmd;
            VectorMath.Vector2 c3p2 = new VectorMath.Vector2();
            VectorMath.Vector2 c4p2 = new VectorMath.Vector2();
            VectorMath.Vector2 c4p3 = new VectorMath.Vector2();
            double lastX = 0;
            double lasty = 0;
            double lastMoveX = 0;
            double lastMoveY = 0;
            do
            {
                //this vertex
                cmd = snapIter.GetNextVertex(out x, out y);
                switch (cmd)
                {
                    case VertexCmd.P2c:
                        {
                            switch (latestCurveMode)
                            {
                                case CurvePointMode.P2:
                                    {
                                    }
                                    break;
                                case CurvePointMode.P3:
                                    {
                                    }
                                    break;
                                case CurvePointMode.NotCurve:
                                    {
                                        c3p2.x = x;
                                        c3p2.y = y;
                                    }
                                    break;
                                default:
                                    {
                                    }
                                    break;
                            }
                            latestCurveMode = CurvePointMode.P2;
                        }
                        break;
                    case VertexCmd.P3c:
                        {
                            //this is p3c
                            switch (latestCurveMode)
                            {
                                case CurvePointMode.P2:
                                    {
                                        c3p2.x = x;
                                        c3p2.y = y;
                                    }
                                    break;
                                case CurvePointMode.P3:
                                    {
                                        // vxs.AddVertex(x, y, cmd);
                                        c4p3.x = x;
                                        c4p3.y = y;
                                        //m_curve4.MakeLines(vxs,
                                        //    lastX, lasty,
                                        //    c3p2.X, c3p2.Y,
                                        //    c4p2.x, c4p2.y,
                                        //    x, y);

                                        // vxs.AddVertex(x, y, cmd);

                                    }
                                    break;
                                case CurvePointMode.NotCurve:
                                    {
                                        c4p2.x = x;
                                        c4p2.y = y;
                                    }
                                    break;
                            }
                            latestCurveMode = CurvePointMode.P3;
                        }
                        break;
                    case VertexCmd.LineTo:
                        {
                            switch (latestCurveMode)
                            {
                                case CurvePointMode.P2:
                                    {
                                        m_curve3.MakeLines(vxs,
                                            lastX,
                                            lasty,
                                            c3p2.X,
                                            c3p2.Y,
                                            x,
                                            y);
                                    }
                                    break;
                                case CurvePointMode.P3:
                                    {
                                        //from curve4
                                        // vxs.AddVertex(x, y, cmd);
                                        m_curve4.MakeLines(vxs,
                                            lastX, lasty,
                                            c4p2.x, c4p2.y,
                                            c4p3.x, c4p3.y,
                                            x, y);
                                    }
                                    break;
                                default:
                                    {
                                        vxs.AddVertex(x, y, cmd);
                                    }
                                    break;
                            }
                            //-----------
                            latestCurveMode = CurvePointMode.NotCurve;
                            lastX = x;
                            lasty = y;
                            //-----------
                        }
                        break;
                    case VertexCmd.MoveTo:
                        {
                            //move to, and end command
                            vxs.AddVertex(x, y, cmd);
                            //-----------
                            latestCurveMode = CurvePointMode.NotCurve;
                            lastMoveX = lastX = x;
                            lastMoveY = lasty = y;
                            //-----------
                        }
                        break;
                    case VertexCmd.CloseAndEndFigure:
                        {
                            latestCurveMode = CurvePointMode.NotCurve;
                            vxs.AddVertex(x, y, cmd);
                            //move to begin 
                            lastX = lastMoveX;
                            lasty = lastMoveY;
                        }
                        break;
                    case VertexCmd.EndFigure:
                        {
                            latestCurveMode = CurvePointMode.NotCurve;
                            vxs.AddVertex(x, y, cmd);
                        }
                        break;
                    default:
                        {
                            //move to, and end command
                            vxs.AddVertex(x, y, cmd);
                            //-----------
                            latestCurveMode = CurvePointMode.NotCurve;
                            lastX = x;
                            lasty = y;
                            //-----------
                        }
                        break;
                }
            } while (cmd != VertexCmd.Stop);

        }
예제 #20
0
        //--------------------------------------------------------------------
        // Join path. The path is joined with the existing one, that is, 
        // it behaves as if the pen of a plotter was always down (drawing)
        //template<class VertexSource>  
        public void JoinPath(VertexStoreSnap s)
        {
            double x, y;
            var snapIter = s.GetVertexSnapIter();
            VertexCmd cmd = snapIter.GetNextVertex(out x, out y);
            if (cmd == VertexCmd.Stop)
            {
                return;
            }

            if (VertexHelper.IsVertextCommand(cmd))
            {
                double x0, y0;
                VertexCmd flags0 = GetLastVertex(out x0, out y0);
                if (VertexHelper.IsVertextCommand(flags0))
                {
                    if (AggMath.calc_distance(x, y, x0, y0) > AggMath.VERTEX_DISTANCE_EPSILON)
                    {
                        if (VertexHelper.IsMoveTo(cmd))
                        {
                            cmd = VertexCmd.LineTo;
                        }
                        myvxs.AddVertex(x, y, cmd);
                    }
                }
                else
                {
                    if (VertexHelper.IsEmpty(flags0))
                    {
                        cmd = VertexCmd.MoveTo;
                    }
                    else
                    {
                        if (VertexHelper.IsMoveTo(cmd))
                        {
                            cmd = VertexCmd.LineTo;
                        }
                    }
                    myvxs.AddVertex(x, y, cmd);
                }
            }

            while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
            {
                myvxs.AddVertex(x, y, VertexHelper.IsMoveTo(cmd) ? VertexCmd.LineTo : cmd);
            }
        }
예제 #21
0
 //// Concatenate path. The path is added as is.
 public void ConcatPath(VertexStoreSnap s)
 {
     double x, y;
     VertexCmd cmd_flags;
     var snapIter = s.GetVertexSnapIter();
     while ((cmd_flags = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
     {
         myvxs.AddVertex(x, y, cmd_flags);
     }
 }
예제 #22
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());
            }
        }
예제 #23
0
        public VertexStore MakeVxs2(VertexStoreSnap vsnap)
        {
            VertexStore vxs = new VertexStore();

            m_curve3.Reset();
            m_curve4.Reset();
            var            snapIter = vsnap.GetVertexSnapIter();
            CurvePointMode latestCurveMode = CurvePointMode.NotCurve;
            double         x, y;
            VertexCmd      cmd;

            VectorMath.Vector2 c3p2      = new VectorMath.Vector2();
            VectorMath.Vector2 c4p2      = new VectorMath.Vector2();
            VectorMath.Vector2 c4p3      = new VectorMath.Vector2();
            double             lastX     = 0;
            double             lasty     = 0;
            double             lastMoveX = 0;
            double             lastMoveY = 0;

            do
            {
                //this vertex
                cmd = snapIter.GetNextVertex(out x, out y);
                switch (cmd)
                {
                //this p2 control
                case VertexCmd.P2c:
                {
                    switch (latestCurveMode)
                    {
                    case CurvePointMode.P2:
                    {
                    }
                    break;

                    case CurvePointMode.P3:
                    {
                    }
                    break;

                    case CurvePointMode.NotCurve:
                    {
                        c3p2.x = x;
                        c3p2.y = y;
                    }
                    break;

                    default:
                    {
                    }
                    break;
                    }
                    latestCurveMode = CurvePointMode.P2;
                }
                break;

                case VertexCmd.P3c:
                {
                    //this is p3c
                    switch (latestCurveMode)
                    {
                    case CurvePointMode.P2:
                    {
                        c4p2.x = c3p2.x;
                        c4p2.y = c3p2.y;
                        c4p3.x = x;
                        c4p3.y = y;
                        c3p2.x = x;
                    }
                    break;

                    case CurvePointMode.P3:
                    {
                        // vxs.AddVertex(x, y, cmd);
                        c4p3.x = x;
                        c4p3.y = y;
                        //m_curve4.MakeLines(vxs,
                        //    lastX, lasty,
                        //    c3p2.X, c3p2.Y,
                        //    c4p2.x, c4p2.y,
                        //    x, y);

                        // vxs.AddVertex(x, y, cmd);
                    }
                    break;

                    case CurvePointMode.NotCurve:
                    {
                        c4p2.x = x;
                        c4p2.y = y;
                    }
                    break;
                    }
                    latestCurveMode = CurvePointMode.P3;
                }
                break;

                case VertexCmd.LineTo:
                {
                    switch (latestCurveMode)
                    {
                    case CurvePointMode.P2:
                    {
                        m_curve3.MakeLines(vxs,
                                           lastX,
                                           lasty,
                                           c3p2.X,
                                           c3p2.Y,
                                           x,
                                           y);
                    }
                    break;

                    case CurvePointMode.P3:
                    {
                        //from curve4
                        // vxs.AddVertex(x, y, cmd);
                        m_curve4.MakeLines(vxs,
                                           lastX, lasty,
                                           c4p2.x, c4p2.y,
                                           c4p3.x, c4p3.y,
                                           x, y);
                    }
                    break;

                    default:
                    {
                        vxs.AddVertex(x, y, cmd);
                    }
                    break;
                    }
                    //-----------
                    latestCurveMode = CurvePointMode.NotCurve;
                    lastX           = x;
                    lasty           = y;
                    //-----------
                }
                break;

                case VertexCmd.MoveTo:
                {
                    //move to, and end command
                    vxs.AddVertex(x, y, cmd);
                    //-----------
                    latestCurveMode = CurvePointMode.NotCurve;
                    lastMoveX       = lastX = x;
                    lastMoveY       = lasty = y;
                    //-----------
                }
                break;

                case VertexCmd.CloseAndEndFigure:
                {
                    latestCurveMode = CurvePointMode.NotCurve;
                    vxs.AddVertex(x, y, cmd);
                    //move to begin
                    lastX = lastMoveX;
                    lasty = lastMoveY;
                }
                break;

                case VertexCmd.EndFigure:
                {
                    latestCurveMode = CurvePointMode.NotCurve;
                    vxs.AddVertex(x, y, cmd);
                }
                break;

                default:
                {
                    //move to, and end command
                    vxs.AddVertex(x, y, cmd);
                    //-----------
                    latestCurveMode = CurvePointMode.NotCurve;
                    lastX           = x;
                    lasty           = y;
                    //-----------
                }
                break;
                }
            } while (cmd != VertexCmd.Stop);
            return(vxs);
        }
예제 #24
0
            InternalGraphicsPath CreateGraphicsPath(VertexStoreSnap vxsSnap, bool buildForRenderVx)
            {
                VertexSnapIter vxsIter     = vxsSnap.GetVertexSnapIter();
                double         prevX       = 0;
                double         prevY       = 0;
                double         prevMoveToX = 0;
                double         prevMoveToY = 0;

                xylist.Clear();
                //TODO: reivew here
                //about how to reuse this list

                bool isAddToList = true;
                //result...
                List <Figure> figures = new List <Figure>();

                for (; ;)
                {
                    double x, y;
                    switch (vxsIter.GetNextVertex(out x, out y))
                    {
                    case PixelFarm.Agg.VertexCmd.MoveTo:
                        if (!isAddToList)
                        {
                            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.Close:
                        //from current point
                    {
                        xylist.Add((float)prevMoveToX);
                        xylist.Add((float)prevMoveToY);
                        prevX = prevMoveToX;
                        prevY = prevMoveToY;
                        //-----------
                        Figure newfig = new Figure(xylist.ToArray());
                        newfig.SupportVertexBuffer = buildForRenderVx;
                        figures.Add(newfig);
                        //-----------
                        xylist.Clear();
                        isAddToList = false;
                    }
                    break;

                    case VertexCmd.CloseAndEndFigure:
                        //from current point
                    {
                        xylist.Add((float)prevMoveToX);
                        xylist.Add((float)prevMoveToY);
                        prevX = prevMoveToX;
                        prevY = prevMoveToY;
                        //
                        Figure newfig = new Figure(xylist.ToArray());
                        newfig.SupportVertexBuffer = buildForRenderVx;
                        figures.Add(newfig);
                        //-----------
                        xylist.Clear();
                        isAddToList = false;
                    }
                    break;

                    case PixelFarm.Agg.VertexCmd.NoMore:
                        goto EXIT_LOOP;

                    default:
                        throw new System.NotSupportedException();
                    }
                }
EXIT_LOOP:

                if (figures.Count == 0)
                {
                    Figure newfig = new Figure(xylist.ToArray());
                    newfig.SupportVertexBuffer = buildForRenderVx;
                    figures.Add(newfig);
                }
                return(new InternalGraphicsPath(figures));
            }
예제 #25
0
 public VertexStore TransformToVxs(VertexStoreSnap snap, VertexStore vxs)
 {
     var vsnapIter = snap.GetVertexSnapIter();
     double x, y;
     VertexCmd cmd;
     do
     {
         cmd = vsnapIter.GetNextVertex(out x, out y);
         this.Transform(ref x, ref y);
         vxs.AddVertex(x, y, cmd);
     } while (!VertexHelper.IsEmpty(cmd));
     return vxs;
 }
        public void MakeVxs(VertexStoreSnap vsnap, VertexStore vxs)
        {
            m_curve3.Reset();
            m_curve4.Reset();
            var            snapIter = vsnap.GetVertexSnapIter();
            CurvePointMode latestCurveMode = CurvePointMode.NotCurve;
            double         x, y;
            VertexCmd      cmd;

            VectorMath.Vector2 c3p2      = new VectorMath.Vector2();
            VectorMath.Vector2 c4p2      = new VectorMath.Vector2();
            VectorMath.Vector2 c4p3      = new VectorMath.Vector2();
            double             lastX     = 0;
            double             lasty     = 0;
            double             lastMoveX = 0;
            double             lastMoveY = 0;


            do
            {
                //this vertex
                cmd = snapIter.GetNextVertex(out x, out y);
#if DEBUG
                if (VertexStore.dbugCheckNANs(x, y))
                {
                    int dbugIter = snapIter.dbugIterIndex;
                }

                //if (VertexStore.dbugCheckIfNAN(x, y))
                //{
                //
                //}
#endif
                switch (cmd)
                {
                case VertexCmd.P2c:
                {
                    switch (latestCurveMode)
                    {
                    case CurvePointMode.P2:
                    {
                    }
                    break;

                    case CurvePointMode.P3:
                    {
                    }
                    break;

                    case CurvePointMode.NotCurve:
                    {
                        c3p2.x = x;
                        c3p2.y = y;
                    }
                    break;

                    default:
                    {
                    }
                    break;
                    }
                    latestCurveMode = CurvePointMode.P2;
                }
                break;

                case VertexCmd.P3c:
                {
                    //this is p3c
                    switch (latestCurveMode)
                    {
                    case CurvePointMode.P2:
                    {
                        c3p2.x = x;
                        c3p2.y = y;
                    }
                    break;

                    case CurvePointMode.P3:
                    {
                        c4p3.x = x;
                        c4p3.y = y;
                    }
                    break;

                    case CurvePointMode.NotCurve:
                    {
                        c4p2.x = x;
                        c4p2.y = y;
                    }
                    break;
                    }
                    latestCurveMode = CurvePointMode.P3;
                }
                break;

                case VertexCmd.LineTo:
                {
                    switch (latestCurveMode)
                    {
                    case CurvePointMode.P2:
                    {
                        m_curve3.MakeLines(vxs,
                                           lastX,
                                           lasty,
                                           c3p2.X,
                                           c3p2.Y,
                                           x,
                                           y);
                    }
                    break;

                    case CurvePointMode.P3:
                    {
                        m_curve4.MakeLines(vxs,
                                           lastX, lasty,
                                           c4p2.x, c4p2.y,
                                           c4p3.x, c4p3.y,
                                           x, y);
                    }
                    break;

                    default:
                    {
                        vxs.AddVertex(x, y, cmd);
                    }
                    break;
                    }
                    //-----------
                    latestCurveMode = CurvePointMode.NotCurve;
                    lastX           = x;
                    lasty           = y;
                    //-----------
                }
                break;

                case VertexCmd.MoveTo:
                {
                    //move to, and end command
                    vxs.AddVertex(x, y, cmd);
                    //-----------
                    latestCurveMode = CurvePointMode.NotCurve;
                    lastMoveX       = lastX = x;
                    lastMoveY       = lasty = y;
                    //-----------
                }
                break;

                case VertexCmd.Close:
                case VertexCmd.CloseAndEndFigure:
                {
                    latestCurveMode = CurvePointMode.NotCurve;
                    vxs.AddVertex(x, y, cmd);
                    //move to begin
                    lastX = lastMoveX;
                    lasty = lastMoveY;
                }
                break;

                default:
                {
                    //move to, and end command
                    vxs.AddVertex(x, y, cmd);
                    //-----------
                    latestCurveMode = CurvePointMode.NotCurve;
                    lastX           = x;
                    lasty           = y;
                    //-----------
                }
                break;
                }
            } while (cmd != VertexCmd.NoMore);
        }
예제 #27
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;

            //bool vxsMoreThan1 =  vxsSnap.VxsHasMoreThanOnePart;
            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.Close:
                    //from current point
                    xylist.Add((float)prevMoveToX);
                    xylist.Add((float)prevMoveToY);
                    prevX = prevMoveToX;
                    prevY = prevMoveToY;
                    //xylist = new List<float>();
                    //isAddToList = false;
                    break;

                case VertexCmd.CloseAndEndFigure:
                    //from current point
                    xylist.Add((float)prevMoveToX);
                    xylist.Add((float)prevMoveToY);
                    prevX = prevMoveToX;
                    prevY = prevMoveToY;
                    //
                    xylist      = new List <float>();
                    isAddToList = false;
                    break;

                case PixelFarm.Agg.VertexCmd.NoMore:
                    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));
        }
예제 #28
0
 /// <summary>
 /// we do NOT store vxs, return original outputVxs
 /// </summary>
 /// <param name="src"></param>
 /// <param name="outputVxs"></param>
 /// <returns></returns>
 public VertexStore TransformToVxs(VertexStoreSnap src, VertexStore outputVxs)
 {
     var snapIter = src.GetVertexSnapIter();
     VertexCmd cmd;
     double x, y;
     while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
     {
         this.Transform(ref x, ref y);
         outputVxs.AddVertex(x, y, cmd);
     }
     return outputVxs;
 }