CineCode
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

CrateResponsibility
cinecode-coreThe Scene Document / IR β€” the data model every other crate reads or writes.
cinecode-timelineAnimation tracks: evaluating keyframes and easing per frame.
cinecode-highlightSyntax highlighting via syntect (~212 languages).
cinecode-simDeterministic simulations: terrain, pathfind, particles, graph, life, boids.
cinecode-renderRendering: a CPU backend (cosmic-text + swash) and a GPU backend (wgpu, WGSL, bloom).
cinecode-scriptLoading projects: parsing codescene.toml (TOML) and .ccs scripts (Rhai).
cinecode-cliThe cinecode command (clap) and the ffmpeg encode pipeline.

How data flows

  1. Load. cinecode-script reads the manifest and runs each .ccs script (Rhai), with cinecode-highlight colorizing any code. The result is a Scene Document: a JSON-serializable intermediate representation.
  2. Evaluate. For each frame, cinecode-timeline evaluates every animation track and the camera to produce an AnimatedState and a CameraState. Simulations from cinecode-sim contribute their state for that frame.
  3. Draw. cinecode-render projects the camera and rasterizes the state into an RGBA frame β€” on the CPU, or on the GPU when --gpu is set.
  4. Encode. cinecode-cli streams 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.

On this page