Edit

Share via


CGContext.AddCurveToPoint Method

Definition

Adds a cubic Bézier curve at the current point, with the specified control parameters.

public void AddCurveToPoint (nfloat cp1x, nfloat cp1y, nfloat cp2x, nfloat cp2y, nfloat x, nfloat y);
member this.AddCurveToPoint : nfloat * nfloat * nfloat * nfloat * nfloat * nfloat -> unit

Parameters

cp1x
nfloat

The x-value of the first control point.

cp1y
nfloat

The y-value of the first control point.

cp2x
nfloat

The x-value of the second control point.

cp2y
nfloat

The y-value of the second control point.

x
nfloat

The x-value at which the Bézier curve should end.

y
nfloat

The y-value at which the Bézier curve should end.

Remarks

All coordinates are in user space coordinates.

public override void Draw (RectangleF rect)
{
	base.Draw (rect);
	using (var ctxt = UIGraphics.GetCurrentContext ()) {
		var startingPoint = new PointF (100, 100);
		var controlPoint1 = new PointF (20, 100);
		var controlPoint2 = new PointF (4, 110);
		var endingPoint = new PointF (120, 120);

		ctxt.SetStrokeColor (UIColor.Red.CGColor);
		ctxt.MoveTo (startingPoint.X, startingPoint.Y);
		ctxt.AddCurveToPoint (controlPoint1.X, controlPoint1.Y, controlPoint2.X, controlPoint2.Y, endingPoint.X, endingPoint.Y);
		ctxt.StrokePath ();

		//Illustrate parameters
		ctxt.SetStrokeColor (UIColor.Black.CGColor);
		var sz = new SizeF (2, 2);
		Func<PointF,PointF> offset = (PointF pt) => new PointF(pt.X - 1, pt.Y - 1);
		ctxt.AddEllipseInRect (new RectangleF (offset(startingPoint),sz));
		ctxt.AddEllipseInRect (new RectangleF (offset(controlPoint1), sz));
		ctxt.AddEllipseInRect (new RectangleF (offset(controlPoint2), sz));
		ctxt.AddEllipseInRect (new RectangleF (offset(endingPoint), sz));
		ctxt.StrokePath();
	}
}

Applies to