Structure

Path

The outline of a 2D shape.

Declaration

@frozen struct Path

Topics

Creating a Path

init()

Creates an empty path.

init(CGMutablePath)

Creates a path from a copy of a mutable shape path.

init(CGPath)

Creates a path from an immutable shape path.

init((inout Path) -> ())

Creates an empty path, and then executes the closure to add the initial elements.

init(CGRect)

Creates a path as the given rectangle.

init(ellipseIn: CGRect)

Creates a path as an ellipse inscribed within the given rectangle.

Instance Methods

func addArc(tangent1End: CGPoint, tangent2End: CGPoint, radius: CGFloat, transform: CGAffineTransform)

Adds an arc of a circle to the path, specified with a radius and two tangent lines.

func addCurve(to: CGPoint, control1: CGPoint, control2: CGPoint)

Adds a cubic Bézier curve to the path, with the specified end point and control points.

func addLine(to: CGPoint)

Appends a straight line segment from the current point to the specified point.

func addLines([CGPoint])

Adds a sequence of connected straight-line segments to the path.

func addPath(Path, transform: CGAffineTransform)

Appends a copy of path to the path.

func addQuadCurve(to: CGPoint, control: CGPoint)

Adds a quadratic Bézier curve to the path, with the specified end point and control point.

func addRect(CGRect, transform: CGAffineTransform)

Adds a rectangular subpath to the path.

func addRects([CGRect], transform: CGAffineTransform)

Adds a sequence of rectangular subpaths to the path.

func addRelativeArc(center: CGPoint, radius: CGFloat, startAngle: Angle, delta: Angle, transform: CGAffineTransform)

Adds an arc of a circle to the path, specified with a radius and a difference in angle.

func applying(CGAffineTransform) -> Path

Returns a path constructed by applying the transform to all points of the path.

func closeSubpath()

Closes and completes the current subpath.

func contains(CGPoint, eoFill: Bool) -> Bool

Returns true if the path contains a specified point.

func forEach((Path.Element) -> Void)

Calls body with each element in the path.

func move(to: CGPoint)

Begins a new subpath at the specified point.

func offset(CGSize) -> OffsetShape<Path>

Changes the relative position of this shape using the specified size.

func offset(CGPoint) -> OffsetShape<Path>

Changes the relative position of this shape using the specified point.

func offset(x: CGFloat, y: CGFloat) -> OffsetShape<Path>

Changes the relative position of this shape using the specified coordinates.

func offsetBy(dx: CGFloat, dy: CGFloat) -> Path

Returns a path constructed by translating self by (dx, dy).

func rotation(Angle, anchor: UnitPoint) -> RotatedShape<Path>

Rotates this shape around an anchor point at the angle you specify.

func scale(CGFloat, anchor: UnitPoint) -> ScaledShape<Path>

Scales this shape without changing its bounding frame.

func scale(x: CGFloat, y: CGFloat, anchor: UnitPoint) -> ScaledShape<Path>

Scales this shape without changing its bounding frame.

func strokedPath(StrokeStyle) -> Path

Returns a stroked copy of the path using style to define how the stroked outline is created.

func transform(CGAffineTransform) -> TransformedShape<Path>

Applies an affine transform to this shape.

func trimmedPath(from: CGFloat, to: CGFloat) -> Path

Returns a partial copy of the path.

Instance Properties

var boundingRect: CGRect

A rectangle containing all path segments.

var cgPath: CGPath

An immutable path representing the elements in the path.

var isEmpty: Bool

A Boolean value indicating whether the path contains zero elements.

Enumerations

enum Path.Element

An element of a path.

Comparing Paths

static func != (Path, Path) -> Bool

Returns a Boolean value indicating whether two values are not equal.

Applying Standard Modifiers

View Modifiers

Configure this view and the views it contains by applying standard modifiers.

Relationships

See Also

Shapes

struct Rectangle

A rectangular shape aligned inside the frame of the view containing it.

enum Edge

An enumeration to indicate one edge of a rectangle.

struct RoundedRectangle

A rectangular shape with rounded corners, aligned inside the frame of the view containing it.

struct Circle

A circle centered on the frame of the view containing it.

struct Ellipse

An ellipse aligned inside the frame of the view containing it.

struct Capsule

A capsule shape aligned inside the frame of the view containing it.