Skip to content

Latest commit

 

History

History
289 lines (158 loc) · 7.05 KB

ImageSketchpad.ImageSketchpad-1.md

File metadata and controls

289 lines (158 loc) · 7.05 KB

image-sketchpad - v1.0.4 / Modules / ImageSketchpad / ImageSketchpad

Class: ImageSketchpad

ImageSketchpad.ImageSketchpad

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.

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new ImageSketchpad(image, options?)

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

Name Type Description
image HTMLImageElement Image html element.
options? Partial<Options> Sketchpad options as javascript object.

Defined in

ImageSketchpad/index.ts:78

Properties

canvas

Readonly canvas: Canvas

Canvas helper class.

Defined in

ImageSketchpad/index.ts:18

Methods

clear

clear(): ImageSketchpad

Clears the image sketchpad.

Returns

ImageSketchpad

Defined in

ImageSketchpad/index.ts:200


destroy

destroy(): void

Destroy the instance and remove the canvas.

Returns

void

Defined in

ImageSketchpad/index.ts:311


disable

disable(): ImageSketchpad

Disables image sketchpad.

Returns

ImageSketchpad

Defined in

ImageSketchpad/index.ts:144


download

download(originalSize?): Promise<string>

Download merged image with sketch as png file.

Parameters

Name Type Default value Description
originalSize boolean true Download image with original size.

Returns

Promise<string>

Defined in

ImageSketchpad/index.ts:289


enable

enable(): ImageSketchpad

Enables image sketchpad.

Returns

ImageSketchpad

Defined in

ImageSketchpad/index.ts:135


loadJson

loadJson(json): Promise<ImageSketchpad>

Load a sketch from a json string.

Parameters

Name Type Description
json string JSON string to parse.

Returns

Promise<ImageSketchpad>

Defined in

ImageSketchpad/index.ts:174


mergeImageWithSketch

mergeImageWithSketch(originalSize?): Promise<string>

Merges image with sketch and returns a base64 string as promise.

Parameters

Name Type Default value Description
originalSize boolean true Download image with original size.

Returns

Promise<string>

Defined in

ImageSketchpad/index.ts:244


redo

redo(): ImageSketchpad

ReDo the last UnDone drawing on your sketch.

Returns

ImageSketchpad

Defined in

ImageSketchpad/index.ts:226


setOptions

setOptions(options): ImageSketchpad

Set sketchpad options.

Parameters

Name Type Description
options Partial<Options> Sketchpad options.

Returns

ImageSketchpad

Defined in

ImageSketchpad/index.ts:126


toJson

toJson(): string

Get a json string which can be used to load a sketch again.

Returns

string

Defined in

ImageSketchpad/index.ts:153


toJsonAsync

toJsonAsync(): Promise<string>

Returns

Promise<string>

Defined in

ImageSketchpad/index.ts:165


undo

undo(): ImageSketchpad

UnDo the last drawing on your sketch.

Returns

ImageSketchpad

Defined in

ImageSketchpad/index.ts:210