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
pointThe 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) -> PathParameters
pointThe 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
xThe x coordinate of the start point for drawing path.
yThe 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) -> PathParameters
xThe x coordinate of the start point for drawing path.
yThe 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.zerois used as one.Declaration
Swift
public mutating func appendLine(to point: Point)Parameters
pointThe 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.zerois used as one.Declaration
Swift
@inlinable public func appendingLine(to point: Point) -> PathParameters
pointThe 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.zerois used as one.Declaration
Swift
@inlinable public mutating func appendLine(toX x: Float, y: Float)Parameters
xThe x coordinate of end point of the path.
yThe 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.zerois used as one.Declaration
Swift
@inlinable public func appendingLine(toX x: Float, y: Float) -> PathParameters
xThe x coordinate of end point of the path.
yThe 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() -> PathReturn 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
centerThe center point of the arc.
radiusThe radius of the arc.
beginningAngleThe angle of the begining of the arc.
endAngleThe 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) -> PathParameters
centerThe center point of the arc.
radiusThe radius of the arc.
beginningAngleThe angle of the begining of the arc.
endAngleThe 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
xThe x coordinate of the center point of the arc.
yThe y coordinate of the center point of the arc.
radiusThe radius of the arc.
beginningAngleThe angle of the begining of the arc.
endAngleThe 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) -> PathParameters
xThe x coordinate of the center point of the arc.
yThe y coordinate of the center point of the arc.
radiusThe radius of the arc.
beginningAngleThe angle of the begining of the arc.
endAngleThe 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
centerThe center point of the circle.
radiusThe 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) -> PathParameters
centerThe center point of the circle.
radiusThe 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
xThe x coordinate of the center point of the circle.
yThe y coordinate of the center point of the circle.
radiusThe 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) -> PathParameters
xThe x coordinate of the center point of the circle.
yThe y coordinate of the center point of the circle.
radiusThe 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
rectThe 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) -> PathParameters
rectThe 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
originThe lower-left point of the rectangle.
sizeThe 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
xThe x coordinate of the lower-left point of the rectangle.
yThe y coordinate of the lower-left point of the rectangle.
widthThe width of the rectangle.
heightThe 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) -> PathParameters
xThe x coordinate of the lower-left point of the rectangle.
yThe y coordinate of the lower-left point of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
Return Value
The new path.
-
Appends a Bézier curve to the current path using the control points
controlPoint1,controlPoint2andendPoint, then sets the current point toendPoint.
Declaration
Parameters
controlPoint1The first control point of the curve.
controlPoint2The second control point of the curve.
endPointThe end point of the curve.
-
Creates a new path by appending a Bézier curve to the old path using the control points
controlPoint1,controlPoint2andendPoint, then sets the current point toendPoint.
Declaration
Parameters
controlPoint1The first control point of the curve.
controlPoint2The second control point of the curve.
endPointThe 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
controlPoint1and the pointendPointare used as the control points for a Bézier curve; the current point is moved to theendPoint.
Parameters
controlPoint1The first control point of the curve.
endPointThe 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
controlPoint1and the pointendPointare used as the control points for a Bézier curve; the current point is moved to theendPoint.
Declaration
Parameters
controlPoint1The first control point of the curve.
endPointThe end point of the curve.
Return Value
The new path.
-
Appends a Bézier curve to the current path using the current point,
controlPoint2andendPointas control points. Then, the current point is set toendPoint.
Parameters
controlPoint2The second control point of the curve.
endPointThe end point of the curve.
-
Creates a new path by appending a Bézier curve to the old path using the current point,
controlPoint2andendPointas control points. Then, the current point is set toendPoint.
Declaration
Parameters
controlPoint2The second control point of the curve.
endPointThe 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
centerThe center point of the ellipse.
horizontalRadiusThe horizontal radius of the ellipse.
verticalRadiusThe 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) -> PathParameters
centerThe center point of the ellipse.
horizontalRadiusThe horizontal radius of the ellipse.
verticalRadiusThe 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
xThe x coordinate of the center point of the ellipse.
yThe y coordinate of the center point of the ellipse.
horizontalRadiusThe horizontal radius of the ellipse.
verticalRadiusThe 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) -> PathParameters
xThe x coordinate of the center point of the ellipse.
yThe y coordinate of the center point of the ellipse.
horizontalRadiusThe horizontal radius of the ellipse.
verticalRadiusThe 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
rectangleThe 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) -> PathParameters
rectangleThe 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
View on GitHub
Path Structure Reference