Skip to content

PencilBrush

Defined in: src/brushes/PencilBrush.ts:19

demo

new PencilBrush(canvas): PencilBrush

Defined in: src/brushes/PencilBrush.ts:47

Canvas

PencilBrush

BaseBrush.constructor

canvas: Canvas

Defined in: src/brushes/BaseBrush.ts:73

add type

BaseBrush.canvas


color: string = 'rgb(0, 0, 0)'

Defined in: src/brushes/BaseBrush.ts:16

Color of a brush

BaseBrush.color


decimate: number = 0.4

Defined in: src/brushes/PencilBrush.ts:25

Discard points that are less than decimate pixel distant from each other

0.4

drawStraightLine: boolean = false

Defined in: src/brushes/PencilBrush.ts:34

Draws a straight line between last recorded point to current pointer Used for shift functionality

false

limitedToCanvasSize: boolean = false

Defined in: src/brushes/BaseBrush.ts:68

When true, the free drawing is limited to the whiteboard size. Default to false.

false

BaseBrush.limitedToCanvasSize


shadow: null | Shadow = null

Defined in: src/brushes/BaseBrush.ts:32

Shadow object representing shadow of this shape. Backwards incompatibility note: This property replaces “shadowColor” (String), “shadowOffsetX” (Number), “shadowOffsetY” (Number) and “shadowBlur” (Number) since v1.2.12

BaseBrush.shadow


straightLineKey: undefined | null | "altKey" | "ctrlKey" | "metaKey" | "shiftKey" = 'shiftKey'

Defined in: src/brushes/PencilBrush.ts:41

The event modifier key that makes the brush draw a straight line. If null or ‘none’ or any other string that is not a modifier key the feature is disabled.


strokeDashArray: null | number[] = null

Defined in: src/brushes/BaseBrush.ts:60

Stroke Dash Array.

BaseBrush.strokeDashArray


strokeLineCap: CanvasLineCap = 'round'

Defined in: src/brushes/BaseBrush.ts:39

Line endings style of a brush (one of “butt”, “round”, “square”)

BaseBrush.strokeLineCap


strokeLineJoin: CanvasLineJoin = 'round'

Defined in: src/brushes/BaseBrush.ts:46

Corner style of a brush (one of “bevel”, “round”, “miter”)

BaseBrush.strokeLineJoin


strokeMiterLimit: number = 10

Defined in: src/brushes/BaseBrush.ts:53

Maximum miter length (used for strokeLineJoin = “miter”) of a brush’s

BaseBrush.strokeMiterLimit


width: number = 1

Defined in: src/brushes/BaseBrush.ts:23

Width of a brush, has to be a Number, no string literals

BaseBrush.width

_finalizeAndAddPath(): void

Defined in: src/brushes/PencilBrush.ts:273

On mouseup after drawing the path on contextTop canvas we use the points captured to create an new Path object and add it to the canvas.

void


convertPointsToSVGPath(points): TSimplePathData

Defined in: src/brushes/PencilBrush.ts:212

Converts points to SVG path

Point[]

Array of points

TSimplePathData

SVG path commands


createPath(pathData): Path

Defined in: src/brushes/PencilBrush.ts:222

Creates a Path object to add on canvas

TSimplePathData

Path data

Path

Path to add on canvas


decimatePoints(points, distance): Point[]

Defined in: src/brushes/PencilBrush.ts:243

Decimate points array with the decimate value

Point[]

number

Point[]


needsFullRender(): boolean

Defined in: src/brushes/PencilBrush.ts:53

boolean

BaseBrush.needsFullRender


onMouseDown(pointer, __namedParameters): void

Defined in: src/brushes/PencilBrush.ts:67

Invoked on mouse down

Point

TEvent

void

BaseBrush.onMouseDown


onMouseMove(pointer, __namedParameters): void

Defined in: src/brushes/PencilBrush.ts:83

Invoked on mouse move

Point

TEvent

void

BaseBrush.onMouseMove


onMouseUp(__namedParameters): boolean

Defined in: src/brushes/PencilBrush.ts:121

Invoked on mouse up

TEvent

boolean

BaseBrush.onMouseUp


static drawSegment(ctx, p1, p2): Point

Defined in: src/brushes/PencilBrush.ts:57

CanvasRenderingContext2D

Point

Point

Point