Explanation
Architecture
The crates that make up CineCode and how data flows from manifest to MP4.
CineCode is a Rust workspace of seven focused crates. Each owns one stage of the journey from a text project to a finished video.
The crates
| Crate | Responsibility |
|---|---|
cinecode-core | The Scene Document / IR β the data model every other crate reads or writes. |
cinecode-timeline | Animation tracks: evaluating keyframes and easing per frame. |
cinecode-highlight | Syntax highlighting via syntect (~212 languages). |
cinecode-sim | Deterministic simulations: terrain, pathfind, particles, graph, life, boids. |
cinecode-render | Rendering: a CPU backend (cosmic-text + swash) and a GPU backend (wgpu, WGSL, bloom). |
cinecode-script | Loading projects: parsing codescene.toml (TOML) and .ccs scripts (Rhai). |
cinecode-cli | The cinecode command (clap) and the ffmpeg encode pipeline. |
How data flows
- Load.
cinecode-scriptreads the manifest and runs each.ccsscript (Rhai), withcinecode-highlightcolorizing any code. The result is a Scene Document: a JSON-serializable intermediate representation. - Evaluate. For each frame,
cinecode-timelineevaluates every animation track and the camera to produce anAnimatedStateand aCameraState. Simulations fromcinecode-simcontribute their state for that frame. - Draw.
cinecode-renderprojects the camera and rasterizes the state into an RGBA frame β on the CPU, or on the GPU when--gpuis set. - Encode.
cinecode-clistreams raw frames into ffmpeg, which encodes H.264 and muxes audio into the final MP4.
Why this shape
- The Scene Document is the contract. Anything that can produce one can be rendered; anything that can read one can analyze or transform a film.
- Separating evaluate from draw is what makes rendering deterministic and seekable β see The rendering pipeline.
- Keeping simulations in their own crate lets them be pure functions of
(parameters, frame), so they slot onto the timeline like any other node.