Shapes: export per-corner rc.r as a Lottie property

The equal-radii and zero fallback branches wrote a bare number where the
uniform branch (and every other Value field) writes `{a, k}`; external
players may reject that form even though our importer reads it. Write
`{"a": 0, "k": value}` in both branches and update the export assertions.
This commit is contained in:
Camille Moine
2026-10-30 01:24:59 +01:00
parent 3bc1caaedb
commit d249f255ae
2 changed files with 5 additions and 4 deletions
+3 -2
View File
@@ -239,11 +239,12 @@ pub(crate) fn export_items(ex: &mut Ex, contents: &PropGroup, label: &str) -> Ve
let 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);
+2 -2
View File
@@ -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);