示例#1
0
        public void AddVertex(double x, double y, VertexCmd cmd)
        {
            switch (cmd)
            {
            case VertexCmd.NoMore:
            {
            }
            break;

            case VertexCmd.MoveTo:
                Render(false);
                MoveTo(x, y);
                break;

            case VertexCmd.Close:
            case VertexCmd.CloseAndEndFigure:
                Render(true);
                MoveTo(m_start_x, m_start_y);
                break;

            default:
                LineTo(x, y);
                break;
            }
        }
示例#2
0
        void AddVertex(VertexCmd cmd, double x, double y)
        {
            switch (cmd)
            {
            case VertexCmd.MoveTo:
                MoveTo(x, y);
                break;

            case VertexCmd.LineTo:
            case VertexCmd.P2c:
            case VertexCmd.P3c:
                LineTo(x, y);
                break;

            case VertexCmd.Close:
            case VertexCmd.CloseAndEndFigure:
                ClosePolygon();
                break;

            default:
            {
            }
            break;
            }
        }
示例#3
0
        void AllocIfRequired(int indexToAdd)
        {
            if (indexToAdd < m_allocated_vertices)
            {
                return;
            }

            while (indexToAdd >= m_allocated_vertices)
            {
                int newSize = m_allocated_vertices + 256;

                double[]    new_xy = new double[newSize << 1];
                VertexCmd[] newCmd = new VertexCmd[newSize];
                if (m_coord_xy != null)
                {
                    //copy old buffer to new buffer
                    int actualLen = m_num_vertices << 1;
                    for (int i = actualLen - 1; i >= 0;)
                    {
                        new_xy[i] = m_coord_xy[i];
                        i--;
                        new_xy[i] = m_coord_xy[i];
                        i--;
                    }
                    for (int i = m_num_vertices - 1; i >= 0; --i)
                    {
                        newCmd[i] = m_cmds[i];
                    }
                }
                m_coord_xy = new_xy;
                m_cmds     = newCmd;

                m_allocated_vertices = newSize;
            }
        }
        void AddVertex(VertexCmd cmd, double x, double y)
        {
            switch (cmd)
            {
            case VertexCmd.MoveTo:
            {
                MoveTo(x, y);
            } break;

            case VertexCmd.LineTo:
            case VertexCmd.P2c:
            case VertexCmd.P3c:
            {
                LineTo(x, y);
            } break;

            case VertexCmd.EndAndCloseFigure:
            {
                ClosePolygon();
            } break;

            default:
            {
            } break;
            }
        }
示例#5
0
        public void AddVertex(double x, double y, VertexCmd cmd)
        {
            m_status = StrokeMath.Status.Init;
            switch (cmd)
            {
            case VertexCmd.MoveTo:
                vertexDistanceList.ReplaceLast(new VertexDistance(x, y));
                break;

            case VertexCmd.Close:
            case VertexCmd.CloseAndEndFigure:
            {
                //end and close
                m_closed = true;
                if (m_orientation == EndVertexOrientation.Unknown)
                {
                    switch ((int)x)
                    {
                    case 1:
                    case 2:
                    {
                        m_orientation = (EndVertexOrientation)x;
                    }
                    break;
                    }
                }
            }
            break;

            default:

                vertexDistanceList.AddVertex(new VertexDistance(x, y));
                break;
            }
        }
示例#6
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);
        }
示例#7
0
 public void AddVertex(double x, double y, VertexCmd cmd)
 {
     if (m_num_vertices >= m_allocated_vertices)
     {
         AllocIfRequired(m_num_vertices);
     }
     m_coord_xy[m_num_vertices << 1]       = x;
     m_coord_xy[(m_num_vertices << 1) + 1] = y;
     m_cmds[m_num_vertices] = (byte)cmd;
     m_num_vertices++;
 }
示例#8
0
        static void FindActualPointCount(PixelFarm.Drawing.VertexStore vxs, out int actualPointCount)
        {
            int       pp = vxs.Count;
            double    vtx0, vty0;
            VertexCmd cmd = vxs.GetVertex(--pp, out vtx0, out vty0);

            while (cmd == VertexCmd.NoMore)
            {
                cmd = vxs.GetVertex(--pp, out vtx0, out vty0);
            }
            actualPointCount = pp + 1;
        }
示例#9
0
        internal void SwapVertices(int v1, int v2)
        {
            double x_tmp = m_coord_xy[v1 << 1];
            double y_tmp = m_coord_xy[(v1 << 1) + 1];

            m_coord_xy[v1 << 1]       = m_coord_xy[v2 << 1];       //x
            m_coord_xy[(v1 << 1) + 1] = m_coord_xy[(v2 << 1) + 1]; //y
            m_coord_xy[v2 << 1]       = x_tmp;
            m_coord_xy[(v2 << 1) + 1] = y_tmp;
            VertexCmd cmd = m_cmds[v1];

            m_cmds[v1] = m_cmds[v2];
            m_cmds[v2] = cmd;
        }
示例#10
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);
            }
        }
示例#11
0
        public static void FlipY(VertexStore vxs, double y1, double y2)
        {
            int    i;
            double x, y;
            int    count = vxs.Count;

            for (i = 0; i < count; ++i)
            {
                VertexCmd flags = vxs.GetVertex(i, out x, out y);
                if (VertexHelper.IsVertextCommand(flags))
                {
                    vxs.ReplaceVertex(i, x, y2 - y + y1);
                }
            }
        }
示例#12
0
        /// <summary>
        ///  we do NOT store vxsSnap
        /// </summary>
        /// <param name="vxs"></param>
        /// <returns></returns>
        public static System.Drawing.Drawing2D.GraphicsPath CreateGraphicsPath(VertexStore vxs)
        {
            //render vertice in store
            int    vcount      = vxs.Count;
            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 (int i = 0; i < vcount; ++i)
            {
                double    x, y;
                VertexCmd cmd = vxs.GetVertex(i, out x, out y);
                switch (cmd)
                {
                case VertexCmd.MoveTo:
                    prevMoveToX = prevX = x;
                    prevMoveToY = prevY = y;
                    brush_path.StartFigure();
                    break;

                case VertexCmd.LineTo:
                    brush_path.AddLine((float)prevX, (float)prevY, (float)x, (float)y);
                    prevX = x;
                    prevY = y;
                    break;

                case VertexCmd.Close:
                case VertexCmd.CloseAndEndFigure:
                    brush_path.AddLine((float)prevX, (float)prevY, (float)prevMoveToX, (float)prevMoveToY);
                    prevMoveToX = prevX = x;
                    prevMoveToY = prevY = y;
                    brush_path.CloseFigure();
                    break;

                case VertexCmd.NoMore:

                    i = vcount + 1;    //exit from loop
                    goto EXIT_LOOP;

                default:
                    throw new NotSupportedException();
                }
            }
EXIT_LOOP:
            return(brush_path);
        }
示例#13
0
        public void AddVertex(double x, double y, VertexCmd cmd)
        {
#if DEBUG
            if (VertexStore.dbugCheckNANs(x, y))
            {
            }
#endif
            if (m_num_vertices >= m_allocated_vertices)
            {
                AllocIfRequired(m_num_vertices);
            }
            m_coord_xy[m_num_vertices << 1]       = x;
            m_coord_xy[(m_num_vertices << 1) + 1] = y;
            m_cmds[m_num_vertices] = (byte)cmd;
            m_num_vertices++;
        }
示例#14
0
        //----------------------------------------------------------

        public void AddSubVertices(VertexStore anotherVxs)
        {
            int j = anotherVxs.Count;

            this.HasMoreThanOnePart = true;
            for (int i = 0; i < j; ++i)
            {
                double    x, y;
                VertexCmd cmd = anotherVxs.GetVertex(i, out x, out y);
                this.AddVertex(x, y, cmd);
                if (cmd == VertexCmd.Stop)
                {
                    break;
                }
            }
        }
示例#15
0
        public void AddVertex(double x, double y, VertexCmd cmd)
        {
#if DEBUG
            if (VertexStore.dbugCheckNANs(x, y))
            {
            }
#endif
            if (_vertices_count >= _allocated_vertices_count)
            {
                AllocIfRequired(_vertices_count);
            }
            _coord_xy[_vertices_count << 1]       = x;
            _coord_xy[(_vertices_count << 1) + 1] = y;
            _cmds[_vertices_count] = (byte)cmd;
            _vertices_count++;
        }
示例#16
0
        static void SimpleSolidLine(VertexStore outputVxs, VertexCmd cmd, double x, double y)
        {
            //solid
            switch (cmd)
            {
            default: throw new NotSupportedException();

            case VertexCmd.MoveTo:
                outputVxs.AddMoveTo(x, y);
                break;

            case VertexCmd.LineTo:
                outputVxs.AddLineTo(x, y);
                break;
            }
        }
示例#17
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(VertexStore vxs)
        {
            double    x, y;
            int       index = 0;
            VertexCmd cmd   = vxs.GetVertex(index++, out x, out y);

            if (cmd == VertexCmd.NoMore)
            {
                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 = vxs.GetVertex(index++, out x, out y)) != VertexCmd.NoMore)
            {
                _myvxs.AddVertex(x, y, VertexHelper.IsMoveTo(cmd) ? VertexCmd.LineTo : cmd);
            }
        }
示例#18
0
        public void AddVertex(double x, double y, VertexCmd cmd)
        {
            m_status = StrokeMath.Status.Init;
            switch (cmd)
            {
            case VertexCmd.MoveTo:
                vertexDistanceList.ReplaceLast(new VertexDistance(x, y));
                break;

            case VertexCmd.Close:
            case VertexCmd.CloseAndEndFigure:
                m_closed = true;
                break;

            default:
                vertexDistanceList.AddVertex(new VertexDistance(x, y));
                break;
            }
        }
示例#19
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.NoMore);
            return(allPolys);
        }
示例#20
0
        static void InvertPolygon(VertexStore myvxs, int start, int end)
        {
            int       i;
            VertexCmd tmp_PathAndFlags = myvxs.GetCommand(start);

            --end; // Make "end" inclusive
            // Shift all commands to one position
            for (i = start; i < end; i++)
            {
                myvxs.ReplaceCommand(i, myvxs.GetCommand(i + 1));
            }
            // Assign starting command to the ending command
            myvxs.ReplaceCommand(end, tmp_PathAndFlags);

            // Reverse the polygon
            while (end > start)
            {
                myvxs.SwapVertices(start++, end--);
            }
        }
        public static void Load(PathWriter vertexSource, string pathAndFileName)
        {
            vertexSource.Clear();
            var vxs = vertexSource.Vxs;

            string[] allLines = File.ReadAllLines(pathAndFileName);
            foreach (string line in allLines)
            {
                string[]  elements        = line.Split(',');
                double    x               = double.Parse(elements[0]);
                double    y               = double.Parse(elements[1]);
                VertexCmd flagsAndCommand = (VertexCmd)System.Enum.Parse(typeof(VertexCmd), elements[2].Trim());
                int       len             = elements.Length;
                for (int i = 3; i < len; i++)
                {
                    flagsAndCommand |= (VertexCmd)System.Enum.Parse(typeof(VertexCmd), elements[i].Trim());
                }
                vxs.AddVertex(x, y, flagsAndCommand);
            }
        }
示例#22
0
        public void AddVertex(double x, double y, VertexCmd cmd)
        {
            //TODO: review
            m_status = Status.Init;
            switch (cmd)
            {
            case VertexCmd.MoveTo:
                multipartVertexDistanceList.AddMoveTo(x, y);
                break;

            case VertexCmd.Close:
            case VertexCmd.CloseAndEndFigure:
                //m_closed = true;
                break;

            default:
                multipartVertexDistanceList.AddVertex(new Vertex2d(x, y));
                break;
            }
        }
示例#23
0
        public void WriteTo(VertexStore outputVxs)
        {
            this.Rewind();
            int    currentRangeIndex = 0;
            double x = 0, y = 0;

            //int n = 0;
            for (;;)
            {
                VertexCmd cmd = GetNextVertex(out x, out y);
                if (cmd == VertexCmd.NoMore)
                {
                    if (currentRangeIndex + 1 < multipartVertexDistanceList.RangeCount)
                    {
                        //move to next range
                        multipartVertexDistanceList.SetRangeIndex(currentRangeIndex + 1);
                        currentRangeIndex++;

                        m_status     = Status.Ready;
                        m_src_vertex = 0;
                        m_out_vertex = 0;
                        continue;
                    }
                    else
                    {
                        break;//exit from loop
                    }
                }
                outputVxs.AddVertex(x, y, cmd);


                //Console.WriteLine(n + " " + x + "," + y);
                //n++;
                //if (n == 419)
                //{
                //}
            }
        }
示例#24
0
        public static void ReadPathDataFromStream(BinaryReader reader, out PathWriter newPath)
        {
            newPath = new PathWriter();
            //1.
            int num_alloc_vertice = reader.ReadInt32(); //hint
            //2.
            int num_vertice = reader.ReadInt32();       //actual vertice num
            int totalCoord  = num_vertice << 1;

            //3.
            double[] coord_xy = new double[totalCoord];
            //4.
            VertexCmd[] cmds = new VertexCmd[num_vertice];

            for (int i = 0; i < totalCoord;)
            {
                coord_xy[i] = reader.ReadDouble();
                i++;
                coord_xy[i] = reader.ReadDouble();
                i++;
            }
            //4.
            int cmds_count = reader.ReadInt32();

            for (int i = 0; i < cmds_count; ++i)
            {
                cmds[i] = (VertexCmd)reader.ReadByte();
            }

            PathWriter.UnsafeDirectSetData(
                newPath,
                num_alloc_vertice,
                num_vertice,
                coord_xy,
                cmds);
            int end = reader.ReadInt32();
        }
 //public static bool IsClose(VertexCmd c)
 //{
 //    return c == VertexCmd.CloseAndEndFigure;
 //}
 public static bool IsNextPoly(VertexCmd c)
 {
     //?
     return c <= VertexCmd.MoveTo;
 }
示例#26
0
 internal void ReplaceCommand(int index, VertexCmd CommandAndFlags)
 {
     m_cmds[index] = (byte)CommandAndFlags;
 }
示例#27
0
 public void AddVertex(double x, double y, VertexCmd cmd)
 {
     if (m_num_vertices >= m_allocated_vertices)
     {
         AllocIfRequired(m_num_vertices);
     }
     m_coord_xy[m_num_vertices << 1] = x;
     m_coord_xy[(m_num_vertices << 1) + 1] = y;
     m_cmds[m_num_vertices] = (byte)cmd;
     m_num_vertices++;
 }
 void AddVertex(VertexCmd cmd, double x, double y)
 {
     switch (cmd)
     {
         case VertexCmd.MoveTo:
             {
                 MoveTo(x, y);
             }
             break;
         case VertexCmd.LineTo:
         case VertexCmd.P2c:
         case VertexCmd.P3c:
             {
                 LineTo(x, y);
             }
             break;
         case VertexCmd.CloseAndEndFigure:
             {
                 ClosePolygon();
             }
             break;
         default:
             {
             }
             break;
     }
 }
示例#29
0
 public static bool IsEmpty(VertexCmd c)
 {
     return(c == VertexCmd.NoMore);
 }
 public void AddVertex(double x, double y, VertexCmd cmd)
 {
     switch (cmd)
     {
         case VertexCmd.Stop:
             {
             }
             break;
         case VertexCmd.MoveTo:
             Render(false);
             MoveTo(x, y);
             break;
         case VertexCmd.CloseAndEndFigure:
             Render(true);
             MoveTo(m_start_x, m_start_y);
             break;
         case VertexCmd.EndFigure:
             Render(false);
             break;
         default:
             LineTo(x, y);
             break;
     }
 }
 public static bool IsEndFigure(VertexCmd c)
 {
     //check only 2 lower bit
     return ((int)c & 0x3) >= (int)VertexCmd.EndFigure;
 }
示例#32
0
 public VertexData(VertexCmd command, Vector2 position)
 {
     this.command = command;
     this.x = position.x;
     this.y = position.y;
 }
示例#33
0
        public void AddVertex(double x, double y, VertexCmd cmd)
        {
            m_status = StrokeMath.Status.Init;
            switch (cmd)
            {
                case VertexCmd.MoveTo:
                    vertexDistanceList.ReplaceLast(new VertexDistance(x, y));
                    break;
                case VertexCmd.CloseAndEndFigure:
                    {
                        //end and close
                        m_closed = true;
                        if (m_orientation == EndVertexOrientation.Unknown)
                        {
                            switch ((int)x)
                            {
                                case 1:
                                case 2:
                                    {
                                        m_orientation = (EndVertexOrientation)x;
                                    }
                                    break;
                            }
                        }
                    }
                    break;
                case VertexCmd.EndFigure:

                    //end not close 
                    if (m_orientation == EndVertexOrientation.Unknown)
                    {
                        switch ((int)x)
                        {
                            case 1:
                            case 2:
                                {
                                    m_orientation = (EndVertexOrientation)x;
                                }
                                break;
                        }
                    }
                    break;
                default:

                    vertexDistanceList.AddVertex(new VertexDistance(x, y));
                    break;
            }
        }
示例#34
0
 public static bool IsCloseOrEnd(VertexCmd c)
 {
     //check only 2 lower bit
     //TODO: review here
     return(((int)c & 0x3) >= (int)VertexCmd.Close);
 }
示例#35
0
 public VertexData(VertexCmd command, double x, double y)
 {
     this.command = command;
     this.x = x;
     this.y = y;
 }
示例#36
0
 public void AddVertex(double x, double y, VertexCmd cmd)
 {
     m_status = StrokeMath.Status.Init;
     switch (cmd)
     {
         case VertexCmd.MoveTo:
             vertexDistanceList.ReplaceLast(new VertexDistance(x, y));
             break;
         case VertexCmd.CloseAndEndFigure:
             m_closed = true;
             break;
         case VertexCmd.EndFigure:
             m_closed = false;
             break;
         default:
             vertexDistanceList.AddVertex(new VertexDistance(x, y));
             break;
     }
 }
示例#37
0
 public static bool IsVertextCommand(VertexCmd c)
 {
     // return c >= VertexCmd.MoveTo;
     return(c > VertexCmd.NoMore);
 }
 public static bool IsVertextCommand(VertexCmd c)
 {
     return c >= VertexCmd.MoveTo;
 }
示例#39
0
 public static bool IsMoveTo(VertexCmd c)
 {
     return(c == VertexCmd.MoveTo);
 }
 public static bool IsEmpty(VertexCmd c)
 {
     return c == VertexCmd.Stop;
 }
示例#41
0
 public static bool IsNextPoly(VertexCmd c)
 {
     //?
     return(c <= VertexCmd.MoveTo);
 }
 public static bool IsMoveTo(VertexCmd c)
 {
     return c == VertexCmd.MoveTo;
 }
示例#43
0
        public void init(double x, double y,
                         double rx, double ry,
                         double start_angle,
                         double sweep_angle)
        {
            start_angle = fmod(start_angle, 2.0 * Math.PI);
            if (sweep_angle >= 2.0 * Math.PI)
            {
                sweep_angle = 2.0 * Math.PI;
            }
            if (sweep_angle <= -2.0 * Math.PI)
            {
                sweep_angle = -2.0 * Math.PI;
            }

            if (fabs(sweep_angle) < 1e-10)
            {
                m_num_vertices = 4;
                m_cmd          = VertexCmd.LineTo;
                m_vertices[0]  = x + rx * Math.Cos(start_angle);
                m_vertices[1]  = y + ry * Math.Sin(start_angle);
                m_vertices[2]  = x + rx * Math.Cos(start_angle + sweep_angle);
                m_vertices[3]  = y + ry * Math.Sin(start_angle + sweep_angle);
                return;
            }

            double total_sweep = 0.0;
            double local_sweep = 0.0;
            double prev_sweep;

            m_num_vertices = 2;
            m_cmd          = VertexCmd.P3c;

            bool done = false;

            do
            {
                if (sweep_angle < 0.0)
                {
                    prev_sweep   = total_sweep;
                    local_sweep  = -Math.PI * 0.5;
                    total_sweep -= Math.PI * 0.5;
                    if (total_sweep <= sweep_angle + bezier_arc_angle_epsilon)
                    {
                        local_sweep = sweep_angle - prev_sweep;
                        done        = true;
                    }
                }
                else
                {
                    prev_sweep   = total_sweep;
                    local_sweep  = Math.PI * 0.5;
                    total_sweep += Math.PI * 0.5;
                    if (total_sweep >= sweep_angle - bezier_arc_angle_epsilon)
                    {
                        local_sweep = sweep_angle - prev_sweep;
                        done        = true;
                    }
                }

                unsafe
                {
                    fixed(double *m_head = m_vertices)
                    {
                        arc_to_bezier(x, y, rx, ry,
                                      start_angle,
                                      local_sweep,
                                      m_head + m_num_vertices - 2);
                    }
                }


                m_num_vertices += 6;
                start_angle    += local_sweep;
            }while (!done && m_num_vertices < 26);
        }
示例#44
0
 public VertexData(VertexCmd command)
 {
     this.command = command;
     x = y = 0;
 }