Skip to content
pixi-silk
GitHub repository
Class

BrushCursor

import { BrushCursor } from 'pixi-silk/ui/brush';

Experimental

Brush cursor for paint and sculpt tools: a ring the size of the brush that follows the pointer.

  • An inner ring shows hardness. A disc grows with pen pressure while drawing.
  • Small brushes get a crosshair, so the hot spot stays visible.
  • Hold F (or drag with the right button) and move: sideways changes the size, up and down the hardness. The ring stays where the resize began and a pill reads out the values.
  • [ and ] step the size.

Size, hardness, opacity and pressure are signals on state: bind your brush engine to them. The cursor only shows the brush. It does not paint. Key handling listens on window.

Experimental: the API may change in a minor release.

Extends#

  • Container

Constructors#

Constructor#

new BrushCursor(options?: BrushCursorOptions): BrushCursor;

Experimental

Parameters#

ParameterType
optionsBrushCursorOptions

Returns#

BrushCursor

Overrides#

Container.constructor

Properties#

PropertyModifierTypeDescriptionDefined in
statereadonlyBrushStateExperimental Size, hardness, opacity, pressure and gesture flags. Write to them or call the setters.ui/brush.ts:82

Methods#

beginResize()#

beginResize(): void;

Experimental

Starts a resize gesture at the current pointer position.

Returns#

void


destroy()#

destroy(options?: DestroyOptions): void;

Experimental

Stops the animation and input listeners and gives surface its auto cursor back.

Parameters#

ParameterType
options?DestroyOptions

Returns#

void

Overrides#

Container.destroy

endResize()#

endResize(): void;

Experimental

Ends the resize gesture. The ring jumps to the pointer with a short pop. No-op without a resize.

Returns#

void


setBrushSize()#

setBrushSize(size: number): void;

Experimental

Sets the diameter, clamped to minSize and maxSize.

Parameters#

ParameterType
sizenumber

Returns#

void


setHardness()#

setHardness(hardness: number): void;

Experimental

Sets the hardness, clamped to 0..1.

Parameters#

ParameterType
hardnessnumber

Returns#

void


setPointer()#

setPointer(x: number, y: number): void;

Experimental

Moves the cursor to (x, y) in its own coordinates. Pointer moves call this. During a resize the ring stays put and the move changes size and hardness instead.

Parameters#

ParameterType
xnumber
ynumber

Returns#

void


tick()#

tick(dt: number): boolean;

Experimental

Advances the animation by dt seconds (only needed with ticker: null). Returns true while moving.

Parameters#

ParameterType
dtnumber

Returns#

boolean