CineCode
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 .ccs file should call scene(...) 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, and s(2) is a short alias. Conversion uses the project's [output].fps.
  • Markers name timeline moments. Use mark("focus", sec(3)), reuse it with at("focus"), and offset it with after("focus", ms(600)).
  • Line numbers passed to focus/highlight methods are 1-based.
  • Colors are r, g, b (and sometimes a) numbers in 0..1.

Global functions

FunctionReturnsDescription
scene(name, frames)sceneDeclare the scene and its duration.
read(path)stringRead a file (relative to the project) as text.
ms(n) / millis(n) / milliseconds(n)numberConvert milliseconds to frames.
sec(n) / secs(n) / seconds(n) / s(n)numberConvert seconds to frames.
mark(name, time)numberStore a named timeline moment and return its frame.
at(name)numberRead a named timeline marker.
after(name, offset)numberReturn a marker plus an offset.
after(time, offset)numberReturn one time value plus another.
seq(start)numberSet the relative-sequencing cursor and return it.
cue(dur)numberReturn the cursor, then advance it by dur.
gap(dur)numberAdvance the cursor without scheduling an action.
cursor()numberRead the current sequencing cursor.
center_x(width) / center_y(height)numberReturn a centered top-left coordinate.
ease(equation, mode)easingBuild 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

  • Texts.text(...)
  • Codes.code(...) (syntax-highlighted; see Scene API)
  • Shapes & imagess.rect, s.circle, s.path, s.image, … (guide)
  • Simulationss.terrain, s.pathfind, s.particles, s.graph, s.life, s.boids (reference)
  • Cameras.camera() (reference)
  • Groups & layouts.group, s.row, s.column, s.grid, s.stack (reference)

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]:

ConstantDescription
WIDTH, HEIGHTOutput dimensions in pixels.
FPSOutput frames per second.
CENTER_X, CENTER_YFrame midpoint.
SAFE_X, SAFE_YTop-left of the 90% action-safe area.
SAFE_W, SAFE_HSafe-area dimensions.
SAFE_MARGINSafe 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_IN

See Easing for how they combine.

Where to go next

On this page