Path
public struct Path : Hashable
A type for graphics paths: mathematical descriptions of shapes or lines to be drawn in a DrawingContext
.
-
Creates an empty path.
Declaration
Swift
public init()
-
The current position for path construction. Initial value is
Point.zero
.Declaration
Swift
public var currentPosition: Point { get }
-
Starts a new subpath and moves the current point for drawing path, sets the start point for the path to the
point
.Declaration
Swift
public mutating func move(to point: Point)
Parameters
point
The start point for drawing path.
-
Creates a new path by starting a new subpath in the old one and moves the current point for drawing path, sets the start point for the new path to the
point
.Declaration
Swift
@inlinable public func moving(to point: Point) -> Path
Parameters
point
The start point for drawing path.
Return Value
The new path.
-
Starts a new subpath and moves the current point for drawing path, sets the start point for the path to the point with the specified coordinates.
Declaration
Swift
@inlinable public mutating func move(toX x: Float, y: Float)
Parameters
x
The x coordinate of the start point for drawing path.
y
The y coordinate of the start point for drawing path.
-
Creates a new path by starting a new subpath in the old one and moves the current point for drawing path, sets the start point for the new path to the point with the specified coordinates.
Declaration
Swift
@inlinable public func moving(toX x: Float, y: Float) -> Path
Parameters
x
The x coordinate of the start point for drawing path.
y
The y coordinate of the start point for drawing path.
Return Value
The new path.
-
Appends a line from the current point to the specified point. If this method has been called before setting the current position by calling
move(to:)
, thenPoint.zero
is used as one.Declaration
Swift
public mutating func appendLine(to point: Point)
Parameters
point
The end point of the path.
-
Creates a new path by appending a line from the current point of the old path to the specified point. If this method has been called before setting the current position by calling
move(to:)
, thenPoint.zero
is used as one.Declaration
Swift
@inlinable public func appendingLine(to point: Point) -> Path
Parameters
point
The end point of the new path.
Return Value
The new path.
-
Appends a line from the current point to the point with specified coordinates. If this method has been called before setting the current position by calling
move(to:)
, thenPoint.zero
is used as one.Declaration
Swift
@inlinable public mutating func appendLine(toX x: Float, y: Float)
Parameters
x
The x coordinate of end point of the path.
y
The y coordinate of end point of the path.
-
Creates a new path by appending a line from the current point of the old path to the point with specified coordinates. If this method has been called before setting the current position by calling
move(to:)
, thenPoint.zero
is used as one.Declaration
Swift
@inlinable public func appendingLine(toX x: Float, y: Float) -> Path
Parameters
x
The x coordinate of end point of the path.
y
The y coordinate of end point of the path.
Return Value
The new path.
-
Appends a straight line from the current point to the start point of subpath. The current point is moved to the start point of subpath.
Declaration
Swift
public mutating func closeSubpath()
-
Creates a new path by appending a straight line from the current point of the old path to the start point of the subpath. The current point is moved to the start point of the subpath.
Declaration
Swift
@inlinable public func closingSubpath() -> Path
Return Value
The new path.
-
Appends a circle arc to the current path. Angles are given in degrees, with 0 degrees being vertical, upward, and in clockwise direction.
Declaration
Swift
public mutating func appendArc(center: Point, radius: Float, beginningAngle: Float, endAngle: Float)
Parameters
center
The center point of the arc.
radius
The radius of the arc.
beginningAngle
The angle of the begining of the arc.
endAngle
The angle of the end of the arc. It must be greater than
beginningAngle
. -
Creates a new path by appending a circle arc to the old path. Angles are given in degrees, with 0 degrees being vertical, upward, and in clockwise direction.
Declaration
Swift
@inlinable public func appendingArc(center: Point, radius: Float, beginningAngle: Float, endAngle: Float) -> Path
Parameters
center
The center point of the arc.
radius
The radius of the arc.
beginningAngle
The angle of the begining of the arc.
endAngle
The angle of the end of the arc. It must be greater than
beginningAngle
.Return Value
The new path.
-
Appends a circle arc to the current path. Angles are given in degrees, with 0 degrees being vertical, upward, and in clockwise direction.
Declaration
Swift
@inlinable public mutating func appendArc(x: Float, y: Float, radius: Float, beginningAngle: Float, endAngle: Float)
Parameters
x
The x coordinate of the center point of the arc.
y
The y coordinate of the center point of the arc.
radius
The radius of the arc.
beginningAngle
The angle of the begining of the arc.
endAngle
The angle of the end of the arc. It must be greater than
beginningAngle
. -
Creates a new path by appending a circle arc to the old path. Angles are given in degrees, with 0 degrees being vertical, upward, and in clockwise direction.
Declaration
Swift
@inlinable public func appendingArc(x: Float, y: Float, radius: Float, beginningAngle: Float, endAngle: Float) -> Path
Parameters
x
The x coordinate of the center point of the arc.
y
The y coordinate of the center point of the arc.
radius
The radius of the arc.
beginningAngle
The angle of the begining of the arc.
endAngle
The angle of the end of the arc. It must be greater than
beginningAngle
.Return Value
The new path.
-
Appends a circle to the current path, then sets the current point to the leftmost point of the circle, i. e.
Point(x: center.x - radius, y: center.y)
.Declaration
Swift
public mutating func appendCircle(center: Point, radius: Float)
Parameters
center
The center point of the circle.
radius
The radius of the circle.
-
Creates a new path by appending a circle to the old path, then sets the current point to the leftmost point of the circle, i. e.
Point(x: center.x - radius, y: center.y)
.Declaration
Swift
@inlinable public func appendingCircle(center: Point, radius: Float) -> Path
Parameters
center
The center point of the circle.
radius
The radius of the circle.
Return Value
The new path.
-
Appends a circle to the current path, then sets the current point to the leftmost point of the circle, i. e.
Point(x: x - radius, y: y)
.Declaration
Swift
@inlinable public mutating func appendCircle(x: Float, y: Float, radius: Float)
Parameters
x
The x coordinate of the center point of the circle.
y
The y coordinate of the center point of the circle.
radius
The radius of the circle.
-
Creates a new path by appending a circle to the old path, then sets the current point to the leftmost point of the circle, i. e.
Point(x: x - radius, y: y)
.Declaration
Swift
@inlinable public func appendingCircle(x: Float, y: Float, radius: Float) -> Path
Parameters
x
The x coordinate of the center point of the circle.
y
The y coordinate of the center point of the circle.
radius
The radius of the circle.
Return Value
The new path.
-
Appends a rectangle to the current path, then sets the current point to the lower-left point of the rectangle.
Declaration
Swift
public mutating func appendRectangle(_ rect: Rectangle)
Parameters
rect
The rectangle to append.
-
Creates a new path by appending a rectangle to the old path, then sets the current point to the lower-left point of the rectangle.
Declaration
Swift
@inlinable public func appendingRectangle(_ rect: Rectangle) -> Path
Parameters
rect
The rectangle to append.
Return Value
The new path.
-
Creates a new path by appending a rectangle to the old path, then sets the current point to the lower-left point of the rectangle.
Parameters
origin
The lower-left point of the rectangle.
size
The size of the rectangle.
Return Value
The new path.
-
Appends a rectangle to the current path, then sets the current point to the lower-left point of the rectangle.
Declaration
Swift
@inlinable public mutating func appendRectangle(x: Float, y: Float, width: Float, height: Float)
Parameters
x
The x coordinate of the lower-left point of the rectangle.
y
The y coordinate of the lower-left point of the rectangle.
width
The width of the rectangle.
height
The height of the rectangle.
-
Creates a new path by appending a rectangle to the old path, then sets the current point to the lower-left point of the rectangle.
Declaration
Swift
@inlinable public func appendingRectangle(x: Float, y: Float, width: Float, height: Float) -> Path
Parameters
x
The x coordinate of the lower-left point of the rectangle.
y
The y coordinate of the lower-left point of the rectangle.
width
The width of the rectangle.
height
The height of the rectangle.
Return Value
The new path.
-
Appends a Bézier curve to the current path using the control points
controlPoint1
,controlPoint2
andendPoint
, then sets the current point toendPoint
.Declaration
Parameters
controlPoint1
The first control point of the curve.
controlPoint2
The second control point of the curve.
endPoint
The end point of the curve.
-
Creates a new path by appending a Bézier curve to the old path using the control points
controlPoint1
,controlPoint2
andendPoint
, then sets the current point toendPoint
.Declaration
Parameters
controlPoint1
The first control point of the curve.
controlPoint2
The second control point of the curve.
endPoint
The end point of the curve.
Return Value
The new path.
-
Appends a Bézier curve to the current path using two spesified points. The point
controlPoint1
and the pointendPoint
are used as the control points for a Bézier curve; the current point is moved to theendPoint.
Parameters
controlPoint1
The first control point of the curve.
endPoint
The end point of the curve.
-
Creates a new path by appending a Bézier curve to the old path using two spesified points. The point
controlPoint1
and the pointendPoint
are used as the control points for a Bézier curve; the current point is moved to theendPoint.
Declaration
Parameters
controlPoint1
The first control point of the curve.
endPoint
The end point of the curve.
Return Value
The new path.
-
Appends a Bézier curve to the current path using the current point,
controlPoint2
andendPoint
as control points. Then, the current point is set toendPoint
.Parameters
controlPoint2
The second control point of the curve.
endPoint
The end point of the curve.
-
Creates a new path by appending a Bézier curve to the old path using the current point,
controlPoint2
andendPoint
as control points. Then, the current point is set toendPoint
.Declaration
Parameters
controlPoint2
The second control point of the curve.
endPoint
The end point of the curve.
Return Value
The new path.
-
Appends an ellipse to the current path, then sets the current point to the leftmost point of the ellipse, i. e.
Point(x: center.x - horizontalRadius, y: center.y)
.Declaration
Swift
public mutating func appendEllipse(center: Point, horizontalRadius: Float, verticalRadius: Float)
Parameters
center
The center point of the ellipse.
horizontalRadius
The horizontal radius of the ellipse.
verticalRadius
The vertical radius of the ellipse.
-
Creates a new path by appending an ellipse to the old path, then sets the current point to the leftmost point of the ellipse, i. e.
Point(x: center.x - horizontalRadius, y: center.y)
.Declaration
Swift
@inlinable public func appendingEllipse(center: Point, horizontalRadius: Float, verticalRadius: Float) -> Path
Parameters
center
The center point of the ellipse.
horizontalRadius
The horizontal radius of the ellipse.
verticalRadius
The vertical radius of the ellipse.
Return Value
The new path.
-
Appends an ellipse to the current path, then sets the current point to the leftmost point of the ellipse, i. e.
Point(x: x - horizontalRadius, y: y)
.Declaration
Swift
@inlinable public mutating func appendEllipse(x: Float, y: Float, horizontalRadius: Float, verticalRadius: Float)
Parameters
x
The x coordinate of the center point of the ellipse.
y
The y coordinate of the center point of the ellipse.
horizontalRadius
The horizontal radius of the ellipse.
verticalRadius
The vertical radius of the ellipse.
-
Creates a new path by appending an ellipse to the old path, then sets the current point to the leftmost point of the ellipse, i. e.
Point(x: x - horizontalRadius, y: y)
.Declaration
Swift
@inlinable public func appendingEllipse(x: Float, y: Float, horizontalRadius: Float, verticalRadius: Float) -> Path
Parameters
x
The x coordinate of the center point of the ellipse.
y
The y coordinate of the center point of the ellipse.
horizontalRadius
The horizontal radius of the ellipse.
verticalRadius
The vertical radius of the ellipse.
Return Value
The new path.
-
Appends an ellipse to the current path, then sets the current point to the leftmost point of the ellipse, i. e.
Point(x: rectangle.midX - rectangle.width / 2, y: rectangle.y + rectangle.height / 2)
.Declaration
Swift
@inlinable public mutating func appendEllipse(inscribedIn rectangle: Rectangle)
Parameters
rectangle
The rectangle the ellipse should be inscribed in.
-
Creates a new path by appending an ellipse to the old path, then sets the current point to the leftmost point of the ellipse, i. e.
Point(x: rectangle.midX - rectangle.width / 2, y: rectangle.y + rectangle.height / 2)
.Declaration
Swift
@inlinable public func appendingEllipse(inscribedIn rectangle: Rectangle) -> Path
Parameters
rectangle
The rectangle the ellipse should be inscribed in.
Return Value
The new path.
-
Rules for determining which regions are interior to a path, used by the
See moreDrawingContext.clip(to:rule:_:)
andDrawingContext.fill(_:rule:stroke:)
methods.Declaration
Swift
public enum FillRule