Block
import { Block } from 'pixi-silk/ui/blocks';
A piece of UI that paints into its surface’s painter. Subclass it and implement
Block.paint: draw at (x, y), the top-left corner of the block’s slot, with the size in
w and h. Animate with spring, follow state with watch, take
input with pressable. Put blocks in a BlockSurface with
Block.layout or stack.
Extends#
Container
Extended by#
Constructors#
Constructor#
new Block(options?: BlockOptions): Block;
Parameters#
| Parameter | Type |
|---|---|
options | BlockOptions |
Returns#
Block
Overrides#
Container.constructor
Properties#
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
h | public | number | Height of the slot, design units. The layout sets it. | packages/pixi-silk/src/ui/blocks.ts:86 |
layer | readonly | BlockLayer | The layer it asked for. See BlockOptions.layer. | packages/pixi-silk/src/ui/blocks.ts:88 |
w | public | number | Width of the slot, design units. The layout sets it. | packages/pixi-silk/src/ui/blocks.ts:84 |
Accessors#
surface#
Get Signature#
get surface(): BlockSurface | null;
The surface the block is in, or null.
Returns
BlockSurface | null
Methods#
destroy()#
destroy(options?: DestroyOptions): void;
Stops following watched signals.
Parameters#
| Parameter | Type |
|---|---|
options? | DestroyOptions |
Returns#
void
Overrides#
Container.destroy
layout()#
layout(style?: SmartLayout): SmartLayout;
The flex style of this block’s slot: its size, no shrinking, and an onSize that keeps
w and h in step with the layout. An absolute slot stretched between two edges (inset,
or left and right) takes its size from them instead. Pass it to add of a
FlexContainer or SmartContainer.
Parameters#
| Parameter | Type |
|---|---|
style | SmartLayout |
Returns#
paint()#
abstract paint(
g: SilkGraphics,
x: number,
y: number
): void;
Draws the block into g with its slot’s top-left corner at (x, y), in the surface’s space.
Parameters#
| Parameter | Type |
|---|---|
g | SilkGraphics |
x | number |
y | number |
Returns#
void
step()#
step(dt: number): boolean;
Advances the block’s springs by dt seconds. Returns true while any moves. Override it to
animate something else, and return true while that runs.
Parameters#
| Parameter | Type |
|---|---|
dt | number |
Returns#
boolean
wake()#
wake(): void;
Asks the surface to repaint this block. The surface repaints until every block settles, then
sleeps. The first call moves an 'auto' block to the live layer.
Returns#
void