# The page

> The page contract as a lookup table. Every meta, attribute, global and CSS property that the renderer and the checks read.

Canonical: https://vawe.dev/docs/the-page

A film is one <Term id="page">page</Term>, `films/<name>/page.html`, with its own assets folder. This page lists what the <Term id="page-contract">page contract</Term> contains. The list comes from `AGENTS.md`, `harness/media/render-page.mjs`, `core/engine/page-seek.js` and `harness/media/page-audio.mjs`.

All paths in the page are relative. A page that breaks a row below can still render, but the checks then measure the wrong thing.

## Meta tags

The renderer reads `<meta name="..." content="...">` before the page runs.

| meta        | what it does                                                                                                   | default                                           | example                                                          |
| ----------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- | ---------------------------------------------------------------- |
| `duration`  | The film length in seconds, or `auto` (see below).                                                             | The end of the last animation.                    | `<meta name="duration" content="12.4">`                          |
| `aspect`    | The <Term id="aspect">aspect</Term> of the film. `--aspect` on a render verb replaces it.                      | `16:9`                                            | `<meta name="aspect" content="9:16">`                            |
| `fps`       | The rate of your frame tables. The render rate is separate.                                                    | None. `window.vawe.fps` is `undefined`.           | `<meta name="fps" content="30">`                                 |
| `message`   | The one thing a viewer must remember. The board, `frame --world` and the fresh judge read it.                  | None.                                             | `<meta name="message" content="zero fees">`                      |
| `spectacle` | The second of the one big moment. Put quiet before it.                                                         | None.                                             | `<meta name="spectacle" content="6.2">`                          |
| `signature` | Six dials, written as `dial=value` pairs split by `;`: `band`, `ease`, `stagger`, `seam`, `palette`, `thread`. | None.                                             | `<meta name="signature" content="band=professional; ease=land">` |
| `loudness`  | A delivery loudness in LUFS. The mix then normalises to it. See [Audio](https://vawe.dev/docs/audio).                          | The mix is not normalised.                        | `<meta name="loudness" content="-14">`                           |
| `blank`     | Seconds where an empty frame is intended, as `from-to` ranges split by commas.                                 | None. A flat blank frame in the film is an error. | `<meta name="blank" content="0-0.4, 4.8-5">`                     |

The attribute `data-blank` on `<html>` takes the same ranges as `blank`.

### The length

`duration` has three forms. A number gives the length in seconds. The value `auto` gives the end of the last animation plus a hold. The hold is 1.2 s or the read time of the last <Term id="world">world</Term>, rounded up to 1/30 s. Without the meta, the length is the end of the last animation, with no hold.

An `auto` page must have all its animations at load. A page that moves only through `window.seek` has no end to find, so it must state a number. Run `bin/vawe dev <page> --lock-length` to write the found number into the meta.

## Attributes on elements

| attribute                 | on                        | what it does                                                                                       | read more                              |
| ------------------------- | ------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------- |
| `data-world="<id>"`       | one element for each beat | Marks a world. The id is lowercase and matches the Shots ids of the brief.                         | [Worlds](https://vawe.dev/docs/worlds)                 |
| `data-chrome`             | an element                | Marks the label of a product that you show as texture. It keeps a 2.5% cap floor and no read hold. | [Text and fonts](https://vawe.dev/docs/text-and-fonts) |
| `data-ui`                 | an element                | Marks a mock screen that is the subject of the film. Its text has a 3% cap floor.                  | [Text and fonts](https://vawe.dev/docs/text-and-fonts) |
| `data-texture="<reason>"` | an element                | Says why the text is texture. The reason needs 12 characters or more.                              | [Text and fonts](https://vawe.dev/docs/text-and-fonts) |
| `aria-hidden="true"`      | an element                | Marks texture. The text checks skip the text when it is texture by measure.                        | [Text and fonts](https://vawe.dev/docs/text-and-fonts) |
| `data-aspect`             | `<html>`                  | The renderer sets it. Do not write it.                                                             | [Aspect ratios](https://vawe.dev/docs/aspect-ratios)   |

The `<audio>` attributes are in [Audio](https://vawe.dev/docs/audio).

## Globals

The renderer sets these before your scripts run.

| name                                      | type                  | what it is                                                                                                          |
| ----------------------------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `window.seek(t)`                          | function you define   | Paints the frame for `t` seconds. See [Time and seek](https://vawe.dev/docs/time-and-seek).                                         |
| `window.vawe.aspect`                      | string                | The aspect of this render, such as `16:9`.                                                                          |
| `window.vawe.width`, `window.vawe.height` | number                | The size of the layout viewport in pixels. A draft has the same values as a final.                                  |
| `window.vawe.fps`                         | number or `undefined` | The value of the `fps` meta.                                                                                        |
| `window.vawe.duration`                    | number or `undefined` | The `duration` meta. For `auto` it is the found length in the render, and 0 while the renderer measures the length. |
| `window.vawe.onFrame(fn)`                 | function              | Registers a hook that runs after every seek with `t`.                                                               |
| `window.vawe.animationEnd()`              | function              | Returns the end in seconds of the last finite animation, and whether an animation is infinite.                      |

## CSS custom properties

| property        | on      | value                                                                                                     |
| --------------- | ------- | --------------------------------------------------------------------------------------------------------- |
| `--vw`          | `:root` | The viewport width in pixels, with the unit (`1920px`).                                                   |
| `--vh`          | `:root` | The viewport height in pixels, with the unit (`1080px`).                                                  |
| `--ease-<name>` | `:root` | A named ease from `core/motion/presets.js`, such as `--ease-land`. Names with capitals become kebab case. |

Write `calc(var(--vh) * 0.11)`. Never write `* 0.11px`, because `--vh` already has the unit.

## Script blocks

| block                                             | what it holds                                          |
| ------------------------------------------------- | ------------------------------------------------------ |
| `<script type="module">`                          | Your page code.                                        |
| `<script type="application/json" id="authoring">` | The waivers of the page. See [Waivers](https://vawe.dev/docs/waivers). |

## Rules that no tag shows

> Time is the seek, never the clock. Every frame must come from `t` alone. See [Determinism](https://vawe.dev/docs/determinism).

* Every tunable number is a <Term id="literal">literal</Term> in the page: a `[[f, v]]` table, a keyframe stop or a `:root` custom property. `bin/vawe dev <page> --studio` edits these in place.
* A page can read options from the URL: `--param look=riso` loads `page.html?look=riso`, and the page reads it with `new URLSearchParams(location.search)`.
* Sound is `<audio>` tags: small effects on actions. A music track only comes from a file that you give.

## A complete page

```html
<!doctype html>
<meta charset="utf-8">
<meta name="duration" content="4">
<meta name="message" content="one page in">
<style>
  body { margin: 0; background: #16151a; color: #fff; font: 700 calc(var(--vh) * 0.1) system-ui; }
  h1 { position: absolute; left: 8%; top: 38%; margin: 0; }
  #bar { position: absolute; left: 8%; top: 62%; width: 40%; height: calc(var(--vh) * 0.012);
         background: #0a87ff; transform-origin: left; transform: scaleX(0); }
</style>
<div data-world="s1">
  <h1 id="word">One page in</h1>
  <div id="bar"></div>
</div>
<script type="module">
  import { EASE } from '../../core/motion/presets.js';
  document.getElementById('word').animate(
    [{ transform: 'translateY(0.5em)', opacity: 0 }, { transform: 'none', opacity: 1 }],
    { duration: 500, delay: 300, easing: EASE.land, fill: 'both' });

  window.seek = (t) => {
    const p = Math.min(1, Math.max(0, (t - 0.6) / 1.2));
    document.getElementById('bar').style.transform = `scaleX(${1 - (1 - p) ** 3})`;
  };
</script>
```

The heading moves on a Web Animation. The bar moves in `window.seek(t)`. Both are pure functions of time, so frame 400 never needs frame 399.

Worked pages: `films/examples/colour-sting/page.html` (a 5 s sting) and `films/examples/three-star/page.html` (three.js).

  <Card title="Worlds" href="/docs/worlds">
    One element for each beat.
  </Card>

  <Card title="Time and seek" href="/docs/time-and-seek">
    How the renderer sets the time.
  </Card>

  <Card title="Waivers" href="/docs/waivers">
    Break a rule with a reason.
  </Card>

  <Card title="Glossary" href="/docs/glossary">
    The words the docs use.
  </Card>

{/* sources (vawe d8481cc61, current main):
  meta list: grep of metaOf/readPageMeta/meta[name=] over harness, core: duration aspect fps message spectacle signature loudness; blank: harness/media/render-page.mjs:662,709-710
  duration forms, auto, hold 1.2 s, 1/30 s grid, errors, --lock-length: AGENTS.md "Hard rules"; harness/media/page-duration.mjs (autoLength, lengthOfOpenPage, lockPageLength); read-hold.mjs HOLD_RULE.floor = taste/build/limits.json readable-hold hold_floor_s 1.2
  no meta: page-duration.mjs lengthOfOpenPage (stated === null returns endS)
  globals: core/engine/page-seek.js installPageFrame (aspect, width, height, onFrame, fps, animationEnd, duration)
  --vw --vh --ease-<name> data-aspect: installPageFrame apply(); EASE_VARS core/motion/presets.js:55
  --param: AGENTS.md "Hard rules"; harness/lib/page-params.mjs
  signature dials: core/motion/signature.js DIALS
  data-chrome 2.5%, data-ui 3%, data-texture 12 chars: taste/build/limits.json readable-text-size; taste/rules/readable-text-size.md
  --vw has unit, calc: skills/vawe-page/SKILL.md "Page-code mistakes" 10
  complete page: example kept from the old page, imports core/motion/presets.js EASE
  */}
