# Roll: Looks and effects

> A flat strip, a drum, a cube, a rolling circle, a tipping square or a swap in place, in any direction, faded, scaled or blurred as it goes.

Source: https://cesarvenzac.com/roll/docs/looks

A symbol slides on a flat strip unless you say otherwise. `look` changes how it turns, `direction` where it goes and `effects` what's laid over it:

```tsx
<Roll value={price} look="drum" />
<Roll value={time} look="circle" direction="right" />
<Roll value={label} look="swap" effects={["scale", "blur"]} />
```

## Looks

- `slide`: a flat strip, symbols a line apart. The default.
- `drum`: symbols round a drum, 30° apart, seen in perspective and shaded as they turn away, as a slot machine's.
- `cube`: each symbol a face of a box, a quarter turn a step.
- `circle`: each symbol rolls along without slipping, on a wheel half a line across.
- `square`: each symbol tips over its leading corner, a quarter turn a step.
- `swap`: in place, the old symbol giving way to the next: a crossfade, unless effects say more.

A face of a drum or a cube shows only while it faces you: a symbol a whole turn round, as a letter turning through the alphabet passes, never shows over the one there.

## Directions

`direction` is where a symbol goes as the value turns forward: `up` (the default: it leaves upward and the next comes up from below), `down`, `left` or `right`. Counting down runs a turn the other way. A circle rolling right turns clockwise, rolling left the other way.

Going across, what leaves stays inside its own cell, fading at its sides, never passing over the characters beside it.

## Effects

`effects` lays any of these over any look, together or alone:

- `fade`: out as it leaves and in as it comes, as far as it has gone.
- `scale`: down to 60% as it leaves and back as it comes, never to nothing, which reads as a glitch.
- `blur`: to 0.08em as it leaves, sharp as it lands.
- `motion`: blurred by how fast it goes rather than how far, up to 0.12em: a long spin smears, then lands sharp. With `count`, it's an odometer's blur.

```tsx
<Roll value={visitors} count effects={["motion"]} />
<Roll value={status} look="swap" effects={["scale", "blur"]} />
```

## How they're drawn

Each look is geometry the browser works out every frame from one sprung value, through CSS's `sin()`, `cos()` and `round()`: as smooth as the spring, with no script running frame by frame. A flat look moves in the page as the text beside it does, so it lands on the text's own pixels; `drum` and `cube` are drawn in 3D, on layers of their own, and land within half a device pixel of it.

Looks and effects need a registered CSS property and CSS's trigonometry and rounding: Chrome 125, Safari 16.4, Firefox 128. Elsewhere every look slides up, without effects. Under reduced motion none of them moves: [In the page](https://cesarvenzac.com/roll/docs/page) says what happens instead.

## Roll's docs

- [Overview](https://cesarvenzac.com/roll.md): Text that rolls as it changes: digits turn like an odometer's and keep their places, letters and icons roll over.
- [Getting started](https://cesarvenzac.com/roll/docs/getting-started.md): Install Roll and give it a value to show: in React, in any page, as an element, in Svelte or in Vue.
- [How it rolls](https://cesarvenzac.com/roll/docs/rolling.md): Digits that keep their places and turn the way the number went, everything else rolling over, on springs that carry on.
- [Looks and effects](https://cesarvenzac.com/roll/docs/looks.md): A flat strip, a drum, a cube, a rolling circle, a tipping square or a swap in place, in any direction, faded, scaled or blurred as it goes.
- [Counting and knowing when it's done](https://cesarvenzac.com/roll/docs/numbers.md): Count a number through the values between, tint it as it rises or falls, move several rollers as one, and know when they've landed.
- [In the page](https://cesarvenzac.com/roll/docs/page.md): What assistive tech hears, what reduced motion gets, how to style it, how it's drawn on a server, and what it costs.
- [API reference](https://cesarvenzac.com/roll/docs/api.md): Every function, component and type the package exports, entry by entry: the core, React, the element, Svelte and Vue.
