# Paylines and overlays

> Find any cell on screen to draw paylines, badges and highlights over the board, or to make a cell tappable.

Source: https://pixi-reels.schmooky.dev/mechanics/cells-and-banners/

`reelSet.spotlight` dims the losing symbols, lifts the winners above the
mask, and can step through several lines in turn.

## One win, one line

```ts
reelSet.events.on('spin:complete', async (result) => {
  const wins = detectWins(result.symbols);      // your logic
  if (wins.length === 0) return;

  // positions: [{ reelIndex, cellIndex }, ...]
  await reelSet.spotlight.show(wins[0].positions, {
    dimAmount: 0.3,
    playWinAnimation: true,
  });
});
```

## Several lines in turn

```ts
await reelSet.spotlight.cycle(
  wins.map((w) => ({ positions: w.positions })),   // WinLine[]
  {
    displayDuration: 1000,   // ms per line. Default 2000
    gapDuration: 300,        // ms between lines
    cycles: 1,
    dimAmount: 0.3,          // losers fade to 30%
  },
);
```

## Symbol animations

With `playWinAnimation: true` the spotlight calls `playWin()` on each
highlighted symbol. The three built-in symbol classes all implement it.

```ts
await reelSet.spotlight.show(wins[0].positions, { playWinAnimation: true });
```

`show()` resolves when the animation is done, so you can await it before
the next step.

## Events

`spotlight:start` and `spotlight:end` bracket a `cycle()`. Use them to
disable the spin button while a win plays.

## Demos

`reelSet.getCellBounds(reel, cell)` returns the screen rect of a visible cell. Paylines, win outlines and hit areas are all drawn from it, so they line up with the symbols. The engine itself draws no paylines. For a banner reel above the grid, see [Sideways and upward reels](/mechanics/orientation-and-direction/#horizontal-banner).

## Cell rects

The rect of any visible cell, used here to outline cells and draw a line through them.

Live demo (cell-bounds): https://pixi-reels.schmooky.dev/mechanics/cells-and-banners/#cell-bounds-overlays-paylines--hit-areas

## Paylines

### From win events

`WinPresenter` animates the winning symbols and draws nothing else. Subscribe to `win:group` and draw each line from `getCellBounds`. `win:symbol` fires per winning symbol, for anything drawn per cell.

Live demo (paylines-events-only): https://pixi-reels.schmooky.dev/mechanics/cells-and-banners/#draw-paylines-yourself-from-wingroup

### With WinLines

`WinLines` from `pixi-reels/debug` draws the cells it is given. A payline is one stroke through one cell per reel. A payway joins every winning cell to every winning cell on the next reel. The demo alternates: one spin pays ten fixed lines and draws each as the presenter reaches it, the next pays ways and draws all of them at once.

Live demo (win-lines): https://pixi-reels.schmooky.dev/mechanics/cells-and-banners/#paylines-and-payways-with-winlines

## Tappable cells

One pointer target per cell, built from `getCellBounds`. Hover previews a cell, a click toggles a pick, and picks stay through spins.

Fill the hit rect with alpha 0 rather than setting `visible = false`. A transparent filled rect still receives pointer events; a hidden one does not.

Live demo (cell-hit-areas): https://pixi-reels.schmooky.dev/mechanics/cells-and-banners/#cell-hit-areas-click-to-pick-hover-to-preview

## Horizontal sets

### Rects

`getCellBounds(reel, cell)` takes the same arguments on either axis, and (0, 0) is still the first cell of the first reel. The rect it returns is transposed: on a horizontal set the reel index goes down the screen and the cell index goes across it.

So a line through the same cell index on every reel runs vertically here, where the same code draws a horizontal line on a vertical set. Read the rects instead of working them out from the indices.

Live demo (cells-horizontal-bounds): https://pixi-reels.schmooky.dev/mechanics/cells-and-banners/#cell-bounds-on-a-horizontal-set

### Hit areas

The same loop over reels and cells as the vertical demo, with no orientation check. The rects are already in screen space, so the hit areas sit on the symbols either way.

Live demo (cells-horizontal-hit-areas): https://pixi-reels.schmooky.dev/mechanics/cells-and-banners/#hit-areas-on-a-horizontal-set
