private void CurveTo(bool isRelative) { var point = NewPoint(NextValue, NextValue, isRelative, false); var x = NextValue; var y = NextValue; var isQuad = char.IsLetter(_commandStack.Peek()[0]); var point2 = NewPoint(x, y, isRelative, isQuad); if (isQuad) { _path.QuadTo(point, point2); } else { var point3 = NewPoint(NextValue, NextValue, isRelative, true); _path.CurveTo(point, point2, point3); _lastCurveControlPoint = point2; } }
public PathF Rotate(float angle, PointF pivotPoint) { var path = new PathF(); var index = 0; var arcIndex = 0; var clockwiseIndex = 0; foreach (var operation in _operations) { if (operation == PathOperation.MoveTo) { var point = GetRotatedPoint(index++, pivotPoint, angle); path.MoveTo(point); } else if (operation == PathOperation.Line) { var point = GetRotatedPoint(index++, pivotPoint, angle); path.LineTo(point.X, point.Y); } else if (operation == PathOperation.Quad) { var controlPoint = GetRotatedPoint(index++, pivotPoint, angle); var point = GetRotatedPoint(index++, pivotPoint, angle); path.QuadTo(controlPoint.X, controlPoint.Y, point.X, point.Y); } else if (operation == PathOperation.Cubic) { var controlPoint1 = GetRotatedPoint(index++, pivotPoint, angle); var controlPoint2 = GetRotatedPoint(index++, pivotPoint, angle); var point = GetRotatedPoint(index++, pivotPoint, angle); path.CurveTo(controlPoint1.X, controlPoint1.Y, controlPoint2.X, controlPoint2.Y, point.X, point.Y); } else if (operation == PathOperation.Arc) { var topLeft = GetRotatedPoint(index++, pivotPoint, angle); var bottomRight = GetRotatedPoint(index++, pivotPoint, angle); var startAngle = _arcAngles[arcIndex++]; var endAngle = _arcAngles[arcIndex++]; var clockwise = _arcClockwise[clockwiseIndex++]; path.AddArc(topLeft, bottomRight, startAngle, endAngle, clockwise); } else if (operation == PathOperation.Close) { path.Close(); } } return(path); }