WorkspaceBezierPath

@objcMembers public final class WorkspaceBezierPath: NSObject

Object for constructing a bezier path from a Workspace coordinate system and translating that path into the UIView coordinate system.

Under the hood, this class uses a UIBezierPath object, but it has added the following:

  • enables the ability to add segments by relative location, based on the current point
  • adds SVG-equivalent methods for smooth curveto and smooth quadratic curveto
  • The translated bezier path in the UIView coordinate system.

    Declaration

    Swift

    public let viewBezierPath: UIBezierPath
  • The current point of the bezier path, specified in the Workspace coordinate system.

    Declaration

    Swift

    public private(set) var currentWorkspacePoint: WorkspacePoint = WorkspacePoint.zero
  • Appends a straight line to the receiver’s path.

    Declaration

    Swift

    public func addLine(to point: WorkspacePoint, relative: Bool)
  • Appends a straight line to the receiver’s path.

    Declaration

    Swift

    public func addLineTo(x: CGFloat, y: CGFloat, relative: Bool)
  • Appends an arc to the receiver’s path.

    Declaration

    Swift

    public func addArc(
        withCenter center: WorkspacePoint, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat,
        clockwise: Bool, relative: Bool)
  • Appends a cubic Bézier curve to the receiver’s path.

    Declaration

    Swift

    public func addCurve(
        to endPoint: WorkspacePoint, controlPoint1: WorkspacePoint, controlPoint2: WorkspacePoint,
        relative: Bool)
  • Appends a quadratic Bézier curve to the receiver’s path.

    Declaration

    Swift

    public func addQuadCurve(
        to endPoint: WorkspacePoint, controlPoint: WorkspacePoint, relative: Bool)
  • Appends a cubic Bézier curve to the receiver’s path. Similar to SVG’s smooth curveto method, if the previous method call appended a cubic or quadratic Bézier curve, this method will create a smooth transition between both curves.

    Note: This method should only be called directly after appending a cubic or quadratic Bézier curve. Otherwise, addCurveToPoint(...) is a more suitable method to use.

    Declaration

    Swift

    public func addSmoothCurve(
        to endPoint: WorkspacePoint, controlPoint2: WorkspacePoint, relative: Bool)
  • Appends a quadratic Bézier curve to the receiver’s path. Similar to SVG’s smooth quadratic curveto method, if the previous method call appended a cubic or quadratic Bézier curve, this method will create a smooth transition between both curves.

    Note: This method should only be called directly after appending a cubic or quadratic Bézier curve. Otherwise, addQuadCurveToPoint(...) is a more suitable method to use.

    Declaration

    Swift

    public func addSmoothQuadCurve(to endPoint: WorkspacePoint, relative: Bool)
  • Appends the contents of the specified path object to the receiver’s path.

    Declaration

    Swift

    public func append(_ bezierPath: WorkspaceBezierPath)
  • Closes the most recently added subpath.

    Declaration

    Swift

    public func closePath()
  • Moves the receiver’s current point to the specified location.

    Declaration

    Swift

    public func move(to point: WorkspacePoint, relative: Bool)
  • Moves the receiver’s current point to the specified location.

    Declaration

    Swift

    public func moveTo(x: CGFloat, y: CGFloat, relative: Bool)
  • Removes all points from the receiver, effectively deleting all subpaths.

    Declaration

    Swift

    public func removeAllPoints()