Documentation
    Preparing search index...

    DrawingCanvas – a CanvasView-based view that provides interactive drawing with multiple modes, layers, undo/redo, selection & transform, and JSON serialization.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _canvasMatrix: Matrix

    Global canvas Matrix applied when drawing (useful for zoom integration)

    _currentDisplayScale: number

    The effective display scale computed each frame in onDraw (canvasScale × matrix scale). Used by drawShapeSelectionOverlay to keep handle sizes constant on screen.

    augmentedCanvas: Canvas
    cached: boolean
    callDrawBeforeShapes: boolean
    canvasScale: number

    Global canvas scale factor applied when drawing (useful for zoom integration). Touch coordinates are inverse-transformed automatically.

    canvasTranslateX: number

    Global canvas X translation applied when drawing (useful for pan integration)

    canvasTranslateY: number

    Global canvas Y translation applied when drawing (useful for pan integration)

    density: number
    drawFrameRate: boolean
    fillColor: Color

    Current fill colour

    handleSize: number

    Handle size for selection overlay in dp

    handleTouchRadius: number

    Handle hit-test radius in dp

    hardwareAccelerated: boolean
    layers: ObservableArray<DrawableShape>

    All drawable layers, bottom-to-top order (ObservableArray for data-binding)

    matrixMapPointArray: any
    maxUndoDepth: number

    Maximum number of undo snapshots to retain (default: 50)

    minShapeSize: number

    Minimum dimension when resizing a shape in dp

    shapeOpacity: number

    Global opacity for newly created shapes (0-1)

    shapes: ObservableArray<Shape>
    simplificationOptions: SimplificationOptions

    Simplification options for pen strokes

    strokeColor: Color

    Current stroke colour

    strokeWidth: number

    Current stroke width in dp

    Accessors

    • get canRedo(): boolean

      Whether redo is available

      Returns boolean

    • get canUndo(): boolean

      Whether undo is available

      Returns boolean

    • get canvasMatrix(): Matrix

      Returns Matrix

    • set canvasMatrix(matrix: Matrix): void

      Parameters

      Returns void

    • get editingTextField(): TextView

      Returns TextView

    • get editingTextShape(): TextShape

      Returns TextShape

    • get modeName(): string

      Get the current active mode name

      Returns string

    Methods

    • Parameters

      • name: string
      • value: any[]

      Returns any

    • Parameters

      • name: string
      • value: any

      Returns any

    • Parameters

      • name: string
      • value: any

      Returns any

    • Add a shape to the top of the layer stack

      Parameters

      Returns void

    • Parameters

      • shape: Shape

      Returns any

    • Open the shared TextField over the given TextShape so the user can type. If the same shape is already being edited, the TextField is just repositioned (no keyboard flicker). Pass touchPoint (in canvas coords) to position the text cursor at the tap location; omit to leave the cursor where the platform puts it.

      Parameters

      • shape: TextShape
      • OptionaltouchPoint: { x: number; y: number }

      Returns void

    • Called by drawing modes to commit a finished shape to the layers

      Parameters

      Returns void

    • Draw the selection overlay for the given shape. Override this method to customise the selection overlay appearance across all shapes, or let individual shapes override their own drawSelectionOverlay() for per-shape customisation.

      Parameters

      Returns void

    • Commit the TextField content to the shape and hide the TextField. An undo snapshot is pushed only if the text actually changed.

      Returns void

    • TODO: work in progress , just for testing. Export the current canvas layers as an off-screen bitmap.

      Parameters

      • targetWidthDp: number

        width of the output image in dp (defaults to the DrawingCanvas width)

      • targetHeightDp: number

        height of the output image in dp (defaults to the DrawingCanvas height)

      • rect: RectF
      • OptionalbackgroundImageSource: ImageSource

      Returns ImageSource

      ImageSource containing the rendered bitmap, or null on error

    • Export all layers as a compact JSON string

      Returns string

    • Import layers from a JSON string, replacing current layers

      Parameters

      • json: string

      Returns void

    • Parameters

      • shape: Shape
      • atIndex: number

      Returns any

    • Returns any

    • Move a layer down by one

      Parameters

      Returns void

    • Move a layer up by one

      Parameters

      Returns void

    • Move a shape to a specific index in the layer stack

      Parameters

      Returns void

    • Parameters

      Returns void

    • Parameters

      • w: number
      • h: number
      • oldw: number
      • oldh: number

      Returns any

    • Take a snapshot of the current layers and push to undo stack

      Returns void

    • Returns void

    • Returns any

    • Register a custom drawing mode

      Parameters

      Returns void

    • Register a custom shape factory for a given type string

      Parameters

      Returns void

    • Remove a shape (undoable)

      Parameters

      Returns void

    • Parameters

      • shape: Shape

      Returns any

    • Programmatically select a shape: switches to 'select' mode and marks the shape as selected. Fires a 'selectionChange' event.

      Parameters

      Returns void

    • Parameters

      Returns void

    • Switch to a built-in or registered mode

      Parameters

      • name: string

      Returns void

    • Change the fill colour of a specific shape

      Parameters

      Returns void

    • Change the stroke colour of a specific shape (or all selected shapes)

      Parameters

      Returns void

    • Change the stroke width of a specific shape

      Parameters

      Returns void

    • Returns void

    • Re-position the shared TextField to match the currently edited TextShape's screen bounds. Called from SelectMode during resize/move so the TextField follows the shape live.

      Returns void