test(xfl): tighten native color effect parity

This commit is contained in:
Dylan M. Taylor committed 2026-11-15 07:31:11 +00:00
1 parent 7a05cc1f08
commit de7f52f207
2 files changed
+8 -6

No files matched your search

+1 -4
View File
@@ -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 {
+7 -2
View File
@@ -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]