Each demo passes a mask strategy to .maskStrategy(...). Rounded windows come first, then the helpers that trim or combine a mask, then a mask drawn from your own path.
Rounded corners#
The whole window#
RoundedRectMaskStrategy with scope: 'set' rounds the corners of the box around all the reels. It works at any cross gap, which is why it is the default scope.
Loading recipe…
Each reel as a card#
scope: 'reel' rounds every reel’s box instead, so the reels read as separate cards.
It needs a cross gap above 0. At gap 0 neighbouring reels share an edge, and rounding both sides of it cuts a notch into every seam. The strategy warns once when it sees touching reels.
Loading recipe…
Outer corners only#
scope: 'outer' keeps one rect per reel, as the default mask does, so buffer cells past a short reel stay hidden. It rounds a corner only where it is also a corner of the box around all the reels: the outer pair on the first reel and on the last. The inner edges stay square, so it works at cross gap 0, where scope: 'reel' notches. corners: { topLeft: true, ... } limits any scope to the named screen corners.
On a jagged set the corners of the box may not touch any reel, and then nothing is rounded. Use SilhouetteMaskStrategy there.
Loading recipe…
Jagged boards#
A pyramid has no single rectangle to round. Rounding each reel notches the seams, and rounding the bounding box hides the staircase and shows buffer cells past the short reels. SilhouetteMaskStrategy follows the outline of all the reels together and rounds every corner of it. The inward corners, where a short reel meets a taller one, use concaveRadius. On a board with no steps it gives a plain rounded rect.
The reels must touch, at cross gap 0. With a gap the strategy warns and falls back to a rounded rect per reel.
Loading recipe…
Hold & Win cells#
Every Hold & Win cell is its own 1x1 reel set with its own mask. cellMask on the Hold & Win builder takes a function that is called once per cell with { reel, cell } (column and row) and { cols, rows, corners }, and returns that cell’s strategy. Here every cell gets a plain rect except the four corner cells, which each round their one outer corner, so the gapless board clips as one rounded window made of fifteen masks. corners is the cell’s corner set already worked out, for the short form (_, { corners }) => new RoundedRectMaskStrategy({ radius, corners }).
Loading recipe…
Trimming and combining#
Inset and compose#
inset(strategy, px) shrinks what any strategy draws by px on every side, and a negative value grows it. Use it when the art shows a pixel past the frame. composeMasks(a, b, ...) joins several strategies into the viewport’s one mask. Here a rounded window inset by 4px is joined with a banner strip above the reels.
composeMasks can only form a union, because a Graphics mask is the union of its filled shapes. To subtract, use .cut() inside a PathMaskStrategy.
Loading recipe…
A different trim per side#
Frame art rarely has four equal lips. inset(strategy, { top, right, bottom, left }) trims each side by its own amount, for example inset(new RoundedRectMaskStrategy({ radius: 43 }), { top: 4, bottom: 12 }). Sides are screen sides in every orientation, and a side you leave out is not trimmed. Here the bottom lip is four times thicker than the top one.
Loading recipe…
Any shape#
PathMaskStrategy takes a (graphics, context) => void callback. The context carries rects, width, height, axis and bleed. Do not call g.clear(), because the strategy already has. The demo fills the board and cuts a hole in the middle, so only the outer ring of symbols shows.
cut() subtracts from the last shape filled, so fill first. If you draw the hole before filling, the mask is empty and the board disappears, with no error.
Loading recipe…