CGMutablePath
A mutable graphics path: a mathematical description of shapes or lines to be drawn in a graphics context.
Constructor Summary
Public Constructor | ||
public |
Creates a mutable graphics path. |
Method Summary
Public Methods | ||
public |
addArc(center: CGPoint, radius: number, startAngle: number, endAngle: number, clockwise: boolean, transform: CGAffineTransform): void This method calculates starting and ending points using the radius and angles you specify, uses a sequence of cubic Bézier curves to approximate a segment of a circle between those points, and then appends those curves to the path.The clockwise parameter determines the direction in which the arc is created; the actual direction of the final path is dependent on the transform parameter and the current transform of a context where the path is drawn. |
|
public |
addCurveTo(end: CGPoint, control1: CGPoint, control2: CGPoint, transform: CGAffineTransform): void This method constructs a curve starting from the path's current point and ending at the specified end point, with curvature defined by the two control points. After this method appends that curve to the current path, the end point of the curve becomes the path's current point. |
|
public |
addEllipseIn(rect: CGRect, transform: CGAffineTransform): void The ellipse is approximated by a sequence of Bézier curves. |
|
public |
After adding the line segment, the current point is set to the endpoint of the line segment. |
|
public |
addLinesBetween(points: CGPoint[], transform: CGAffineTransform): void Calling this convenience method is equivalent to calling the move(to:transform:) method with the first value in the points array, then calling the addLine(to:transform:) method for each subsequent point until the array is exhausted. |
|
public |
If the path parameter is a non-empty empty path, its path elements are appended in order to this path. |
|
public |
addQuadCurveTo(end: CGPoint, control: CGPoint, transform: CGAffineTransform): void This method constructs a curve starting from the path's current point and ending at the specified end point, with curvature defined by the control point. After this method appends that curve to the current path, the end point of the curve becomes the path's current point. |
|
public |
This is a convenience function that adds a rectangle to a path, starting by moving to the bottom left corner and then adding lines counter-clockwise to create a rectangle, closing the subpath. |
|
public |
Calling this convenience method is equivalent to repeatedly calling the addRect(_:transform:) method for each rectangle in the array. |
|
public |
addRelativeArc(center: CGPoint, radius: number, startAngle: number, delta: number, transform: CGAffineTransform): void This method calculates starting and ending points using the radius and angles you specify, uses a sequence of cubic Bézier curves to approximate a segment of a circle between those points, and then appends those curves to the path.The delta parameter determines both the length of the arc the direction in which the arc is created; the actual direction of the final path is dependent on the transform parameter and the current transform of a context where the path is drawn. |
|
public |
addRoundedRectIn(rect: CGRect, cornerWidth: number, cornerHeight: number, transform: CGAffineTransform): void This convenience method is equivalent to a move operation to start the subpath followed by a series of arc and line operations that construct the rounded rectangle. |
|
public |
closeSubpath(): void Appends a line from the current point to the starting point of the current subpath and ends the subpath. |
|
public |
The specified point becomes the start point of a new subpath. |
|
public |
You can modify a mutable graphics path by calling the various path geometry functions, such as addArc(:x:y:radius:startAngle:endAngle:clockwise:), addLineTo(:x:y:), and moveTo(_:x:y:). |
|
public |
mutableCopyUsing(transform: UnsafePointer<CGAffineTransform>): CGMutablePath Creates a mutable copy of a graphics path transformed by a transformation matrix. |
Public Constructors
Public Methods
public addArc(center: CGPoint, radius: number, startAngle: number, endAngle: number, clockwise: boolean, transform: CGAffineTransform): void source
This method calculates starting and ending points using the radius and angles you specify, uses a sequence of cubic Bézier curves to approximate a segment of a circle between those points, and then appends those curves to the path.The clockwise parameter determines the direction in which the arc is created; the actual direction of the final path is dependent on the transform parameter and the current transform of a context where the path is drawn. In a flipped coordinate system (the default for UIView drawing methods in iOS), specifying a clockwise arc results in a counterclockwise arc after the transformation is applied.If the path already contains a subpath, this method adds a line connecting the current point to the starting point of the arc. If the current path is empty, his method creates a new subpath whose starting point is the starting point of the arc. The ending point of the arc becomes the new current point of the path.
Params:
Name | Type | Attribute | Description |
center | CGPoint | The center of the arc, in user space coordinates. |
|
radius | number | The radius of the arc, in user space coordinates. |
|
startAngle | number | The angle to the starting point of the arc, measured in radians from the positive x-axis. |
|
endAngle | number | The angle to the end point of the arc, measured in radians from the positive x-axis. |
|
clockwise | boolean | true to make a clockwise arc; false to make a counterclockwise arc. |
|
transform | CGAffineTransform | An affine transform to apply to the arc before adding to the path. Defaults to the identity transform if not specified. |
Return:
void |
public addCurveTo(end: CGPoint, control1: CGPoint, control2: CGPoint, transform: CGAffineTransform): void source
This method constructs a curve starting from the path's current point and ending at the specified end point, with curvature defined by the two control points. After this method appends that curve to the current path, the end point of the curve becomes the path's current point.
Params:
Name | Type | Attribute | Description |
end | CGPoint | The point, in user space coordinates, at which to end the curve. |
|
control1 | CGPoint | The first control point of the curve, in user space coordinates. |
|
control2 | CGPoint | The second control point of the curve, in user space coordinates. |
|
transform | CGAffineTransform | An affine transform to apply to the curve before adding to the path. Defaults to the identity transform if not specified. |
Return:
void |
public addEllipseIn(rect: CGRect, transform: CGAffineTransform): void source
The ellipse is approximated by a sequence of Bézier curves. Its center is the midpoint of the rectangle defined by the rect parameter. If the rectangle is square, then the ellipse is circular with a radius equal to one-half the width (or height) of the rectangle. If the rect parameter specifies a rectangular shape, then the major and minor axes of the ellipse are defined by the width and height of the rectangle.The ellipse forms a complete subpath of the path—that is, the ellipse drawing starts with a move-to operation and ends with a close-subpath operation, with all moves oriented in the clockwise direction.
Params:
Name | Type | Attribute | Description |
rect | CGRect | A rectangle that defines the area for the ellipse to fit in. |
|
transform | CGAffineTransform | An affine transform to apply to the ellipse before adding to the path. Defaults to the identity transform if not specified. |
Return:
void |
public addLineTo(point: CGPoint, transform: CGAffineTransform): void source
After adding the line segment, the current point is set to the endpoint of the line segment.
Params:
Name | Type | Attribute | Description |
point | CGPoint | The location, in user space coordinates, for the end of the new line segment. |
|
transform | CGAffineTransform | An affine transform to apply to the point before adding to the path. Defaults to the identity transform if not specified. |
Return:
void |
public addLinesBetween(points: CGPoint[], transform: CGAffineTransform): void source
Calling this convenience method is equivalent to calling the move(to:transform:) method with the first value in the points array, then calling the addLine(to:transform:) method for each subsequent point until the array is exhausted. After calling this method, the path's current point is the last point in the array.
Params:
Name | Type | Attribute | Description |
points | CGPoint[] | An array of values that specify the start and end points of the line segments to draw. Each point in the array specifies a position in user space. The first point in the array specifies the initial starting point. |
|
transform | CGAffineTransform | An affine transform to apply to the points before adding to the path. Defaults to the identity transform if not specified. |
Return:
void |
public addPath(path: CGPath, transform: CGAffineTransform): void source
If the path parameter is a non-empty empty path, its path elements are appended in order to this path. Afterward, the start point and current point of this path are those of the last subpath in the path parameter.
Params:
Name | Type | Attribute | Description |
path | CGPath | The path to add. |
|
transform | CGAffineTransform | An affine transform to apply to the path parameter before adding to this path. Defaults to the identity transform if not specified. |
Return:
void |
public addQuadCurveTo(end: CGPoint, control: CGPoint, transform: CGAffineTransform): void source
This method constructs a curve starting from the path's current point and ending at the specified end point, with curvature defined by the control point. After this method appends that curve to the current path, the end point of the curve becomes the path's current point.
Params:
Name | Type | Attribute | Description |
end | CGPoint | The point, in user space coordinates, at which to end the curve. |
|
control | CGPoint | The control point of the curve, in user space coordinates. |
|
transform | CGAffineTransform | An affine transform to apply to the curve before adding to the path. Defaults to the identity transform if not specified. |
Return:
void |
public addRect(rect: CGRect, transform: CGAffineTransform): void source
This is a convenience function that adds a rectangle to a path, starting by moving to the bottom left corner and then adding lines counter-clockwise to create a rectangle, closing the subpath.
Params:
Name | Type | Attribute | Description |
rect | CGRect | A rectangle, specified in user space coordinates. |
|
transform | CGAffineTransform | An affine transform to apply to the rectangle before adding to the path. Defaults to the identity transform if not specified. |
Return:
void |
public addRects(rects: CGRect[], transform: CGAffineTransform): void source
Calling this convenience method is equivalent to repeatedly calling the addRect(_:transform:) method for each rectangle in the array.
Params:
Name | Type | Attribute | Description |
rects | CGRect[] | An array of rectangles, specified in user space coordinates. |
|
transform | CGAffineTransform | An affine transform to apply to the rectangles before adding to the path. Defaults to the identity transform if not specified. |
Return:
void |
public addRelativeArc(center: CGPoint, radius: number, startAngle: number, delta: number, transform: CGAffineTransform): void source
This method calculates starting and ending points using the radius and angles you specify, uses a sequence of cubic Bézier curves to approximate a segment of a circle between those points, and then appends those curves to the path.The delta parameter determines both the length of the arc the direction in which the arc is created; the actual direction of the final path is dependent on the transform parameter and the current transform of a context where the path is drawn. In a flipped coordinate system (the default for UIView drawing methods in iOS), specifying a clockwise arc results in a counterclockwise arc after the transformation is applied.If the path already contains a subpath, this method adds a line connecting the current point to the starting point of the arc. If the current path is empty, his method creates a new subpath whose starting point is the starting point of the arc. The ending point of the arc becomes the new current point of the path.
Params:
Name | Type | Attribute | Description |
center | CGPoint | The center of the arc, in user space coordinates. |
|
radius | number | The radius of the arc, in user space coordinates. |
|
startAngle | number | The angle to the starting point of the arc, measured in radians from the positive x-axis. |
|
delta | number | The difference, measured in radians, between the starting angle and ending angle of the arc. A positive value creates a counter-clockwise arc (in user space coordinates), and vice versa. |
|
transform | CGAffineTransform | An affine transform to apply to the arc before adding to the path. Defaults to the identity transform if not specified. |
Return:
void |
public addRoundedRectIn(rect: CGRect, cornerWidth: number, cornerHeight: number, transform: CGAffineTransform): void source
This convenience method is equivalent to a move operation to start the subpath followed by a series of arc and line operations that construct the rounded rectangle. Each corner of the rounded rectangle is one-quarter of an ellipse with axes equal to the cornerWidth and cornerHeight parameters. The rounded rectangle forms a closed subpath oriented in the clockwise direction.
Params:
Name | Type | Attribute | Description |
rect | CGRect | The rectangle to add, specified in user space coordinates. |
|
cornerWidth | number | The horizontal size, in user space coordinates, for rounded corner sections. |
|
cornerHeight | number | The vertical size, in user space coordinates, for rounded corner sections. |
|
transform | CGAffineTransform | An affine transform to apply to the rectangle before adding to the path. Defaults to the identity transform if not specified. |
Return:
void |
public closeSubpath(): void source
Appends a line from the current point to the starting point of the current subpath and ends the subpath. After closing the subpath, your application can begin a new subpath without first calling moveTo(_:x:y:). In this case, a new subpath is implicitly created with a starting and current point equal to the previous subpath’s starting point.
Return:
void |
public moveTo(point: CGPoint, transform: CGAffineTransform): void source
The specified point becomes the start point of a new subpath. The current point is set to this start point.
Params:
Name | Type | Attribute | Description |
point | CGPoint | The point, in user space coordinates, at which to start a new subpath. |
|
transform | CGAffineTransform | An affine transform to apply to the point before adding to the path. Defaults to the identity transform if not specified. |
Return:
void |
public mutableCopy(): CGMutablePath source
You can modify a mutable graphics path by calling the various path geometry functions, such as addArc(:x:y:radius:startAngle:endAngle:clockwise:), addLineTo(:x:y:), and moveTo(_:x:y:).
public mutableCopyUsing(transform: UnsafePointer<CGAffineTransform>): CGMutablePath source
Creates a mutable copy of a graphics path transformed by a transformation matrix.
Params:
Name | Type | Attribute | Description |
transform | UnsafePointer<CGAffineTransform> |
|
A pointer to an affine transformation matrix, or NULL if no transformation is needed. If specified, Core Graphics applies the transformation to all elements of the new path. |