Class Board

Board class create and controls the main canvas and manages the shapes in the workspace

Constructors

  • Creates a new stage, layer, background and selection instance

    Parameters

    Returns Board

Properties

activeDrawing: null | string = null

Demonstrates the current active drawing. it's a string value or null.

This property is managing by [[ShapeDrawer]] directly

background: Background

The background of main layer that contains image and overlay

Remark

Background component is a not selectable shape that represents Image and Rect nodes. The nodes are accessible with background.image and background.overlay APIs

See

[[https://konvajs.org/api/Konva.Image.html | Image]] and [[ https://konvajs.org/api/Konva.Rect.html | Rect]]

Example

editor.board.background.setImageFromUrl('<url>')

Example

editor.board.background.fill('rgba(0, 0, 0, 0.5)')

Example

editor.board.background.filter({
name: 'Blur',
options: {
blurRadius: 20
}
})
container: undefined | HTMLDivElement

The html container element which the editor renders into that

events: Events

See

[[Events]]

groups: Groups

See

[[Groups]]

history: History

See

[[History]]

layer: Layer

The main layer that contains all shapes and transformers

selection: Selection

The selection manager components that lets select and manage shapes with UI or API

Example

Selects all shapes

editor.board.selection.selectAll()

Example

Deselects all shapes

editor.board.selection.deselectAll()
settings: Partial<BaseSettings>

The settings

stage: Stage

The stage that contains all layers

Accessors

  • get activeShapes(): ShapeModel<Shape<ShapeConfig> | Group, ShapeConfig>[]
  • Returns all created shapes except deleted and hidden shpaes

    Returns ShapeModel<Shape<ShapeConfig> | Group, ShapeConfig>[]

    See

    [[ShapeModel]]

  • get shapes(): ShapeModel<Shape<ShapeConfig> | Group, ShapeConfig>[]
  • Returns all created shapes

    Returns ShapeModel<Shape<ShapeConfig> | Group, ShapeConfig>[]

    See

    [[ShapeModel]]

Methods

  • Adds a new shape to the list of the shapes

    Parameters

    • shape: ShapeModel<Shape<ShapeConfig> | Group, ShapeConfig>

    Returns void

  • Redraws the main layer

    Returns void

  • Deletes all removed shapes in order to free up memory

    Returns void

  • Calculates the CSS transformations of board based on stage width and height

    Returns undefined | string

    transform style of the container

  • Calculates the board dimensions based on different components

    Returns {
        height: number;
        width: number;
    }

    [[Dimension]]

    • height: number
    • width: number
  • Returns all nodes in the main layer including background nodes

    Returns (Shape<ShapeConfig> | Group)[]

    array of [[ShapeModel.node]]

  • Removes a shape from the list of the shapes

    Parameters

    • shape: ShapeModel<Shape<ShapeConfig> | Group, ShapeConfig>

    Returns void

  • Rescales the container based on its width and height

    Returns void

  • Changes the active drawing mode

    Parameters

    • drawType: null | string

      The drawing type string

    Returns void

  • Updates list of the shapes

    Parameters

    • shapes: ShapeModel<Shape<ShapeConfig> | Group, ShapeConfig>[]

    Returns void