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/graphics/src/params.rs | 72 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 rust/crates/graphics/src/params.rs (limited to 'rust/crates/graphics/src/params.rs') diff --git a/rust/crates/graphics/src/params.rs b/rust/crates/graphics/src/params.rs new file mode 100644 index 00000000..6c0fedd2 --- /dev/null +++ b/rust/crates/graphics/src/params.rs @@ -0,0 +1,72 @@ +use scene::params::{ParamValue, ParamValues}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ParamGroup { + Stroke, +} + +impl ParamGroup { + pub fn as_str(&self) -> &'static str { + match self { + ParamGroup::Stroke => "stroke", + } + } +} + +#[derive(Debug, Clone, PartialEq)] +pub struct SelectOption { + pub value: &'static str, + pub label: &'static str, +} + +#[derive(Debug, Clone, PartialEq)] +pub enum ParamDefinition { + Number { + key: &'static str, + label: &'static str, + group: Option, + default: f64, + min: f64, + max: Option, + step: f64, + short_label: Option<&'static str>, + }, + Color { + key: &'static str, + label: &'static str, + group: Option, + default: &'static str, + }, + Select { + key: &'static str, + label: &'static str, + group: Option, + default: &'static str, + options: &'static [SelectOption], + }, +} + +impl ParamDefinition { + pub fn key(&self) -> &'static str { + match self { + ParamDefinition::Number { key, .. } => key, + ParamDefinition::Color { key, .. } => key, + ParamDefinition::Select { key, .. } => key, + } + } + + pub fn default_value(&self) -> ParamValue { + match self { + ParamDefinition::Number { default, .. } => ParamValue::Number(*default), + ParamDefinition::Color { default, .. } => ParamValue::String((*default).to_string()), + ParamDefinition::Select { default, .. } => ParamValue::String((*default).to_string()), + } + } +} + +pub fn build_default_param_values(params: &[ParamDefinition]) -> ParamValues { + params + .iter() + .map(|param| (param.key().to_string(), param.default_value())) + .collect() +} -- cgit v1.3.1