Class ShapeDrawer<T, P>Abstract

This is an abstract class that Shapes have to extend that to insert or draw their own

Example

editor.board.shapes.circle.insert({
x: 100,
y: 100,
radius: 10,
fill: 'red'
})

Example

editor.board.shapes.circle.draw()

Example

editor.board.shapes.circle.stopDrawing()

Type Parameters

Hierarchy (view full)

Implements

Constructors

  • Creates a Shape Drawer instance to build and draw different shapes

    Type Parameters

    • T extends Shape<ShapeConfig>
    • P extends ShapeConfig

    Parameters

    • board: Board

      The [[Board]]

    • drawType: string

      The type of [[string | Drawing]]

    • Optional options: DrawingOptions

      The drawing possible options

    Returns ShapeDrawer<T, P>

Properties

config: Partial<P>

Reperesents the configuration of the shape that is drawing that

node: null | T

Reperesents the node which is drawing or has been drawn

startPoint: Point

Reperesents the start point of the drawing shape

Accessors

  • get isDrawing(): boolean
  • Checks wheather the current shape is drawing or not

    Returns boolean

Methods

  • Enables the drawing mode

    Parameters

    • config: Partial<P>

      The initial [[ShapeModel]] config

    Returns void

  • Returns current position of the shape

    Returns {
        x: number;
        y: number;
    }

    the current position of the shape as a [[Point]]

    • x: number
    • y: number
  • Creates a new shape and insert that into the [[Board]]

    Parameters

    • config: ShapeConfig

      The [[ShapeModel]] configuration

    Returns ShapeModel<T, ShapeConfig>

    The created [[ShapeModel]]