From 32438ce25f69de99d2523b98237f62cfa90890d7 Mon Sep 17 00:00:00 2001 From: cashmere Date: Tue, 28 Jul 2026 20:14:51 +0200 Subject: 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) --- rust/crates/renderer/src/node.rs | 123 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 rust/crates/renderer/src/node.rs (limited to 'rust/crates/renderer/src/node.rs') 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, + pub transform: Transform, + pub animations: Option, + pub opacity: f64, + pub blend_mode: Option, + pub effects: Vec, + pub masks: Vec, +} + +#[derive(Clone, Debug)] +pub struct TextNodeParams { + pub element: TextElement, + pub transform: Transform, + pub opacity: f64, + pub blend_mode: Option, + pub canvas_center_x: f64, + pub canvas_center_y: f64, + pub canvas_height: f64, + pub effects: Vec, +} + +#[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, + 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, + pub intrinsic_height: Option, +} + +#[derive(Clone, Debug)] +pub enum Node { + Root { duration: MediaTime, children: Vec }, + Color { color: String }, + BlurBackground(BlurBackgroundParams), + EffectLayer(EffectLayerParams), + Video { visual: VisualParams, media_id: String, path: PathBuf }, + Image { visual: VisualParams, path: PathBuf, max_source_size: Option }, + Sticker(StickerNodeParams), + Graphic(GraphicNodeParams), + Text(TextNodeParams), +} + +impl Node { + pub fn children(&self) -> &[Node] { + match self { + Node::Root { children, .. } => children, + _ => &[], + } + } +} -- cgit v1.3.1