Shape

public protocol Shape : AnyObject, Decodable, Encodable

Base protocol which all shapes must implement.

Note: If you implement your own shapes, see Drawing.shapeDecoder!

  • id

    Globally unique identifier for this shape. Meant to be used for equality checks, especially for network-based updates.

    Declaration

    Swift

    var id: String { get }
  • String value of this shape, for serialization and debugging

    Declaration

    Swift

    static var type: String { get }
  • Draw this shape to the given Core Graphics context. Transforms for drawing position and scale are already applied.

    Declaration

    Swift

    func render(in context: CGContext)
  • Return true iff the given point meaningfully intersects with the pixels drawn by this shape. See ShapeWithBoundingRect for a shortcut.

    Declaration

    Swift

    func hitTest(point: CGPoint) -> Bool
  • Apply any relevant values in userSettings (colors, sizes, fonts…) to this shape

    Declaration

    Swift

    func apply(userSettings: UserSettings)