From de7f52f207b6189b2ec8b43be1bac0248854fa34 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 15 Nov 2026 07:31:11 +0000 Subject: [PATCH] test(xfl): tighten native color effect parity --- crates/xfl/src/import.rs | 5 +---- crates/xfl/src/tests.rs | 9 +++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/xfl/src/import.rs b/crates/xfl/src/import.rs index 2c195cf4..89c3acfb 100644 --- a/crates/xfl/src/import.rs +++ b/crates/xfl/src/import.rs @@ -622,10 +622,7 @@ impl<'a> Builder<'a> { if alpha != 1.0 { bright.with_alpha(alpha) } else { bright } } else { let offsets = native.offsets().map(|value| value / 255.0); - let t = ColorTransform { - mul: multipliers, - add: offsets, - }; + let t = ColorTransform { mul: multipliers, add: offsets }; if t.changes_colour() || t.add[3] != 0.0 { ColorEffect::Advanced(t) } else if alpha != 1.0 { diff --git a/crates/xfl/src/tests.rs b/crates/xfl/src/tests.rs index 9e1ca2ef..cc981731 100644 --- a/crates/xfl/src/tests.rs +++ b/crates/xfl/src/tests.rs @@ -226,7 +226,8 @@ fn shared_native_color_effect_view_preserves_anicraft_style_mapping() { let (doc, _) = import(&files).unwrap(); let elements = &doc.timeline(0).layers[0].keyframes[0].elements; - let tint = ColorTransform { mul: [0.75, 0.75, 0.75, 0.5], add: [0.25 * 0x33 as f32 / 255.0, 0.25 * 0x66 as f32 / 255.0, 0.25 * 0x99 as f32 / 255.0, 0.0] }; + let mut tint = ColorTransform::tint(Rgba::hex(0x336699), 0.25); + tint.mul[3] = 0.5; assert_eq!(elements[0].name, "Tint"); assert_eq!(elements[0].color, ColorEffect::Advanced(tint).sanitized(), "tint keeps precedence over brightness and composes alpha"); @@ -236,7 +237,11 @@ fn shared_native_color_effect_view_preserves_anicraft_style_mapping() { let advanced = ColorTransform { mul: [2.0, 1.0, -0.5, 0.5], add: [1.0, -0.5, 0.0, 128.0 / 255.0] }; assert_eq!(elements[2].name, "Advanced"); - assert_eq!(elements[2].color, ColorEffect::Advanced(advanced).sanitized(), "invalid multipliers default to identity and offsets stay in XFL byte units until mapping"); + assert_eq!( + elements[2].color, + ColorEffect::Advanced(advanced).sanitized(), + "invalid multipliers default to identity and offsets stay in XFL byte units until mapping" + ); } #[test]