Skip to main content

alpha2_compose/
spec.rs

1//! The compose spec: a video described by intent, which [`crate::compile`] turns into a
2//! project document.
3//!
4//! Times are seconds, rounded to the nearest tick (1/120 000 s). Lengths are canvas pixels.
5//! Colors are CSS hex strings or the project's `{red, green, blue, alpha}` object. Nodes are
6//! tagged by `type`, and a node with an `id` can be named by another (a music bed ducks under
7//! it).
8
9use std::collections::BTreeMap;
10
11use alpha2_model::{
12    Animated, Composition, Easing, EffectValue, Extrapolation, LayoutNode, MediaSource, Rgba,
13    TextShadow, TextStroke, Track,
14};
15use serde::{Deserialize, Serialize};
16
17/// The newest compose spec version this build reads.
18pub const COMPOSE_VERSION: u32 = 1;
19
20/// A whole video: a body, what is drawn over it, and what plays under it.
21#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
22#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
23#[serde(deny_unknown_fields)]
24pub struct VideoSpec {
25    /// The schema the spec follows (`https://alpha2.sh/schema/compose.v1.json`), for editors and
26    /// validators. The compiler does not read it.
27    #[serde(rename = "$schema", default, skip_serializing_if = "Option::is_none")]
28    pub schema: Option<String>,
29    /// Spec version. This build reads only [`COMPOSE_VERSION`].
30    #[serde(default = "compose_version")]
31    #[cfg_attr(feature = "schema", schemars(extend("const" = COMPOSE_VERSION)))]
32    pub compose_version: u32,
33    /// The project's name. Default `video`.
34    #[serde(default, skip_serializing_if = "Option::is_none")]
35    pub name: Option<String>,
36    /// Size, rate and background. Default `youtube-1080p`.
37    #[serde(default)]
38    pub canvas: Canvas,
39    /// Fonts, colors, sizes and default timings. Default `clean-dark`.
40    #[serde(default)]
41    pub theme: ThemeChoice,
42    /// The main picture, from time zero. Its length is the video's unless `duration` says
43    /// otherwise.
44    pub body: Node,
45    /// Nodes drawn over the body in order, placed by their own `at` (default 0) and lasting to
46    /// the end unless they say otherwise.
47    #[serde(default, skip_serializing_if = "Vec::is_empty")]
48    pub overlays: Vec<Node>,
49    /// Sound beside the body's: `audio` and `music_bed` nodes, placed as overlays are.
50    #[serde(default, skip_serializing_if = "Vec::is_empty")]
51    pub audio: Vec<Node>,
52    /// The video's length in seconds. Default: the body's.
53    #[serde(default, skip_serializing_if = "Option::is_none")]
54    pub duration: Option<f64>,
55    /// The loudness an export normalizes the mix to. Returned as an export option, not stored
56    /// in the project.
57    #[serde(default, skip_serializing_if = "Option::is_none")]
58    pub loudness: Option<Loudness>,
59    /// The part of each frame over which nodes marked `motion_blur` are averaged: the project's
60    /// `settings.shutter`. Default: 180 degrees centred on the frame time, 16 samples.
61    #[serde(default, skip_serializing_if = "Option::is_none")]
62    pub shutter: Option<alpha2_model::Shutter>,
63}
64
65const fn compose_version() -> u32 {
66    COMPOSE_VERSION
67}
68
69/// The canvas: a preset name, or its parts.
70#[derive(Clone, Debug, PartialEq, Serialize)]
71#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
72#[serde(untagged)]
73pub enum Canvas {
74    /// A preset at 30 fps: `youtube-1080p` (1920x1080), `youtube-4k` (3840x2160), `youtube-720p`
75    /// (1280x720), `shorts` (1080x1920), `square` (1080x1080) or `portrait` (1080x1350).
76    Preset(String),
77    /// A preset with some parts replaced, or every part given.
78    Custom(CustomCanvas),
79}
80
81impl Default for Canvas {
82    fn default() -> Self {
83        Self::Preset("youtube-1080p".to_owned())
84    }
85}
86
87/// A canvas by its parts.
88#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
89#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
90#[serde(deny_unknown_fields)]
91pub struct CustomCanvas {
92    /// The preset the other parts replace parts of. Default `youtube-1080p`.
93    #[serde(default, skip_serializing_if = "Option::is_none")]
94    pub preset: Option<String>,
95    /// Width in pixels.
96    #[serde(default, skip_serializing_if = "Option::is_none")]
97    pub width: Option<u32>,
98    /// Height in pixels.
99    #[serde(default, skip_serializing_if = "Option::is_none")]
100    pub height: Option<u32>,
101    /// Frames per second: an integer, 23.976, 29.97 or 59.94, or the project's exact
102    /// `{num, den}`.
103    #[serde(default, skip_serializing_if = "Option::is_none")]
104    pub frame_rate: Option<FrameRateChoice>,
105    /// The opaque color under everything. Default: the theme's.
106    #[serde(default, skip_serializing_if = "Option::is_none")]
107    pub background: Option<Rgba>,
108}
109
110/// A frame rate, as a number or exactly.
111#[derive(Clone, Copy, Debug, PartialEq, Serialize)]
112#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
113#[serde(untagged)]
114pub enum FrameRateChoice {
115    /// Frames per second: an integer, or 23.976, 29.97 or 59.94 for the NTSC rates.
116    Number(f64),
117    /// The project's exact rate.
118    Exact(alpha2_time::FrameRate),
119}
120
121/// A theme by name, or one built on a named theme.
122#[derive(Clone, Debug, PartialEq, Serialize)]
123#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
124#[serde(untagged)]
125pub enum ThemeChoice {
126    /// A built-in theme: `clean-dark` or `clean-light`.
127    Named(String),
128    /// A theme of its own.
129    Custom(Box<Theme>),
130}
131
132impl Default for ThemeChoice {
133    fn default() -> Self {
134        Self::Named("clean-dark".to_owned())
135    }
136}
137
138/// How text, panels and timings look. Parts left out come from the base theme. Sizes are
139/// fractions of the canvas's shorter side, so a theme looks the same on wide and tall canvases.
140#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
141#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
142#[serde(deny_unknown_fields)]
143pub struct Theme {
144    /// The built-in theme this one changes. Default `clean-dark`.
145    #[serde(default, skip_serializing_if = "Option::is_none")]
146    pub base: Option<String>,
147    /// Font family, as the font names it. Unset, text draws in the first font an export
148    /// registers.
149    #[serde(default, skip_serializing_if = "Option::is_none")]
150    pub font_family: Option<String>,
151    /// Text color.
152    #[serde(default, skip_serializing_if = "Option::is_none")]
153    pub text: Option<Rgba>,
154    /// The canvas background.
155    #[serde(default, skip_serializing_if = "Option::is_none")]
156    pub background: Option<Rgba>,
157    /// What title and end cards are drawn on.
158    #[serde(default, skip_serializing_if = "Option::is_none")]
159    pub surface: Option<Rgba>,
160    /// The boxes behind labels, lower thirds and boxed captions.
161    #[serde(default, skip_serializing_if = "Option::is_none")]
162    pub panel: Option<Rgba>,
163    /// A highlight: a lower third's bar.
164    #[serde(default, skip_serializing_if = "Option::is_none")]
165    pub accent: Option<Rgba>,
166    /// Title size.
167    #[serde(default, skip_serializing_if = "Option::is_none")]
168    pub title_size: Option<f32>,
169    /// Subtitle size.
170    #[serde(default, skip_serializing_if = "Option::is_none")]
171    pub subtitle_size: Option<f32>,
172    /// Body text size.
173    #[serde(default, skip_serializing_if = "Option::is_none")]
174    pub body_size: Option<f32>,
175    /// Caption size.
176    #[serde(default, skip_serializing_if = "Option::is_none")]
177    pub caption_size: Option<f32>,
178    /// Label size: a grid cell's.
179    #[serde(default, skip_serializing_if = "Option::is_none")]
180    pub label_size: Option<f32>,
181    /// The space kept clear at the canvas's edges.
182    #[serde(default, skip_serializing_if = "Option::is_none")]
183    pub margin: Option<f32>,
184    /// The transition a slideshow, or a sequence asking for `theme`, puts between children.
185    #[serde(default, skip_serializing_if = "Option::is_none")]
186    pub transition: Option<Transition>,
187    /// How long a still shows when nothing says, in seconds.
188    #[serde(default, skip_serializing_if = "Option::is_none")]
189    pub still_seconds: Option<f64>,
190    /// How long a card or text shows when nothing says, in seconds.
191    #[serde(default, skip_serializing_if = "Option::is_none")]
192    pub text_seconds: Option<f64>,
193    /// How long text and cards fade in and out, in seconds.
194    #[serde(default, skip_serializing_if = "Option::is_none")]
195    pub fade_seconds: Option<f64>,
196}
197
198/// The loudness an export normalizes to: a target, or a target and a ceiling.
199#[derive(Clone, Copy, Debug, PartialEq, Serialize)]
200#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
201#[serde(untagged)]
202pub enum Loudness {
203    /// Integrated loudness in LUFS, under a -1 dBTP ceiling.
204    Lufs(f64),
205    /// Integrated loudness and a true-peak ceiling.
206    Target(crate::LoudnessTarget),
207}
208
209/// The transition between two neighbours of a sequence.
210#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
211#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
212#[serde(deny_unknown_fields)]
213pub struct Transition {
214    /// `crossfade`, a built-in transition's short name (`wipe-left`, `circle-open`, ...), or a
215    /// full effect id (`alpha2.transition.fade`).
216    #[serde(rename = "type")]
217    pub kind: String,
218    /// How long the neighbours overlap, in seconds.
219    pub duration: f64,
220    /// The timing curve. Default linear.
221    #[serde(default, skip_serializing_if = "Option::is_none")]
222    pub easing: Option<Easing>,
223    /// The effect's parameters by name.
224    #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
225    pub params: BTreeMap<String, Animated<EffectValue>>,
226    /// The effect definition's version. Default 1.
227    #[serde(default, skip_serializing_if = "Option::is_none")]
228    pub version: Option<u32>,
229}
230
231/// A sequence's transitions: none, the theme's, or one given.
232#[derive(Clone, Debug, PartialEq, Serialize)]
233#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
234#[serde(untagged)]
235pub enum TransitionChoice {
236    /// `none` for cuts, `theme` for the theme's transition, or a transition name at the theme's
237    /// duration.
238    Named(String),
239    /// A transition.
240    Given(Transition),
241}
242
243/// Space kept clear inside an area.
244#[derive(Clone, Copy, Debug, PartialEq, Serialize)]
245#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
246#[serde(untagged)]
247pub enum Inset {
248    /// The same on every side.
249    Uniform(f32),
250    /// `[top, right, bottom, left]`.
251    Sides([f32; 4]),
252}
253
254/// How a picture fills its area.
255#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
256#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
257#[serde(rename_all = "snake_case")]
258pub enum Fit {
259    /// All of it, as large as fits; the rest of the area stays empty.
260    #[default]
261    Contain,
262    /// All of the area, cropped to it.
263    Cover,
264    /// Stretched to the area.
265    Fill,
266    /// At its own size in pixels, cropped to the area.
267    None,
268}
269
270/// A point of an area: its center, an edge's middle or a corner.
271#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
272#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
273#[serde(rename_all = "kebab-case")]
274pub enum Align {
275    /// The center.
276    #[default]
277    Center,
278    /// The top edge's middle.
279    Top,
280    /// The bottom edge's middle.
281    Bottom,
282    /// The left edge's middle.
283    Left,
284    /// The right edge's middle.
285    Right,
286    /// The top-left corner.
287    TopLeft,
288    /// The top-right corner.
289    TopRight,
290    /// The bottom-left corner.
291    BottomLeft,
292    /// The bottom-right corner.
293    BottomRight,
294}
295
296/// What a media file holds, when its extension does not say.
297#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
298#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
299#[serde(rename_all = "snake_case")]
300pub enum FileKind {
301    /// Moving pictures, perhaps with sound.
302    Video,
303    /// A still picture.
304    Image,
305    /// Sound alone.
306    Audio,
307}
308
309/// What a video shorter than its node does once it ends.
310#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
311#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
312#[serde(rename_all = "snake_case")]
313pub enum WhenShort {
314    /// Holds its last frame.
315    Freeze,
316    /// Plays again from its start.
317    Loop,
318    /// Slows to fill the node.
319    Stretch,
320    /// Shows nothing.
321    Blank,
322    /// The spec does not compile.
323    Error,
324}
325
326/// What a video longer than its node does.
327#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
328#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
329#[serde(rename_all = "snake_case")]
330pub enum WhenLong {
331    /// Ends with the node.
332    Trim,
333    /// Speeds up to fit the node.
334    Stretch,
335    /// The spec does not compile.
336    Error,
337}
338
339/// One part of a video.
340#[derive(Clone, Debug, PartialEq, Serialize)]
341#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
342#[serde(tag = "type", rename_all = "snake_case", deny_unknown_fields)]
343pub enum Node {
344    /// Children one after another, with transitions between them.
345    Sequence(Sequence),
346    /// Children over each other, each over the ones before.
347    Stack(Stack),
348    /// Children in the cells of a grid, row by row.
349    Grid(Grid),
350    /// A video or still file.
351    Media(Media),
352    /// Text.
353    Text(Text),
354    /// An area painted one color.
355    Color(ColorFill),
356    /// An area drawn by a generator: noise, a pattern, or a generator the host registers.
357    Generator(GeneratorNode),
358    /// Timed text from cues, a SubRip or WebVTT file, or word timestamps.
359    Captions(Captions),
360    /// A layout generator: boxes, text and shapes laid out by CSS flexbox and grid.
361    Layout(Layout),
362    /// A sound file.
363    Audio(Audio),
364    /// Part of a project (sources, tracks, compositions) at its own times. Overlays only.
365    Raw(Raw),
366    /// Stills or clips in turn, with transitions and slow zooms.
367    Slideshow(Slideshow),
368    /// A video under its captions.
369    CaptionedVideo(CaptionedVideo),
370    /// Music under the video, faded in and out and ducked under speech.
371    MusicBed(MusicBed),
372    /// A number counting from one value to another, as text.
373    Counter(Counter),
374    /// Children drawn together into one picture, which then takes an opacity, a blend mode,
375    /// effects and a transform as one layer.
376    Group(Group),
377    /// No picture of its own: its effects apply to everything under it.
378    Adjustment(Adjustment),
379    /// Shapes drawn with one fill and one stroke: bars, frames, dividers, badges, icons.
380    Shape(Shape),
381    /// A node shown only where another node's picture is.
382    Matte(Matte),
383    /// A node shown only inside outlines.
384    Mask(Mask),
385    /// Boxes laid out by CSS flexbox or grid around text, shapes and any other node.
386    Box(BoxNode),
387}
388
389/// Children drawn together as one layer. Unlike a stack, whose children each meet what is under
390/// them, a group composites its children first: its opacity, blend mode, effects and transform
391/// apply to that one picture.
392///
393/// A group's children share its time as one picture does: a video or animated picture in it
394/// starts with the group and plays at its own speed, and it holds no sequences, captions or
395/// sound nodes. A child's sound still plays, outside the picture.
396#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
397#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
398#[serde(deny_unknown_fields)]
399pub struct Group {
400    /// The node's name, for other nodes to refer to.
401    #[serde(default, skip_serializing_if = "Option::is_none")]
402    pub id: Option<String>,
403    /// The children, each over the ones before, placed in the group's area.
404    pub children: Vec<Node>,
405    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
406    #[serde(default, skip_serializing_if = "Option::is_none")]
407    pub at: Option<f64>,
408    /// Length in seconds. Default: the longest child's.
409    #[serde(default, skip_serializing_if = "Option::is_none")]
410    pub duration: Option<f64>,
411    /// Pixels kept clear inside the parent's area: the group's area.
412    #[serde(default, skip_serializing_if = "Option::is_none")]
413    pub inset: Option<Inset>,
414    /// Opacity of the whole, 0..=1. Default 1.
415    #[serde(default, skip_serializing_if = "Option::is_none")]
416    pub opacity: Option<Anim<f32>>,
417    /// How the whole meets what is under it. Default `normal`.
418    #[serde(default, skip_serializing_if = "Option::is_none")]
419    pub blend: Option<alpha2_model::ClipBlendMode>,
420    /// Effects on the whole, in order, before its transform.
421    #[serde(default, skip_serializing_if = "Vec::is_empty")]
422    pub effects: Vec<EffectUse>,
423    /// Moves, scales or turns the whole.
424    #[serde(default, skip_serializing_if = "Option::is_none")]
425    pub transform: Option<GroupTransform>,
426    /// How it comes in at its start.
427    #[serde(default, skip_serializing_if = "Option::is_none")]
428    pub enter: Option<Motion>,
429    /// How it goes out, ending at its end.
430    #[serde(default, skip_serializing_if = "Option::is_none")]
431    pub exit: Option<Motion>,
432}
433
434/// An adjustment layer: its effects apply to the picture of everything under it, mixed back in by
435/// its opacity and met with it by its blend mode. In a sequence or an overlay that is everything
436/// composited before it; in a group, the group's children before it, and the children after it
437/// are drawn over the result. Wrapped in a `mask`, it applies inside the outlines only; it takes
438/// no `matte`.
439#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
440#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
441#[serde(deny_unknown_fields)]
442pub struct Adjustment {
443    /// The node's name, for other nodes to refer to.
444    #[serde(default, skip_serializing_if = "Option::is_none")]
445    pub id: Option<String>,
446    /// Effects on the picture under it, in order. None changes nothing.
447    #[serde(default, skip_serializing_if = "Vec::is_empty")]
448    pub effects: Vec<EffectUse>,
449    /// How much of the result replaces the picture under it, 0..=1. Default 1.
450    #[serde(default, skip_serializing_if = "Option::is_none")]
451    pub opacity: Option<Anim<f32>>,
452    /// How the result meets the picture under it. Default `normal`.
453    #[serde(default, skip_serializing_if = "Option::is_none")]
454    pub blend: Option<alpha2_model::ClipBlendMode>,
455    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
456    #[serde(default, skip_serializing_if = "Option::is_none")]
457    pub at: Option<f64>,
458    /// Length in seconds. Default: what its parent gives it.
459    #[serde(default, skip_serializing_if = "Option::is_none")]
460    pub duration: Option<f64>,
461}
462
463/// One effect: a built-in by its short name (`gaussian-blur`) or any effect by its full id, with
464/// its parameters by name. A parameter is a constant, a ramp or keys; a named image input is a
465/// node.
466#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
467#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
468pub struct EffectUse {
469    /// The effect: a built-in's short name or a full id with its dots.
470    pub effect: String,
471    /// The version a full id names. Default: the built-in's, else 1.
472    #[serde(default, skip_serializing_if = "Option::is_none")]
473    pub version: Option<u32>,
474    /// Parameters and named inputs, as `schema/effects.v1.json` lists them.
475    #[serde(flatten)]
476    pub params: BTreeMap<String, serde_json::Value>,
477}
478
479/// A group's movement, about `anchor`.
480#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
481#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
482#[serde(deny_unknown_fields)]
483pub struct GroupTransform {
484    /// Offset in pixels, `[x, y]`. Default `[0, 0]`.
485    #[serde(default, skip_serializing_if = "Option::is_none")]
486    pub position: Option<Anim<[f32; 2]>>,
487    /// Size multiple. Default 1.
488    #[serde(default, skip_serializing_if = "Option::is_none")]
489    pub scale: Option<Anim<f32>>,
490    /// Clockwise turn in degrees. Default 0.
491    #[serde(default, skip_serializing_if = "Option::is_none")]
492    pub rotation: Option<Anim<f32>>,
493    /// The point it scales and turns about, `[0, 0]` the area's top left to `[1, 1]` its bottom
494    /// right. Default `[0.5, 0.5]`.
495    #[serde(default, skip_serializing_if = "Option::is_none")]
496    pub anchor: Option<[f32; 2]>,
497    /// Draws the movement with motion blur, averaged over the video's `shutter`.
498    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
499    pub motion_blur: bool,
500}
501
502/// Children one after another.
503#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
504#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
505#[serde(deny_unknown_fields)]
506pub struct Sequence {
507    /// The node's name, for other nodes to refer to.
508    #[serde(default, skip_serializing_if = "Option::is_none")]
509    pub id: Option<String>,
510    /// The children, in play order.
511    pub children: Vec<Node>,
512    /// What joins neighbours: a transition overlaps them by its duration, and their sound
513    /// crosses over it. Default `none`. Only single pictures (media, text, color, layout) can
514    /// transition into each other; anything else, or a part shorter than the transition,
515    /// joins by crossfade.
516    #[serde(default, skip_serializing_if = "Option::is_none")]
517    pub transition: Option<TransitionChoice>,
518    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
519    #[serde(default, skip_serializing_if = "Option::is_none")]
520    pub at: Option<f64>,
521    /// Length in seconds. Default: the node's own length, else what its parent gives it.
522    #[serde(default, skip_serializing_if = "Option::is_none")]
523    pub duration: Option<f64>,
524    /// How it comes in at its start.
525    #[serde(default, skip_serializing_if = "Option::is_none")]
526    pub enter: Option<Motion>,
527    /// How it goes out, ending at its end.
528    #[serde(default, skip_serializing_if = "Option::is_none")]
529    pub exit: Option<Motion>,
530}
531
532/// Children over each other.
533#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
534#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
535#[serde(deny_unknown_fields)]
536pub struct Stack {
537    /// The node's name, for other nodes to refer to.
538    #[serde(default, skip_serializing_if = "Option::is_none")]
539    pub id: Option<String>,
540    /// The children, each drawn over the ones before and starting at its own `at`.
541    pub children: Vec<Node>,
542    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
543    #[serde(default, skip_serializing_if = "Option::is_none")]
544    pub at: Option<f64>,
545    /// Length in seconds. Default: the node's own length, else what its parent gives it.
546    #[serde(default, skip_serializing_if = "Option::is_none")]
547    pub duration: Option<f64>,
548    /// Pixels kept clear inside the parent's area: one number, or `[top, right, bottom, left]`.
549    #[serde(default, skip_serializing_if = "Option::is_none")]
550    pub inset: Option<Inset>,
551    /// How it comes in at its start.
552    #[serde(default, skip_serializing_if = "Option::is_none")]
553    pub enter: Option<Motion>,
554    /// How it goes out, ending at its end.
555    #[serde(default, skip_serializing_if = "Option::is_none")]
556    pub exit: Option<Motion>,
557    /// Seconds between the children's entrances. With it, the node's `enter` and `exit` move
558    /// each child rather than the whole, and child `i`'s entrance (its own `enter` too) starts
559    /// `i * stagger` after the child does.
560    #[serde(default, skip_serializing_if = "Option::is_none")]
561    pub stagger: Option<f64>,
562}
563
564/// Children in grid cells.
565#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
566#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
567#[serde(deny_unknown_fields)]
568pub struct Grid {
569    /// The node's name, for other nodes to refer to.
570    #[serde(default, skip_serializing_if = "Option::is_none")]
571    pub id: Option<String>,
572    /// The cells' contents, row by row.
573    pub children: Vec<Node>,
574    /// Columns. Default: as square a grid as the children make.
575    #[serde(default, skip_serializing_if = "Option::is_none")]
576    pub columns: Option<u32>,
577    /// Pixels between cells.
578    #[serde(default)]
579    pub gap: f32,
580    /// How long the grid lasts when its cells differ, and what a cell that ends early shows.
581    /// Default `shortest`.
582    #[serde(default)]
583    pub length: GridLength,
584    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
585    #[serde(default, skip_serializing_if = "Option::is_none")]
586    pub at: Option<f64>,
587    /// Length in seconds. Default: the node's own length, else what its parent gives it.
588    #[serde(default, skip_serializing_if = "Option::is_none")]
589    pub duration: Option<f64>,
590    /// Pixels kept clear inside the parent's area: one number, or `[top, right, bottom, left]`.
591    #[serde(default, skip_serializing_if = "Option::is_none")]
592    pub inset: Option<Inset>,
593    /// How it comes in at its start.
594    #[serde(default, skip_serializing_if = "Option::is_none")]
595    pub enter: Option<Motion>,
596    /// How it goes out, ending at its end.
597    #[serde(default, skip_serializing_if = "Option::is_none")]
598    pub exit: Option<Motion>,
599    /// Seconds between the children's entrances. With it, the node's `enter` and `exit` move
600    /// each child rather than the whole, and child `i`'s entrance (its own `enter` too) starts
601    /// `i * stagger` after the child does.
602    #[serde(default, skip_serializing_if = "Option::is_none")]
603    pub stagger: Option<f64>,
604}
605
606/// How long a grid of clips of different lengths lasts.
607#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
608#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
609#[serde(rename_all = "snake_case")]
610pub enum GridLength {
611    /// As long as its shortest cell.
612    #[default]
613    Shortest,
614    /// As long as its longest; shorter clips hold their last frame.
615    LongestFreeze,
616    /// As long as its longest; shorter clips play again from their start.
617    LongestLoop,
618}
619
620/// The speed of a video at one time of its node.
621#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
622#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
623#[serde(deny_unknown_fields)]
624pub struct SpeedPoint {
625    /// Seconds from the node's start. No point lies before the one it follows; two at one time
626    /// are a jump in speed.
627    pub at: f64,
628    /// Playback speed there: 2 plays twice as fast, 0 holds the frame. 0 or more.
629    pub speed: f64,
630}
631
632/// A video or still file.
633#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
634#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
635#[serde(deny_unknown_fields)]
636#[expect(
637    clippy::struct_excessive_bools,
638    reason = "each is a field of the spec's JSON"
639)]
640pub struct Media {
641    /// The node's name, for other nodes to refer to.
642    #[serde(default, skip_serializing_if = "Option::is_none")]
643    pub id: Option<String>,
644    /// The file. It becomes the source's locator and the export's asset.
645    pub path: String,
646    /// What the file holds. Default: by its extension.
647    #[serde(default, skip_serializing_if = "Option::is_none")]
648    pub kind: Option<FileKind>,
649    /// Where in the file a video starts, in seconds.
650    #[serde(default, skip_serializing_if = "Option::is_none")]
651    pub trim_start: Option<f64>,
652    /// Where in the file a video ends, in seconds. Default: its end.
653    #[serde(default, skip_serializing_if = "Option::is_none")]
654    pub trim_end: Option<f64>,
655    /// Playback speed of a video: 2 plays it twice as fast. Default 1. A video that loops takes
656    /// only speed 1.
657    #[serde(default, skip_serializing_if = "Option::is_none")]
658    pub speed: Option<f64>,
659    /// Speeds of a video over the node's time, for a speed that changes: linear between
660    /// points, the first point's before it and the last point's after it. A speed of 0 holds
661    /// the frame. The video's own length is the time its speeds take to play the trimmed range,
662    /// or the last point's time when they end at 0 before that. Not with a `speed` other than
663    /// 1, `reverse`, a loop, or `stretch` in `when_short` or `when_long`.
664    #[serde(default, skip_serializing_if = "Vec::is_empty")]
665    pub speed_points: Vec<SpeedPoint>,
666    /// Keeps a video's sound at its pitch when `speed` is not 1 (time-stretched instead of
667    /// resampled). Default true.
668    #[serde(default, skip_serializing_if = "Option::is_none")]
669    pub preserve_pitch: Option<bool>,
670    /// Shifts the pitch of a video's sound by this many cents (100 to a semitone), within
671    /// 2,400 either way, without changing its length. It suits speech and intervals of a few
672    /// semitones; music and wide intervals sound rougher. Default 0. A video that loops takes
673    /// none.
674    #[serde(default, skip_serializing_if = "Option::is_none")]
675    pub pitch_cents: Option<f32>,
676    /// Plays a video again from its start while the node lasts. Its `speed` must be 1.
677    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
678    pub r#loop: bool,
679    /// Plays a video's trimmed range backward, from `trim_end` to `trim_start`, at its `speed`
680    /// or stretched to fit; a node that outlasts it then holds the frame at `trim_start`. Not
681    /// with `speed_points` or a loop.
682    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
683    pub reverse: bool,
684    /// What a video shows at a time between two of its frames: `hold` keeps the earlier frame,
685    /// `mix` blends the two by how far the time is between them, which smooths slow motion and a
686    /// frame rate that differs from the output's. Default `hold`. A still takes neither.
687    #[serde(default, skip_serializing_if = "Option::is_none")]
688    pub frame_interpolation: Option<alpha2_model::FrameInterpolation>,
689    /// What a video does when the node outlasts it. Default: what its parent asks (a grid's
690    /// length rule), else `freeze`.
691    #[serde(default, skip_serializing_if = "Option::is_none")]
692    pub when_short: Option<WhenShort>,
693    /// What a video does when it outlasts the node. Default `trim`.
694    #[serde(default, skip_serializing_if = "Option::is_none")]
695    pub when_long: Option<WhenLong>,
696    /// Linear gain of a video's sound. Default 1.
697    #[serde(default, skip_serializing_if = "Option::is_none")]
698    pub volume: Option<f32>,
699    /// Silences a video's sound.
700    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
701    pub muted: bool,
702    /// Opacity, 0..=1. Default 1.
703    #[serde(default, skip_serializing_if = "Option::is_none")]
704    pub opacity: Option<f32>,
705    /// Seconds of fade in from transparent.
706    #[serde(default, skip_serializing_if = "Option::is_none")]
707    pub fade_in: Option<f64>,
708    /// Seconds of fade out to transparent.
709    #[serde(default, skip_serializing_if = "Option::is_none")]
710    pub fade_out: Option<f64>,
711    /// How large it shows, as a multiple of its fitted size: a constant, a ramp
712    /// (`{"from": 1, "to": 1.2}` is a slow zoom over the node), or keys. Default 1.
713    #[serde(default, skip_serializing_if = "Option::is_none")]
714    pub zoom: Option<Anim<f32>>,
715    /// A Gaussian blur's radius, as a fraction of the picture's shorter side.
716    #[serde(default, skip_serializing_if = "Option::is_none")]
717    pub blur: Option<f32>,
718    /// A label a comparison grid shows on the cell.
719    #[serde(default, skip_serializing_if = "Option::is_none")]
720    pub label: Option<String>,
721    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
722    #[serde(default, skip_serializing_if = "Option::is_none")]
723    pub at: Option<f64>,
724    /// Length in seconds. Default: the node's own length, else what its parent gives it.
725    #[serde(default, skip_serializing_if = "Option::is_none")]
726    pub duration: Option<f64>,
727    /// Pixels kept clear inside the parent's area: one number, or `[top, right, bottom, left]`.
728    #[serde(default, skip_serializing_if = "Option::is_none")]
729    pub inset: Option<Inset>,
730    /// How a picture fills its area. Default `contain`.
731    #[serde(default, skip_serializing_if = "Option::is_none")]
732    pub fit: Option<Fit>,
733    /// Where in its area the picture or text lies. Default `center`.
734    #[serde(default, skip_serializing_if = "Option::is_none")]
735    pub align: Option<Align>,
736    /// How it comes in at its start.
737    #[serde(default, skip_serializing_if = "Option::is_none")]
738    pub enter: Option<Motion>,
739    /// How it goes out, ending at its end.
740    #[serde(default, skip_serializing_if = "Option::is_none")]
741    pub exit: Option<Motion>,
742    /// Draws its movement (entrance, exit, zoom) with motion blur, averaged over the video's
743    /// `shutter`. What moves inside a video's own picture is not blurred.
744    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
745    pub motion_blur: bool,
746}
747
748impl Media {
749    /// A node of the file at `path`, everything else by default.
750    #[must_use]
751    pub fn new(path: impl Into<String>) -> Self {
752        Self {
753            id: None,
754            path: path.into(),
755            kind: None,
756            trim_start: None,
757            trim_end: None,
758            speed: None,
759            speed_points: Vec::new(),
760            preserve_pitch: None,
761            pitch_cents: None,
762            r#loop: false,
763            reverse: false,
764            frame_interpolation: None,
765            volume: None,
766            muted: false,
767            opacity: None,
768            fade_in: None,
769            fade_out: None,
770            zoom: None,
771            when_short: None,
772            when_long: None,
773            blur: None,
774            label: None,
775            at: None,
776            duration: None,
777            inset: None,
778            fit: None,
779            align: None,
780            enter: None,
781            exit: None,
782            motion_blur: false,
783        }
784    }
785}
786
787/// A file given by its path alone, or a media node.
788#[derive(Clone, Debug, PartialEq, Serialize)]
789#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
790#[serde(untagged)]
791pub enum MediaItem {
792    /// The file, everything else by default.
793    Path(String),
794    /// A `media` node.
795    Node(Box<Node>),
796}
797
798/// Text in one of the theme's styles.
799#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
800#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
801#[serde(deny_unknown_fields)]
802pub struct Text {
803    /// The node's name, for other nodes to refer to.
804    #[serde(default, skip_serializing_if = "Option::is_none")]
805    pub id: Option<String>,
806    /// The text; `\n` starts a line.
807    pub text: String,
808    /// The theme style it starts from. Default `body`.
809    #[serde(default)]
810    pub style: TextRole,
811    /// Font size in pixels, or a theme length. Default: the style's.
812    #[serde(default, skip_serializing_if = "Option::is_none")]
813    pub font_size: Option<Size>,
814    /// Family. Default: the theme's.
815    #[serde(default, skip_serializing_if = "Option::is_none")]
816    pub font_family: Option<String>,
817    /// Color. Default: the theme's text color.
818    #[serde(default, skip_serializing_if = "Option::is_none")]
819    pub color: Option<SolidColor>,
820    /// A box of this color behind each line.
821    #[serde(default, skip_serializing_if = "Option::is_none")]
822    pub background: Option<SolidColor>,
823    /// Bands around the glyphs, innermost first, widths as fractions of the font size (as a
824    /// text style's `strokes`).
825    #[serde(default, skip_serializing_if = "Vec::is_empty")]
826    pub strokes: Vec<TextStroke>,
827    /// Shadows of the glyphs, the first on top, lengths as fractions of the font size (as a
828    /// text style's `shadows`).
829    #[serde(default, skip_serializing_if = "Vec::is_empty")]
830    pub shadows: Vec<TextShadow>,
831    /// The most lines it may take. It first shrinks within `fit`; text still longer is cut after
832    /// its last line, ended by `ellipsis`. Default: no limit.
833    #[serde(default, skip_serializing_if = "Option::is_none")]
834    pub max_lines: Option<u32>,
835    /// The font sizes in pixels it is fitted between, the largest at which it fits its area and
836    /// `max_lines`. Default with `max_lines`: 0.3 times its font size up to its font size;
837    /// otherwise its font size alone.
838    #[serde(default, skip_serializing_if = "Option::is_none")]
839    pub fit: Option<TextFit>,
840    /// What ends a line `max_lines` cuts: `true` an ellipsis, `false` nothing, or this text.
841    /// Default `true`.
842    #[serde(default, skip_serializing_if = "Option::is_none")]
843    pub ellipsis: Option<Ellipsis>,
844    /// Opacity, 0..=1. Default 1.
845    #[serde(default, skip_serializing_if = "Option::is_none")]
846    pub opacity: Option<f32>,
847    /// Seconds of fade in and out. Default none.
848    #[serde(default, skip_serializing_if = "Option::is_none")]
849    pub fade: Option<f64>,
850    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
851    #[serde(default, skip_serializing_if = "Option::is_none")]
852    pub at: Option<f64>,
853    /// Length in seconds. Default: the node's own length, else what its parent gives it.
854    #[serde(default, skip_serializing_if = "Option::is_none")]
855    pub duration: Option<f64>,
856    /// Pixels kept clear inside the parent's area: one number, or `[top, right, bottom, left]`.
857    #[serde(default, skip_serializing_if = "Option::is_none")]
858    pub inset: Option<Inset>,
859    /// Where in its area the picture or text lies. Default `center`.
860    #[serde(default, skip_serializing_if = "Option::is_none")]
861    pub align: Option<Align>,
862    /// How it comes in at its start.
863    #[serde(default, skip_serializing_if = "Option::is_none")]
864    pub enter: Option<Motion>,
865    /// How it goes out, ending at its end.
866    #[serde(default, skip_serializing_if = "Option::is_none")]
867    pub exit: Option<Motion>,
868    /// Reveals the text a word or a line at a time.
869    #[serde(default, skip_serializing_if = "Option::is_none")]
870    pub reveal: Option<Reveal>,
871    /// Draws its movement (entrance, exit) with motion blur, averaged over the video's
872    /// `shutter`. A reveal is not blurred.
873    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
874    pub motion_blur: bool,
875}
876
877/// The font sizes a text is fitted between, in pixels.
878#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
879#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
880#[serde(deny_unknown_fields)]
881pub struct TextFit {
882    /// Smallest font size; when nothing larger fits, the text draws at this size.
883    pub min: f32,
884    /// Largest font size. Default: the text's font size, so it only shrinks.
885    #[serde(default, skip_serializing_if = "Option::is_none")]
886    pub max: Option<f32>,
887}
888
889/// What ends a cut line: an ellipsis or nothing (`true`, `false`), or a text.
890#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
891#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
892#[serde(untagged)]
893pub enum Ellipsis {
894    /// An ellipsis, or nothing.
895    Shown(bool),
896    /// This text, 1 to 64 bytes without line breaks or control characters.
897    Text(String),
898}
899
900/// A theme text style.
901#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
902#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
903#[serde(rename_all = "snake_case")]
904pub enum TextRole {
905    /// The largest.
906    Title,
907    /// Under a title.
908    Subtitle,
909    /// Running text.
910    #[default]
911    Body,
912    /// A cell's label.
913    Label,
914}
915
916/// Shapes in the node's area, filled and stroked as one compound path. Coordinates are fractions
917/// of the area, `[0, 0]` its top left to `[1, 1]` its bottom right; lengths are fractions of its
918/// shorter side.
919#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
920#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
921#[serde(deny_unknown_fields)]
922pub struct Shape {
923    /// The node's name, for other nodes to refer to.
924    #[serde(default, skip_serializing_if = "Option::is_none")]
925    pub id: Option<String>,
926    /// The outlines, at least one.
927    pub shapes: Vec<Geometry>,
928    /// What covers their inside. Default: nothing, unless there is no stroke, then the theme's
929    /// accent.
930    #[serde(default, skip_serializing_if = "Option::is_none")]
931    pub fill: Option<PaintChoice>,
932    /// A line along the outlines.
933    #[serde(default, skip_serializing_if = "Option::is_none")]
934    pub stroke: Option<Stroke>,
935    /// Keeps part of the outlines' length. A line that draws itself has
936    /// `{"end": {"from": 0, "to": 1}}`.
937    #[serde(default, skip_serializing_if = "Option::is_none")]
938    pub trim: Option<Trim>,
939    /// Opacity, 0..=1. Default 1.
940    #[serde(default, skip_serializing_if = "Option::is_none")]
941    pub opacity: Option<f32>,
942    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
943    #[serde(default, skip_serializing_if = "Option::is_none")]
944    pub at: Option<f64>,
945    /// Length in seconds. Default: what its parent gives it.
946    #[serde(default, skip_serializing_if = "Option::is_none")]
947    pub duration: Option<f64>,
948    /// Pixels kept clear inside the parent's area: the shapes' area.
949    #[serde(default, skip_serializing_if = "Option::is_none")]
950    pub inset: Option<Inset>,
951    /// How it comes in at its start.
952    #[serde(default, skip_serializing_if = "Option::is_none")]
953    pub enter: Option<Motion>,
954    /// How it goes out, ending at its end.
955    #[serde(default, skip_serializing_if = "Option::is_none")]
956    pub exit: Option<Motion>,
957}
958
959/// `content` shown where `by`'s picture is: by its alpha (text as a window onto video) or its
960/// luminance. `by` is never drawn itself. Both are placed in the node's area.
961#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
962#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
963#[serde(deny_unknown_fields)]
964pub struct Matte {
965    /// The node's name, for other nodes to refer to.
966    #[serde(default, skip_serializing_if = "Option::is_none")]
967    pub id: Option<String>,
968    /// What is shown.
969    pub content: Box<Node>,
970    /// Where it is shown. One picture: not a sequence.
971    pub by: Box<Node>,
972    /// What of `by` counts: `alpha` (default) or `luma`.
973    #[serde(rename = "use", default, skip_serializing_if = "Option::is_none")]
974    pub uses: Option<MatteUse>,
975    /// Shows `content` where `by` is not instead.
976    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
977    pub invert: bool,
978    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
979    #[serde(default, skip_serializing_if = "Option::is_none")]
980    pub at: Option<f64>,
981    /// Length in seconds. Default: the content's.
982    #[serde(default, skip_serializing_if = "Option::is_none")]
983    pub duration: Option<f64>,
984    /// Pixels kept clear inside the parent's area.
985    #[serde(default, skip_serializing_if = "Option::is_none")]
986    pub inset: Option<Inset>,
987}
988
989/// What of a matte's picture is coverage.
990#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
991#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
992#[serde(rename_all = "snake_case")]
993pub enum MatteUse {
994    /// Its opacity.
995    #[default]
996    Alpha,
997    /// Its brightness.
998    Luma,
999}
1000
1001/// `content` shown only inside outlines, combined in order. Outlines are in the node's area as a
1002/// shape's are, and stay put while the content moves.
1003#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1004#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1005#[serde(deny_unknown_fields)]
1006pub struct Mask {
1007    /// The node's name, for other nodes to refer to.
1008    #[serde(default, skip_serializing_if = "Option::is_none")]
1009    pub id: Option<String>,
1010    /// What is shown.
1011    pub content: Box<Node>,
1012    /// The outlines, at least one.
1013    pub shapes: Vec<MaskShape>,
1014    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
1015    #[serde(default, skip_serializing_if = "Option::is_none")]
1016    pub at: Option<f64>,
1017    /// Length in seconds. Default: the content's.
1018    #[serde(default, skip_serializing_if = "Option::is_none")]
1019    pub duration: Option<f64>,
1020    /// Pixels kept clear inside the parent's area.
1021    #[serde(default, skip_serializing_if = "Option::is_none")]
1022    pub inset: Option<Inset>,
1023}
1024
1025/// One mask outline and how it combines with those before it.
1026#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1027#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1028pub struct MaskShape {
1029    /// The outline.
1030    #[serde(flatten)]
1031    pub geometry: Geometry,
1032    /// `add` (default; the first adds to nothing), `subtract` or `intersect`.
1033    #[serde(default, skip_serializing_if = "Option::is_none")]
1034    pub mode: Option<alpha2_model::MaskMode>,
1035    /// Edge softness, as a fraction of the area's shorter side. Default 0.
1036    #[serde(default, skip_serializing_if = "Option::is_none")]
1037    pub feather: Option<Anim<f32>>,
1038    /// Keeps the outside of the outline instead.
1039    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
1040    pub invert: bool,
1041}
1042
1043/// A box laid out by CSS flexbox (the default) or grid, filling the node's area. Its fields are
1044/// the engine layout's container fields as CSS writes them (`flex_direction`, `gap`,
1045/// `"8px 16px"` paddings, `"repeat(3, 1fr)"` tracks); `background` and `border` take theme
1046/// colors.
1047///
1048/// Text, shapes, colors and boxes among its children are drawn by the layout itself. Any other
1049/// child (a video, a group, a sequence) gets a place in the layout and is drawn there, clipped to
1050/// its rounded corners; such a place keeps still.
1051#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1052#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1053pub struct BoxNode {
1054    /// The node's name, for other nodes to refer to.
1055    #[serde(default, skip_serializing_if = "Option::is_none")]
1056    pub id: Option<String>,
1057    /// The children, in paint order.
1058    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1059    pub children: Vec<BoxChild>,
1060    /// What covers the box, rounded by `border_radius`.
1061    #[serde(default, skip_serializing_if = "Option::is_none")]
1062    pub background: Option<PaintChoice>,
1063    /// A border inside the box.
1064    #[serde(default, skip_serializing_if = "Option::is_none")]
1065    pub border: Option<BoxBorder>,
1066    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
1067    #[serde(default, skip_serializing_if = "Option::is_none")]
1068    pub at: Option<f64>,
1069    /// Length in seconds. Default: the longest picture child's, else what its parent gives it.
1070    #[serde(default, skip_serializing_if = "Option::is_none")]
1071    pub duration: Option<f64>,
1072    /// Pixels kept clear inside the parent's area. A nested box places itself by its item fields.
1073    #[serde(default, skip_serializing_if = "Option::is_none")]
1074    pub inset: Option<Inset>,
1075    /// The other container fields of an engine layout box, by name. A length may be a theme
1076    /// length, `{"$theme": "margin", "scale": 2}`: `margin`, `title_size`, `subtitle_size`,
1077    /// `body_size`, `caption_size` or `label_size`, times `scale` (default 1).
1078    #[serde(flatten)]
1079    pub css: BTreeMap<String, serde_json::Value>,
1080}
1081
1082/// A box border.
1083#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1084#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1085#[serde(deny_unknown_fields)]
1086pub struct BoxBorder {
1087    /// Width, as a layout size: a fraction of the picture's shorter side or `"<n>px"`.
1088    pub width: LayoutSize,
1089    /// What covers it.
1090    pub paint: PaintChoice,
1091}
1092
1093/// A layout size: a number is a fraction of the picture's shorter side, `"<n>px"` canvas pixels.
1094#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1095#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1096#[serde(untagged)]
1097pub enum LayoutSize {
1098    /// A fraction of the picture's shorter side.
1099    Fraction(f32),
1100    /// Pixels, `"<n>px"`.
1101    Pixels(String),
1102}
1103
1104/// A box's child: a node, or `{"box": item fields, "node": node}` when it has item fields (size,
1105/// flex or grid placement, `aspect_ratio`, `border_radius`, `margin`).
1106#[derive(Clone, Debug, PartialEq, Serialize)]
1107#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1108#[serde(untagged)]
1109pub enum BoxChild {
1110    /// A node with its item fields.
1111    Placed(PlacedChild),
1112    /// A node.
1113    Plain(Node),
1114}
1115
1116/// A box child with item fields.
1117#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1118#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1119#[serde(deny_unknown_fields)]
1120pub struct PlacedChild {
1121    /// Item fields of an engine layout box, as it writes them; lengths may be theme lengths.
1122    #[serde(rename = "box")]
1123    pub item: BTreeMap<String, serde_json::Value>,
1124    /// The node.
1125    pub node: Node,
1126}
1127
1128impl BoxChild {
1129    /// The node.
1130    #[must_use]
1131    pub const fn node(&self) -> &Node {
1132        match self {
1133            Self::Placed(placed) => &placed.node,
1134            Self::Plain(node) => node,
1135        }
1136    }
1137
1138    /// Its item fields; none for a plain node.
1139    #[must_use]
1140    pub fn item(&self) -> BTreeMap<String, serde_json::Value> {
1141        match self {
1142            Self::Placed(placed) => placed.item.clone(),
1143            Self::Plain(_) => BTreeMap::new(),
1144        }
1145    }
1146}
1147
1148impl<'de> Deserialize<'de> for BoxChild {
1149    // An object with `node` is a placed child; anything else is a node, so a node's own errors
1150    // are reported as they are.
1151    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1152        use serde::de::Error as _;
1153        let value = serde_json::Value::deserialize(deserializer)?;
1154        if value
1155            .as_object()
1156            .is_some_and(|object| object.contains_key("node"))
1157        {
1158            serde_json::from_value(value)
1159                .map(Self::Placed)
1160                .map_err(D::Error::custom)
1161        } else {
1162            Node::deserialize(value)
1163                .map(Self::Plain)
1164                .map_err(D::Error::custom)
1165        }
1166    }
1167}
1168
1169/// One outline, in its area's unit square. Masks take the same outlines.
1170#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1171#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1172#[serde(tag = "shape", rename_all = "snake_case", deny_unknown_fields)]
1173pub enum Geometry {
1174    /// A rectangle, optionally with rounded corners.
1175    Rect {
1176        /// Centre. Default `[0.5, 0.5]`.
1177        #[serde(default, skip_serializing_if = "Option::is_none")]
1178        center: Option<Anim<[f32; 2]>>,
1179        /// Width and height. Default `[1, 1]`.
1180        #[serde(default, skip_serializing_if = "Option::is_none")]
1181        size: Option<Anim<[f32; 2]>>,
1182        /// Corner radius. Default 0.
1183        #[serde(default, skip_serializing_if = "Option::is_none")]
1184        corner_radius: Option<Anim<f32>>,
1185        /// Clockwise turn in degrees. Default 0.
1186        #[serde(default, skip_serializing_if = "Option::is_none")]
1187        rotation: Option<Anim<f32>>,
1188    },
1189    /// An ellipse.
1190    Ellipse {
1191        /// Centre. Default `[0.5, 0.5]`.
1192        #[serde(default, skip_serializing_if = "Option::is_none")]
1193        center: Option<Anim<[f32; 2]>>,
1194        /// Width and height. Default `[1, 1]`.
1195        #[serde(default, skip_serializing_if = "Option::is_none")]
1196        size: Option<Anim<[f32; 2]>>,
1197        /// Clockwise turn in degrees. Default 0.
1198        #[serde(default, skip_serializing_if = "Option::is_none")]
1199        rotation: Option<Anim<f32>>,
1200    },
1201    /// A regular polygon.
1202    Polygon {
1203        /// Centre. Default `[0.5, 0.5]`.
1204        #[serde(default, skip_serializing_if = "Option::is_none")]
1205        center: Option<Anim<[f32; 2]>>,
1206        /// Corners, 3 or more.
1207        points: u32,
1208        /// Distance of the corners from the centre. Default 0.5.
1209        #[serde(default, skip_serializing_if = "Option::is_none")]
1210        radius: Option<Anim<f32>>,
1211        /// How round the corners are, 0..=1. Default 0.
1212        #[serde(default, skip_serializing_if = "Option::is_none")]
1213        roundness: Option<Anim<f32>>,
1214        /// Clockwise turn in degrees. Default 0.
1215        #[serde(default, skip_serializing_if = "Option::is_none")]
1216        rotation: Option<Anim<f32>>,
1217    },
1218    /// A star.
1219    Star {
1220        /// Centre. Default `[0.5, 0.5]`.
1221        #[serde(default, skip_serializing_if = "Option::is_none")]
1222        center: Option<Anim<[f32; 2]>>,
1223        /// Tips, 3 or more.
1224        points: u32,
1225        /// Distance of the tips from the centre. Default 0.5.
1226        #[serde(default, skip_serializing_if = "Option::is_none")]
1227        outer_radius: Option<Anim<f32>>,
1228        /// Distance of the inner corners from the centre. Default 0.25.
1229        #[serde(default, skip_serializing_if = "Option::is_none")]
1230        inner_radius: Option<Anim<f32>>,
1231        /// Clockwise turn in degrees. Default 0.
1232        #[serde(default, skip_serializing_if = "Option::is_none")]
1233        rotation: Option<Anim<f32>>,
1234    },
1235    /// An outline as SVG path data (`d`), in the area's unit square.
1236    Path {
1237        /// The path data: `M`, `L`, `H`, `V`, `C`, `S`, `Q`, `T`, `A` and `Z`, absolute or
1238        /// relative.
1239        d: String,
1240    },
1241}
1242
1243/// A color, a theme color, or a gradient.
1244#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1245#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1246#[serde(untagged)]
1247pub enum PaintChoice {
1248    /// A theme color by name.
1249    Theme(ThemeColor),
1250    /// Colors along a line across the area.
1251    Linear(LinearPaint),
1252    /// Colors out from a point.
1253    Radial(RadialPaint),
1254    /// Colors around a point.
1255    Conic(ConicPaint),
1256    /// One color: CSS hex or the project's color object.
1257    Color(Rgba),
1258}
1259
1260/// `{"linear": gradient}`.
1261#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1262#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1263#[serde(deny_unknown_fields)]
1264pub struct LinearPaint {
1265    /// The gradient.
1266    pub linear: Gradient,
1267}
1268
1269/// `{"radial": gradient}`.
1270#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1271#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1272#[serde(deny_unknown_fields)]
1273pub struct RadialPaint {
1274    /// The gradient.
1275    pub radial: Gradient,
1276}
1277
1278/// `{"conic": gradient}`.
1279#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1280#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1281#[serde(deny_unknown_fields)]
1282pub struct ConicPaint {
1283    /// The gradient.
1284    pub conic: Gradient,
1285}
1286
1287/// Where the compose schema is published.
1288pub const COMPOSE_SCHEMA_ID: &str = "https://alpha2.sh/schema/compose.v1.json";
1289
1290/// A size in pixels, or one of the theme's lengths.
1291#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
1292#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1293#[serde(untagged)]
1294pub enum Size {
1295    /// Pixels of the canvas.
1296    Pixels(f32),
1297    /// A theme length.
1298    Theme(ThemeLength),
1299}
1300
1301/// One of the theme's lengths times `scale`, as a fraction of the picture's shorter side.
1302#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
1303#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1304#[serde(deny_unknown_fields)]
1305pub struct ThemeLength {
1306    /// Which of the theme's lengths.
1307    #[serde(rename = "$theme")]
1308    pub token: LengthToken,
1309    /// What it is multiplied by. Default 1.
1310    #[serde(default, skip_serializing_if = "Option::is_none")]
1311    pub scale: Option<f32>,
1312}
1313
1314/// A theme's named lengths.
1315#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
1316#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1317#[serde(rename_all = "snake_case")]
1318pub enum LengthToken {
1319    /// Space kept from the edges.
1320    Margin,
1321    /// The title style's font size.
1322    TitleSize,
1323    /// The subtitle style's font size.
1324    SubtitleSize,
1325    /// The body style's font size.
1326    BodySize,
1327    /// Captions' font size.
1328    CaptionSize,
1329    /// The label style's font size.
1330    LabelSize,
1331}
1332
1333/// A theme color, so a design follows whatever theme it is drawn with.
1334#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
1335#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1336#[serde(deny_unknown_fields)]
1337pub struct ThemeColor {
1338    /// Which of the theme's colors.
1339    #[serde(rename = "$theme")]
1340    pub token: ThemeToken,
1341    /// Opacity multiplied into it, 0..=1. Default 1.
1342    #[serde(default, skip_serializing_if = "Option::is_none")]
1343    pub alpha: Option<f32>,
1344}
1345
1346/// A theme's named colors.
1347#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
1348#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1349#[serde(rename_all = "snake_case")]
1350pub enum ThemeToken {
1351    /// Text.
1352    Text,
1353    /// The canvas behind everything.
1354    Background,
1355    /// Cards and title cards.
1356    Surface,
1357    /// Bars behind text.
1358    Panel,
1359    /// Highlights.
1360    Accent,
1361}
1362
1363/// Colors spread over a gradient.
1364#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1365#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1366#[serde(deny_unknown_fields)]
1367pub struct Gradient {
1368    /// Two or more colors, evenly spaced unless each says its `offset` in 0..=1.
1369    pub stops: Vec<Stop>,
1370    /// A linear gradient's direction in degrees, as CSS: 0 upward, 90 rightward. A conic one's
1371    /// start. Default 180 for linear (downward), 0 for conic.
1372    #[serde(default, skip_serializing_if = "Option::is_none")]
1373    pub angle: Option<f32>,
1374    /// A radial or conic gradient's centre. Default `[0.5, 0.5]`.
1375    #[serde(default, skip_serializing_if = "Option::is_none")]
1376    pub center: Option<[f32; 2]>,
1377    /// A radial gradient's radius. Default 0.5.
1378    #[serde(default, skip_serializing_if = "Option::is_none")]
1379    pub radius: Option<f32>,
1380}
1381
1382/// One gradient color.
1383#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1384#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1385#[serde(untagged)]
1386pub enum Stop {
1387    /// A color at a set position.
1388    At(OffsetStop),
1389    /// A color, spaced evenly with the others.
1390    Even(SolidColor),
1391}
1392
1393/// A gradient color at a set position.
1394#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1395#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1396#[serde(deny_unknown_fields)]
1397pub struct OffsetStop {
1398    /// The color.
1399    pub color: SolidColor,
1400    /// Where along the gradient, 0..=1.
1401    pub offset: f32,
1402}
1403
1404/// One color: a theme color, CSS hex, or the project's color object.
1405#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
1406#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1407#[serde(untagged)]
1408pub enum SolidColor {
1409    /// A theme color by name.
1410    Theme(ThemeColor),
1411    /// CSS hex or the color object.
1412    Color(Rgba),
1413}
1414
1415/// A line along outlines.
1416#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1417#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1418#[serde(deny_unknown_fields)]
1419pub struct Stroke {
1420    /// What covers it. Default: the theme's text color.
1421    #[serde(default, skip_serializing_if = "Option::is_none")]
1422    pub paint: Option<PaintChoice>,
1423    /// Width, as a fraction of the area's shorter side.
1424    pub width: Anim<f32>,
1425    /// Dash and gap lengths, as fractions of the area's shorter side. Default: solid.
1426    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1427    pub dash: Vec<f32>,
1428    /// How open ends look. Default `butt`.
1429    #[serde(default, skip_serializing_if = "Option::is_none")]
1430    pub cap: Option<alpha2_model::LineCap>,
1431    /// How segments meet. Default `miter`.
1432    #[serde(default, skip_serializing_if = "Option::is_none")]
1433    pub join: Option<alpha2_model::LineJoin>,
1434}
1435
1436/// The part of outlines' length that is kept, from `start` to `end`, shifted by `offset` turns.
1437#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
1438#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1439#[serde(deny_unknown_fields)]
1440pub struct Trim {
1441    /// Default 0.
1442    #[serde(default, skip_serializing_if = "Option::is_none")]
1443    pub start: Option<Anim<f32>>,
1444    /// Default 1.
1445    #[serde(default, skip_serializing_if = "Option::is_none")]
1446    pub end: Option<Anim<f32>>,
1447    /// Default 0.
1448    #[serde(default, skip_serializing_if = "Option::is_none")]
1449    pub offset: Option<Anim<f32>>,
1450}
1451
1452/// An area painted one color.
1453#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1454#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1455#[serde(deny_unknown_fields)]
1456pub struct ColorFill {
1457    /// The node's name, for other nodes to refer to.
1458    #[serde(default, skip_serializing_if = "Option::is_none")]
1459    pub id: Option<String>,
1460    /// The color. Default: the theme's surface.
1461    #[serde(default, skip_serializing_if = "Option::is_none")]
1462    pub color: Option<SolidColor>,
1463    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
1464    #[serde(default, skip_serializing_if = "Option::is_none")]
1465    pub at: Option<f64>,
1466    /// Length in seconds. Default: the node's own length, else what its parent gives it.
1467    #[serde(default, skip_serializing_if = "Option::is_none")]
1468    pub duration: Option<f64>,
1469    /// Pixels kept clear inside the parent's area: one number, or `[top, right, bottom, left]`.
1470    #[serde(default, skip_serializing_if = "Option::is_none")]
1471    pub inset: Option<Inset>,
1472    /// How it comes in at its start.
1473    #[serde(default, skip_serializing_if = "Option::is_none")]
1474    pub enter: Option<Motion>,
1475    /// How it goes out, ending at its end.
1476    #[serde(default, skip_serializing_if = "Option::is_none")]
1477    pub exit: Option<Motion>,
1478}
1479
1480/// An area drawn by a generator. The generator draws the whole picture, which is scaled to the
1481/// node's area, and its ramps and keys run over the node's time.
1482#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1483#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1484#[serde(deny_unknown_fields)]
1485pub struct GeneratorNode {
1486    /// The node's name, for other nodes to refer to.
1487    #[serde(default, skip_serializing_if = "Option::is_none")]
1488    pub id: Option<String>,
1489    /// The generator: a built-in by its short name (`fractal-noise`) or any generator by its full
1490    /// id, under `effect`, with its parameters by name.
1491    #[cfg_attr(feature = "schema", schemars(schema_with = "generator_use_reference"))]
1492    pub generator: EffectUse,
1493    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
1494    #[serde(default, skip_serializing_if = "Option::is_none")]
1495    pub at: Option<f64>,
1496    /// Length in seconds. Default: what its parent gives it.
1497    #[serde(default, skip_serializing_if = "Option::is_none")]
1498    pub duration: Option<f64>,
1499    /// Pixels kept clear inside the parent's area: one number, or `[top, right, bottom, left]`.
1500    #[serde(default, skip_serializing_if = "Option::is_none")]
1501    pub inset: Option<Inset>,
1502    /// How it comes in at its start.
1503    #[serde(default, skip_serializing_if = "Option::is_none")]
1504    pub enter: Option<Motion>,
1505    /// How it goes out, ending at its end.
1506    #[serde(default, skip_serializing_if = "Option::is_none")]
1507    pub exit: Option<Motion>,
1508}
1509
1510#[cfg(feature = "schema")]
1511fn generator_use_reference(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
1512    schemars::json_schema!({ "$ref": "#/$defs/GeneratorUse" })
1513}
1514
1515/// Timed text.
1516#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1517#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1518#[cfg_attr(feature = "schema", schemars(rename = "CaptionsNode"))]
1519#[serde(deny_unknown_fields)]
1520pub struct Captions {
1521    /// The node's name, for other nodes to refer to.
1522    #[serde(default, skip_serializing_if = "Option::is_none")]
1523    pub id: Option<String>,
1524    /// Cues as given, in seconds from the node's start.
1525    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1526    pub cues: Vec<Cue>,
1527    /// Words with their times, as speech recognition gives them, grouped into cues of up to
1528    /// `max_chars` characters.
1529    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1530    pub words: Vec<Cue>,
1531    /// A SubRip (`.srt`) or WebVTT (`.vtt`) file, read by the binding.
1532    #[serde(default, skip_serializing_if = "Option::is_none")]
1533    pub file: Option<String>,
1534    /// SubRip text.
1535    #[serde(default, skip_serializing_if = "Option::is_none")]
1536    pub srt: Option<String>,
1537    /// WebVTT text.
1538    #[serde(default, skip_serializing_if = "Option::is_none")]
1539    pub vtt: Option<String>,
1540    /// How the captions look. Default `outline`.
1541    #[serde(default)]
1542    pub style: CaptionStyle,
1543    /// The longest cue words are grouped into, in characters. Default 32 on a tall canvas, 42
1544    /// on a wide one.
1545    #[serde(default, skip_serializing_if = "Option::is_none")]
1546    pub max_chars: Option<u32>,
1547    /// Font size in pixels. Default: the theme's caption size.
1548    #[serde(default, skip_serializing_if = "Option::is_none")]
1549    pub font_size: Option<Size>,
1550    /// Text color. Default: the theme's.
1551    #[serde(default, skip_serializing_if = "Option::is_none")]
1552    pub color: Option<SolidColor>,
1553    /// The color `karaoke` and `pop` give the word being said. Default: the theme's accent.
1554    #[serde(default, skip_serializing_if = "Option::is_none")]
1555    pub highlight: Option<SolidColor>,
1556    /// Each speaker's look, keyed by a WebVTT voice or a cue's `speaker`; it overrides the
1557    /// style.
1558    #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
1559    pub speakers: BTreeMap<String, SpeakerLook>,
1560    /// Where the text's middle lies, as a fraction of the canvas height. Default depends on the
1561    /// style and the canvas's shape.
1562    #[serde(default, skip_serializing_if = "Option::is_none")]
1563    pub position: Option<f32>,
1564    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
1565    #[serde(default, skip_serializing_if = "Option::is_none")]
1566    pub at: Option<f64>,
1567    /// Length in seconds. Default: the node's own length, else what its parent gives it.
1568    #[serde(default, skip_serializing_if = "Option::is_none")]
1569    pub duration: Option<f64>,
1570}
1571
1572/// Text over an interval.
1573#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1574#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1575#[serde(deny_unknown_fields)]
1576pub struct Cue {
1577    /// Start in seconds.
1578    pub start: f64,
1579    /// End in seconds.
1580    pub end: f64,
1581    /// The text.
1582    pub text: String,
1583    /// Who says it: a key of the captions' `speakers` gives the cue its look.
1584    #[serde(default, skip_serializing_if = "Option::is_none")]
1585    pub speaker: Option<String>,
1586}
1587
1588/// How one speaker's captions look.
1589#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
1590#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1591#[serde(deny_unknown_fields)]
1592pub struct SpeakerLook {
1593    /// Their text color.
1594    #[serde(default, skip_serializing_if = "Option::is_none")]
1595    pub color: Option<SolidColor>,
1596    /// Where their text's middle lies, as fractions of the canvas, `(0, 0)` top-left.
1597    #[serde(default, skip_serializing_if = "Option::is_none")]
1598    pub position: Option<alpha2_model::Vec2>,
1599}
1600
1601/// How captions look.
1602#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
1603#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1604#[serde(rename_all = "kebab-case")]
1605pub enum CaptionStyle {
1606    /// Text with a dark band around the glyphs, near the bottom.
1607    #[default]
1608    Outline,
1609    /// Text on a panel behind each line, near the bottom.
1610    Boxed,
1611    /// Text centered on a translucent bar across the canvas near the bottom, shown as long as
1612    /// the captions.
1613    BarBottom,
1614    /// Larger outlined text a little below the middle, as short-form video draws it.
1615    BoldCenter,
1616    /// White text with a black stroke and a soft shadow, near the bottom.
1617    Bold,
1618    /// `bold`, each word turning the highlight color as it is said. Needs word times (`words`
1619    /// or WebVTT inline timestamps), else draws as `bold`.
1620    Karaoke,
1621    /// `bold`, the word being said growing a little in the highlight color. Needs word times.
1622    Pop,
1623}
1624
1625/// A layout generator.
1626#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1627#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1628#[serde(deny_unknown_fields)]
1629pub struct Layout {
1630    /// The node's name, for other nodes to refer to.
1631    #[serde(default, skip_serializing_if = "Option::is_none")]
1632    pub id: Option<String>,
1633    /// The root box, as a project's layout generator writes it.
1634    pub root: Box<LayoutNode>,
1635    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
1636    #[serde(default, skip_serializing_if = "Option::is_none")]
1637    pub at: Option<f64>,
1638    /// Length in seconds. Default: the node's own length, else what its parent gives it.
1639    #[serde(default, skip_serializing_if = "Option::is_none")]
1640    pub duration: Option<f64>,
1641    /// Pixels kept clear inside the parent's area: one number, or `[top, right, bottom, left]`.
1642    #[serde(default, skip_serializing_if = "Option::is_none")]
1643    pub inset: Option<Inset>,
1644    /// Where in its area the picture or text lies. Default `center`.
1645    #[serde(default, skip_serializing_if = "Option::is_none")]
1646    pub align: Option<Align>,
1647    /// How it comes in at its start.
1648    #[serde(default, skip_serializing_if = "Option::is_none")]
1649    pub enter: Option<Motion>,
1650    /// How it goes out, ending at its end.
1651    #[serde(default, skip_serializing_if = "Option::is_none")]
1652    pub exit: Option<Motion>,
1653}
1654
1655/// A sound file.
1656#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1657#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1658#[serde(deny_unknown_fields)]
1659pub struct Audio {
1660    /// The node's name, for other nodes to refer to.
1661    #[serde(default, skip_serializing_if = "Option::is_none")]
1662    pub id: Option<String>,
1663    /// The file.
1664    pub path: String,
1665    /// Where in the file it starts, in seconds.
1666    #[serde(default, skip_serializing_if = "Option::is_none")]
1667    pub trim_start: Option<f64>,
1668    /// Where in the file it ends, in seconds. Default: its end.
1669    #[serde(default, skip_serializing_if = "Option::is_none")]
1670    pub trim_end: Option<f64>,
1671    /// Plays the file again from its start while the node lasts.
1672    #[serde(default, skip_serializing_if = "std::ops::Not::not")]
1673    pub r#loop: bool,
1674    /// Linear gain. Default 1.
1675    #[serde(default, skip_serializing_if = "Option::is_none")]
1676    pub volume: Option<f32>,
1677    /// Seconds of fade in.
1678    #[serde(default, skip_serializing_if = "Option::is_none")]
1679    pub fade_in: Option<f64>,
1680    /// Seconds of fade out.
1681    #[serde(default, skip_serializing_if = "Option::is_none")]
1682    pub fade_out: Option<f64>,
1683    /// The `id` of a node (or `body`) whose sound this ducks under.
1684    #[serde(default, skip_serializing_if = "Option::is_none")]
1685    pub duck_under: Option<String>,
1686    /// How far ducking lowers it, in dB (negative). Default -12.
1687    #[serde(default, skip_serializing_if = "Option::is_none")]
1688    pub duck_depth_db: Option<f32>,
1689    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
1690    #[serde(default, skip_serializing_if = "Option::is_none")]
1691    pub at: Option<f64>,
1692    /// Length in seconds. Default: the node's own length, else what its parent gives it.
1693    #[serde(default, skip_serializing_if = "Option::is_none")]
1694    pub duration: Option<f64>,
1695}
1696
1697/// Part of a project at its own times.
1698#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1699#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1700#[serde(deny_unknown_fields)]
1701pub struct Raw {
1702    /// Sources its tracks read. Ids must not collide with the compiler's (`s1`, `s2`, ...); a
1703    /// `src-` prefix keeps them apart.
1704    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1705    pub sources: Vec<MediaSource>,
1706    /// Tracks drawn over what comes before, at timeline times.
1707    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1708    pub tracks: Vec<Track>,
1709    /// Compositions its clips show.
1710    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1711    pub compositions: Vec<Composition>,
1712    /// Each file a media source of the fragment reads, by source id: the export's assets.
1713    #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
1714    pub assets: BTreeMap<String, String>,
1715}
1716
1717/// Stills or clips in turn.
1718#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1719#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1720#[serde(deny_unknown_fields)]
1721pub struct Slideshow {
1722    /// The node's name, for other nodes to refer to.
1723    #[serde(default, skip_serializing_if = "Option::is_none")]
1724    pub id: Option<String>,
1725    /// The slides.
1726    pub items: Vec<MediaItem>,
1727    /// How long each slide shows, transitions included, in seconds. Default: `fit_to`'s length
1728    /// shared out, else the theme's still length.
1729    #[serde(default, skip_serializing_if = "Option::is_none")]
1730    pub seconds: Option<f64>,
1731    /// A sound file whose length the slides share out. It is not played; add it as a music bed.
1732    #[serde(default, skip_serializing_if = "Option::is_none")]
1733    pub fit_to: Option<String>,
1734    /// What joins slides. Default `theme`.
1735    #[serde(default, skip_serializing_if = "Option::is_none")]
1736    pub transition: Option<TransitionChoice>,
1737    /// How far each slide zooms in over its time, as a multiple (1.15 ends 15% larger). Default
1738    /// none.
1739    #[serde(default, skip_serializing_if = "Option::is_none")]
1740    pub ken_burns: Option<f32>,
1741    /// How slides fill the canvas. Default `cover`.
1742    #[serde(default, skip_serializing_if = "Option::is_none")]
1743    pub fit: Option<Fit>,
1744    /// When it starts in its parent; its length is the slides'.
1745    #[serde(default, skip_serializing_if = "Option::is_none")]
1746    pub at: Option<f64>,
1747}
1748
1749/// A video under its captions.
1750#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1751#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1752#[serde(deny_unknown_fields)]
1753pub struct CaptionedVideo {
1754    /// The node's name, for other nodes to refer to. Its sound is the video's.
1755    #[serde(default, skip_serializing_if = "Option::is_none")]
1756    pub id: Option<String>,
1757    /// The video.
1758    pub video: MediaItem,
1759    /// The captions, timed from the video's start.
1760    pub captions: Box<Captions>,
1761    /// How the video fills the canvas. Default `cover`.
1762    #[serde(default, skip_serializing_if = "Option::is_none")]
1763    pub fit: Option<Fit>,
1764    /// When it starts in its parent; its length is the video's.
1765    #[serde(default, skip_serializing_if = "Option::is_none")]
1766    pub at: Option<f64>,
1767}
1768
1769/// Music under the video.
1770#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1771#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1772#[serde(deny_unknown_fields)]
1773pub struct MusicBed {
1774    /// The node's name, for other nodes to refer to.
1775    #[serde(default, skip_serializing_if = "Option::is_none")]
1776    pub id: Option<String>,
1777    /// The file.
1778    pub path: String,
1779    /// Linear gain. Default 1.
1780    #[serde(default, skip_serializing_if = "Option::is_none")]
1781    pub volume: Option<f32>,
1782    /// Seconds of fade in. Default 1.
1783    #[serde(default, skip_serializing_if = "Option::is_none")]
1784    pub fade_in: Option<f64>,
1785    /// Seconds of fade out at the end. Default 2.
1786    #[serde(default, skip_serializing_if = "Option::is_none")]
1787    pub fade_out: Option<f64>,
1788    /// The `id` of a node (or `body`) whose sound it ducks under.
1789    #[serde(default, skip_serializing_if = "Option::is_none")]
1790    pub duck_under: Option<String>,
1791    /// How far ducking lowers it, in dB (negative). Default -12.
1792    #[serde(default, skip_serializing_if = "Option::is_none")]
1793    pub duck_depth_db: Option<f32>,
1794    /// Plays the file again from its start while the video lasts. Default true.
1795    #[serde(default = "yes")]
1796    pub r#loop: bool,
1797    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
1798    #[serde(default, skip_serializing_if = "Option::is_none")]
1799    pub at: Option<f64>,
1800    /// Length in seconds. Default: the node's own length, else what its parent gives it.
1801    #[serde(default, skip_serializing_if = "Option::is_none")]
1802    pub duration: Option<f64>,
1803}
1804
1805const fn yes() -> bool {
1806    true
1807}
1808
1809/// A timing curve: a name, a CSS easing function, a spring or a project easing object.
1810#[derive(Clone, Debug, PartialEq, Serialize)]
1811#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1812#[serde(untagged)]
1813pub enum EasingChoice {
1814    /// A name or a CSS easing function. The names are `linear`, `ease`, `ease-in`, `ease-out`,
1815    /// `ease-in-out`, `step-start`, `step-end`, and `ease-in-`, `ease-out-` or `ease-in-out-`
1816    /// before `sine`, `quad`, `cubic`, `quart`, `quint`, `expo`, `circ`, `back`, `elastic` or
1817    /// `bounce`. The functions are `cubic-bezier(x1, y1, x2, y2)`, `steps(count)`,
1818    /// `steps(count, position)` with a CSS position word, and `linear(...)` whose points start
1819    /// at 0, end at 1 and rise in input.
1820    Named(String),
1821    /// A spring.
1822    Spring(SpringChoice),
1823    /// A project easing.
1824    Curve(Easing),
1825}
1826
1827/// A mass on a damped spring, released toward its target. The easing is the spring's motion
1828/// over the time it takes to stay within a thousandth of the target; an entrance or exit
1829/// without a `duration` lasts that long.
1830#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1831#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1832#[serde(deny_unknown_fields)]
1833pub struct SpringChoice {
1834    /// `spring`.
1835    #[serde(rename = "type")]
1836    pub kind: SpringKind,
1837    /// The mass, above 0. Default 1.
1838    #[serde(default, skip_serializing_if = "Option::is_none")]
1839    pub mass: Option<f64>,
1840    /// The spring constant, above 0.
1841    pub stiffness: f64,
1842    /// The damping coefficient, above 0.
1843    pub damping: f64,
1844    /// The velocity at the start, in distances to the target per second. Default 0.
1845    #[serde(default, skip_serializing_if = "Option::is_none")]
1846    pub velocity: Option<f64>,
1847}
1848
1849/// The tag of a [`SpringChoice`].
1850#[derive(Copy, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
1851#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1852#[serde(rename_all = "snake_case")]
1853pub enum SpringKind {
1854    /// A spring.
1855    Spring,
1856}
1857
1858/// A value over a node's time: a constant, a ramp from one value to another, or keys. Times are
1859/// seconds from the node's start.
1860#[derive(Clone, Debug, PartialEq, Serialize)]
1861#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1862#[serde(untagged)]
1863pub enum Anim<T> {
1864    /// From `from` to `to`.
1865    Ramp(Ramp<T>),
1866    /// Through keyed values.
1867    Keys(Keys<T>),
1868    /// One value throughout.
1869    Value(T),
1870}
1871
1872impl<'de, T: serde::de::DeserializeOwned> Deserialize<'de> for Anim<T> {
1873    // An object with `keys` is keys and one with `from` a ramp; anything else is a value. Ramps
1874    // and keys are objects only, as the schema says, though serde reads a struct from an array.
1875    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1876        use serde::de::Error as _;
1877        let value = serde_json::Value::deserialize(deserializer)?;
1878        let object = value.as_object();
1879        if object.is_some_and(|object| object.contains_key("keys")) {
1880            serde_json::from_value(value).map(Anim::Keys)
1881        } else if object.is_some_and(|object| object.contains_key("from")) {
1882            serde_json::from_value(value).map(Anim::Ramp)
1883        } else if value.is_array() && !accepts_array::<T>() {
1884            return Err(D::Error::custom(
1885                "expected a value, `{from, to}` or `{keys}`, not an array",
1886            ));
1887        } else {
1888            serde_json::from_value(value).map(Anim::Value)
1889        }
1890        .map_err(D::Error::custom)
1891    }
1892}
1893
1894/// Whether `T` itself is written as an array, as a vector value is.
1895fn accepts_array<T: serde::de::DeserializeOwned>() -> bool {
1896    serde_json::from_value::<T>(serde_json::json!([0, 0])).is_ok()
1897        || serde_json::from_value::<T>(serde_json::json!([0, 0, 0, 0])).is_ok()
1898}
1899
1900/// A change from one value to another; before it the value is `from`, after it `to`.
1901#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1902#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1903#[serde(deny_unknown_fields)]
1904pub struct Ramp<T> {
1905    /// The value at the start.
1906    pub from: T,
1907    /// The value at the end.
1908    pub to: T,
1909    /// The timing curve. Default linear.
1910    #[serde(default, skip_serializing_if = "Option::is_none")]
1911    pub ease: Option<EasingChoice>,
1912    /// When it starts. Default 0.
1913    #[serde(default, skip_serializing_if = "Option::is_none")]
1914    pub at: Option<f64>,
1915    /// How long it lasts. Default: to the node's end.
1916    #[serde(default, skip_serializing_if = "Option::is_none")]
1917    pub duration: Option<f64>,
1918}
1919
1920/// Values at times; the value holds before the first and after the last.
1921#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1922#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1923#[serde(deny_unknown_fields)]
1924pub struct Keys<T> {
1925    /// The keys, in increasing time; at least one.
1926    pub keys: Vec<Key<T>>,
1927    /// What the value does before the first key: `hold` (the default), `linear`, `repeat`,
1928    /// `repeat_offset` or `ping_pong`.
1929    #[serde(default, skip_serializing_if = "Option::is_none")]
1930    pub before: Option<Extrapolation>,
1931    /// What the value does after the last key.
1932    #[serde(default, skip_serializing_if = "Option::is_none")]
1933    pub after: Option<Extrapolation>,
1934}
1935
1936/// One keyed value.
1937#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1938#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1939#[serde(deny_unknown_fields)]
1940pub struct Key<T> {
1941    /// Seconds from the node's start.
1942    pub t: f64,
1943    /// The value.
1944    pub v: T,
1945    /// The timing curve to the next key. Default linear.
1946    #[serde(default, skip_serializing_if = "Option::is_none")]
1947    pub ease: Option<EasingChoice>,
1948}
1949
1950/// An entrance or exit, timed from the node's own start or back from its own end.
1951#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
1952#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1953#[serde(deny_unknown_fields)]
1954pub struct Motion {
1955    /// What moves: `fade` (opacity alone), `rise` (a slide up), `slide` (toward `direction`) or
1956    /// `scale` (from `size` times its size). `rise`, `slide` and `scale` fade too unless `fade`
1957    /// is false.
1958    #[serde(rename = "type")]
1959    pub kind: MotionKind,
1960    /// Length in seconds; 0 is no motion. Default: the theme's fade length.
1961    #[serde(default, skip_serializing_if = "Option::is_none")]
1962    pub duration: Option<f64>,
1963    /// The timing curve. Default linear.
1964    #[serde(default, skip_serializing_if = "Option::is_none")]
1965    pub easing: Option<EasingChoice>,
1966    /// Which way a `slide` travels, entering into place and leaving out of it. Default `up`.
1967    #[serde(default, skip_serializing_if = "Option::is_none")]
1968    pub direction: Option<Direction>,
1969    /// How far a `rise` or `slide` travels, in pixels. Default: the theme's margin.
1970    #[serde(default, skip_serializing_if = "Option::is_none")]
1971    pub distance: Option<f32>,
1972    /// The size a `scale` enters from or exits to, as a multiple of its own. Default 0.
1973    #[serde(default, skip_serializing_if = "Option::is_none")]
1974    pub size: Option<f32>,
1975    /// Whether a `rise`, `slide` or `scale` also fades. Default true.
1976    #[serde(default, skip_serializing_if = "Option::is_none")]
1977    pub fade: Option<bool>,
1978}
1979
1980/// What an entrance or exit moves.
1981#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
1982#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1983#[serde(rename_all = "snake_case")]
1984pub enum MotionKind {
1985    /// Opacity alone.
1986    Fade,
1987    /// A slide up.
1988    Rise,
1989    /// A slide toward `direction`.
1990    Slide,
1991    /// A change of size about the node's own anchor.
1992    Scale,
1993}
1994
1995/// A direction of travel on the canvas.
1996#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
1997#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1998#[serde(rename_all = "snake_case")]
1999pub enum Direction {
2000    /// Toward the top.
2001    #[default]
2002    Up,
2003    /// Toward the bottom.
2004    Down,
2005    /// Toward the left.
2006    Left,
2007    /// Toward the right.
2008    Right,
2009}
2010
2011/// A text revealed a unit at a time. Each unit moves at a constant rate over `duration`.
2012#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
2013#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2014#[serde(deny_unknown_fields)]
2015pub struct Reveal {
2016    /// The unit: `word` (words holding a letter or digit) or `line` (laid-out lines).
2017    pub by: RevealUnit,
2018    /// How each unit appears: `fade`, or `rise` (fading in while moving up). Default `fade`.
2019    #[serde(rename = "type", default, skip_serializing_if = "Option::is_none")]
2020    pub kind: Option<RevealKind>,
2021    /// Seconds between one unit's start and the next's. Default half the duration.
2022    #[serde(default, skip_serializing_if = "Option::is_none")]
2023    pub stagger: Option<f64>,
2024    /// Seconds each unit takes. Default: the theme's fade length.
2025    #[serde(default, skip_serializing_if = "Option::is_none")]
2026    pub duration: Option<f64>,
2027    /// How far a `rise` moves, in pixels. Default half the font size.
2028    #[serde(default, skip_serializing_if = "Option::is_none")]
2029    pub distance: Option<f32>,
2030}
2031
2032/// The unit a text is revealed by.
2033#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
2034#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2035#[serde(rename_all = "snake_case")]
2036pub enum RevealUnit {
2037    /// Words that hold a letter or digit; other characters show throughout.
2038    Word,
2039    /// Laid-out lines.
2040    Line,
2041}
2042
2043/// How a revealed unit appears.
2044#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
2045#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2046#[serde(rename_all = "snake_case")]
2047pub enum RevealKind {
2048    /// Opacity alone.
2049    Fade,
2050    /// Fading in while moving up.
2051    Rise,
2052}
2053
2054/// A number counting from `start` to `end`, shown as text that changes on the frame grid.
2055#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
2056#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2057#[serde(deny_unknown_fields)]
2058pub struct Counter {
2059    /// The node's name, for other nodes to refer to.
2060    #[serde(default, skip_serializing_if = "Option::is_none")]
2061    pub id: Option<String>,
2062    /// The value it counts from.
2063    pub start: f64,
2064    /// The value it counts to.
2065    pub end: f64,
2066    /// Seconds the count takes from the node's start, at most 100,000 frames; it then holds
2067    /// `end`. Default: the node's whole length.
2068    #[serde(default, skip_serializing_if = "Option::is_none")]
2069    pub count_duration: Option<f64>,
2070    /// The timing curve of the count. Default linear.
2071    #[serde(default, skip_serializing_if = "Option::is_none")]
2072    pub easing: Option<EasingChoice>,
2073    /// How the number is written.
2074    #[serde(default, skip_serializing_if = "Option::is_none")]
2075    pub format: Option<NumberFormat>,
2076    /// The theme style it starts from. Default `title`.
2077    #[serde(default, skip_serializing_if = "Option::is_none")]
2078    pub style: Option<TextRole>,
2079    /// Font size in pixels, or a theme length. Default: the style's.
2080    #[serde(default, skip_serializing_if = "Option::is_none")]
2081    pub font_size: Option<Size>,
2082    /// Family. Default: the theme's.
2083    #[serde(default, skip_serializing_if = "Option::is_none")]
2084    pub font_family: Option<String>,
2085    /// Color. Default: the theme's text color.
2086    #[serde(default, skip_serializing_if = "Option::is_none")]
2087    pub color: Option<SolidColor>,
2088    /// Bands around the glyphs, as a text node's `strokes`.
2089    #[serde(default, skip_serializing_if = "Vec::is_empty")]
2090    pub strokes: Vec<TextStroke>,
2091    /// Shadows of the glyphs, as a text node's `shadows`.
2092    #[serde(default, skip_serializing_if = "Vec::is_empty")]
2093    pub shadows: Vec<TextShadow>,
2094    /// Opacity, 0..=1. Default 1.
2095    #[serde(default, skip_serializing_if = "Option::is_none")]
2096    pub opacity: Option<f32>,
2097    /// Seconds from the parent's start (an overlay's: the video's). Ignored in a sequence.
2098    #[serde(default, skip_serializing_if = "Option::is_none")]
2099    pub at: Option<f64>,
2100    /// Length in seconds. Default: the node's own length, else what its parent gives it.
2101    #[serde(default, skip_serializing_if = "Option::is_none")]
2102    pub duration: Option<f64>,
2103    /// Pixels kept clear inside the parent's area: one number, or `[top, right, bottom, left]`.
2104    #[serde(default, skip_serializing_if = "Option::is_none")]
2105    pub inset: Option<Inset>,
2106    /// Where in its area the number lies. Default `center`.
2107    #[serde(default, skip_serializing_if = "Option::is_none")]
2108    pub align: Option<Align>,
2109    /// How it comes in at its start.
2110    #[serde(default, skip_serializing_if = "Option::is_none")]
2111    pub enter: Option<Motion>,
2112    /// How it goes out, ending at its end.
2113    #[serde(default, skip_serializing_if = "Option::is_none")]
2114    pub exit: Option<Motion>,
2115}
2116
2117/// How a counter writes its number.
2118#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
2119#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2120#[serde(deny_unknown_fields)]
2121pub struct NumberFormat {
2122    /// Digits after the decimal point, at most 6. Default 0.
2123    #[serde(default, skip_serializing_if = "Option::is_none")]
2124    pub decimals: Option<u32>,
2125    /// Put between each group of three integer digits, as `,`. Default none.
2126    #[serde(default, skip_serializing_if = "Option::is_none")]
2127    pub thousands: Option<String>,
2128    /// The decimal point. Default `.`.
2129    #[serde(default, skip_serializing_if = "Option::is_none")]
2130    pub point: Option<String>,
2131    /// Text before the number.
2132    #[serde(default, skip_serializing_if = "Option::is_none")]
2133    pub prefix: Option<String>,
2134    /// Text after the number.
2135    #[serde(default, skip_serializing_if = "Option::is_none")]
2136    pub suffix: Option<String>,
2137}