Skip to content

Latest commit

 

History

History
157 lines (87 loc) · 3.54 KB

Canvas.Canvas-1.md

File metadata and controls

157 lines (87 loc) · 3.54 KB

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

Class: Canvas

Canvas.Canvas

Canvas helper class. Inserts {@link HTMLCanvasElement|element} and handles position and size adjustments.

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Canvas()

Creates an instance of the canvas helper class.

Defined in

Canvas/index.ts:20

Properties

element

Readonly element: HTMLCanvasElement

Reference to the HTML canvas {@link HTMLCanvasElement|element}.

Defined in

Canvas/index.ts:10

Methods

adjust

adjust(width, height, top, left): void

Adjusts canvas size and position.

Parameters

Name Type Description
width number New width for canvas.
height number New height for canvas.
top number New top position for canvas.
left number New left position for canvas.

Returns

void

Defined in

Canvas/index.ts:47


adjustFromElement

adjustFromElement(element): void

Adjust canvas size and position from existing element.

Parameters

Name Type Description
element HTMLElement Existing {@link HTMLElement|element} as reference.

Returns

void

Defined in

Canvas/index.ts:62


clear

clear(): Canvas

Clear the canvas area.

Returns

Canvas

Defined in

Canvas/index.ts:69


drawStroke

drawStroke(stroke, ratio): Promise<void>

Draw stroke as a path on canvas area.

Parameters

Name Type Description
stroke Stroke Stroke object with meta data.
ratio number Image/canvas ratio.

Returns

Promise<void>

Defined in

Canvas/index.ts:81


insert

insert(refElement): void

Inserts canvas html element right after the reference element.

Parameters

Name Type Description
refElement HTMLElement Reference {@link HTMLElement|element} where we want position the canvas.

Returns

void

Defined in

Canvas/index.ts:30