2026-07-20 15:53:30 +02:00
# Examples
Self-contained compositions demonstrating the JSX API (see [reference/jsx ](../reference/jsx/README.md )).
2026-08-25 14:32:48 +02:00
Each one is a whole project entry file: it default-exports a component rendering a
`<stage>` with one `<scene>` in it. To run one, copy it into a project folder as the
2026-09-09 14:01:06 +02:00
entry and [`open` ](../reference/tools/open.md ) that folder — from a shell:
2026-08-25 14:32:48 +02:00
```sh
cp examples/01-basics.tsx ~/Projects/basics/index.tsx
2026-09-23 14:49:01 +02:00
diffusion open ~/Projects/basics
2026-08-25 14:32:48 +02:00
```
2026-07-20 15:53:30 +02:00
2026-08-14 14:52:20 +02:00
| Example | Shows |
| --- | --- |
2026-08-25 14:32:48 +02:00
| [01-basics.tsx ](01-basics.tsx ) | `<stage>` / `<scene>` , `<sequence>` with a dissolve, `<video>` , `<audio>` , `<image>` , `<text>` titles from data via `<For>` , `<animation>` children |
2026-08-14 14:52:20 +02:00
| [02-genai.tsx ](02-genai.tsx ) | multi-stage generation: `generate.image` refs feeding `generate.video` , TTS voiceover, generated ambience, `<captions>` |
| [03-ticker.tsx ](03-ticker.tsx ) | declarative animation: `useTicker` + `createMemo` derived values driving props |
2026-08-25 14:32:48 +02:00
| [04-html-in-canvas.tsx ](04-html-in-canvas.tsx ) | `<htmlPaint>` : an AI prompt box as real DOM, typed out from the playhead |
2026-08-14 14:52:20 +02:00
| [05-anime-timeline.tsx ](05-anime-timeline.tsx ) | anime.js timeline seeked from `useTicker` , driving an ECS node and `<html>` content in lockstep |
| [06-three.tsx ](06-three.tsx ) | three.js WebGL renderer owning a `<surface>` , glTF model loaded over the network |
| [07-webgpu.tsx ](07-webgpu.tsx ) | raw WebGPU on a `<surface>` : a triangle whose colors cycle with composition time |
| [08-shader-paint.tsx ](08-shader-paint.tsx ) | `<shaderPaint>` post-processing a `<video>` : WGSL chromatic aberration + vignette, uniforms patchable live |
2026-09-01 13:36:27 +02:00
| [09-inspect-variables.tsx ](09-inspect-variables.tsx ) | `@inspect` variables: annotated top-level consts becoming sidebar controls, values written back into the source |
| [10-typegpu.tsx ](10-typegpu.tsx ) | TypeGPU on a `<surface>` : shaders written in TypeScript (`'use gpu'` ), compiled through the project's own [babel config ](../reference/jsx/module.md#compile-time-plugins-babel-config ) |
2026-09-01 14:54:44 +02:00
| [11-redraw.tsx ](11-redraw.tsx ) | [Redraw ](https://redraw.dev ) on a `<surface>` : the docs' Hello World write-on stroke, a vendored-tarball package driven by composition time; the surface spans one animation cycle, `@inspect` variables tune it, and `useResolution` keeps it sharp at any export size |
2026-07-20 15:53:30 +02:00
Requirements: `02-genai.tsx` consumes generation credits (results are cached per session);
2026-07-20 20:56:32 +02:00
`01-basics.tsx` , `06-three.tsx` , and `08-shader-paint.tsx` fetch remote media.
2026-09-01 14:18:07 +02:00
`10-typegpu.tsx` and `11-redraw.tsx` need packages installed in the project folder
and a babel config next to the entry — the commands are in their header comments.
`11-redraw.tsx` additionally needs the `redraw` tarball vendored into the project
([Redraw is in technical preview ](https://redraw.dev/docs/installation )).
2026-07-20 15:53:30 +02:00
2026-08-25 14:32:48 +02:00
Typecheck with `tsc -p examples --noEmit` (part of `npm run check` ). `06-three.tsx`
2026-09-01 14:18:07 +02:00
needs `three` installed to typecheck, `10-typegpu.tsx` needs `typegpu` and
`@typegpu/noise` , and `11-redraw.tsx` needs `redraw` and `typegpu` ; none of these
are dependencies of this repo.