internal void ArcFor(PDFUnit rx, PDFUnit ry, double ang, PathArcSize size, PathArcSweep sweep, PDFPoint enddelta) { PDFPoint end = ConvertDeltaToActual(enddelta); PathArcData arc = new PathArcData() { RadiusX = rx, RadiusY = ry, XAxisRotation = ang, ArcSize = size, ArcSweep = sweep, EndPoint = end }; CurrentPath.Add(arc); IEnumerable <PathBezierCurveData> curves = PathDataHelper.GetBezierCurvesForArc(this.Cursor, arc); foreach (PathBezierCurveData bez in curves) { IncludeInBounds(bez.EndPoint); if (bez.HasStartHandle) { IncludeInBounds(bez.StartHandle); } if (bez.HasEndHandle) { IncludeInBounds(bez.EndHandle); } } Cursor = end; }
private void RenderPathOp(PathData data, PDFPoint location, ref PDFPoint cursor) { switch (data.Type) { case PathDataType.Move: PathMoveData move = (PathMoveData)data; cursor = move.MoveTo; this.RenderMoveTo(move.MoveTo.X + location.X, move.MoveTo.Y + location.Y); break; case PathDataType.Line: PathLineData line = (PathLineData)data; cursor = line.LineTo; this.RenderLineTo(line.LineTo.X + location.X, line.LineTo.Y + location.Y); break; case PathDataType.Rect: PathRectData rect = (PathRectData)data; cursor = rect.Rect.Location; this.RenderRectangle(rect.Rect.X + location.X, rect.Rect.Y + location.Y, rect.Rect.Width, rect.Rect.Height); break; case PathDataType.SubPath: PathSubPathData sub = (PathSubPathData)data; this.RenderPathData(location, sub.InnerPath, ref cursor); break; case PathDataType.Bezier: PathBezierCurveData bez = (PathBezierCurveData)data; cursor = bez.EndPoint; if (bez.HasStartHandle && bez.HasEndHandle) { this.RenderBezierCurveTo(bez.EndPoint.X + location.X, bez.EndPoint.Y + location.Y, bez.StartHandle.X + location.X, bez.StartHandle.Y + location.Y, bez.EndHandle.X + location.X, bez.EndHandle.Y + location.Y); } else if (bez.HasStartHandle) { this.RenderBezierCurveToWithStartHandleOnly(bez.EndPoint.X + location.X, bez.EndPoint.Y + location.Y, bez.StartHandle.X + location.X, bez.StartHandle.Y + location.Y); } else if (bez.HasEndHandle) { this.RenderBezierCurveToWithEndHandleOnly(bez.EndPoint.X + location.X, bez.EndPoint.Y + location.Y, bez.EndHandle.X + location.X, bez.EndHandle.Y + location.Y); } else { this.RenderLineTo(bez.Points[2].X, bez.Points[2].Y); } break; case PathDataType.Arc: IEnumerable <PathBezierCurveData> segments; PathArcData arc = (PathArcData)data; segments = PathDataHelper.GetBezierCurvesForArc(cursor, arc); foreach (PathBezierCurveData segment in segments) { this.RenderBezierCurveTo(segment.EndPoint.X + location.X, segment.EndPoint.Y + location.Y, segment.StartHandle.X + location.X, segment.StartHandle.Y + location.Y, segment.EndHandle.X + location.X, segment.EndHandle.Y + location.Y); } cursor = arc.EndPoint; break; case PathDataType.Quadratic: IEnumerable <PathBezierCurveData> quadSegments; PathQuadraticCurve quad = (PathQuadraticCurve)data; quadSegments = PathDataHelper.GetBezierCurvesForQuadratic(cursor, quad); foreach (PathBezierCurveData quadSeg in quadSegments) { this.RenderBezierCurveTo(quadSeg.EndPoint.X + location.X, quadSeg.EndPoint.Y + location.Y, quadSeg.StartHandle.X + location.X, quadSeg.StartHandle.Y + location.Y, quadSeg.EndHandle.X + location.X, quadSeg.EndHandle.Y + location.Y); } cursor = quad.EndPoint; break; case PathDataType.Close: this.RenderClosePathOp(); cursor = PDFPoint.Empty; break; default: throw new ArgumentOutOfRangeException("data.Type"); } }