# Hockey puck

A cylinder on ice: Coulomb friction is a constant deceleration, so the slide is exact and the puck stops where the maths says. The boards reflect it, and the silhouette is the hull of its two rims.

> For the complete index, see [llms.txt](https://robocn.dev/llms.txt). A Markdown version of any page is available by appending `.md` to its URL or by sending an `Accept: text/markdown` header.

## Install

```bash
bunx --bun shadcn@latest add https://robocn.dev/r/robot-hockey-puck.json
```

Registry item: `robot-hockey-puck` · [`https://robocn.dev/r/robot-hockey-puck.json`](https://robocn.dev/r/robot-hockey-puck.json)

## Notes

- Solved: the silhouette, which is the convex hull of the two rims projected — exact face-on, exact edge-on and exact everywhere between, with nothing special-cased. Tip the camera and the disc becomes the slab because it is the same two rims.
- Solved: the slide. Coulomb friction decelerates by `μg` whatever the speed, so the distance left is exactly `v²/2μg`, and a board that takes `e` of the speed therefore takes `e²` of the distance left. Every leg and every reflection is closed form; the clock only says where along the track the puck is.
- Illustrated: the spin, which bleeds off in proportion to the speed rather than being solved from a moment; and the boards, which are a specular reflection, so a puck never leaves one at an angle it did not arrive at.

## Usage

```tsx
import { RobotHockeyPuck } from "@/components/ui/robot-hockey-puck"

// Move the aim and the whole track re-solves, boards and all.
<RobotHockeyPuck behavior="slap" heading={24} />

// Or walk the puck along its own track, which stops the loop.
<RobotHockeyPuck along={0.46} onAlongChange={setAlong} interactive />
```

## Props

| name | type | default | description |
| --- | --- | --- | --- |
| `along` | `number` | — | Where along the solved track the puck is, 0 to 1. Supplying it stops the loop. |
| `onAlongChange` | `(along: number) => void` | — | Fires while it is dragged or keyed, so interaction works in controlled mode too. |
| `behavior` | `"slap" | "wrist" | "dump" | "spin" | "static"` | `"slap"` | Which shot it takes with nobody driving it: how hard, off how many boards, and how much ice it has. |
| `heading` | `number` | — | Degrees off straight up the ice, −80 to 80. The whole track re-solves around it — every reflection, and the point it runs out of ice. |
| `interactive` | `boolean` | `false` | Hand it to a person: drag across to walk the puck along its track, or focus it and use the arrow keys. |
| `showTrack` | `boolean` | `true` | Draw the solved track and the point friction stops it at. |
| `showRink` | `boolean` | `true` | Draw the ice, the boards, the centre line and the goal mouth. |
| `label` | `string` | — | Optional technical caption under the drawing. |
| `view` | `"plan" | "front" | "profile" | "iso"` | `"plan"` | Where the camera stands. One machine, four projections: straight down, straight on, side elevation, or three-quarter from above. |
| `speed` | `number` | `0.32` | Shots per second. |
| `animate` | `boolean` | `true` | Off parks the machine at phase and stops rendering. A reduced-motion preference does the same. |
| `paused` | `boolean` | `false` | Freeze where it stands. |
| `phase` | `number` | `0` | Seconds of offset, so a row of machines breaks step. |
| `variant` | `"solid" | "outline" | "blueprint" | "wire"` | `"solid"` | How the machine is painted. Geometry never changes between variants. |
| `size` | `"xs" | "sm" | "md" | "lg" | "xl" | number` | `"md"` | Rendered width in pixels, or a step on the scale. |
| `color` | `string` | `var(--robot-shell)` | Body panels — the colour the machine reads as. |
| `accent` | `string` | `var(--robot-accent)` | Status colour: tip light, live tool, readouts. |
| `metal` | `string` | `var(--robot-metal)` | Bare machined parts: collars, bolts, tool bodies. |
| `dark` | `string` | `var(--robot-dark)` | Cast joints, base, shadow side. |
| `palette` | `Partial<RobotPalette>` | — | Override any subset of roles at once, including glow and grid. |

## Source

- `src/components/ui/robot-hockey-puck.tsx`
