CanvasView

@available(iOS 9.0, *)
@objcMembers
@objc(PESDKCanvasView)
open class CanvasView : GLKView
extension CanvasView: Identifiable

The CanvasView is responsible for presenting a painting and handling touch events related to paintings.

Properties

  • The painting that is managed by this canvas view.

    Declaration

    Swift

    public let painting: Painting
  • The tool that is currently active. Currently only an instance of FreehandTool is supported.

    Declaration

    Swift

    open var activeTool: Tool
  • The object that acts as the data source for the canvas view.

    Declaration

    Swift

    open weak var dataSource: CanvasViewDataSource?
  • The object that acts as the delegate for the canvas view.

    Declaration

    Swift

    open weak var canvasDelegate: CanvasViewDelegate?
  • true if a user is currently painting, false otherwise.

    Declaration

    Swift

    open private(set) var currentlyPainting: Bool

Initializers

  • Creates a canvas view for the given painting, with the given tool and the given frame.

    Declaration

    Swift

    public required init(painting: Painting, activeTool: Tool, uuid: UUID, frame: CGRect)

    Parameters

    painting

    The painting that is managed by this canvas view.

    activeTool

    The tool that should be used for the painting. Currently only an instance of FreehandTool is supported.

    uuid

    The UUID that matches this instance with its BrushSpriteModel.

    frame

    The frame of the view.

Actions

  • Called by a pan gesture recognizer to handle touches.

    Declaration

    Swift

    open func handlePan(_ gestureRecognizer: UIGestureRecognizer)

    Parameters

    gestureRecognizer

    The recognizer that called this method.

Points

  • Converts a given point from view coordinates to painting coordinates.

    Declaration

    Swift

    open func convertPointToDocument(_ pt: CGPoint) -> CGPoint

    Parameters

    pt

    The point that should be converted.

    Return Value

    The converted point.