PathMaskStrategy
pixi-reels / index / PathMaskStrategy
Class: PathMaskStrategy
Defined in: core/maskStrategies.ts:608
Any mask you can draw, without the class.
The smallest possible custom MaskStrategy is otherwise ~25 lines of
ceremony - a version marker, a build/update split, a clear() on
update - wrapped around one g.rect(...) call. This is that ceremony,
written once.
ctx.axis, ctx.rects and ctx.bleed are all in scope, so an orientation-
aware mask stays a one-liner. Do not call g.clear(); the strategy already
did.
Examples#
// A hexagon over the whole board.
builder.maskStrategy(new PathMaskStrategy((g, ctx) => {
g.regularPoly(ctx.width / 2, ctx.height / 2, ctx.height / 2, 6).fill({ color: 0xffffff });
}))
// A frame: everything except a hole in the middle. `cut()` subtracts from
// the last shape that was already FILLED, so the fill comes first - draw the
// hole before filling and it finds nothing to cut from, leaving an empty
// mask and an invisible board.
builder.maskStrategy(new PathMaskStrategy((g, ctx) => {
g.rect(0, 0, ctx.width, ctx.height).fill({ color: 0xffffff });
g.rect(60, 60, ctx.width - 120, ctx.height - 120).cut();
}))
Implements#
Constructors#
Constructor#
new PathMaskStrategy(_path: MaskPathFn): PathMaskStrategy;
Defined in: core/maskStrategies.ts:611
Parameters#
| Parameter | Type |
|---|---|
_path | MaskPathFn |
Returns#
PathMaskStrategy
Properties#
| Property | Modifier | Type | Default value | Description | Defined in |
|---|---|---|---|---|---|
version | readonly | 2 | MASK_STRATEGY_VERSION | Must equal MASK_STRATEGY_VERSION. Validated by ReelSetBuilder.maskStrategy(). | core/maskStrategies.ts:609 |
Methods#
build()#
build(ctx: MaskContext): Graphics;
Defined in: core/maskStrategies.ts:617
Build (or rebuild) the mask graphic. Returns the Graphics to use as the mask.
Parameters#
| Parameter | Type |
|---|---|
ctx | MaskContext |
Returns#
Graphics
Implementation of#
draw()#
draw(g: Graphics, ctx: MaskContext): void;
Defined in: core/maskStrategies.ts:628
Draw this strategy’s shapes into g. Must not call g.clear().
Parameters#
| Parameter | Type |
|---|---|
g | Graphics |
ctx | MaskContext |
Returns#
void
Implementation of#
update()#
update(g: Graphics, ctx: MaskContext): void;
Defined in: core/maskStrategies.ts:623
Update the mask when reel boxes resize (e.g. MultiWays reshape).
Parameters#
| Parameter | Type |
|---|---|
g | Graphics |
ctx | MaskContext |
Returns#
void