Source root fields#
Top-level fields on the project object. Everything that isn't on an element lives here.
interface Source { clipkit_version?: string; output_format?: "tok-str">'mp4' | "tok-str">'gif'; width?: number; height?: number; duration?: number | "tok-str">'auto'; frame_rate?: number; background_color?: string; fonts?: FontFace[]; "tok-cmt">// Scene (3D / lighting) — all optional; omit for flat, unlit 2D motion_blur?: { samples?: number; shutter?: number }; camera?: Camera; lights?: Light[]; environment?: Environment; bloom?: { threshold?: number; knee?: number; intensity?: number; radius?: number }; elements: Element[]; }
Fields#
| Field | Type | Default | Description |
|---|---|---|---|
clipkit_version | string | "1.0" | The Clipkit Protocol version this Source conforms to. SHOULD be present on documents produced by tooling. Runtimes attempt to render any 1.x document and warn about 2.x+. |
output_format | 'mp4' | 'gif' | 'mp4' | What the renderer should produce. Clipkit is video-only: mp4 (H.264 + AAC) is the default; gif is animated (audio dropped). |
width | number | 1920 | Output canvas width in pixels. |
height | number | 1080 | Output canvas height in pixels. |
duration | number | 'auto' | 'auto' | Output duration in seconds. 'auto' uses the last element's time + duration. |
frame_rate | number | 30 | Output frame rate (fps). The renderer encodes every frame; higher = smoother + bigger. |
background_color | string (hex) | '#000000' | Solid background color applied behind all elements. Use a full-canvas shape element if you need a gradient. |
fonts | FontFace[] | — | Font faces the runtime registers before rendering, so the Source doesn't depend on host-installed fonts. See Fonts below. |
styles | Record<string, Style> | — | Named appearance bundles (font/fill/stroke/gradient/radius/opacity) that image/text/shape elements reference via style: "name" — declare once, reference by name, like fonts. Merge: defaults < style < the element's own fields; no cascade. PROTOCOL §2.3. |
motion_blur | object | — | Sub-frame motion blur. See Scene (3D / lighting) below. |
camera | Camera | — | Scene camera (perspective + pose). Omit for flat 2D. See below. |
lights | Light[] | — | Scene lights for PBR materials. Omit for unlit. See below. |
environment | Environment | — | Environment map for material reflections. See below. |
bloom | object | — | Post-process bloom (glow on bright areas). See below. |
elements | Element[] | required | The scene contents (at least one). See common element fields for what's on every element. |
Scene (3D / lighting)#
These root fields turn on Clipkit's 2.5D camera, PBR lighting, and post-process passes. Every one is optional — omit them all and the scene renders flat and unlit. For the math and the full pose/lighting model, see PROTOCOL.md §4.4 (camera) and §4.8 (lights & material).
motion_blur#
Renders each frame as a blend of sub-frame samples taken across the shutter window.
| Field | Type | Default | Description |
|---|---|---|---|
samples | number (int, 1–32) | 8 | Sub-frame samples blended per output frame. More = smoother blur, slower render. |
shutter | number (0–1) | 0.5 | Shutter open time as a fraction of the frame interval. 0.5 = 180° shutter. |
camera#
Adds a perspective projection and a movable pose. With no camera the scene is pure flat 2D and z only re-sorts elements. perspective is the only required field. Pose components (x/y/z, rotations) accept keyframes or expressions.
| Field | Type | Default | Description |
|---|---|---|---|
perspective | number (>0) | required | Focal distance in px. Smaller = stronger perspective foreshortening. |
origin_x | number | string | canvas center | Vanishing-point x (px or string). |
origin_y | number | string | canvas center | Vanishing-point y (px or string). |
x | number | 0 | Camera dolly x in px. |
y | number | 0 | Camera dolly y in px. |
z | number | 0 | Camera dolly toward the scene in px; +z = closer. |
x_rotation | number | 0 | Camera pitch in degrees. |
y_rotation | number | 0 | Camera yaw in degrees. |
z_rotation | number | 0 | Camera roll in degrees. |
sort | 'depth' | 'paint' | 'depth' | Compositing order: 'depth' (2.5D by z) or 'paint' (fixed layer order, layer 1 on top). |
lights#
An array of lights for PBR material elements. Each entry is one of two types (discriminated on type):
ambient — flat fill from every direction.
| Field | Type | Default | Description |
|---|---|---|---|
type | 'ambient' | required | — |
color | string (hex) | '#FFFFFF' | Ambient light color. |
intensity | number | 1 | Ambient brightness multiplier. |
directional — a sun-like light with a direction.
| Field | Type | Default | Description |
|---|---|---|---|
type | 'directional' | required | — |
azimuth | number (deg) | 0 | Compass direction of the light. |
elevation | number (deg) | 45 | Height of the light above the screen plane. |
color | string (hex) | '#FFFFFF' | Directional light color. |
intensity | number | 1 | Directional brightness multiplier. |
environment#
An environment map sampled for material reflections — one of two types:
| Field | Type | Description |
|---|---|---|
type: 'gradient', stops | GradientStop[] (2–6) | Sky gradient stops, sampled by the reflection ray's vertical component. |
type: 'image', src | string | Equirectangular environment image URL. |
bloom#
A post-process pass that adds a glow to bright pixels.
| Field | Type | Default | Description |
|---|---|---|---|
threshold | number (0–1) | 0.75 | Luma above which pixels bloom. |
knee | number | 0.1 | Soft-knee width around the threshold. |
intensity | number | 1 | Bloom strength multiplier. |
radius | number (px) | 24 | Bloom blur sigma. |
Fonts#
Each entry registers one face, exactly like a CSS @font-face rule:
interface FontFace { family: string; "tok-cmt">// name text elements reference weight?: number | string; "tok-cmt">// CSS font-weight; variable fonts may use a range ("100 900") style?: "tok-str">'normal' | "tok-str">'italic'; src: string; "tok-cmt">// absolute / relative URL or data: URI unicode_range?: string; "tok-cmt">// CSS unicode-range, e.g. "U+0000-00FF" }
Multiple entries may share a family — different weights, styles, or
unicode_range subsets. Subsetted webfonts (one file per script under
identical descriptors) need their unicode_range carried through, or
every subset competes for every codepoint and text can fall back to the
wrong file's glyphs. The snapshot importer captures all of this
automatically.
Examples#
Minimal 16:9, 6 seconds, 30 fps#
{ "clipkit_version": "1.0", "width": 1920, "height": 1080, "duration": 6, "frame_rate": 30, "elements": [ /* ... */ ] }
Vertical 9:16 for Stories / TikTok#
{ "clipkit_version": "1.0", "width": 1080, "height": 1920, "duration": 8, "frame_rate": 30, "elements": [ /* ... */ ] }
Notes#
- Aspect ratio is implicit — the Source has no
aspect_ratiofield; setwidthandheightdirectly. (aspect_ratiodoes exist as an element field, where it derives a missing box dimension from the other one — see common element fields.) duration: 'auto'is the recommended default while you're iterating; pin a number once the timing is final so adding a hidden element doesn't extend the output.background_coloris rendered before any element. Elements withopacity < 1show this color through.