#635: one tint sign for REST file JSON and .fig

Both carry the same image filter value, which the public docs describe as green when lower and
magenta when higher; a positive native tint adds green. Both readers flip it now (the .fig path
did, the REST path didn't). The .fig test message no longer names the product.
This commit is contained in:
bflatastic committed 2026-10-17 14:03:57 +07:00
1 parent 2ac4ce3a73
commit 48d74df226
3 files changed
+8 -6

No files matched your search

+1 -1
View File
@@ -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);
+3 -2
View File
@@ -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"),
},
+4 -3
View File
@@ -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:?}");
}