From adff749f33f2a6af83c1b6d565fba552815b2556 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Fri, 30 Oct 2026 10:23:11 +0700 Subject: [PATCH] Tests: Simple Choker keeps growing the matte down to -100 (#2102) Co-Authored-By: Claude Opus 5.5 --- crates/effects/src/matte.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/effects/src/matte.rs b/crates/effects/src/matte.rs index 4c42c9c39..d695a3b41 100644 --- a/crates/effects/src/matte.rs +++ b/crates/effects/src/matte.rs @@ -362,6 +362,22 @@ mod tests { assert!(a > 0.99 && c[0] > 0.5, "{c:?}"); } + /// #2102: negative Choke Matte keeps growing the matte past -20, down to -100: a 120 px hole + /// in an opaque frame closes a bit more with every step. + #[test] + fn simple_choker_grows_the_matte_at_large_negative_values() { + let mut img = Image::filled(200, 200, [1.0, 1.0, 1.0, 1.0]); + for y in 40..160 { + for x in 40..160 { + img.set(x, y, [0.0; 4]); + } + } + let filled = |c: f64| alpha_sum(&run("ec.matte.simplechoker", &[("chokeMatte", num(c))], img.clone())); + let sums: Vec = [-10.0, -20.0, -40.0, -60.0].into_iter().map(filled).collect(); + assert!(sums.windows(2).all(|w| w[1] > w[0] + 100.0), "{sums:?}"); + assert!((filled(-100.0) - 200.0 * 200.0).abs() < 1.0, "-100 closes the hole"); + } + #[test] fn matte_choker_defaults_shrink() { let img = square();