CGPath
An immutable graphics path: a mathematical description of shapes or lines to be drawn in a graphics context.
Static Member Summary
Static Public Members | ||
public static get |
typeID: CFTypeID |
Constructor Summary
Public Constructor | ||
public |
constructor(rect: CGRect, transform: UnsafePointer<CGAffineTransform>) This is a convenience function that creates a path of an rectangle. |
Member Summary
Public Members | ||
public get |
The bounding box is the smallest rectangle completely enclosing all points in the path, including control points for Bézier and quadratic curves. |
|
public get |
The path bounding box is the smallest rectangle completely enclosing all points in the path but not including control points for Bézier and quadratic curves. |
|
public get |
If the path is empty—that is, if it has no elements—this function returns CGPointZero (see CGGeometry). |
|
public get |
An empty path contains no elements. |
Method Summary
Public Methods | ||
public |
apply(info: Object, _function: CGPathApplierFunction): void For each element in the specified path, Core Graphics calls the applier function, which can examine (but not modify) the element. |
|
public |
containsUsing(point: CGPoint, rule: CGPathFillRule, transform: CGAffineTransform): boolean A point is contained in a path if it would be inside the painted region when the path is filled. |
|
public |
Creates an immutable copy of a graphics path. |
|
public |
copyDashingWithPhase(phase: number, lengths: number[], transform: CGAffineTransform): CGPath The new path is created so that filling the new path draws the same pixels as stroking the original path with the specified dash parameters. |
|
public |
copyStrokingWithWidth(lineWidth: number, lineCap: CGLineCap, lineJoin: CGLineJoin, miterLimit: number, transform: CGAffineTransform): CGPath The new path is created so that filling the new path draws the same pixels as stroking the original path with the specified line style. |
|
public |
Creates an immutable copy of a graphics path transformed by a transformation matrix. |
|
public |
initEllipseIn(rect: CGRect, transform: UnsafePointer<CGAffineTransform>): void This is a convenience function that creates a path of an ellipse. |
|
public |
initRoundedRect(rect: CGRect, cornerWidth: number, cornerHeight: number, transform: UnsafePointer<CGAffineTransform>): void This is a convenience function that creates a path of an rounded rectangle. |
|
public |
init__byDashing(path: CGPath, transform: UnsafePointer<CGAffineTransform>, phase: number, lengths: UnsafePointer<CGFloat>, count: number): void The new path is created so that filling the new path draws the same pixels as stroking the original path with the specified dash parameters. |
|
public |
init__byStroking(path: CGPath, transform: UnsafePointer<CGAffineTransform>, lineWidth: number, lineCap: CGLineCap, lineJoin: CGLineJoin, miterLimit: number): void The new path is created so that filling the new path draws the same pixels as stroking the original path.If the line join style is set to kCGLineJoinMiter, Core Graphics uses the miter limit to determine whether the lines should be joined with a bevel instead of a miter. |
|
public |
Indicates whether or not a graphics path represents a rectangle. |
|
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. |
Static Public Members
public static get typeID: CFTypeID source
Public Constructors
public constructor(rect: CGRect, transform: UnsafePointer<CGAffineTransform>) source
This is a convenience function that creates a path of an rectangle. Using this convenience function is more efficient than creating a mutable path and adding an rectangle to it.Calling this function is equivalent to using minX and related functions to find the corners of the rectangle, then using the moveTo(:x:y:), addLineTo(:x:y:), and closeSubpath() functions to draw the rectangle.
Params:
Name | Type | Attribute | Description |
rect | CGRect | The rectangle to add. |
|
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 the rectangle before it is added to the path. |
Public Members
public get boundingBox: CGRect source
The bounding box is the smallest rectangle completely enclosing all points in the path, including control points for Bézier and quadratic curves.
public get boundingBoxOfPath: CGRect source
The path bounding box is the smallest rectangle completely enclosing all points in the path but not including control points for Bézier and quadratic curves.
public get currentPoint: CGPoint source
If the path is empty—that is, if it has no elements—this function returns CGPointZero (see CGGeometry). To determine whether a path is empty, use isEmpty.
Public Methods
public apply(info: Object, _function: CGPathApplierFunction): void source
For each element in the specified path, Core Graphics calls the applier function, which can examine (but not modify) the element.
Params:
Name | Type | Attribute | Description |
info | Object |
|
A pointer to the user data that Core Graphics will pass to the function being applied, or NULL. |
_function | CGPathApplierFunction |
Return:
void |
public containsUsing(point: CGPoint, rule: CGPathFillRule, transform: CGAffineTransform): boolean source
A point is contained in a path if it would be inside the painted region when the path is filled.
Params:
Name | Type | Attribute | Description |
point | CGPoint | The point to check. |
|
rule | CGPathFillRule | The rule for determining which areas to treat as the interior of the path. Defaults to the winding rule if not specified. |
|
transform | CGAffineTransform | An affine transform to apply to the point before checking for containment in the path. Defaults to the identity transform if not specified. |
public copyDashingWithPhase(phase: number, lengths: number[], transform: CGAffineTransform): CGPath source
The new path is created so that filling the new path draws the same pixels as stroking the original path with the specified dash parameters.
Params:
Name | Type | Attribute | Description |
phase | number | A value that specifies how far into the dash pattern the line starts, in units of the user space. For example, a value of 0 draws a line starting with the beginning of a dash pattern, and a value of 3 means the line is drawn with the dash pattern starting at three units from its beginning. |
|
lengths | number[] | An array of values that specify the lengths, in user space coordinates, of the painted and unpainted segments of the dash pattern.For example, the array [2,3] sets a dash pattern that alternates between a 2-unit-long painted segment and a 3-unit-long unpainted segment. The array [1,3,4,2] sets the pattern to a 1-unit painted segment, a 3-unit unpainted segment, a 4-unit painted segment, and a 2-unit unpainted segment.Pass an empty array to clear the dash pattern so that all stroke drawing in the context uses solid lines. |
|
transform | CGAffineTransform | An affine transform to apply to the path before dashing. Defaults to the identity transform if not specified. |
public copyStrokingWithWidth(lineWidth: number, lineCap: CGLineCap, lineJoin: CGLineJoin, miterLimit: number, transform: CGAffineTransform): CGPath source
The new path is created so that filling the new path draws the same pixels as stroking the original path with the specified line style.
Params:
Name | Type | Attribute | Description |
lineWidth | number | The line width to use, in user space units. The value must be greater than 0. |
|
lineCap | CGLineCap | The line cap style to render. (For equivalent CGContext drawing methods, the default style is butt.) |
|
lineJoin | CGLineJoin | The line join style to render. (For equivalent CGContext drawing methods, the default style is miter.) |
|
miterLimit | number | A value that limits how sharp individual corners in the path can be when using the miter line join style. When the ratio of a the length required for a mitered corner to the line width exceeds this value, that corner uses the bevel style instead. |
|
transform | CGAffineTransform | An affine transform to apply to the path before dashing. Defaults to the identity transform if not specified. |
public copyUsing(transform: UnsafePointer<CGAffineTransform>): CGPath source
Creates an immutable 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. |
public initEllipseIn(rect: CGRect, transform: UnsafePointer<CGAffineTransform>): void source
This is a convenience function that creates a path of an ellipse. Using this convenience function is more efficient than creating a mutable path and adding an ellipse to it.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. If you supply an affine transform, then the constructed Bézier curves that define the ellipse are transformed before they are added to the path.
Params:
Name | Type | Attribute | Description |
rect | CGRect | The rectangle that bounds the ellipse. |
|
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 the ellipse before it is added to the path. |
Return:
void |
public initRoundedRect(rect: CGRect, cornerWidth: number, cornerHeight: number, transform: UnsafePointer<CGAffineTransform>): void source
This is a convenience function that creates a path of an rounded rectangle. Using this convenience function is more efficient than creating a mutable path and adding an rectangle to it.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 complete subpath and is oriented in the clockwise direction.
Params:
Name | Type | Attribute | Description |
rect | CGRect | The rectangle to add. |
|
cornerWidth | number | The width of the rounded corner sections. |
|
cornerHeight | number | The height of the rounded corner sections. |
|
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 the rectangle before it is added to the path. |
Return:
void |
public init__byDashing(path: CGPath, transform: UnsafePointer<CGAffineTransform>, phase: number, lengths: UnsafePointer<CGFloat>, count: number): void source
The new path is created so that filling the new path draws the same pixels as stroking the original path with the specified dash parameters.
Params:
Name | Type | Attribute | Description |
path | CGPath | The path to copy. |
|
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 elements of the converted path before adding them to the new path. |
phase | number | A value that specifies how far into the dash pattern the line starts, in units of the user space. For example, passing a value of 3 means the line is drawn with the dash pattern starting at three units from its beginning. Passing a value of 0 draws a line starting with the beginning of a dash pattern. |
|
lengths | UnsafePointer<CGFloat> |
|
An array of values that specify the lengths of the painted segments and unpainted segments, respectively, of the dash pattern—or NULL for no dash pattern.For example, passing an array with the values [2,3] sets a dash pattern that alternates between a 2-user-space-unit-long painted segment and a 3-user-space-unit-long unpainted segment. Passing the values [1,3,4,2] sets the pattern to a 1-unit painted segment, a 3-unit unpainted segment, a 4-unit painted segment, and a 2-unit unpainted segment. |
count | number | If the lengths parameter specifies an array, pass the number of elements in the array. Otherwise, pass 0. |
Return:
void |
public init__byStroking(path: CGPath, transform: UnsafePointer<CGAffineTransform>, lineWidth: number, lineCap: CGLineCap, lineJoin: CGLineJoin, miterLimit: number): void source
The new path is created so that filling the new path draws the same pixels as stroking the original path.If the line join style is set to kCGLineJoinMiter, Core Graphics uses the miter limit to determine whether the lines should be joined with a bevel instead of a miter. Core Graphics divides the length of the miter by the line width. If the result is greater than the miter limit, Core Graphics converts the style to a bevel.
Params:
Name | Type | Attribute | Description |
path | CGPath | The path to copy. |
|
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 elements of the converted path before adding them to the new path. |
lineWidth | number | The line width to use, in user space units. The value must be greater than 0. |
|
lineCap | CGLineCap | A line cap style constant—butt (the default), round, or square. |
|
lineJoin | CGLineJoin | A line join value—miter (the default), round, or bevel. |
|
miterLimit | number | The miter limit to use. |
Return:
void |
public isRect(rect: UnsafeMutablePointer<CGRect>): boolean source
Indicates whether or not a graphics path represents a rectangle.
Params:
Name | Type | Attribute | Description |
rect | UnsafeMutablePointer<CGRect> |
|
On input, a pointer to an uninitialized rectangle. If the specified path represents a rectangle, on return contains a copy of the rectangle. |
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. |