/// <summary>
        /// Parses one or more smooth quadratic path commands in the format endx,endy
        /// </summary>
        /// <param name="path"></param>
        /// <param name="cmd"></param>
        /// <param name="absolute"></param>
        /// <param name="args"></param>
        /// <remarks>The handle is inferred as a reflection of the previous handle</remarks>
        private void ParseSVGSmoothQuadraticCommand(PDFGraphicsPath path, char cmd, bool absolute, string[] args)
        {
            PDFUnit endPtX, endPtY;
            int     index = 0;

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

                    if (absolute)
                    {
                        path.SmoothQuadraticCurveTo(new PDFPoint(endPtX, endPtY));
                    }
                    else
                    {
                        path.SmoothQuadraticCurveFor(new PDFPoint(endPtX, endPtY));
                    }
                }
                else if (string.IsNullOrEmpty(args[index]))
                {
                    index++;
                }
            }
        }
        public void CubicTo_Test()
        {
            PDFGraphicsPath target = new PDFGraphicsPath();

            Assert.IsTrue(target.Paths.Count == 1);
            Assert.IsTrue(target.HasCurrentPath);

            Assert.AreEqual(target.Cursor, PDFPoint.Empty);

            PDFPoint end         = new PDFPoint(100, 100);
            PDFPoint handleStart = new PDFPoint(0, 50);
            PDFPoint handleEnd   = new PDFPoint(50, 100);

            target.CubicCurveTo(end, handleStart, handleEnd);

            Assert.AreEqual(target.Cursor, end);
            Assert.AreEqual(target.Paths[0].Operations.Count, 1);
            Assert.IsInstanceOfType(target.Paths[0].Operations[0], typeof(PathBezierCurveData));

            PathBezierCurveData data = (PathBezierCurveData)target.Paths[0].Operations[0];

            Assert.AreEqual(data.Points.Length, 3);
            Assert.IsTrue(data.HasStartHandle);
            Assert.IsTrue(data.HasEndHandle);
            Assert.AreEqual(data.EndPoint, end);
            Assert.AreEqual(data.StartHandle, handleStart);
            Assert.AreEqual(data.EndHandle, handleEnd);
        }
        //
        // helper methods
        //


        #region protected virtual void BuildPath(PDFGraphicsPath path, PDFPoint[] points, PDFStyle style, bool end)

        /// <summary>
        /// Adds a series of lines to the path based on the points. Moving to the first in the array, adding lines after, and optionally closing and ending the path.
        /// </summary>
        /// <param name="path">The path to build the lines in</param>
        /// <param name="points">The points to add lines between</param>
        /// <param name="close">Closes the path (adds an extra line back to the starting point</param>
        /// <param name="end">If true then ends the path so no more points can be added to it</param>
        protected virtual void BuildPath(PDFGraphicsPath path, PDFPoint[] points, Style style, bool end)
        {
            if (path.HasCurrentPath == false)
            {
                path.BeginPath();
            }

            for (int i = 0; i < points.Length; i++)
            {
                if (i == 0)
                {
                    path.MoveTo(points[i]);
                }
                else
                {
                    path.LineTo(points[i]);
                }
            }

            bool closed = style.GetValue(StyleKeys.ShapeClosedKey, true);

            if (closed)
            {
                path.ClosePath(end);
            }
            else if (end)
            {
                path.EndPath();
            }
        }
        protected override PDFGraphicsPath CreatePath(PDFSize available, Style fullstyle)
        {
            var bounds = this.GetBounds();

            var xoffset = bounds.X.PointsValue;
            var yoffset = bounds.Y.PointsValue;

            PDFGraphicsPath path = new PDFGraphicsPath();

            if (null != this.Points)
            {
                for (int i = 0; i < this.Points.Count; i++)
                {
                    var pt = this.Points[i];
                    pt = pt.Offset(-xoffset, -yoffset);

                    if (i == 0)
                    {
                        path.MoveTo(pt);
                    }
                    else
                    {
                        path.LineTo(pt);
                    }
                }
            }
            return(path);
        }
        public void CubicForWithHandleEnd_Test()
        {
            PDFGraphicsPath target = new PDFGraphicsPath();

            Assert.IsTrue(target.Paths.Count == 1);
            Assert.IsTrue(target.HasCurrentPath);

            PDFPoint pos = new PDFPoint(10, 10);

            target.MoveTo(pos);
            Assert.AreEqual(target.Cursor, pos);

            PDFPoint end         = new PDFPoint(100, 100);
            PDFPoint handleStart = new PDFPoint(0, 50);
            PDFPoint handleEnd   = new PDFPoint(50, 100);

            target.CubicCurveForWithHandleEnd(end, handleEnd);

            end         = end.Offset(pos);
            handleEnd   = handleEnd.Offset(pos);
            handleStart = handleStart.Offset(pos);

            Assert.AreEqual(target.Cursor, end);
            Assert.AreEqual(target.Paths[0].Operations.Count, 2);
            Assert.IsInstanceOfType(target.Paths[0].Operations[1], typeof(PathBezierCurveData));

            PathBezierCurveData data = (PathBezierCurveData)target.Paths[0].Operations[1];

            Assert.AreEqual(data.Points.Length, 3);
            Assert.IsFalse(data.HasStartHandle);
            Assert.IsTrue(data.HasEndHandle);
            Assert.AreEqual(data.EndPoint, end);
            Assert.AreEqual(data.StartHandle, PDFPoint.Empty);
            Assert.AreEqual(data.EndHandle, handleEnd);
        }
        private void ParseSVGLineCommand(PDFGraphicsPath path, char cmd, bool absolute, string[] args)
        {
            PDFUnit x, y;
            int     index = 0;

            while (index < args.Length)
            {
                //must be at least an x and y, but can optionally be more x and y's
                if (index == 0 || !string.IsNullOrEmpty(args[index]))
                {
                    if (!AssertParseUnit(args, ref index, cmd, out x))
                    {
                        return;
                    }
                    if (!AssertParseUnit(args, ref index, cmd, out y))
                    {
                        return;
                    }

                    if (absolute)
                    {
                        path.LineTo(new PDFPoint(x, y));
                    }
                    else
                    {
                        path.LineFor(new PDFPoint(x, y));
                    }
                }
                else if (string.IsNullOrEmpty(args[index]))
                {
                    index++;
                }
            }
        }
        public void Bounds_Test()
        {
            PDFGraphicsPath target = new PDFGraphicsPath();

            Assert.IsTrue(target.Paths.Count == 1);
            Assert.IsTrue(target.HasCurrentPath);

            PDFPoint pos = new PDFPoint(10, 10);

            target.MoveTo(pos);

            PDFPoint end         = new PDFPoint(100, 100);
            PDFPoint handleStart = new PDFPoint(0, 50);
            PDFPoint handleEnd   = new PDFPoint(50, 100);

            target.CubicCurveForWithHandleEnd(end, handleEnd);

            end         = end.Offset(pos);
            handleEnd   = handleEnd.Offset(pos);
            handleStart = handleStart.Offset(pos);

            PDFRect bounds = target.Bounds;

            Assert.AreEqual(bounds.X, PDFUnit.Zero);
            Assert.AreEqual(bounds.Y, PDFUnit.Zero);
            Assert.AreEqual(bounds.Width, end.X);
            Assert.AreEqual(bounds.Height, end.Y);
        }
        public void HorizontalLineFor_Test()
        {
            PDFGraphicsPath target = new PDFGraphicsPath();

            Assert.IsTrue(target.Paths.Count == 1);
            Assert.IsTrue(target.HasCurrentPath);

            Assert.AreEqual(target.Cursor, PDFPoint.Empty);

            PDFPoint pos = new PDFPoint(10, 10);

            target.LineTo(pos);

            Assert.AreEqual(target.Cursor, pos);
            Assert.AreEqual(target.Paths[0].Operations.Count, 1);
            Assert.IsInstanceOfType(target.Paths[0].Operations[0], typeof(PathLineData));
            PathLineData data = (PathLineData)target.Paths[0].Operations[0];

            Assert.AreEqual(data.LineTo, pos);

            PDFUnit h = 40;

            target.HorizontalLineFor(h);

            pos = new PDFPoint(pos.X + h, pos.Y);
            Assert.AreEqual(target.Cursor, pos);
            Assert.AreEqual(target.Paths[0].Operations.Count, 2);
            Assert.IsInstanceOfType(target.Paths[0].Operations[1], typeof(PathLineData));
            data = (PathLineData)target.Paths[0].Operations[1];
            Assert.AreEqual(data.LineTo, pos);
        }
        public void LineFor_Test()
        {
            PDFGraphicsPath target = new PDFGraphicsPath();

            Assert.IsTrue(target.Paths.Count == 1);
            Assert.IsTrue(target.HasCurrentPath);

            Assert.AreEqual(target.Cursor, PDFPoint.Empty);

            PDFPoint pos = new PDFPoint(10, 10);

            target.LineTo(pos);

            Assert.AreEqual(target.Cursor, pos);
            Assert.AreEqual(target.Paths[0].Operations.Count, 1);
            Assert.IsInstanceOfType(target.Paths[0].Operations[0], typeof(PathLineData));
            PathLineData data = (PathLineData)target.Paths[0].Operations[0];

            Assert.AreEqual(data.LineTo, pos);

            PDFPoint pos2 = new PDFPoint(40, 40);

            target.LineFor(pos2);
            PDFPoint total = new PDFPoint(pos.X + pos2.X, pos.Y + pos2.Y);

            Assert.AreEqual(target.Cursor, total);
            Assert.AreEqual(target.Paths[0].Operations.Count, 2);
            Assert.IsInstanceOfType(target.Paths[0].Operations[1], typeof(PathLineData));
            data = (PathLineData)target.Paths[0].Operations[1];
            Assert.AreEqual(data.LineTo, total);
        }
        public void MoveTo_Test()
        {
            PDFGraphicsPath target = new PDFGraphicsPath();

            Assert.IsTrue(target.Paths.Count == 1);
            Assert.IsTrue(target.HasCurrentPath);

            Assert.AreEqual(target.Cursor, PDFPoint.Empty);

            PDFPoint pos = new PDFPoint(10, 10);

            target.MoveTo(pos);

            Assert.AreEqual(target.Cursor, pos);
            Assert.AreEqual(target.Paths[0].Operations.Count, 1);
            Assert.IsInstanceOfType(target.Paths[0].Operations[0], typeof(PathMoveData));
            PathMoveData data = (PathMoveData)target.Paths[0].Operations[0];

            Assert.AreEqual(data.MoveTo, pos);

            pos = new PDFPoint(40, 40);
            target.MoveTo(pos);
            Assert.AreEqual(target.Cursor, pos);
            Assert.AreEqual(target.Paths[0].Operations.Count, 2);
            Assert.IsInstanceOfType(target.Paths[0].Operations[1], typeof(PathMoveData));
            data = (PathMoveData)target.Paths[0].Operations[1];
            Assert.AreEqual(data.MoveTo, pos);
        }
        private void ParseSVGHorizontalCommand(PDFGraphicsPath path, char cmd, bool absolute, string[] args)
        {
            PDFUnit h;
            int     index = 0;


            while (index < args.Length)
            {
                //must be at least one, but can optionally be more
                if (index == 0 || !string.IsNullOrEmpty(args[index]))
                {
                    if (AssertParseUnit(args, ref index, cmd, out h))
                    {
                        if (absolute)
                        {
                            path.HorizontalLineTo(h);
                        }
                        else
                        {
                            path.HorizontalLineFor(h);
                        }
                    }
                }
                else if (string.IsNullOrEmpty(args[index]))
                {
                    index++;
                }
            }
        }
        public void ClosePath_Test()
        {
            PDFGraphicsPath target = new PDFGraphicsPath();

            Assert.IsTrue(target.Paths.Count == 1);
            Assert.IsTrue(target.HasCurrentPath);

            bool end = false;

            target.ClosePath(end);
            Assert.IsTrue(target.Paths.Count == 1, "Paths count after close was not 1");
            Assert.IsTrue(target.Paths[0].Count == 1, "First path does not have one entry");
            Assert.IsTrue(target.Paths[0].Operations.Count == 1, "First path operations count was not 1");
            Assert.IsInstanceOfType(target.Paths[0].Operations[0], typeof(PathCloseData), "Opertation type was not a PathClose");

            //should still have a current path.
            Assert.IsTrue(target.HasCurrentPath, "There is no current path");
            Assert.IsNotNull(target.CurrentPath);


            end    = true;
            target = new PDFGraphicsPath();
            Assert.IsTrue(target.Paths.Count == 1);
            Assert.IsTrue(target.HasCurrentPath);

            target.ClosePath(true);
            Assert.IsTrue(target.Paths.Count == 1, "Paths count after close was not 1");
            Assert.IsTrue(target.Paths[0].Count == 1, "First path does not have one entry");
            Assert.IsTrue(target.Paths[0].Operations.Count == 1, "First path operations count was not 1");
            Assert.IsInstanceOfType(target.Paths[0].Operations[0], typeof(PathCloseData), "Opertation type was not a PathClose");

            //should NOT have a current path.
            Assert.IsFalse(target.HasCurrentPath, "There is a current path after ending it");
            Assert.IsNull(target.CurrentPath, "Current path is not null after ending path");
        }
        protected override PDFGraphicsPath CreatePath(PDFSize available, Style fullstyle)
        {
            PDFGraphicsPath path = base.CreatePath(available, fullstyle);

            path.ClosePath(true);

            return(path);
        }
Example #14
0
        protected override PDFGraphicsPath CreatePath(PDFSize available, Style fullstyle)
        {
            var bounds = this.GetBounds();
            var path   = new PDFGraphicsPath();

            Ellipse.BuildElipse(path, bounds, true, 0);

            return(path);
        }
Example #15
0
        protected override PDFGraphicsPath CreatePath(PDFSize available, Style fullstyle)
        {
            PDFRect         rect = this.GetBounds();
            PDFGraphicsPath path = new PDFGraphicsPath();

            Ellipse.BuildElipse(path, rect, true, 0);

            return(path);
        }
        public void PDFGraphicsPathConstructor_Test1()
        {
            PDFGraphicsPath target = new PDFGraphicsPath();

            Assert.IsNotNull(target);
            Assert.IsTrue(target.CurrentPath != null);
            Assert.IsTrue(target.HasCurrentPath);
            Assert.IsNotNull(target.Paths);
            Assert.IsTrue(target.Paths.Count == 1);
        }
        public void ParseEmpty_Test()
        {
            PDFGraphicsPath target = PDFGraphicsPath.Parse("");

            Assert.IsNotNull(target);
            Assert.IsTrue(target.CurrentPath != null);
            Assert.IsTrue(target.HasCurrentPath);
            Assert.IsNotNull(target.Paths);
            Assert.IsTrue(target.Paths.Count == 1);
        }
        /// <summary>
        /// Implements the base classes abstract method to build a path.
        /// </summary>
        /// <param name="available"></param>
        /// <param name="fullstyle"></param>
        /// <returns></returns>
        protected override PDFGraphicsPath CreatePath(PDFSize available, Style fullstyle)
        {
            PDFRect rect = this.GetPrescribedBounds(available, fullstyle);

            PDFPoint[] points = this.GetPoints(rect, fullstyle);

            PDFGraphicsPath path = new PDFGraphicsPath();

            this.BuildPath(path, points, fullstyle, true);

            return(path);
        }
        public void BeginPath_Test()
        {
            PDFGraphicsPath target = new PDFGraphicsPath();

            Assert.IsTrue(target.Paths.Count == 1);
            Assert.IsTrue(target.HasCurrentPath);

            target.BeginPath();
            Assert.IsTrue(target.HasCurrentPath);
            Assert.IsTrue(target.Paths.Count == 2);
            Assert.AreEqual(target.CurrentPath.Count, 0);
        }
        public void ParseClose_Test()
        {
            PDFGraphicsPath target = PDFGraphicsPath.Parse("Z");

            Assert.IsNotNull(target);
            Assert.IsTrue(target.CurrentPath != null);
            Assert.IsTrue(target.HasCurrentPath);
            Assert.IsNotNull(target.Paths);
            Assert.IsTrue(target.Paths.Count == 1);
            Assert.IsTrue(target.Paths[0].Operations.Count == 1);
            Assert.IsInstanceOfType(target.Paths[0].Operations[0], typeof(PathCloseData));
        }
        public void ParseSVG(PDFGraphicsPath path, string data)
        {
            string[] tokens = operators.Split(data);

            foreach (string match in tokens)
            {
                if (!string.IsNullOrEmpty(match))
                {
                    ParseSVGCommand(path, match);
                }
            }
        }
Example #22
0
        protected override void BuildPath(PDFGraphicsPath path, PDFPoint[] points, Style style, bool end)
        {
            int  vertexstep = style.GetValue(StyleKeys.ShapeVertexStepKey, 1);
            bool closed     = style.GetValue(StyleKeys.ShapeClosedKey, true);

            if (this.HasPoints == false && vertexstep > 1)
            {
                this.BuildPolygramPath(path, points, vertexstep, closed, end);
            }
            else
            {
                base.BuildPath(path, points, style, end);
            }
        }
        public void EndPath_Test()
        {
            PDFGraphicsPath target = new PDFGraphicsPath();

            Assert.IsTrue(target.Paths.Count == 1);
            Assert.IsTrue(target.HasCurrentPath);

            target.EndPath();
            Assert.IsTrue(target.Paths.Count == 1, "Paths count after close was not 1");
            Assert.IsTrue(target.Paths[0].Count == 0, "First path should not have any entries");

            //should NOT have a current path.
            Assert.IsFalse(target.HasCurrentPath, "There is a current path after ending it");
            Assert.IsNull(target.CurrentPath, "Current path is not null after ending path");
        }
Example #24
0
        protected override PDFGraphicsPath CreatePath(PDFSize available, Style fullstyle)
        {
            PDFRect             bounds = GetPrescribedBounds(available, fullstyle);
            StyleValue <bool>   isclosed;
            StyleValue <double> rotation;

            fullstyle.TryGetValue(StyleKeys.ShapeClosedKey, out isclosed);
            fullstyle.TryGetValue(StyleKeys.ShapeRotationKey, out rotation);
            PDFGraphicsPath path = new PDFGraphicsPath();

            BuildElipse(path, bounds,
                        (isclosed == null)? true : isclosed.Value,
                        ((rotation == null)? 0.0 : rotation.Value) + this.DefaultRotation);

            return(path);
        }
Example #25
0
        protected override PDFGraphicsPath CreatePath(PDFSize available, Style fullstyle)
        {
            //We use top left zero based moving and line
            var bounds = this.GetBounds();
            var x1     = this.X1 - bounds.X;
            var x2     = this.X2 - bounds.X;
            var y1     = this.Y1 - bounds.Y;
            var y2     = this.Y2 - bounds.Y;

            var path = new PDFGraphicsPath();

            path.MoveTo(new PDFPoint(x1, y1));
            path.LineTo(new PDFPoint(x2, y2));

            return(path);
        }
        /// <summary>
        /// Parses a single svg path command - first character is the command character, and the numeric arguments follow after.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="command"></param>
        public void ParseSVGCommand(PDFGraphicsPath path, string command)
        {
            char cmd = command[0];

            string[] args;

            if (command.Length > 0)
            {
                args = arguments.Split(command.Substring(1).Trim());
            }
            else
            {
                args = null;
            }

            ParseSVGCommand(path, cmd, args);
        }
        public void SVGParser_Test()
        {
            var pathData = @"M-84.1487,-15.8513h168.2974 V10.053 H-2Z";

            PDFSVGPathDataParser parser = new PDFSVGPathDataParser(true, null);
            PDFGraphicsPath      path   = new PDFGraphicsPath();

            parser.ParseSVG(path, pathData);
            Assert.AreEqual(path.Paths.Count, 1);
            Assert.AreEqual(path.Paths[0].Operations.Count, 5);

            //M-84.1487,-15.8513
            Assert.IsInstanceOfType(path.Paths[0].Operations[0], typeof(PathMoveData));
            PathMoveData move = (PathMoveData)path.Paths[0].Operations[0];

            Assert.AreEqual(move.MoveTo.X.PointsValue, -84.1487);
            Assert.AreEqual(move.MoveTo.Y.PointsValue, -15.8513);

            //h168.2974
            Assert.IsInstanceOfType(path.Paths[0].Operations[1], typeof(PathLineData));
            PathLineData line = (PathLineData)path.Paths[0].Operations[1];

            Assert.AreEqual(line.LineTo.X.PointsValue, -84.1487 + 168.2974);
            Assert.AreEqual(line.LineTo.Y.PointsValue, -15.8513);

            //V10.053
            Assert.IsInstanceOfType(path.Paths[0].Operations[2], typeof(PathLineData));
            line = (PathLineData)path.Paths[0].Operations[2];
            Assert.AreEqual(line.LineTo.X.PointsValue, -84.1487 + 168.2974);
            Assert.AreEqual(line.LineTo.Y.PointsValue, 10.053);

            //H-2
            Assert.IsInstanceOfType(path.Paths[0].Operations[3], typeof(PathLineData));
            line = (PathLineData)path.Paths[0].Operations[3];
            Assert.AreEqual(line.LineTo.X.PointsValue, -2.0);
            Assert.AreEqual(line.LineTo.Y.PointsValue, 10.053);

            //Z close
            Assert.IsInstanceOfType(path.Paths[0].Operations[path.Paths[0].Operations.Count - 1], typeof(PathCloseData));
        }
        /// <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++;
                }
            }
        }
Example #29
0
        public static void BuildElipse(PDFGraphicsPath path, PDFRect rect, bool closed, double angle)
        {
            double width  = rect.Width.PointsValue;
            double height = rect.Height.PointsValue;

            if (width <= 0 || height <= 0)
            {
                return;
            }

            // build the ellipse around the origin
            // rotate each by the required amount
            // then translate into position.

            double centerX = rect.Width.PointsValue / 2.0;
            double centerY = rect.Height.PointsValue / 2.0;

            double radX = width / 2.0;
            double radY = height / 2.0;

            double lengthX = (double)((width * CircularityFactor) / 2.0);
            double lengthY = (double)((height * CircularityFactor) / 2.0);

            double rotation = angle * InRadians;

            //start at left, middle
            PDFPoint start = Rotate(new PDFPoint(-radX, 0), rotation);


            //4 curve definitions with 3 points each.
            PDFPoint[,] curves = new PDFPoint[4, 3];


            //arc to center, top
            curves[0, 0] = Rotate(new PDFPoint(0, -radY), rotation);
            curves[0, 1] = Rotate(new PDFPoint(-radX, -lengthY), rotation);
            curves[0, 2] = Rotate(new PDFPoint(-lengthX, -radY), rotation);



            //arc to right, middle
            curves[1, 0] = Rotate(new PDFPoint(radX, 0), rotation);
            curves[1, 1] = Rotate(new PDFPoint(lengthX, -radY), rotation);
            curves[1, 2] = Rotate(new PDFPoint(radX, -lengthY), rotation);


            //arc to center, bottom
            curves[2, 0] = Rotate(new PDFPoint(0, radY), rotation);
            curves[2, 1] = Rotate(new PDFPoint(radX, lengthY), rotation);
            curves[2, 2] = Rotate(new PDFPoint(lengthX, radY), rotation);


            //arc to left middle
            curves[3, 0] = Rotate(new PDFPoint(-radX, 0), rotation);
            curves[3, 1] = Rotate(new PDFPoint(-lengthX, radY), rotation);
            curves[3, 2] = Rotate(new PDFPoint(-radX, lengthY), rotation);

            //get the minimun x and y values
            PDFUnit minx = start.X;
            PDFUnit miny = start.Y;

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    PDFPoint pt = curves[i, j];
                    minx = PDFUnit.Min(minx, pt.X);
                    miny = PDFUnit.Min(miny, pt.Y);
                }
            }
            PDFUnit offsetx = 0 - minx;
            PDFUnit offsety = 0 - miny;

            //translate the point by the minimum values so the topleft is always 0,0 in the boundary rect.

            start = Translate(start, offsetx, offsety);

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    PDFPoint pt = curves[i, j];
                    pt           = Translate(pt, offsetx, offsety);
                    curves[i, j] = pt;
                }
            }

            path.MoveTo(start);
            path.CubicCurveTo(curves[0, 0], curves[0, 1], curves[0, 2]);
            path.CubicCurveTo(curves[1, 0], curves[1, 1], curves[1, 2]);
            path.CubicCurveTo(curves[2, 0], curves[2, 1], curves[2, 2]);
            path.CubicCurveTo(curves[3, 0], curves[3, 1], curves[3, 2]);



            //close
            if (closed)
            {
                path.ClosePath(true);
            }
            else
            {
                path.EndPath();
            }
        }
        private void ParseSVGCommand(PDFGraphicsPath path, char cmd, string[] args)
        {
            switch (cmd)
            {
            case ('M'):
                ParseSVGMoveCommand(path, cmd, true, args);
                break;

            case ('m'):
                ParseSVGMoveCommand(path, cmd, false, args);
                break;

            case ('Z'):
                ParseSVGCloseCommand(path, args);
                break;

            case ('z'):
                ParseSVGCloseCommand(path, args);
                break;

            case ('L'):
                ParseSVGLineCommand(path, cmd, true, args);
                break;

            case ('l'):
                ParseSVGLineCommand(path, cmd, false, args);
                break;

            case ('H'):
                ParseSVGHorizontalCommand(path, cmd, true, args);
                break;

            case ('h'):
                ParseSVGHorizontalCommand(path, cmd, false, args);
                break;

            case ('V'):
                ParseSVGVerticalCommand(path, cmd, true, args);
                break;

            case ('v'):
                ParseSVGVerticalCommand(path, cmd, false, args);
                break;

            case ('C'):
                ParseSVGCubicCommand(path, cmd, true, args);
                break;

            case ('c'):
                ParseSVGCubicCommand(path, cmd, false, args);
                break;

            case ('S'):
                ParseSVGSmoothCubicCommand(path, cmd, true, args);
                break;

            case ('s'):
                ParseSVGSmoothCubicCommand(path, cmd, false, args);
                break;

            case ('Q'):
                ParseSVGQuadraticCommand(path, cmd, true, args);
                break;

            case ('q'):
                ParseSVGQuadraticCommand(path, cmd, false, args);
                break;

            case ('T'):
                ParseSVGSmoothQuadraticCommand(path, cmd, true, args);
                break;

            case ('t'):
                ParseSVGSmoothQuadraticCommand(path, cmd, false, args);
                break;

            case ('A'):
                ParseSVGArcCommand(path, cmd, true, args);
                break;

            case ('a'):
                ParseSVGArcCommand(path, cmd, false, args);
                break;

            default:
                break;
            }
        }