mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Smart objects: an identity warp test allows the warp kernel's difference (#17577)
The test now checks the stored warp is the identity in source space and lets the pixels differ by the smooth warp kernel, still well under half a pixel of misplacement. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
6d2b2fe148
commit
4e5deed971
1 file changed
+10
-1
@@ -1038,7 +1038,16 @@ fn identity_mesh_on_a_skewed_smart_object_changes_nothing() {
|
||||
let mesh = photocraft_geom::warp::BezierMesh::fit(&place, vec![0.0, 1.0], vec![0.0, 0.25, 1.0]);
|
||||
let rect = [x0, y0, x1, y1 + 10.0];
|
||||
s.execute("layer.smartObjects.warp", json!({"layer": id, "style": "custom", "rect": rect, "mesh": mesh})).unwrap();
|
||||
assert!(mean_diff(&before, &flat(&s)) < 0.01, "mean diff {}", mean_diff(&before, &flat(&s)));
|
||||
// In source space the stored warp leaves every point where it was.
|
||||
let w = active_smart(&s).warp.unwrap();
|
||||
for (u, v) in [(0.0, 0.0), (1.0, 0.0), (0.5, 0.3), (0.0, 1.0), (1.0, 1.0)] {
|
||||
let (x, y) = (b[0] + u * (b[2] - b[0]), b[1] + v * (b[3] - b[1]));
|
||||
let (wx, wy) = w.map(x, y);
|
||||
assert!((wx - x).abs() < 0.05 && (wy - y).abs() < 0.05, "({x}, {y}) -> ({wx}, {wy})");
|
||||
}
|
||||
// A warped smart object samples with the warp's smooth kernel (#17577), not the placement's
|
||||
// bicubic, so the pixels differ by that alone (about 0.012); half a pixel off is about 0.06.
|
||||
assert!(mean_diff(&before, &flat(&s)) < 0.02, "mean diff {}", mean_diff(&before, &flat(&s)));
|
||||
}
|
||||
|
||||
fn convert_to_layers(s: &mut Session) -> Value {
|
||||
|
||||
Reference in new issue
Block a user