Skip to content
pixi-silk
GitHub repository
Class

SnapGuides

import { SnapGuides } from 'pixi-silk/ui/snap';

Experimental

Draws what a SnapEngine found: dashed alignment lines with end marks, and equal-gap markers with their distance in a pill. Each alignment fades in when found and out when lost, so the guides never slide from one alignment to the next. Add it to the same space as the rectangles you snap. It ignores pointer events.

Experimental: the API may change in a minor release.

Extends#

  • Container

Constructors#

Constructor#

new SnapGuides(options?: SnapGuidesOptions): SnapGuides;

Experimental

Parameters#

ParameterType
optionsSnapGuidesOptions

Returns#

SnapGuides

Overrides#

Container.constructor

Accessors#

guides#

Get Signature#

get guides(): readonly SnapGuide[];

Experimental

Guides shown now, not counting ones fading out. Allocates a new array.

Returns

readonly SnapGuide[]

Methods#

clear()#

clear(): void;

Experimental

Fades every guide out.

Returns#

void


destroy()#

destroy(options?: DestroyOptions): void;

Experimental

Removes all internal references and listeners as well as removes children from the display list. Do not use a Container after calling destroy.

Parameters#

ParameterTypeDescription
options?DestroyOptionsOptions parameter. A boolean will act as if all options have been set to that value

Returns#

void

Example#

container.destroy();
container.destroy(true);
container.destroy({ children: true });
container.destroy({ children: true, texture: true, textureSource: true });

Overrides#

Container.destroy

show()#

show(guides: 
  | SnapResult
  | readonly SnapGuide[]): void;

Experimental

Shows the guides of a snap result, replacing the last call’s. Guides no longer in it fade out.

Parameters#

ParameterType
guides| SnapResult | readonly SnapGuide[]

Returns#

void


tick()#

tick(dt: number): boolean;

Experimental

Advances the fades by dt seconds (clamped to 0..0.1) and redraws. Only needed with ticker: null.

Parameters#

ParameterType
dtnumber

Returns#

boolean