mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-30 04:57:54 -06:00
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:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user