Skip to content
pixi-silk
GitHub repository
Class

Eyedropper

import { Eyedropper } from 'pixi-silk/ui/color';

Pick a colour from the scene. start() turns the canvas into a sampling surface: a loupe follows the pointer showing the colour under it, a click or tap picks it, Escape or a right click cancels. Add it to the stage first. start() moves it to the top of its parent, and while active it takes every pointer press on the canvas.

Extends#

  • Container

Constructors#

Constructor#

new Eyedropper(options: EyedropperOptions): Eyedropper;

Parameters#

ParameterType
optionsEyedropperOptions

Returns#

Eyedropper

Overrides#

Container.constructor

Properties#

PropertyModifierTypeDescriptionDefined in
activereadonlySignal<boolean>True while sampling.ui/color/Eyedropper.ts:36
sampledreadonlySignal<number | null>Colour under the pointer as 0xRRGGBB, or null.ui/color/Eyedropper.ts:38

Methods#

cancel()#

cancel(): void;

Stops without picking. onDone gets null.

Returns#

void


destroy()#

destroy(options?: DestroyOptions): void;

Stops the animation and the Escape listener. Destroys children by default.

Parameters#

ParameterType
options?DestroyOptions

Returns#

void

Overrides#

Container.destroy

sampleAt()#

sampleAt(globalX: number, globalY: number): number | null;

Samples at a global (canvas) point, updates sampled and moves the loupe there. Works while inactive too.

Parameters#

ParameterType
globalXnumber
globalYnumber

Returns#

number | null


start()#

start(): void;

Starts sampling. Does nothing when already active.

Returns#

void


tick()#

tick(dt: number): boolean;

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

Parameters#

ParameterType
dtnumber

Returns#

boolean