feat(lottie): expose raw gradient wire values without opacity elision

This commit is contained in:
Tanish Manku authored and Dylan M. Taylor committed 2026-11-16 23:21:59 -05:00
1 parent 453b0da782
commit 89deb7fac4
2 files changed
+16

No files matched your search

+4
View File
@@ -114,3 +114,7 @@ The XML reader in `crates/plist/src/xml.rs` and its base64 compatibility helper
## GIMP palette reader
`crates/palette` extracts the GPL text parser from AniCraft `crates/doc/src/swatch.rs` at `d875a7feb250e6ab06aa28a37fb78a0699e88330` (MIT OR Apache-2.0), introduced by Tanish Manku in `a64130a9da9bdde545463b852d95d6a6774b1dfd` (AniCraft #270). The import preserves Tanish as primary author. Neutral RGB/name adaptation separates application display-name sanitization and the `Untitled` policy; validation tests and integration are subsequent Dylan M. Taylor changes.
The raw gradient wire ordering in `craft-lottie::Gradient::flat_values` follows
AniCraft's Lottie exporter by Tanish Manku (`63b39355`, `b9258b7b`), MIT OR Apache-2.0.
Sanitization, animation fitting and numeric output policy remain caller-owned.
+12
View File
@@ -29,6 +29,17 @@ impl Gradient {
Some(Self { colors, opacities })
}
/// Raw color groups (`position, r, g, b`), followed by all opacity pairs
/// (`position, alpha`), in input order. No rounding, clamping, or opacity elision.
///
/// This allocation-free view lets callers fit or interpolate equal-sized animated
/// values before applying their own numeric policy. In particular, opaque alpha
/// stops remain present so an opaque frame can interpolate to a translucent one.
/// Non-finite values are preserved; callers must sanitize them before JSON output.
pub fn flat_values(&self) -> impl Iterator<Item = f64> + '_ {
self.colors.iter().flat_map(|(p, [r, g, b])| [*p, *r, *g, *b]).chain(self.opacities.iter().flat_map(|(p, a)| [*p, *a]))
}
/// The flat list, rounded to six decimals. The alpha pairs are left out when every stop is
/// opaque.
pub fn to_flat(&self) -> Json {
@@ -44,3 +55,4 @@ impl Gradient {
json!(out)
}
}