Options
All
  • Public
  • Public/Protected
  • All
Menu

Image sketchpad main class. It handles creation of canvas element, drawing on it, and merge it with the image and handle the data as json out- or input.

Hierarchy

  • ImageSketchpad

Index

Constructors

  • Creates an instance of image sketchpad.

    example

    Run image sketchpad

    VanillaJS

    const imageEl = document.getElementById('Image');
    const sketchPad = ImageSketchpad(imageEl, { lineWidth: 5, lineMaxWidth: 10, lineColor: '#ff0000' });

    Parameters

    • image: HTMLImageElement

      Image html element.

    • Optional options: Partial<Options>

      Sketchpad options as javascript object.

    Returns ImageSketchpad

Properties

canvas: Canvas = ...

Canvas helper class.

Methods

  • destroy(): void
  • download(originalSize?: boolean): Promise<string>
  • Download merged image with sketch as png file.

    Parameters

    • originalSize: boolean = true

      Download image with original size.

    Returns Promise<string>

  • mergeImageWithSketch(originalSize?: boolean): Promise<string>
  • Merges image with sketch and returns a base64 string as promise.

    Parameters

    • originalSize: boolean = true

      Download image with original size.

    Returns Promise<string>

  • toJson(): string
  • toJsonAsync(): Promise<string>

Generated using TypeDoc