コード例 #1
0
        /// <summary>
        /// Parses one or more smooth Cubic path commands in the format endHandleX,endHandeY endX,endY
        /// </summary>
        /// <param name="path"></param>
        /// <param name="cmd"></param>
        /// <param name="absolute"></param>
        /// <param name="args"></param>
        /// <remarks>The curve is a cubic bezier path that starts from the current cursor position.
        /// The start handle is inferred as a reflection of the previous handle point</remarks>
        private void ParseSVGSmoothCubicCommand(PDFGraphicsPath path, char cmd, bool absolute, string[] args)
        {
            PDFUnit endHandleX, endHandleY, endPtX, endPtY;
            int     index = 0;

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

                    if (absolute)
                    {
                        path.SmoothCubicCurveTo(new PDFPoint(endPtX, endPtY), new PDFPoint(endHandleX, endHandleY));
                    }
                    else
                    {
                        path.SmoothCubicCurveFor(new PDFPoint(endPtX, endPtY), new PDFPoint(endHandleX, endHandleY));
                    }
                }
                else if (string.IsNullOrEmpty(args[index]))
                {
                    index++;
                }
            }
        }