diff --git a/crates/format/src/fig/image_filter_tests.rs b/crates/format/src/fig/image_filter_tests.rs index 3216b2b31..83792123d 100644 --- a/crates/format/src/fig/image_filter_tests.rs +++ b/crates/format/src/fig/image_filter_tests.rs @@ -66,7 +66,7 @@ fn image_filters_import_from_current_container_and_skip_ambiguous_data() { assert!((current.filters.contrast - 0.3).abs() < 1e-6, "observed raw contrast remains 0.3"); assert!((current.filters.saturation + 0.4).abs() < 1e-6, "vibrance maps to saturation"); assert!((current.filters.temperature - 0.5).abs() < 1e-6); - assert!((current.filters.tint + 1.0).abs() < 1e-6, "positive Figma tint converts once at the REST boundary"); + assert!((current.filters.tint + 1.0).abs() < 1e-6, "a positive (magenta) tint in the file is a negative native tint"); assert!((current.filters.highlights + 0.6).abs() < 1e-6); assert!((current.filters.shadows - 0.7).abs() < 1e-6); assert!((get("Negative tint").filters.tint - 1.0).abs() < 1e-6); diff --git a/crates/format/src/rest/props.rs b/crates/format/src/rest/props.rs index ac4d35196..0ee2d687b 100644 --- a/crates/format/src/rest/props.rs +++ b/crates/format/src/rest/props.rs @@ -207,8 +207,9 @@ fn image(cx: &mut Ctx, p: &Value) -> ImagePaint { contrast: filter("contrast"), saturation: filter("saturation"), temperature: filter("temperature"), - // A positive tint in .fig sources moves toward magenta; native positive tint adds green. - tint: if fig { -filter("tint") } else { filter("tint") }, + // 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"), highlights: filter("highlights"), shadows: filter("shadows"), }, diff --git a/crates/format/src/rest/tests.rs b/crates/format/src/rest/tests.rs index 282476efe..97e5d8288 100644 --- a/crates/format/src/rest/tests.rs +++ b/crates/format/src/rest/tests.rs @@ -187,7 +187,7 @@ fn paints_gradients_and_image_placeholders() { } #[test] -fn public_rest_image_filter_tint_keeps_its_sign() { +fn image_filter_tint_turns_magenta_positive_into_native_green_positive() { let rect = |name: &str, tint: f64| { json!({ "id": name, "name": name, "type": "RECTANGLE", "relativeTransform": at(0.0, 0.0), "size": {"x": 10, "y": 10}, @@ -199,8 +199,9 @@ fn public_rest_image_filter_tint_keeps_its_sign() { let PaintKind::Image(image) = &named(&doc, name).fills[0].kind else { panic!("{name} is not an image fill") }; image }; - assert!(close(f64::from(image("Magenta").filters.tint), 0.75)); - assert!(close(f64::from(image("Green").filters.tint), -0.5)); + // 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!(!warnings.iter().any(|w| w.contains("approximate renderer")), "{warnings:?}"); }