コード例 #1
0
        /// <summary>
        /// Parses one or more arc commands in the format rx ry ang, large-flag, sweep-flag endx endy.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="cmd"></param>
        /// <param name="absolute"></param>
        /// <param name="args"></param>
        /// <remarks>
        /// The arc is a segment along an ellipse that has 2 radii with the arc
        /// extending from the current cursor position to the end point.
        ///
        /// rx = Radius X of the constructed ellipse
        /// ry = Radius Y of the constructed ellipse
        /// ang = The rotational angle in degrees of the constructed ellipse
        /// large-flag = 1 to use the longest path around the ellipse, 0 to use the shortest path
        /// sweep-flag = 1 to sweep in a positive direction, 0 to sweep in a negative direction.
        /// endx = The X co-ordinate of the end point of the arc
        /// endy = The Y co-ordinate of the end point of the arc
        /// </remarks>
        private void ParseSVGArcCommand(PDFGraphicsPath path, char cmd, bool absolute, string[] args)
        {
            PDFUnit rx, ry, endx, endy;
            double  ang;
            bool    large, sweep;
            int     index = 0;

            while (index < args.Length)
            {
                if (index == 0 || !string.IsNullOrEmpty(args[index]))
                {
                    if (!AssertParseUnit(args, ref index, cmd, out rx))
                    {
                        return;
                    }

                    if (!AssertParseUnit(args, ref index, cmd, out ry))
                    {
                        return;
                    }

                    if (!AssertParseDouble(args, ref index, cmd, out ang))
                    {
                        return;
                    }

                    if (!AssertParseBoolInt(args, ref index, cmd, out large))
                    {
                        return;
                    }

                    if (!AssertParseBoolInt(args, ref index, cmd, out sweep))
                    {
                        return;
                    }

                    if (!AssertParseUnit(args, ref index, cmd, out endx))
                    {
                        return;
                    }

                    if (!AssertParseUnit(args, ref index, cmd, out endy))
                    {
                        return;
                    }

                    if (absolute)
                    {
                        path.ArcTo(rx, ry, ang, large ? PathArcSize.Large : PathArcSize.Small, sweep ? PathArcSweep.Positive : PathArcSweep.Negative, new PDFPoint(endx, endy));
                    }
                    else
                    {
                        path.ArcFor(rx, ry, ang, large ? PathArcSize.Large : PathArcSize.Small, sweep ? PathArcSweep.Positive : PathArcSweep.Negative, new PDFPoint(endx, endy));
                    }
                }
                else if (string.IsNullOrEmpty(args[index]))
                {
                    index++;
                }
            }
        }