# Headless pictures on the web

The web half of [`sona_headless_*`](headless.md): gamerpics, cards and frames from a manifest with
no canvas on the page, at exactly the size asked, transparent by default. The scene draws into a canvas that is
never put on the page, on WebGPU or WebGL2 as `SonaRenderer.create` would choose. The WASM core's own
`sona_headless_*` still answers `SONA_E_UNSUPPORTED` (it has no device of its own in a page, and none in node); in a
page, use this call.

```js
const h = await SonaRenderer.headless({ appId: 'your-app' });
const pic = await h.render(manifest, { width: 64, height: 64, preset: 'face', credit: false });  // { width, height, rgba }
const png = await h.picture(manifest, { width: 300, height: 420, clear: [0.1, 0.1, 0.15, 1] });  // a PNG Blob
await h.batch(manifests, { width: 96, height: 96, preset: 'bust' }, (i, r) => save(i, r));
await h.sequence(manifest, { width: 256, height: 256 }, { frames: 36, sweep: 360 }, (i, f) => frames.push(f));
h.close();
```

The options are `sona_render_options`, by the same names:

| Option | Default | Meaning |
|---|---|---|
| `width`, `height` | 256 | 1 to 8192, exactly; past the device's largest texture is `SonaError('limit')` |
| `preset` | `'full'` | `full`, `upper`, `bust`, `face` |
| `yaw`, `pitch`, `zoom` | 0, 0, 1 | the camera round the preset's target, and its distance divided by `zoom` |
| `turn` | 0 | the avatar turned about its feet under the camera |
| `clip`, `time` | still | a clip key held at `time` seconds |
| `clear` | transparent | premultiplied RGBA 0 to 1 |
| `credit` | true | "Powered by 360sona" in the bottom-right corner; off, the licence still asks for the line somewhere |
| `type`, `quality` | PNG | `picture()` only |
| `waitSeconds` | 120 | `SonaError('not_ready')` after it |

`render` gives RGBA8, not premultiplied. `batch` answers once per manifest in order, `{ error }` for one that fails,
and goes on; `inFlight` avatars (default 4) build ahead while one is drawn, and each is removed once drawn.
`sequence` draws frame i at `time + i / fps` and `turn + sweep * i / frames`; with `frames` 0 it is the clip's
length at `fps`, or 36 for a sweep. The same inputs give the same pixels. Calls run one at a time, in order.

Each picture waits for its face: the clip's expression at that moment is baked before the picture is read.
