cgPath
TypeScriptget cgPath(): _CoreGraphics_CGPathSwift declarationvar cgPath: CGPath { get }An immutable path representing the elements in the path.
struct · iOS 13.0+ · SDK 27.1
@frozen struct PathThe outline of a 2D shape.
get cgPath(): _CoreGraphics_CGPathSwift declarationvar cgPath: CGPath { get }An immutable path representing the elements in the path.
addPath(path: Path, transform?: _CoreFoundation_CGAffineTransform): voidSwift declarationmutating func addPath(_ path: Path, transform: CGAffineTransform = .identity)Appends another path value to this path. If the `path` parameter is a non-empty empty path, its 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. - Parameters: - path: The path to add. - transform: An affine transform to apply to the path parameter before adding to this path. Defaults to the identity transform if not specified.
strokedPath(style: StrokeStyle): PathSwift declarationfunc strokedPath(_ style: StrokeStyle) -> PathReturns a stroked copy of the path using `style` to define how the stroked outline is created.
trimmedPath(from: number, to: number): PathSwift declarationfunc trimmedPath(from: CGFloat, to: CGFloat) -> PathReturns a partial copy of the path. The returned path contains the region between `from` and `to`, both of which must be fractions between zero and one defining points linearly-interpolated along the path.
addEllipse(rect: { x: number; y: number; width: number; height: number }, transform?: _CoreFoundation_CGAffineTransform): voidSwift declarationmutating func addEllipse(in rect: CGRect, transform: CGAffineTransform = .identity)Adds an ellipse that fits inside the specified rectangle to the path. 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. - Parameter: - rect: A rectangle that defines the area for the ellipse to fit in. - transform: An affine transform to apply to the ellipse before adding to the path. Defaults to the identity transform if not specified.
normalized(eoFill?: boolean): PathSwift declarationfunc normalized(eoFill: Bool = true) -> PathReturns a new weakly-simple copy of this path. - Parameters: - eoFill: Whether to use the even-odd rule for determining which areas to treat as the interior of the paths (if true), or the non-zero rule (if false). - Returns: A new path. The returned path is a weakly-simple path, has no self-intersections, and has a normalized orientation. The result of filling this path using either even-odd or non-zero fill rules is identical.
get description(): stringSwift declarationvar description: String { get }A description of the path that may be used to recreate the path via `init?(_:)`.
static initRoundedRectCornerSizeStyle(rect: { x: number; y: number; width: number; height: number }, cornerSize: { width: number; height: number }, style?: RoundedCornerStyle): PathSwift declarationinit(roundedRect rect: CGRect, cornerSize: CGSize, style: RoundedCornerStyle = .continuous)Creates a path containing a rounded rectangle. This is a convenience function that creates a path of a rounded rectangle. Using this convenience function is more efficient than creating a path and adding a rounded rectangle to it. - Parameters: - rect: A rectangle, specified in user space coordinates. - cornerSize: The size of the corners, specified in user space coordinates. - style: The corner style. Defaults to the `continous` style if not specified.
static initRoundedRectCornerRadiiStyle(rect: { x: number; y: number; width: number; height: number }, cornerRadii: RectangleCornerRadii, style?: RoundedCornerStyle): PathSwift declarationinit(roundedRect rect: CGRect, cornerRadii: RectangleCornerRadii, style: RoundedCornerStyle = .continuous)Creates a path as the given rounded rectangle, which may have uneven corner radii. This is a convenience function that creates a path of a rounded rectangle. Using this function is more efficient than creating a path and adding a rounded rectangle to it. - Parameters: - rect: A rectangle, specified in user space coordinates. - cornerRadii: The radius of each corner of the rectangle, specified in user space coordinates. - style: The corner style. Defaults to the `continous` style if not specified.
static initRoundedRectCornerRadiusStyle(rect: { x: number; y: number; width: number; height: number }, cornerRadius: number, style?: RoundedCornerStyle): PathSwift declarationinit(roundedRect rect: CGRect, cornerRadius: CGFloat, style: RoundedCornerStyle = .continuous)Creates a path containing a rounded rectangle. This is a convenience function that creates a path of a rounded rectangle. Using this convenience function is more efficient than creating a path and adding a rounded rectangle to it. - Parameters: - rect: A rectangle, specified in user space coordinates. - cornerRadius: The radius of all corners of the rectangle, specified in user space coordinates. - style: The corner style. Defaults to the `continous` style if not specified.
subtracting(other: Path, eoFill?: boolean): PathSwift declarationfunc subtracting(_ other: Path, eoFill: Bool = false) -> PathReturns a new path with filled regions from this path that are not in the given path. - Parameters: - other: The path to subtract. - eoFill: Whether to use the even-odd rule for determining which areas to treat as the interior of the paths (if true), or the non-zero rule (if false). - Returns: A new path. The filled region of the resulting path is the filled region of this path with the filled region `other` removed from it. Any unclosed subpaths in either path are assumed to be closed. The result of filling this path using either even-odd or non-zero fill rules is identical.
addQuadCurve(end: { x: number; y: number }, control: { x: number; y: number }): voidSwift declarationmutating func addQuadCurve(to end: CGPoint, control: CGPoint)Adds a quadratic Bézier curve to the path, with the specified end point and control point. 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. - Parameters: - end: The point, in user space coordinates, at which to end the curve. - control: The control point of the curve, in user space coordinates.
get boundingRect(): { x: number; y: number; width: number; height: number }Swift declarationvar boundingRect: CGRect { get }A rectangle containing all path segments. This is the smallest rectangle completely enclosing all points in the path but not including control points for Bézier curves.
closeSubpath(): voidSwift declarationmutating func closeSubpath()Closes and completes the current subpath. 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 `move(to:)`. In this case, a new subpath is implicitly created with a starting and current point equal to the previous subpath's starting point.
get currentPoint(): ({ x: number; y: number }) | nullSwift declarationvar currentPoint: CGPoint? { get }Returns the last point in the path, or nil if the path contains no points.
intersection(other: Path, eoFill?: boolean): PathSwift declarationfunc intersection(_ other: Path, eoFill: Bool = false) -> PathReturns a new path with filled regions common to both paths. - Parameters: - other: The path to intersect. - eoFill: Whether to use the even-odd rule for determining which areas to treat as the interior of the paths (if true), or the non-zero rule (if false). - Returns: A new path. The filled region of the resulting path is the overlapping area of the filled region of both paths. This can be used to clip the fill of a path to a mask. Any unclosed subpaths in either path are assumed to be closed. The result of filling this path using either even-odd or non-zero fill rules is identical.
addRelativeArc(center: { x: number; y: number }, radius: number, startAngle: Angle, delta: Angle, transform?: _CoreFoundation_CGAffineTransform): voidSwift declarationmutating func addRelativeArc(center: CGPoint, radius: CGFloat, startAngle: Angle, delta: Angle, transform: CGAffineTransform = .identity)Adds an arc of a circle to the path, specified with a radius and a difference in angle. 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. However, because SwiftUI by default uses a vertically-flipped coordinate system (with the origin in the top-left of the view), specifying a clockwise arc results in a counterclockwise arc after the transformation is applied. If the path ends with an unclosed subpath, this method adds a line connecting the current point to the starting point of the arc. If there is no unclosed subpath, this 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. - Parameters: - center: The center of the arc, in user space coordinates. - radius: The radius of the arc, in user space coordinates. - startAngle: The angle to the starting point of the arc, measured from the positive x-axis. - delta: The difference 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: An affine transform to apply to the arc before adding to the path. Defaults to the identity transform if not specified. /
addRoundedRectInCornerSizeStyleTransform(rect: { x: number; y: number; width: number; height: number }, cornerSize: { width: number; height: number }, style?: RoundedCornerStyle, transform?: _CoreFoundation_CGAffineTransform): voidSwift declarationmutating func addRoundedRect(in rect: CGRect, cornerSize: CGSize, style: RoundedCornerStyle = .continuous, transform: CGAffineTransform = .identity)Adds a rounded rectangle to the path. This is a convenience function that adds a rounded rectangle to a path, starting by moving to the center of the right edge and then adding lines and curves counter-clockwise to create a rounded rectangle, closing the subpath. - Parameters: - rect: A rectangle, specified in user space coordinates. - cornerSize: The size of the corners, specified in user space coordinates. - style: The corner style. Defaults to the `continous` style if not specified. - transform: An affine transform to apply to the rectangle before adding to the path. Defaults to the identity transform if not specified.
addRoundedRectInCornerRadiiStyleTransform(rect: { x: number; y: number; width: number; height: number }, cornerRadii: RectangleCornerRadii, style?: RoundedCornerStyle, transform?: _CoreFoundation_CGAffineTransform): voidSwift declarationmutating func addRoundedRect(in rect: CGRect, cornerRadii: RectangleCornerRadii, style: RoundedCornerStyle = .continuous, transform: CGAffineTransform = .identity)Adds a rounded rectangle with uneven corners to the path. This is a convenience function that adds a rounded rectangle to a path, starting by moving to the center of the right edge and then adding lines and curves counter-clockwise to create a rounded rectangle, closing the subpath. - Parameters: - rect: A rectangle, specified in user space coordinates. - cornerRadii: The radius of each corner of the rectangle, specified in user space coordinates. - style: The corner style. Defaults to the `continous` style if not specified. - transform: An affine transform to apply to the rectangle before adding to the path. Defaults to the identity transform if not specified.
lineSubtraction(other: Path, eoFill?: boolean): PathSwift declarationfunc lineSubtraction(_ other: Path, eoFill: Bool = false) -> PathReturns a new path with a line from this path that does not overlap the filled region of the given path. - Parameters: - other: The path to subtract. - eoFill: Whether to use the even-odd rule for determining which areas to treat as the interior of the paths (if true), or the non-zero rule (if false). - Returns: A new path. The line of the resulting path is the line of this path that does not overlap the filled region of `other`. Intersected subpaths that are clipped create open subpaths. Closed subpaths that do not intersect `other` remain closed.
lineIntersection(other: Path, eoFill?: boolean): PathSwift declarationfunc lineIntersection(_ other: Path, eoFill: Bool = false) -> PathReturns a new path with a line from this path that overlaps the filled regions of the given path. - Parameters: - other: The path to intersect. - eoFill: Whether to use the even-odd rule for determining which areas to treat as the interior of the paths (if true), or the non-zero rule (if false). - Returns: A new path. The line of the resulting path is the line of this path that overlaps the filled region of `other`. Intersected subpaths that are clipped create open subpaths. Closed subpaths that do not intersect `other` remain closed.
symmetricDifference(other: Path, eoFill?: boolean): PathSwift declarationfunc symmetricDifference(_ other: Path, eoFill: Bool = false) -> PathReturns a new path with filled regions either from this path or the given path, but not in both. - Parameters: - other: The path to difference. - eoFill: Whether to use the even-odd rule for determining which areas to treat as the interior of the paths (if true), or the non-zero rule (if false). - Returns: A new path. The filled region of the resulting path is the filled region contained in either this path or `other`, but not both. Any unclosed subpaths in either path are assumed to be closed. The result of filling this path using either even-odd or non-zero fill rules is identical.
move(end: { x: number; y: number }): voidSwift declarationmutating func move(to end: CGPoint)Begins a new subpath at the specified point. The specified point becomes the start point of a new subpath. The current point is set to this start point. - Parameter end: The point, in user space coordinates, at which to start a new subpath.
path(arg0: { x: number; y: number; width: number; height: number }): PathSwift declarationnonisolated func path(in _: CGRect) -> PathDescribes this shape as a path within a rectangular frame of reference. - Parameter rect: The frame of reference for describing this shape. - Returns: A path that describes this shape.
union(other: Path, eoFill?: boolean): PathSwift declarationfunc union(_ other: Path, eoFill: Bool = false) -> PathReturns a new path with filled regions in either this path or the given path. - Parameters: - other: The path to union. - eoFill: Whether to use the even-odd rule for determining which areas to treat as the interior of the paths (if true), or the non-zero rule (if false). - Returns: A new path. The filled region of resulting path is the combination of the filled region of both paths added together. Any unclosed subpaths in either path are assumed to be closed. The result of filling this path using either even-odd or non-zero fill rules is identical.
addArcTangent1EndTangent2EndRadiusTransform(tangent1End: { x: number; y: number }, tangent2End: { x: number; y: number }, radius: number, transform?: _CoreFoundation_CGAffineTransform): voidSwift declarationmutating func addArc(tangent1End: CGPoint, tangent2End: CGPoint, radius: CGFloat, transform: CGAffineTransform = .identity)Adds an arc of a circle to the path, specified with a radius and two tangent lines. This method calculates two tangent lines—the first from the current point to the tangent1End point, and the second from the `tangent1End` point to the `tangent2End` point—then calculates the start and end points for a circular arc of the specified radius such that the arc is tangent to both lines. Finally, this method approximates that arc with a sequence of cubic Bézier curves and appends those curves to the path. If the starting point of the arc (that is, the point where a circle of the specified radius must meet the first tangent line in order to also be tangent to the second line) is not the current point, this method appends a straight line segment from the current point to the starting point of the arc. The ending point of the arc (that is, the point where a circle of the specified radius must meet the second tangent line in order to also be tangent to the first line) becomes the new current point of the path. - Parameters: - tangent1End:The end point, in user space coordinates, for the first tangent line to be used in constructing the arc. (The start point for this tangent line is the path's current point.) - tangent2End: The end point, in user space coordinates, for the second tangent line to be used in constructing the arc. (The start point for this tangent line is the tangent1End point.) - radius: The radius of the arc, in user space coordinates. - transform: An affine transform to apply to the arc before adding to the path. Defaults to the identity transform if not specified.
addArcCenterRadiusStartAngleEndAngleClockwiseTransform(center: { x: number; y: number }, radius: number, startAngle: Angle, endAngle: Angle, clockwise: boolean, transform?: _CoreFoundation_CGAffineTransform): voidSwift declarationmutating func addArc(center: CGPoint, radius: CGFloat, startAngle: Angle, endAngle: Angle, clockwise: Bool, transform: CGAffineTransform = .identity)Adds an arc of a circle to the path, specified with a radius and angles. 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. However, because SwiftUI by default uses a vertically-flipped coordinate system (with the origin in the top-left of the view), specifying a clockwise arc results in a counterclockwise arc after the transformation is applied. If the path ends with an unclosed subpath, this method adds a line connecting the current point to the starting point of the arc. If there is no unclosed subpath, this 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. - Parameters: - center: The center of the arc, in user space coordinates. - radius: The radius of the arc, in user space coordinates. - startAngle: The angle to the starting point of the arc, measured from the positive x-axis. - endAngle: The angle to the end point of the arc, measured from the positive x-axis. - clockwise: true to make a clockwise arc; false to make a counterclockwise arc. - transform: An affine transform to apply to the arc before adding to the path. Defaults to the identity transform if not specified.
addLine(end: { x: number; y: number }): voidSwift declarationmutating func addLine(to end: CGPoint)Appends a straight line segment from the current point to the specified point. After adding the line segment, the current point is set to the endpoint of the line segment. - Parameter end: The location, in user space coordinates, for the end of the new line segment.
addRect(rect: { x: number; y: number; width: number; height: number }, transform?: _CoreFoundation_CGAffineTransform): voidSwift declarationmutating func addRect(_ rect: CGRect, transform: CGAffineTransform = .identity)Adds a rectangular subpath to the path. 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. - Parameters: - rect: A rectangle, specified in user space coordinates. - transform: An affine transform to apply to the rectangle before adding to the path. Defaults to the identity transform if not specified.
forEach(body: ((arg0: Path_Element) => void)): voidSwift declarationfunc forEach(_ body: (Path.Element) -> Void)Calls `body` with each element in the path.
get isEmpty(): booleanSwift declarationvar isEmpty: Bool { get }A Boolean value indicating whether the path contains zero elements.
addCurve(end: { x: number; y: number }, control1: { x: number; y: number }, control2: { x: number; y: number }): voidSwift declarationmutating func addCurve(to end: CGPoint, control1: CGPoint, control2: CGPoint)Adds a cubic Bézier curve to the path, with the specified end point and control points. 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. - Parameters: - end: The point, in user space coordinates, at which to end the curve. - control1: The first control point of the curve, in user space coordinates. - control2: The second control point of the curve, in user space coordinates.
addLines(lines: Array<{ x: number; y: number }>): voidSwift declarationmutating func addLines(_ lines: [CGPoint])Adds a sequence of connected straight-line segments to the path. Calling this convenience method is equivalent to applying the transform to all points in the array, then calling the `move(to:)` method with the first value in the `points` array, then calling the `addLine(to:)` 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. - Parameter: - lines: 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: An affine transform to apply to the points before adding to the path. Defaults to the identity transform if not specified.
addRects(rects: Array<{ x: number; y: number; width: number; height: number }>, transform?: _CoreFoundation_CGAffineTransform): voidSwift declarationmutating func addRects(_ rects: [CGRect], transform: CGAffineTransform = .identity)Adds a set of rectangular subpaths to the path. Calling this convenience method is equivalent to repeatedly calling the `addRect(_:transform:)` method for each rectangle in the array. - Parameter: - rects: An array of rectangles, specified in user space coordinates. - transform: An affine transform to apply to the ellipse before adding to the path. Defaults to the identity transform if not specified.
applying(transform: _CoreFoundation_CGAffineTransform): PathSwift declarationfunc applying(_ transform: CGAffineTransform) -> PathReturns a path constructed by applying the transform to all points of the path. - Parameter transform: An affine transform to apply to the path. - Returns: a new copy of the path with the transform applied to all points.
contains(p: { x: number; y: number }, eoFill?: boolean): booleanSwift declarationfunc contains(_ p: CGPoint, eoFill: Bool = false) -> BoolReturns true if the path contains a specified point. If `eoFill` is true, this method uses the even-odd rule to define which points are inside the path. Otherwise, it uses the non-zero rule.
offsetBy(dx: number, dy: number): PathSwift declarationfunc offsetBy(dx: CGFloat, dy: CGFloat) -> PathReturns a path constructed by translating all its points. - Parameters: - dx: The offset to apply in the horizontal axis. - dy: The offset to apply in the vertical axis. - Returns: a new copy of the path with the offset applied to all points.
static initEllipseIn(rect: { x: number; y: number; width: number; height: number }): PathSwift declarationinit(ellipseIn rect: CGRect)Creates a path as an ellipse within the given rectangle. This is a convenience function that creates a path of an ellipse. Using this convenience function is more efficient than creating a 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. - Parameter rect: The rectangle that bounds the ellipse.
static init(): PathSwift declarationinit()Creates an empty path.
static init96046(string: string): (Path) | nullSwift declarationinit?(_ string: String)Initializes from the result of a previous call to `Path.stringRepresentation`. Fails if the `string` does not describe a valid path.
static init97(path: _CoreGraphics_CGMutablePath): PathSwift declarationinit(_ path: CGMutablePath)Creates a path from a copy of a mutable shape path. - Parameter path: The CoreGraphics path to initialize the new path from.
static init74420(rect: { x: number; y: number; width: number; height: number }): PathSwift declarationinit(_ rect: CGRect)Creates a path containing a rectangle. This is a convenience function that creates a path of a rectangle. Using this convenience function is more efficient than creating a path and adding a rectangle to it. Calling this function is equivalent to using `minX` and related properties to find the corners of the rectangle, then using the `move(to:)`, `addLine(to:)`, and `closeSubpath()` functions to add the rectangle. - Parameter rect: The rectangle to add.
static init71238(path: _CoreGraphics_CGPath): PathSwift declarationinit(_ path: CGPath)Creates a path from an immutable shape path. - Parameter path: The immutable CoreGraphics path to initialize the new path from.
static init97022(callback: ((arg0: Path) => void)): PathSwift declarationinit(_ callback: (inout Path) -> ())Creates an empty path, then executes a closure to add its initial elements. - Parameter callback: The Swift function that will be called to initialize the new path.
No declarations were skipped in this snapshot.