PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Merge main into fix/crop-target-size-samplers
David Mann43a718ffab48
diff --cc crates/engine/src/sampler_cmds.rsindex b7e92550f,57787b2e8..4d70a2bb2--- a/crates/engine/src/sampler_cmds.rs+++ b/crates/engine/src/sampler_cmds.rs@@@ -385,27 -443,10 +443,28 @@@ mod testss.execute("image.crop", json!({"x": 40, "y": 30, "width": 20, "height": 20, "angle": 90})).unwrap();let p = points(&mut s);assert_eq!(p.len(), 1);- assert_eq!(p[0]["position"], json!([10.0, 10.0]));+ assert_eq!(p[0]["position"], json!([10.0, 9.0]));+ assert_eq!(p[0]["rgb"], json!([0, 0, 0]));}+ #[test]+ fn a_crop_to_a_target_size_scales_points() {+ // The crop resamples the 20 x 20 area to 40 x 40: the point (10, 10 after the shift) doubles.+ for angle in [None, Some(90)] {+ let mut s = session();+ s.execute("view.colorSamplers.add", json!({"x": 50, "y": 40})).unwrap();+ let mut p = json!({"x": 40, "y": 30, "width": 20, "height": 20, "targetWidth": 40, "targetHeight": 40});+ if let Some(a) = angle {+ p["angle"] = json!(a);+ }+ s.execute("image.crop", p).unwrap();+ let p = points(&mut s);+ assert_eq!(p.len(), 1, "angle {angle:?}");+ assert_eq!(p[0]["position"], json!([20.0, 20.0]), "angle {angle:?}");+ assert_eq!(s.take_samplers_removed(), 0, "angle {angle:?}");+ }+ }+#[test]fn bad_params_and_no_document_are_errors_not_panics() {let mut s = Session::new();