EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Shapes: export per-corner `rc.r` as a Lottie property
Camille Moined249f255ae78
diff --git a/crates/lottie/src/shapes.rs b/crates/lottie/src/shapes.rsindex fc823b775..5b9d29970 100644--- a/crates/lottie/src/shapes.rs+++ b/crates/lottie/src/shapes.rs@@ -239,11 +239,12 @@ pub(crate) fn export_items(ex: &mut Ex, contents: &PropGroup, label: &str) -> Velet names = ["topLeftRoundness", "topRightRoundness", "bottomRightRoundness", "bottomLeftRoundness"];let radii = names.map(|m| o.f(m));// Lottie `rc` has one `r`: four equal static radii export as that value.+ // `r` is a property (`{a, k}`) like the uniform branch writes, not a bare number.if radii.iter().all(|v| (v - radii[0]).abs() < 1e-6) && !names.iter().any(|m| o.animated(m)) && radii[0] >= 0.0 {- o.raw("r", json!(r(radii[0])));+ o.raw("r", json!({"a": 0, "k": r(radii[0])}));} else {o.ex.warn(format!("{}: per-corner roundness has no Lottie rectangle equivalent (roundness 0 exported)", o.label));- o.raw("r", json!(0));+ o.raw("r", json!({"a": 0, "k": 0}));}} else {o.put("r", "roundness", &anim::num);diff --git a/crates/lottie/src/tests.rs b/crates/lottie/src/tests.rsindex 24b4690eb..83c81e242 100644--- a/crates/lottie/src/tests.rs+++ b/crates/lottie/src/tests.rs@@ -919,12 +919,12 @@ fn per_corner_roundness_exports_equal_radii_and_warns_when_mixed() {// Four equal static radii: `rc.r` carries the value, no warning.let (p, cid) = shape([12.0; 4], 5.0, true);let (_, _, warnings, json) = roundtrip(&p, cid, &ExportOptions::default());- assert_eq!(rc(&json)["r"], json!(12.0));+ assert_eq!(rc(&json)["r"], json!({"a": 0, "k": 12.0}));assert!(!warnings.iter().any(|w| w.contains("per-corner")), "{warnings:?}");// Mixed radii: not representable, roundness 0 exported with a warning.let (p, cid) = shape([10.0, 20.0, 10.0, 20.0], 5.0, true);let (_, _, warnings, json) = roundtrip(&p, cid, &ExportOptions::default());- assert_eq!(rc(&json)["r"], json!(0));+ assert_eq!(rc(&json)["r"], json!({"a": 0, "k": 0}));assert!(warnings.iter().any(|w| w.contains("per-corner roundness")), "{warnings:?}");// The checkbox off exports the single Roundness and ignores the four values.let (p, cid) = shape([10.0, 20.0, 10.0, 20.0], 5.0, false);