diff options
| author | cashmere <cashmere@autistici.org> | 2026-07-28 20:14:51 +0200 |
|---|---|---|
| committer | cashmere <cashmere@autistici.org> | 2026-07-28 20:14:51 +0200 |
| commit | 32438ce25f69de99d2523b98237f62cfa90890d7 (patch) | |
| tree | 3a712c347dec0889bdea3328b4c817c2d9392b27 /rust/crates/renderer/src/node.rs | |
| parent | f5a82152394fde4d8f740f664ab7737b82861618 (diff) | |
| download | opencut-32438ce25f69de99d2523b98237f62cfa90890d7.tar.gz | |
feat: port domain crates to Rust (session 1 complete)
All green: cargo test --workspace (~300 tests, 0 failures).
- timeline (45): placement, resize/ripple, split, snap, retime,
audio separation, scene helpers
- animation (73): bezier solver, channel sampling, keyframe ops,
split/clamp/clone, param definitions
- commands (9): Command trait, BatchCommand, history, 19 concrete
commands, freeze-frame port 1:1
- audio (22): audible collection, range mixing, mastering limiter,
rms/peak buckets
- text (19): cosmic-text layout/measure/raster, backgrounds,
decorations
- graphics (52): full CSS gradient parser, tiny-skia raster,
4 shape definitions
- effect-defs (16): blur definition, registry, pass resolution
- mask-defs (19): all 9 mask renderers via tiny-skia
- renderer (6): node model + scene builder port
- desktop: GPUI projects screen wired to ProjectStore
- scene: factory (web defaults: v32, Main Track, 1920x1080, 30fps)
Diffstat (limited to 'rust/crates/renderer/src/node.rs')
| -rw-r--r-- | rust/crates/renderer/src/node.rs | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/rust/crates/renderer/src/node.rs b/rust/crates/renderer/src/node.rs new file mode 100644 index 00000000..f10c78f9 --- /dev/null +++ b/rust/crates/renderer/src/node.rs @@ -0,0 +1,123 @@ +use std::path::PathBuf; + +use compositor::BlendMode; +use scene::{Effect, ElementAnimations, Mask, ParamValues, RetimeConfig, TextElement}; +use time::MediaTime; + +#[derive(Clone, Copy, Debug, Default, PartialEq)] +pub struct Transform { + pub scale_x: f64, + pub scale_y: f64, + pub position_x: f64, + pub position_y: f64, + pub rotate: f64, +} + +impl Transform { + pub fn identity() -> Self { + Self { + scale_x: 1.0, + scale_y: 1.0, + ..Default::default() + } + } +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum MediaType { + Video, + Image, + Audio, +} + +#[derive(Clone, Debug)] +pub struct MediaSource { + pub id: String, + pub media_type: MediaType, + pub path: PathBuf, +} + +#[derive(Clone, Debug)] +pub struct VisualParams { + pub duration: MediaTime, + pub time_offset: MediaTime, + pub trim_start: MediaTime, + pub trim_end: MediaTime, + pub retime: Option<RetimeConfig>, + pub transform: Transform, + pub animations: Option<ElementAnimations>, + pub opacity: f64, + pub blend_mode: Option<BlendMode>, + pub effects: Vec<Effect>, + pub masks: Vec<Mask>, +} + +#[derive(Clone, Debug)] +pub struct TextNodeParams { + pub element: TextElement, + pub transform: Transform, + pub opacity: f64, + pub blend_mode: Option<BlendMode>, + pub canvas_center_x: f64, + pub canvas_center_y: f64, + pub canvas_height: f64, + pub effects: Vec<Effect>, +} + +#[derive(Clone, Debug)] +pub struct GraphicNodeParams { + pub visual: VisualParams, + pub definition_id: String, + pub params: ParamValues, +} + +#[derive(Clone, Debug)] +pub struct BlurBackgroundParams { + pub media_id: String, + pub path: PathBuf, + pub media_type: MediaType, + pub duration: MediaTime, + pub time_offset: MediaTime, + pub trim_start: MediaTime, + pub trim_end: MediaTime, + pub retime: Option<RetimeConfig>, + pub blur_intensity: f64, +} + +#[derive(Clone, Debug)] +pub struct EffectLayerParams { + pub effect_type: String, + pub effect_params: ParamValues, + pub time_offset: MediaTime, + pub duration: MediaTime, +} + +#[derive(Clone, Debug)] +pub struct StickerNodeParams { + pub visual: VisualParams, + pub sticker_id: String, + pub intrinsic_width: Option<f64>, + pub intrinsic_height: Option<f64>, +} + +#[derive(Clone, Debug)] +pub enum Node { + Root { duration: MediaTime, children: Vec<Node> }, + Color { color: String }, + BlurBackground(BlurBackgroundParams), + EffectLayer(EffectLayerParams), + Video { visual: VisualParams, media_id: String, path: PathBuf }, + Image { visual: VisualParams, path: PathBuf, max_source_size: Option<u32> }, + Sticker(StickerNodeParams), + Graphic(GraphicNodeParams), + Text(TextNodeParams), +} + +impl Node { + pub fn children(&self) -> &[Node] { + match self { + Node::Root { children, .. } => children, + _ => &[], + } + } +} |
