Skip to main content

Class: default

Defined in: src/lib/brushes/BrushTipCache/index.ts:23

Loads and keeps each shape's brush tip. Until a shape's image has loaded, the round tip is used.

Dispatches a change event when a tip finishes loading.

Example​

const tips = new BrushTipCache();
const tip = tips.get(preset); // round until the image loads

Extends​

  • EventTarget

Constructors​

Constructor​

new default(decode?, createCanvas?): BrushTipCache

Defined in: src/lib/brushes/BrushTipCache/index.ts:34

Parameters​

decode?​

ImageDecoder = decodeImage

createCanvas?​

CanvasFactory = createOffscreenCanvas

Returns​

BrushTipCache

Overrides​

EventTarget.constructor

Methods​

addEventListener()​

addEventListener(type, callback, options?): void

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:14380

The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

MDN Reference

Parameters​

type​

string

callback​

EventListenerOrEventListenerObject | null

options?​

boolean | AddEventListenerOptions

Returns​

void

Inherited from​

EventTarget.addEventListener


dispatchEvent()​

dispatchEvent(event): boolean

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:14386

The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

MDN Reference

Parameters​

event​

Event

Returns​

boolean

Inherited from​

EventTarget.dispatchEvent


get()​

get(preset): default

Defined in: src/lib/brushes/BrushTipCache/index.ts:48

Get the tip of a brush's settings, starting to load it if needed. Returns the round tip while loading or if loading fails.

Parameters​

preset​

BrushConfig

Returns​

default


preload()​

preload(presets): void

Defined in: src/lib/brushes/BrushTipCache/index.ts:60

Start loading every preset's tip, so the first stroke with each preset already uses its shape.

Parameters​

presets​

BrushesConfig

Returns​

void


removeEventListener()​

removeEventListener(type, callback, options?): void

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts:14392

The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

MDN Reference

Parameters​

type​

string

callback​

EventListenerOrEventListenerObject | null

options?​

boolean | EventListenerOptions

Returns​

void

Inherited from​

EventTarget.removeEventListener