Skip to main content

Class: default

Defined in: src/lib/rendering/BrushTip/index.ts:71

A brush shape that can be stamped in any colour, size and rotation.

Presets without an image use a hard round shape drawn as a vector ellipse, so it stays crisp at every size. Presets with an image use only its alpha values; tinted copies are cached per colour.

Example​

const tip = await BrushTip.load(preset);
tip.stamp(ctx, 100, 100, params, "#ff0000");

Constructors​

Constructor​

new default(mask?, outline?, createCanvas?): BrushTip

Defined in: src/lib/rendering/BrushTip/index.ts:84

Parameters​

mask?​

OffscreenCanvas

outline?​

OutlineSegment[]

createCanvas?​

CanvasFactory = createOffscreenCanvas

Returns​

BrushTip

Properties​

mask?​

readonly optional mask?: OffscreenCanvas

Defined in: src/lib/rendering/BrushTip/index.ts:73

Alpha mask of the shape image, or undefined for the round shape


outline?​

readonly optional outline?: OutlineSegment[]

Defined in: src/lib/rendering/BrushTip/index.ts:76

Outline of the shape in 0–1 coordinates (for the brush cursor), or undefined for the round shape

Accessors​

isRound​

Get Signature​

get isRound(): boolean

Defined in: src/lib/rendering/BrushTip/index.ts:95

Whether this is the built-in round shape

Returns​

boolean

Methods​

stamp()​

stamp(ctx, x, y, params, colour): void

Defined in: src/lib/rendering/BrushTip/index.ts:148

Stamp the shape centred on a point, with the stamp's size, rotation, offset and alpha.

Parameters​

ctx​

StampContext

x​

number

y​

number

params​

StampParams

colour​

string

Returns​

void


load()​

static load(preset, decode?, createCanvas?): Promise<BrushTip>

Defined in: src/lib/rendering/BrushTip/index.ts:102

Load a preset's shape: decodes its image and keeps only the alpha. Presets without an image get the round shape.

Parameters​

preset​

BrushConfig

decode?​

ImageDecoder = decodeImage

createCanvas?​

CanvasFactory = createOffscreenCanvas

Returns​

Promise<BrushTip>