From 4a572572dbb79bf66cfae89cdc96463cd503cafb Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 17 Oct 2026 14:25:56 +0700 Subject: [PATCH] #635: no negative zero from the flipped tint --- crates/format/src/rest/props.rs | 4 ++-- crates/format/src/rest/tests.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/format/src/rest/props.rs b/crates/format/src/rest/props.rs index 0ee2d687..5fe20c71 100644 --- a/crates/format/src/rest/props.rs +++ b/crates/format/src/rest/props.rs @@ -208,8 +208,8 @@ fn image(cx: &mut Ctx, p: &Value) -> ImagePaint { saturation: filter("saturation"), temperature: filter("temperature"), // The files' tint runs from green (negative) to magenta (positive), in REST file JSON and - // .fig alike; a positive native tint adds green. - tint: -filter("tint"), + // .fig alike; a positive native tint adds green. (`0 - x`: no negative zero.) + tint: 0.0 - filter("tint"), highlights: filter("highlights"), shadows: filter("shadows"), }, diff --git a/crates/format/src/rest/tests.rs b/crates/format/src/rest/tests.rs index 97e5d828..281d0896 100644 --- a/crates/format/src/rest/tests.rs +++ b/crates/format/src/rest/tests.rs @@ -194,7 +194,7 @@ fn image_filter_tint_turns_magenta_positive_into_native_green_positive() { "fills": [{"type": "IMAGE", "imageRef": "tint", "filters": {"tint": tint}}] }) }; - let (doc, warnings) = one(json!([rect("Magenta", 0.75), rect("Green", -0.5)])); + let (doc, warnings) = one(json!([rect("Magenta", 0.75), rect("Green", -0.5), rect("Neutral", 0.0)])); let image = |name: &str| { let PaintKind::Image(image) = &named(&doc, name).fills[0].kind else { panic!("{name} is not an image fill") }; image @@ -202,6 +202,7 @@ fn image_filter_tint_turns_magenta_positive_into_native_green_positive() { // The same sign as a `.fig` import (`fig::tests::image_filters`). assert!(close(f64::from(image("Magenta").filters.tint), -0.75)); assert!(close(f64::from(image("Green").filters.tint), 0.5)); + assert!(image("Neutral").filters.tint.is_sign_positive(), "no negative zero"); assert!(!warnings.iter().any(|w| w.contains("approximate renderer")), "{warnings:?}"); }