public void CubicFor_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.CubicCurveFor(end, handleStart, 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.IsTrue(data.HasStartHandle); Assert.IsTrue(data.HasEndHandle); Assert.AreEqual(data.EndPoint, end); Assert.AreEqual(data.StartHandle, handleStart); Assert.AreEqual(data.EndHandle, handleEnd); }
private void ParseSVGCubicCommand(PDFGraphicsPath path, char cmd, bool absolute, string[] args) { PDFUnit startHandleX, startHandleY, 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 startHandleX)) { return; } if (!AssertParseUnit(args, ref index, cmd, out startHandleY)) { return; } 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.CubicCurveTo(new PDFPoint(endPtX, endPtY), new PDFPoint(startHandleX, startHandleY), new PDFPoint(endHandleX, endHandleY)); } else { path.CubicCurveFor(new PDFPoint(endPtX, endPtY), new PDFPoint(startHandleX, startHandleY), new PDFPoint(endHandleX, endHandleY)); } } else if (string.IsNullOrEmpty(args[index])) { index++; } } }