#635: no negative zero from the flipped tint

This commit is contained in:
bflatastic
2026-10-17 14:25:56 +07:00
parent 1e85d54952
commit 4a572572db
2 changed files with 4 additions and 3 deletions
+2 -2
View File
@@ -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"),
},
+2 -1
View File
@@ -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:?}");
}