Percept
    Preparing search index...

    Class Canvas

    The Canvas object holds an HTMLCanvasElement reference and its 2d context, registers resize observers and can initiate render of Drawing

    Index
    • If no parameters are passed then a new canvas will be created and appended to <body>

      Parameters

      • Optionalelement: HTMLCanvasElement | HTMLDivElement

        Reference to an html <canvas> or <div> element, if a <div> element is passed, then a canvas will be created and appended

      • Optionalwidth: number

        Passing a width will overwrite previously defined canvas width

      • Optionalheight: number

        Passing a height will overwrite previously defined canvas height

      Returns Canvas

    canvasElement: HTMLCanvasElement

    Reference to the bound <canvas> element

    context: CanvasRenderingContext2D
    currDrawing: Drawing

    Drawing that is currently being rendered or paused

    isCanvasCreated: boolean = false
    offCanvasElement: OffscreenCanvas | HTMLCanvasElement

    Reference to the created OffscreenCanvas used as hit-maps (if not supported, another <canvas> will be created)

    offContext: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D
    • Removes the Canvas and cleans-up any listeners

      Returns void

    • Stops rendering current drawing (see Canvas.currDrawing) (if any) and starts the one passed as argument

      Parameters

      • drawing: Drawing

        A Drawing object, which will be rendered by this canvas

      Returns void

    • Resumes rendering the current Drawing (if any)

      Returns void