Reference
The .ccs language
The Rhai-based scene scripting language — globals, builders, and conventions.
A .ccs file is a Rhai script that builds one scene. CineCode
exposes a set of global functions and a fluent, chainable builder API.
Conventions
- One file, one scene. A
.ccsfile should callscene(...)once. - Coordinates are pixels from the top-left, in the output's resolution, before the camera transform.
- Time accepts raw frames or helpers.
ms(500)is half a second,sec(2)is two seconds, ands(2)is a short alias. Conversion uses the project's[output].fps. - Markers name timeline moments. Use
mark("focus", sec(3)), reuse it withat("focus"), and offset it withafter("focus", ms(600)). - Line numbers passed to focus/highlight methods are 1-based.
- Colors are
r, g, b(and sometimesa) numbers in0..1.
Global functions
| Function | Returns | Description |
|---|---|---|
scene(name, frames) | scene | Declare the scene and its duration. |
read(path) | string | Read a file (relative to the project) as text. |
ms(n) / millis(n) / milliseconds(n) | number | Convert milliseconds to frames. |
sec(n) / secs(n) / seconds(n) / s(n) | number | Convert seconds to frames. |
mark(name, time) | number | Store a named timeline moment and return its frame. |
at(name) | number | Read a named timeline marker. |
after(name, offset) | number | Return a marker plus an offset. |
after(time, offset) | number | Return one time value plus another. |
seq(start) | number | Set the relative-sequencing cursor and return it. |
cue(dur) | number | Return the cursor, then advance it by dur. |
gap(dur) | number | Advance the cursor without scheduling an action. |
cursor() | number | Read the current sequencing cursor. |
center_x(width) / center_y(height) | number | Return a centered top-left coordinate. |
ease(equation, mode) | easing | Build a reusable easing curve. |
let s = scene("Introduction", sec(6));
mark("code_in", sec(1));
let source = read("src/main.rs");
let snappy = ease(BACK, EASE_OUT);The builder pattern
Everything on a scene is created through s.* and configured by chaining:
let s = scene("Demo", sec(4));
mark("enter", ms(300));
mark("focus", after("enter", sec(1.5)));
s.text("Title", 96, 64) // create a node…
.font_size(48) // …style it…
.glow(0.5)
.fade_in(at("enter"), ms(533)) // …and animate it
.slide_up(at("enter"), ms(533)).ease(CUBIC, EASE_OUT);Each builder call returns the node (or scene) so chains read top-to-bottom.
What you can create
- Text —
s.text(...) - Code —
s.code(...)(syntax-highlighted; see Scene API) - Shapes & images —
s.rect,s.circle,s.path,s.image, … (guide) - Simulations —
s.terrain,s.pathfind,s.particles,s.graph,s.life,s.boids(reference) - Camera —
s.camera()(reference) - Groups & layout —
s.group,s.row,s.column,s.grid,s.stack(reference)
Focus, links, and transitions
Some helpers act on nodes via the scene:
s.underline(code, 3, 100, 20);
s.surround(code, 1, 4, 100, 24);
s.point_at(code, 5, 760, 320, 120, 18);
s.link(code, 5, sim, 120, 60);
s.transition("crossfade", 18);Constants
Frame and safe-area constants come from [output]:
| Constant | Description |
|---|---|
WIDTH, HEIGHT | Output dimensions in pixels. |
FPS | Output frames per second. |
CENTER_X, CENTER_Y | Frame midpoint. |
SAFE_X, SAFE_Y | Top-left of the 90% action-safe area. |
SAFE_W, SAFE_H | Safe-area dimensions. |
SAFE_MARGIN | Safe inset as a fraction (0.05). |
Easing equations and modes are available as bare identifiers:
LINEAR SINE QUAD CUBIC QUART QUINT EXPO CIRC BACK ELASTIC BOUNCE
EASE_IN EASE_OUT EASE_IN_OUT EASE_OUT_INSee Easing for how they combine.