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#
| Parameter | Type |
|---|---|
options | EyedropperOptions |
Returns#
Eyedropper
Overrides#
Container.constructor
Properties#
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
active | readonly | Signal<boolean> | True while sampling. | ui/color/Eyedropper.ts:36 |
sampled | readonly | Signal<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#
| Parameter | Type |
|---|---|
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#
| Parameter | Type |
|---|---|
globalX | number |
globalY | number |
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#
| Parameter | Type |
|---|---|
dt | number |
Returns#
boolean