# Curved reels

> Bend the strip onto a drum so the top and bottom cells lean away, like a physical machine.

Source: https://pixi-reels.schmooky.dev/mechanics/reel-curvature/

Curvature is presentation only. It never changes what lands where,
`getVisibleGrid()`, or any event payload.

## Two drawing modes

```ts
builder.curve(0.45).curveMode('warp').renderer(app.renderer);
```

| | `'symbol'` (default) | `'warp'` |
|---|---|---|
| Spine and composites bend | no | yes |
| Atlas art keystones | no | yes |
| Motion follows the curve | no | yes |
| Cost | free | 1 render pass per reel per frame |
| Sharpness | native | one resample |
| Needs `renderer()` | no | yes, `build()` throws |

`'warp'` renders each reel to a texture and moves the vertices of a mesh, so
everything inside the reel bends without any help from the symbols.
`'symbol'` projects each cell on its own. It is sharper, but a `Container`
transform is affine, so it can only bend content that is a single texture.

## Lifted symbols stay flat

Under `'warp'`, anything drawn outside the reel's texture is not bent:
`unmask: true` symbols, the win spotlight, pin flights and overlays all draw
flat over a curved board. The builder logs a warning when it sees `unmask`
with the warp. `'symbol'` mode has no such split. For art that overflows its
cell under the warp, use `curveBleed` instead of `unmask`.

## Changing the curve at run time

```ts
reelSet.setCurve(0.4);
reelSet.setCurve([0.2, 0.35, 0.5, 0.35, 0.2]);
reelSet.setCurve(0); // flat
```

## Extending `'symbol'` mode

This only matters if you do not use the warp. The engine hands each symbol a
projected quad through `ReelSymbol.applyCellQuad()`.

`SpriteSymbol` and `AnimatedSpriteSymbol` map it onto a `PerspectiveMesh`,
which keystones the art with no extra render pass, when the texture owns its
whole source. `canProjectTexture()` refuses atlas sub-frames: the mesh
addresses its source with 0..1 UVs, and remapping them onto the frame has not
produced a correct draw yet. Every other symbol gets a uniform scale that
fits inside the quad, so no cell overlaps its neighbour and a `7` is never
squashed.

In this fallback the engine owns `view.scale`. A win animation that tweens
`symbol.view.scale` overwrites the projection while it runs, so animate a
child of `view` instead. The warp has no such conflict.

For your own single-texture symbol, `PerspectiveCell` is exported and does
the mesh work. Art that does not fill its cell reports its real rect through
`ReelSymbol.cellInset`, which the sprite symbols derive from the texture's
trim.

## Demos

`.curve(amount)` bends each reel onto a drum, so the outer cells lean away like the ones on a physical machine. Every demo here uses `.curveMode('warp')`, which bends whatever a reel contains. The Concept section below compares it with the default `'symbol'` mode.

## A curved board

A slot reel is a drum. The middle cell faces you and the outer ones have turned away, so a camera draws them as trapezoids rather than smaller rectangles. The grid on the tiles shows it: the lines converge on the outer rows and stay parallel on the middle one.

`.curve(amount)` takes `0` for flat, the default, and `1` for a hard barrel. Most boards use `0.3` to `0.5`.

Live demo (curved-reels): https://pixi-reels.schmooky.dev/mechanics/reel-curvature/#one-number

```ts
builder.curve(0.45);                          // depth defaults to amount * 0.5
builder.curve({ amount: 0.45, depth: 0.35 }); // stronger perspective
```

`depth` is how much smaller an edge cell is than the middle one. At `0` the projection is orthographic: cells bunch up but nothing recedes. It is capped slightly under `cos(arc)`, past which cells would fold back over each other.

The middle cell is drawn at its authored size, so the drum cannot also fill a window sized for flat cells. The ends fall short, and the buffer cells show in that band. Cover it with a frame, as a cabinet bezel does. `reel.curve.mapMain(0)` is where the drum's top edge lands, so the frame can be measured.

## Art that bends

### Atlas sprites

Playson's Supercharged Diamonds 3, the sheet the sprite Hold &amp; Win recipes use. The frames are trimmed atlas frames, which `'symbol'` mode cannot keystone. Under `'warp'` they bend like everything else, and the blur during the spin still works.

Live demo (curved-reels-gems): https://pixi-reels.schmooky.dev/mechanics/reel-curvature/#on-real-art

### Spine skeletons

Spine skeletons, which `'symbol'` mode cannot bend at all. Under `'warp'` they curve and keep animating, and the spin and the stop bounce follow the drum.

Live demo (curved-reels-warp): https://pixi-reels.schmooky.dev/mechanics/reel-curvature/#curved-reels-warp

Symbols that hang over their cell need two settings. `SymbolData.zIndex` stacks them within the reel, and `.curveBleed(px)` keeps the warp texture from cutting the overhang off at its edge. With `curveBleed` under `curveFocus('reel')`, also set `SharedRectMaskStrategy` yourself, or the per-reel mask clips the overhang.

```ts
builder.symbolData({ mystery: { zIndex: 2 } }).curveBleed(46);
```

### Text

A value reel for prize pickers and jackpot ladders. The symbols are drawn at run time and the symbol id is the amount, so `setResult([['100.00', ...]])` lands the value you name. Each cell is a `PIXI.Text`, which has no texture of its own, so only the warp bends the digits.

Live demo (curved-value-reel): https://pixi-reels.schmooky.dev/mechanics/reel-curvature/#numbers-not-art

## The camera

### One camera for the board

By default each reel has its own camera and is its own drum. `curveFocus('set')` puts one camera in front of the middle of the board, so the outer reels tilt toward the centre and the centre reel barely moves. `'set-lean'` is halfway between and usually looks best on a 5-wide board.

```ts
builder.curve(0.5).curveFocus('reel');     // default: five separate drums
builder.curve(0.5).curveFocus('set-lean'); // halfway
builder.curve(0.5).curveFocus('set');      // one camera, one wide cylinder
```

Leaning cells cross into the next reel's column, so any focus other than `'reel'` selects `SharedRectMaskStrategy`. Pass `.maskStrategy(...)` to override it.

Live demo (curved-reels-focus): https://pixi-reels.schmooky.dev/mechanics/reel-curvature/#where-the-camera-stands

### A curve per reel

`.curvePerReel([...])` gives each reel its own curve. Bending the middle reels hardest and the outer ones least makes the board read as one wide drum. The array needs one entry per reel, matching `reels()`.

Live demo (curved-reels-per-reel): https://pixi-reels.schmooky.dev/mechanics/reel-curvature/#one-drum-not-five

## Board shapes

### A pay band in a taller drum

Five rows are drawn and the middle three pay. The outer rows are there to be curved, and they are what makes the board read as a cylinder. On a bare 3-row board the drum has to bend hard enough to distort the symbols people read. Here the bend goes into rows that do not pay, so this board can use a deeper `curve(0.62)`.

The dimming over the outer rows is drawn from `getCellQuad()`, the four corners the cell is drawn on. `getCellBounds()` returns the quad's bounding box, which is looser than the cell on a curved reel. Outline with the quad and hit-test with the box.

Live demo (curved-reels-payband): https://pixi-reels.schmooky.dev/mechanics/reel-curvature/#a-pay-band-inside-a-taller-drum

### Cascades

The warp applies the bend to the rendered reel, so explosions, survivors sliding down and new symbols dropping in all follow the curve. The cascade code does not know the reel is curved.

A tumble board needs the frame over both ends. At the top the band would show the buffer cell, which holds the refill queue and does not move when survivors fall. At the bottom a pure tumble sets `bufferSymbols({ end: 0 })`, so there is nothing to show.

Live demo (curved-reels-cascade): https://pixi-reels.schmooky.dev/mechanics/reel-curvature/#cascades-on-a-drum
