Documentation / spryte / mask
Function: mask()
mask(
draw,shape,fn):void
Defined in: mask.ts:14
Run fn, keeping what it draws only where shape draws: a sprite (soft, using its alpha), shapes, text, anything. Same units, transform and clips as outside. Nests, and works inside draw.into(). Costs two offscreen passes the size of the destination, so mask a group of things at once rather than each sprite.
ts
import { mask } from "spryte";
mask(draw, () => draw.circle(px, py, 40, "#fff"), () => drawLevel(draw)); // spotlightParameters
draw
shape
() => void
fn
() => void
Returns
void