inset()
pixi-reels / index / inset
Function: inset()
function inset(strategy: MaskStrategy, pixels: number | InsetSides): DrawableMaskStrategy;
Defined in: core/maskStrategies.ts:692
Shrink (or grow) any strategy’s mask by a number of pixels - one number for
all four sides, or { top, right, bottom, left } for a different trim per
screen side.
The fix for “the art bleeds a pixel past the frame” that does not involve rewriting the strategy. Positive shrinks; negative grows. A side left out of the object form is untouched.
Implemented by handing the wrapped strategy a derived MaskContext -
shrunken rects, a shrunken viewport box, and an origin shift for the
strategies that draw from (0, 0). ctx.bleed is passed through unchanged,
so an inset composes with curve bleed rather than cancelling it.
A custom strategy that ignores ctx.origin insets in size but not in
position. Every built-in honours it.
Parameters#
| Parameter | Type |
|---|---|
strategy | MaskStrategy |
pixels | number | InsetSides |
Returns#
Examples#
builder.maskStrategy(inset(new SilhouetteMaskStrategy({ radius: 20 }), 3))
// Trim more off the bottom than the top - a frame whose lower lip is thicker.
builder.maskStrategy(inset(new RoundedRectMaskStrategy({ radius: 43 }), { top: 4, bottom: 12 }))