Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

fix(atn): match exact 0.5 center and assert state preservation on error

seotarek86b7a4f269d2
diff --git a/crates/engine/src/atn_cmds.rs b/crates/engine/src/atn_cmds.rs
index 40af5140d..60e32b11e 100644
--- a/crates/engine/src/atn_cmds.rs
+++ b/crates/engine/src/atn_cmds.rs
@@ -2675,9 +2675,11 @@ fn radial_blur_from(d: &Descriptor) -> Mapped {
}
fn radial_blur_to(_: &str, p: &Value) -> Option<Descriptor> {
+ // Photoshop's Radial Blur has no center parameter and always blurs from the center (0.5, 0.5).
+ // An explicit center must match 0.5 exactly; any non-default center cannot be faithfully exported.
let is_default_center = |k: &str| match p.get(k) {
None | Some(Value::Null) => true,
- Some(v) => v.as_f64().is_some_and(|f| f.is_finite() && (f - 0.5).abs() <= 1e-4),
+ Some(v) => v.as_f64() == Some(0.5),
};
if !is_default_center("centerX") || !is_default_center("centerY") {
return None;
diff --git a/crates/engine/src/atn_cmds/tests.rs b/crates/engine/src/atn_cmds/tests.rs
index dd5915355..0ad2e6bf0 100644
--- a/crates/engine/src/atn_cmds/tests.rs
+++ b/crates/engine/src/atn_cmds/tests.rs
@@ -1411,8 +1411,10 @@ fn radial_blur_off_center_strict_export_refuses_silent_recentering() {
"OffCenter",
vec![("filter.blur.radialBlur".into(), json!({"amount": 50, "method": "spin", "quality": "good", "centerX": 0.1, "centerY": 0.2}))],
));
+ let before_actions = s.actions.list.clone();
let err = s.execute("actions.save", json!({"action": "OffCenter"}));
assert!(err.is_err(), "strict export must reject off-center radial blur rather than silently recentering it");
+ assert_eq!(s.actions.list, before_actions, "actions list must remain unchanged after rejected save");
// With skipUnsupported: true, off-center radial blur is skipped
let skipped = s.execute("actions.save", json!({"action": "OffCenter", "skipUnsupported": true})).unwrap();