pixi-reels

PathMaskStrategy

pixi-reels


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#

ParameterType
_pathMaskPathFn

Returns#

PathMaskStrategy

Properties#

PropertyModifierTypeDefault valueDescriptionDefined in
versionreadonly2MASK_STRATEGY_VERSIONMust 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#

ParameterType
ctxMaskContext

Returns#

Graphics

Implementation of#

DrawableMaskStrategy.build


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#

ParameterType
gGraphics
ctxMaskContext

Returns#

void

Implementation of#

DrawableMaskStrategy.draw


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#

ParameterType
gGraphics
ctxMaskContext

Returns#

void

Implementation of#

DrawableMaskStrategy.update