diff --git a/crates/engine/src/cmd/object/commands.rs b/crates/engine/src/cmd/object/commands.rs index 5e451275b6..a635a56987 100644 --- a/crates/engine/src/cmd/object/commands.rs +++ b/crates/engine/src/cmd/object/commands.rs @@ -61,7 +61,7 @@ pub fn specs() -> Vec { "Shear…", ["Object", "Transform"], None, - "{ids?: [id…] (selected first; default: the selection), angle: deg (positive turns the vertical edges clockwise with the horizontal axis, the top to the right; the horizontal edges clockwise with the vertical axis, the right side down), axis?: \"horizontal\"|\"vertical\", origin?, copy?, objects?: bool (Transform Objects, default true; false: the art stays and, with patterns, only its pattern tiles transform), patterns?: bool (Transform Patterns: pattern fills and strokes transform with the art; default: prefs transformPatternTiles), typeAreas?: bool (area type: the frame is reshaped and the text reflows at its size)}. With anchors selected with Direct Selection (and no copy), only those anchors and their handles transform, about the centre of their own box.", + "{ids?: [id…] (selected first; default: the selection), angle: deg (positive turns the vertical edges clockwise with the horizontal axis, the top to the right; the horizontal edges clockwise with the vertical axis, the right side down), axis?: \"horizontal\"|\"vertical\"|deg (the line the art slides along, counter-clockwise from horizontal on the page, -359 to 359; 0: horizontal, 90: vertical; omitted: horizontal), origin?, copy?, objects?: bool (Transform Objects, default true; false: the art stays and, with patterns, only its pattern tiles transform), patterns?: bool (Transform Patterns: pattern fills and strokes transform with the art; default: prefs transformPatternTiles), typeAreas?: bool (area type: the frame is reshaped and the text reflows at its size)}. With anchors selected with Direct Selection (and no copy), only those anchors and their handles transform, about the centre of their own box.", has_selection, shear ), diff --git a/crates/engine/src/cmd/object/transform.rs b/crates/engine/src/cmd/object/transform.rs index 25a831622e..51e9ab3b51 100644 --- a/crates/engine/src/cmd/object/transform.rs +++ b/crates/engine/src/cmd/object/transform.rs @@ -420,11 +420,29 @@ pub(super) fn shear(s: &mut Session, p: &Value) -> Result { let ids = selected_roots_to_transform(s)?; let o = origin_of(s, p, &ids)?; let t = f64_or(p, "angle", 0.0).clamp(-89.0, 89.0).to_radians().tan(); - let vertical = choice(p, "object.shear", "axis", &["horizontal", "vertical"])? == Some("vertical"); - let m = if vertical { Affine::new([1.0, t, 0.0, 1.0, 0.0, 0.0]) } else { Affine::new([1.0, 0.0, -t, 1.0, 0.0, 0.0]) }; + let horizontal = Affine::new([1.0, 0.0, -t, 1.0, 0.0, 0.0]); + // A named axis, or a line on the page at an angle in degrees, counter-clockwise from horizontal. + let m = match p.get("axis") { + None | Some(Value::Null) => horizontal, + Some(Value::String(a)) if a == "horizontal" => horizontal, + Some(Value::String(a)) if a == "vertical" => Affine::new([1.0, t, 0.0, 1.0, 0.0, 0.0]), + Some(Value::Number(n)) if n.as_f64().is_some_and(|a| (-SHEAR_AXIS_MAX..=SHEAR_AXIS_MAX).contains(&a)) => { + // y is down, so the page's counter-clockwise angle turns the other way on screen. + let r = -n.as_f64().unwrap_or(0.0).to_radians(); + Affine::rotate(r) * horizontal * Affine::rotate(-r) + } + Some(v) => { + let given = v.as_str().map_or_else(|| v.to_string(), str::to_string); + let range = format!("from -{SHEAR_AXIS_MAX} to {SHEAR_AXIS_MAX}"); + return Err(bad("object.shear", format!("axis must be \"horizontal\", \"vertical\" or an angle in degrees {range}, not `{given}`"))); + } + }; apply_transform(s, "Shear", ids, about(o, m), p, true) } +/// The largest angle, either way from horizontal, of the axis `object.shear` takes in degrees. +const SHEAR_AXIS_MAX: f64 = 359.0; + /// The last transform on the selection, with the options `last_transform` keeps for it; an option /// that `p` sets to true or false (a recorded Transform Again's) takes precedence. A Transform /// Each is repeated by running it again (its transform is per object, about each one's bounds). diff --git a/crates/engine/src/tests/xform.rs b/crates/engine/src/tests/xform.rs index 4e13e5fe02..a17f61790e 100644 --- a/crates/engine/src/tests/xform.rs +++ b/crates/engine/src/tests/xform.rs @@ -480,8 +480,8 @@ fn reflect_and_shear_tools() { assert!((b.width() - 150.0).abs() < 1e-6, "{b:?}"); } -/// Reflect and Shear return an error for an `axis` they don't take (Reflect's names it and also -/// takes an angle): nothing moves and no undo step is recorded. A null `axis` counts as not given: Reflect +/// Reflect and Shear return an error for an `axis` they don't take, naming it (both also take an +/// angle, Shear's from -359° to 359°): nothing moves and no undo step is recorded. A null `axis` counts as not given: Reflect /// then reflects across the vertical axis and Shear shears along the horizontal one. #[test] fn reflect_and_shear_reject_unknown_axes_without_changing_state() { @@ -489,13 +489,17 @@ fn reflect_and_shear_reject_unknown_axes_without_changing_state() { let a = rect(&mut s, 10.0, 20.0, 30.0, 10.0); let n = undo_len(&s); let reflect = "axis must be \"vertical\", \"horizontal\" or an angle in degrees"; - let shear = "`axis` must be one of horizontal, vertical"; + let shear = "axis must be \"horizontal\", \"vertical\" or an angle in degrees from -359 to 359"; for (cmd, p, msg) in [ ("object.reflect", json!({"axis": "diagonal", "origin": [0, 0]}), format!("{reflect}, not `diagonal`")), ("object.reflect", json!({"axis": "45", "origin": [0, 0]}), format!("{reflect}, not `45`")), ("object.reflect", json!({"axis": true, "origin": [0, 0]}), format!("{reflect}, not `true`")), - ("object.shear", json!({"angle": 30, "axis": "diagonal"}), shear.to_string()), - ("object.shear", json!({"angle": 30, "axis": 90}), shear.to_string()), + ("object.shear", json!({"angle": 30, "axis": "diagonal"}), format!("{shear}, not `diagonal`")), + ("object.shear", json!({"angle": 30, "axis": "90"}), format!("{shear}, not `90`")), + ("object.shear", json!({"angle": 30, "axis": 360}), format!("{shear}, not `360`")), + ("object.shear", json!({"angle": 30, "axis": -359.5}), format!("{shear}, not `-359.5`")), + ("object.shear", json!({"angle": 30, "axis": [45]}), format!("{shear}, not `[45]`")), + ("object.shear", json!({"angle": 30, "axis": false}), format!("{shear}, not `false`")), ] { let e = s.execute(cmd, &p).expect_err(&format!("{cmd} {p}")); assert_eq!(e.to_string(), format!("invalid parameters for `{cmd}`: {msg}")); @@ -511,6 +515,56 @@ fn reflect_and_shear_reject_unknown_axes_without_changing_state() { assert!((b.y0 + 30.0).abs() < 1e-6 && (b.y1 + 20.0).abs() < 1e-6 && b.width() > 30.0, "along the horizontal axis: {b:?}"); } +/// Shear along an axis at an angle, counter-clockwise from horizontal on the page: each point +/// slides along the axis by the tangent of the shear angle times its distance across the axis +/// from the origin. -359° and 359° are taken, the shear is one undo step and Transform Again +/// repeats it; 0° and 90° shear as the named axes do, and a copy leaves the original in place. +#[test] +fn shear_along_an_axis_at_an_angle() { + let anchors = |s: &Session, id: NodeId| -> Vec { + s.doc().unwrap().doc.node(id).unwrap().path_data().unwrap().anchors().map(|(_, _, an)| an.p).collect() + }; + // The axis's direction and the direction a quarter turn counter-clockwise from it, with y down. + let sheared = |p: Point, o: Point, axis: f64, angle: f64| { + let (a, k) = (axis.to_radians(), angle.to_radians().tan()); + let (along, across) = (Vec2::new(a.cos(), -a.sin()), Vec2::new(-a.sin(), -a.cos())); + p + along * (k * (p - o).dot(across)) + }; + let near = |a: &[Point], b: &[Point]| a.len() == b.len() && a.iter().zip(b).all(|(p, q)| p.distance(*q) < 1e-9); + let o = Point::new(20.0, 30.0); + for (axis, angle) in [(45.0, 30.0), (-120.5, 20.0), (359.0, 30.0), (-359.0, -30.0), (30.0, 30.0)] { + let mut s = session(); + let a = rect(&mut s, 100.0, 100.0, 60.0, 20.0); + let before = anchors(&s, a); + let n = undo_len(&s); + s.execute("object.shear", &json!({"angle": angle, "axis": axis, "origin": [o.x, o.y]})).unwrap(); + let want: Vec = before.iter().map(|p| sheared(*p, o, axis, angle)).collect(); + assert!(near(&anchors(&s, a), &want), "{axis}° {angle}°: {:?}, not {want:?}", anchors(&s, a)); + assert_eq!(undo_len(&s), n + 1, "one undo step"); + s.execute("object.transformAgain", &json!({})).unwrap(); + let again: Vec = want.iter().map(|p| sheared(*p, o, axis, angle)).collect(); + assert!(near(&anchors(&s, a), &again), "Transform Again at {axis}°: {:?}", anchors(&s, a)); + } + for (named, axis) in [("horizontal", 0.0), ("vertical", 90.0), ("vertical", -270.0)] { + let mut s = session(); + let a = rect(&mut s, 100.0, 100.0, 60.0, 20.0); + s.execute("object.shear", &json!({"angle": 30, "axis": named, "origin": [o.x, o.y]})).unwrap(); + let by_name = anchors(&s, a); + s.execute("edit.undo", &json!({})).unwrap(); + s.execute("object.shear", &json!({"angle": 30, "axis": axis, "origin": [o.x, o.y]})).unwrap(); + assert!(near(&anchors(&s, a), &by_name), "{axis}° shears as {named}: {:?}, not {by_name:?}", anchors(&s, a)); + } + let mut s = session(); + let a = rect(&mut s, 100.0, 100.0, 60.0, 20.0); + let before = anchors(&s, a); + s.execute("object.shear", &json!({"angle": 30, "axis": 45, "origin": [o.x, o.y], "copy": true})).unwrap(); + assert!(near(&anchors(&s, a), &before), "the original stays: {:?}", anchors(&s, a)); + let copy = *s.doc().unwrap().selection.objects.first().unwrap(); + assert_ne!(copy, a, "the copy is selected"); + let want: Vec = before.iter().map(|p| sheared(*p, o, 45.0, 30.0)).collect(); + assert!(near(&anchors(&s, copy), &want), "the copy is sheared: {:?}", anchors(&s, copy)); +} + #[test] fn distort_command_maps_corners() { let mut s = session(); diff --git a/crates/ui-egui/src/dialogs/form.rs b/crates/ui-egui/src/dialogs/form.rs index c57671803e..b46f35a79f 100644 --- a/crates/ui-egui/src/dialogs/form.rs +++ b/crates/ui-egui/src/dialogs/form.rs @@ -111,7 +111,7 @@ fn lengths(kind: &str) -> &'static [&'static str] { /// number: fields that ↑/↓ step by one (Shift: ten) and that do math, as the distances do. fn suffix(kind: &str, key: &str) -> Option<&'static str> { match (kind, key) { - ("rotate" | "shear" | "reflect" | "move" | "lineSegment", "angle") => Some("°"), + ("rotate" | "shear" | "reflect" | "move" | "lineSegment", "angle") | ("shear", "axisAngle") => Some("°"), ("scale", "sx" | "sy") | ("spiral", "decay") => Some("%"), _ => None, } @@ -138,6 +138,7 @@ fn order(kind: &str) -> &'static [&'static str] { "spiral" => &["radius", "decay", "segments"], "artboardOptions" => &["name", "width", "height"], "lineSegment" => &["length", "angle"], + "shear" => &["angle", "axis", "axisAngle"], _ => &[], } } @@ -163,8 +164,7 @@ fn choices(kind: &str, key: &str) -> Vec<(&'static str, &'static str)> { match (kind, key) { ("offsetPath", "joins") => vec![("miter", tl!("Miter")), ("round", tl!("Round")), ("bevel", tl!("Bevel"))], ("average", "axis") => vec![axis("horizontal", "Horizontal"), axis("vertical", "Vertical"), axis("both", "Both")], - ("reflect", "axis") => vec![axis("horizontal", "Horizontal"), axis("vertical", "Vertical"), axis("angle", "Angle")], - ("shear", "axis") => vec![axis("horizontal", "Horizontal"), axis("vertical", "Vertical")], + ("reflect" | "shear", "axis") => vec![axis("horizontal", "Horizontal"), axis("vertical", "Vertical"), axis("angle", "Angle")], _ => vec![], } } @@ -368,11 +368,19 @@ pub(super) fn grid_then(ui: &mut egui::Ui, d: &mut Dialog, unit: Unit, more: imp if lengths.contains(&k.as_str()) { length_field(ui, d, &k, &humanized(&k), unit); } else if let Some(suffix) = suffix(&d.kind, &k) { - let row = row_label(ui, &humanized(&k)); + let label = match (d.kind.as_str(), k.as_str()) { + ("shear", "axisAngle") => tl!("Axis Angle").into(), + _ => humanized(&k), + }; + // Shear's Axis Angle is the axis while the Angle axis is chosen, and keeps its value otherwise. + let enabled = d.kind != "shear" || k != "axisAngle" || d.str("axis") == "angle"; + let row = row_label(ui, &label); ui.label_inputs_by(row.id, |ui| { - if let Some(v) = crate::widgets::plain_field(ui, ("dlg-num", &k), d.f64(&k, 0.0), suffix, 3, FIELD_W) { - d.fields.insert(k, json!(v)); - } + ui.add_enabled_ui(enabled, |ui| { + if let Some(v) = crate::widgets::plain_field(ui, ("dlg-num", &k), d.f64(&k, 0.0), suffix, 3, FIELD_W) { + d.fields.insert(k, json!(v)); + } + }); }); ui.end_row(); } else if let Some(ends) = skew_ends(&d.kind, &k) { diff --git a/crates/ui-egui/src/dialogs/tools.rs b/crates/ui-egui/src/dialogs/tools.rs index 6dbcfe28ce..5e7b0d4092 100644 --- a/crates/ui-egui/src/dialogs/tools.rs +++ b/crates/ui-egui/src/dialogs/tools.rs @@ -112,7 +112,7 @@ pub fn open_tool_dialog(app: &mut VectorcraftApp, kind: &str, p: Value) { "rotate" => json!({"angle": 0}), "reflect" => json!({"axis": "vertical", "angle": 90}), "scale" => json!({"sx": 100, "sy": 100, "uniform": true}), - "shear" => json!({"angle": 0, "axis": "horizontal"}), + "shear" => json!({"angle": 0, "axis": "horizontal", "axisAngle": 0}), _ => json!({}), }; if let (Some(b), Some(o)) = (base.as_object_mut(), p.as_object()) { diff --git a/crates/ui-egui/src/dialogs/transform.rs b/crates/ui-egui/src/dialogs/transform.rs index 4f576b561a..cf8c2e6b44 100644 --- a/crates/ui-egui/src/dialogs/transform.rs +++ b/crates/ui-egui/src/dialogs/transform.rs @@ -220,6 +220,7 @@ fn command(app: &VectorcraftApp, d: &Dialog) -> (&'static str, Value) { // The axis by name, or the angle it is at. "reflect" if d.str("axis") == "angle" => ("object.reflect", json!({"axis": d.f64("angle", 90.0)})), "reflect" => ("object.reflect", json!({"axis": d.fields.get("axis").cloned().unwrap_or(json!("vertical"))})), + "shear" if d.str("axis") == "angle" => ("object.shear", json!({"angle": d.f64("angle", 0.0), "axis": d.f64("axisAngle", 0.0)})), _ => ("object.shear", json!({"angle": d.f64("angle", 0.0), "axis": d.str("axis")})), }; params["copy"] = json!(d.bool("copy")); @@ -377,6 +378,54 @@ mod tests { } } + /// Shear's axis is Horizontal, Vertical or an angle: the Axis Angle field takes input only with + /// the Angle axis and keeps its value with the others, and OK sends that angle as the axis, + /// apart from the Shear Angle. + #[test] + fn shear_takes_an_axis_angle() { + use egui::accesskit::Role; + use egui_kittest::kittest::{NodeT, Queryable}; + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 300, "height": 300})).unwrap(); + app.run("shape.rectangle", json!({"x": 100, "y": 100, "width": 60, "height": 20})).unwrap(); + crate::menus::invoke(&mut app, "object.shear", json!({})); + let mut fonts = false; + let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1100.0, 900.0)).build_ui_state( + move |ui, app: &mut VectorcraftApp| { + if !std::mem::replace(&mut fonts, true) { + crate::theme::install_fonts(ui.ctx()); + return; + } + crate::dialogs::show(app, ui.ctx()); + }, + app, + ); + h.run_steps(5); + let dimmed = + |h: &egui_kittest::Harness<'_, VectorcraftApp>| h.get_by_role_and_label(Role::TextInput, "Axis Angle").accesskit_node().is_disabled(); + assert!(dimmed(&h), "Horizontal leaves the Axis Angle off"); + // Along an axis at 90° the left and right sides slide, 45° moving the right one by the width; + // at 0° the top and bottom slide by the height. Each case is undone before the next. + for (axis, axis_angle, sent, size) in + [("angle", 90, json!(90.0), (60.0, 80.0)), ("angle", 0, json!(0.0), (80.0, 20.0)), ("vertical", 30, json!("vertical"), (60.0, 80.0))] + { + let d = h.state_mut().ui.dialog.as_mut().unwrap(); + d.fields.extend([("axis".to_string(), json!(axis)), ("axisAngle".to_string(), json!(axis_angle)), ("angle".to_string(), json!(45))]); + h.run_steps(2); + assert_eq!(dimmed(&h), axis != "angle", "{axis}"); + assert_eq!(h.state().ui.dialog.as_ref().unwrap().fields["axisAngle"], json!(axis_angle), "the field keeps its value"); + crate::dialogs::confirm(h.state_mut()).unwrap(); + let app = h.state(); + let (cmd, p) = app.session.journal.last().unwrap(); + assert_eq!((cmd.as_str(), &p["axis"], &p["angle"]), ("object.shear", &sent, &json!(45.0)), "{axis} {axis_angle}"); + let b = app.session.doc().unwrap().doc.layers[0].children().unwrap()[0].geometric_bounds().unwrap(); + assert_eq!((b.width().round(), b.height().round()), size, "{axis} {axis_angle}"); + h.state_mut().run("edit.undo", json!({})).unwrap(); + crate::menus::invoke(h.state_mut(), "object.shear", json!({})); + h.run_steps(2); + } + } + /// #1915: Move's Distance and Angle follow Horizontal and Vertical, and they follow them back. /// The angle is counter-clockwise on the page and Vertical is down = +, so 90° moves up. #[test] diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 6034fa1ce0..4e3279a9e4 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -4399,6 +4399,7 @@ imageTrace Outline Контур Bevel Фаска Offset Отстъп Axis Ос + Axis Angle Ъгъл на оста axis Horizontal Хоризонтално axis Vertical Вертикално axis Both И двете diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index aa8c08329e..e061c21303 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -1710,6 +1710,7 @@ digits Malayalam Malajalam Underline Podvučeno Vertical Scale % Okomita skala % Axis Osa + Axis Angle Ugao ose ICF Top/Right ICF vrh/desno ICF Bottom/Left ICF dno/lijevo Show Font Height Options Prikaži opcije visine fonta diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 26434e9038..73870fc9f5 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -439,6 +439,7 @@ antiAlias Sharp Nítid Average… Mitjana… Away from the Line Allunyat de la línia Axis Eix + Axis Angle Angle de l’eix Axis side Costat de l’eix Axis: Eix: B4 B4 diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 9e61b2c552..084a4e3bbf 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -1779,6 +1779,7 @@ digits Malayalam Malajálamské Underline Podtržení Vertical Scale % Svislá změna velikosti % Axis Osa + Axis Angle Úhel osy ICF Top/Right ICF horní/pravý ICF Bottom/Left ICF dolní/levý Show Font Height Options Zobrazit možnosti výšky písma diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 5b1309e689..e74e76e9b8 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -4399,6 +4399,7 @@ digits Malayalam Malayalam Underline Understreget Vertical Scale % Lodret skalering % Axis Akse + Axis Angle Aksevinkel ICF Top/Right ICF øverst/højre ICF Bottom/Left ICF nederst/venstre Show Font Height Options Vis indstillinger for skrifthøjde diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 8bf9ea1831..c49cc51c9f 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -4474,6 +4474,7 @@ imageTrace Outline Kontur Bevel Abgeflacht Offset Versatz Axis Achse + Axis Angle Achsenwinkel axis Horizontal Horizontal axis Vertical Vertikal axis Both Beide diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index c8b55b2331..1c427f2113 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -4926,6 +4926,7 @@ digits Malayalam Μαλαγιάλαμ {people} contributors · {commits} commits {people} συνεισφέροντες · {commits} commits Joins Συνδέσεις Axis Άξονας + Axis Angle Γωνία άξονα Drag to move Σύρετε για μετακίνηση Drag to float as a toolbar Σύρετε για αποδέσμευση ως γραμμή εργαλείων Put back in the toolbar Επαναφορά στη γραμμή εργαλείων diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index af8b5f67af..7ea05ee7b4 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -4556,6 +4556,7 @@ imageTrace Outline Contorno Bevel Bisel Offset Desplazamiento Axis Eje + Axis Angle Ángulo del eje axis Horizontal Horizontal axis Vertical Vertical axis Both Ambos diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 5bbb6060dd..4720388bfc 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -1755,6 +1755,7 @@ digits Malayalam Malajalam Underline Alleviivaus Vertical Scale % Pystyskaalaus % Axis Akseli + Axis Angle Akselin kulma ICF Top/Right ICF ylä/oikea ICF Bottom/Left ICF ala/vasen Show Font Height Options Näytä fontin korkeuden asetukset diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 9ee375b3e9..79b3b1166b 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -4538,6 +4538,7 @@ imageTrace Outline Contour Bevel Biseauté Offset Décalage Axis Axe + Axis Angle Angle de l’axe axis Horizontal Horizontal axis Vertical Vertical axis Both Les deux diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index 9f7afbf784..b07d368f6f 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -230,6 +230,7 @@ Anchors selected: {count} પસંદ કરેલા એન્કર: {count} Anchors: એન્કર: Angle ખૂણો + Axis Angle અક્ષનો ખૂણો Angle: ખૂણો: Angled Strokes… ત્રાંસા સ્ટ્રોક… Angles ખૂણા diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 11f699cf54..14e5d821ed 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -537,6 +537,7 @@ antiAlias Sharp शार्प Average… औसत… Away from the Line लाइन से दूर Axis अक्ष + Axis Angle अक्ष कोण Axis side अक्ष की तरफ़ Axis: अक्ष: B4 B4 diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index d158566339..0c5a81bc75 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -387,6 +387,7 @@ font-technology Variable Változó Average Átlagolás Average… Átlagolás… Axis Tengely + Axis Angle Tengely szöge Axis side Tengely oldala Axis: Tengely: B4 B4 diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 6f0af753db..bd123083c5 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -1637,6 +1637,7 @@ digits Malayalam Malayalam Underline Garis bawah Vertical Scale % Skala vertikal % Axis Sumbu + Axis Angle Sudut sumbu ICF Top/Right ICF atas/kanan ICF Bottom/Left ICF bawah/kiri Show Font Height Options Tampilkan opsi tinggi font diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 634cfc4faa..d5dccf1220 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -4612,6 +4612,7 @@ imageTrace Outline Contorno Bevel Smussato Offset Spostamento Axis Asse + Axis Angle Angolo dell'asse axis Horizontal Orizzontale axis Vertical Verticale axis Both Entrambi diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 2acb73fcf5..ccbf63f245 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -4553,6 +4553,7 @@ imageTrace Outline アウトライン Bevel ベベル Offset オフセット Axis 軸 + Axis Angle 軸の角度 axis Horizontal 水平方向 axis Vertical 垂直方向 axis Both 両方 diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 8b9db73874..39834095ef 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -3815,6 +3815,7 @@ digits Malayalam მალაიალამური Underline ხაზგასმული Vertical Scale % ვერტიკალური მასშტაბი % Axis ღერძი + Axis Angle ღერძის კუთხე ICF Top/Right ICF ზედა/მარჯვენა ICF Bottom/Left ICF ქვედა/მარცხენა Show Font Height Options შრიფტის სიმაღლის პარამეტრების ჩვენება diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index c4bd2b6dc7..32b3cf4232 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -4537,6 +4537,7 @@ imageTrace Outline 윤곽선 Bevel 베벨 Offset 오프셋 Axis 축 + Axis Angle 축 각도 axis Horizontal 가로 axis Vertical 세로 axis Both 양쪽 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 1f55d4200b..536f350325 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -2273,6 +2273,7 @@ digits Malayalam Malayalam Underline Onderstrepen Vertical Scale % Verticale schaal % Axis As + Axis Angle Ashoek ICF Top/Right ICF boven/rechts ICF Bottom/Left ICF onder/links Show Font Height Options Opties voor letterhoogte tonen diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 73439e8eb9..90b2c8944a 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -1691,6 +1691,7 @@ digits Malayalam Malajalam Underline Podkreślenie Vertical Scale % Skala pionowa % Axis Oś + Axis Angle Kąt osi ICF Top/Right ICF góra/prawo ICF Bottom/Left ICF dół/lewo Show Font Height Options Pokaż opcje wysokości czcionki diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 2f616b66f2..a02a136dba 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -5710,6 +5710,7 @@ variable-list-end {0}, {1} {0} e {1} [Normal Paragraph Style] [Estilo de Parágrafo Normal] Joins Junções Axis Eixo + Axis Angle Ângulo do eixo Run Executar Run Script Executar script Stop Script Parar script diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 1ea40be06f..4fb8932104 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -4590,6 +4590,7 @@ imageTrace Outline Контур Bevel Скос Offset Смещение Axis Ось + Axis Angle Угол оси axis Horizontal Горизонтально axis Vertical Вертикально axis Both Оба diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 7c6fa5ea88..4057521a47 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -4463,6 +4463,7 @@ imageTrace Outline Kontur Bevel Fasning Offset Förskjutning Axis Axel + Axis Angle Axelvinkel axis Horizontal Horisontell axis Vertical Vertikal axis Both Båda diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index fb01af1c7f..9c75438e1b 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -4317,6 +4317,7 @@ imageTrace Outline Kontur Bevel Eğim Offset Ofset Axis Eksen + Axis Angle Eksen açısı axis Horizontal Yatay axis Vertical Dikey axis Both Her İkisi diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index f1c63d7cf1..b947e57818 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -4601,6 +4601,7 @@ imageTrace Outline Контур Bevel Скіс Offset Зміщення Axis Вісь + Axis Angle Кут осі axis Horizontal Горизонтальна axis Vertical Вертикальна axis Both Обидві diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 463c91b709..26bd22b4ea 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -317,6 +317,7 @@ font-technology Variable Biến thiên Average Trung bình Average… Trung bình… Axis Trục + Axis Angle Góc trục Axis side Mặt trục Axis: Trục: Back Sau diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 4e77e27618..b8baa0eb34 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -5982,6 +5982,7 @@ font-technology Variable 可变 Bevel 斜角 Offset 偏移 Axis 轴 + Axis Angle 轴角度 axis Horizontal 水平 axis Vertical 垂直 axis Both 两者 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 374679c815..5024806afb 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -5812,6 +5812,7 @@ imageTrace Outline 輪廓 Bevel 斜角 Offset 位移 Axis 軸 + Axis Angle 軸角度 axis Horizontal 水平 axis Vertical 垂直 axis Both 兩者 diff --git a/crates/ui-egui/src/menus/invoke.rs b/crates/ui-egui/src/menus/invoke.rs index 996622040a..aa91d84bc5 100644 --- a/crates/ui-egui/src/menus/invoke.rs +++ b/crates/ui-egui/src/menus/invoke.rs @@ -55,7 +55,7 @@ pub(super) fn menu_dialog(app: &VectorcraftApp, id: &str) -> Option<(&'static st // Transform Each opens on the values it was last confirmed with (#1732). "object.transformEach" => (crate::dialogs::transform_each::KIND, crate::dialogs::transform_each::open_fields(app)), "object.reflect" => ("reflect", json!({"axis": "vertical", "angle": 90})), - "object.shear" => ("shear", json!({"angle": 0, "axis": "horizontal"})), + "object.shear" => ("shear", json!({"angle": 0, "axis": "horizontal", "axisAngle": 0})), "path.average" => ("average", json!({"axis": "both"})), // Average & Join opens on the joined anchor chosen last (Corner the first time). "path.averageJoin" if app.ui.average_join.is_object() => ("averageJoin", app.ui.average_join.clone()), diff --git a/docs/mcp.md b/docs/mcp.md index cf4e7dc51e..7862fe4945 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -6695,6 +6695,21 @@ and Shift steps follow the box the same way; a Reflect axis drawn with the tool {"name":"run_command","arguments":{"command":"object.reflect","params":{"axis":"vertical","basis":"page"}}} ``` +## Shear along an angled axis + +`object.shear` takes `axis` as `"horizontal"`, `"vertical"` or a number of degrees from -359 to 359. A number is a +line on the page at that angle, counter-clockwise from horizontal, as `object.reflect`'s numeric `axis` is, and the art +slides along that line about `origin` by the shear `angle`, which stays a separate value. 0 shears as `"horizontal"` +and 90 as `"vertical"`. A numeric `axis` outside the range, a number given as a string, or any other value is an +error, and nothing changes. The shear `angle` is clamped to -89 through 89. The Shear dialog's Axis has Horizontal, +Vertical and Angle; the Axis Angle field beside it starts at 0° and takes input while Angle is chosen. The [help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/shear-objects.html) +describes the Angle axis as a custom slant direction between -359° and 359°, measured from the horizontal. The +counter-clockwise direction on the page and the 0° starting value are VectorCraft's own. + +```json +{"name":"run_command","arguments":{"command":"object.shear","params":{"angle":30,"axis":45}}} +``` + ## Free Distort on a turned bounding box `object.distort` maps the corners of `from` (TL, TR, BR, BL) onto `corners`, which are page coordinates. With @@ -7205,8 +7220,9 @@ wide. `object.align` needs `horizontal` or `vertical`. The three Align commands, `object.reflect` and `object.shear` return an error that lists the choices of a `horizontal`, `vertical`, `to`, `axis` or `bounds` param given another value -(`object.reflect` also takes an angle and names the value given), and one for a `spacing` that is not a number; nothing -moves. +(`object.reflect` and `object.shear` also take a numeric `axis` and name the value given; `object.shear`'s numeric +`axis` runs from -359 to 359, while its `angle` is clamped to -89 through 89), and one for a `spacing` that is not a +number; nothing moves. ## Glyph bounds for type diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index cc425310f5..72c484fffd 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1328,6 +1328,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Align, Distribute, Distribute Spacing, Reflect and Shear return an error for any `horizontal`, `vertical`, `to`, `axis`, `bounds` or `spacing` value they don't take, listing the choices, and Align returns one when a call gives neither `horizontal` nor `vertical`; nothing moves and no undo step is recorded. Align and Distribute act on the anchor points selected with Direct Selection: the points of one path align to each other, not to the artboard, and Distribute spaces them (#1641, fixes #1636; aligning to a key anchor is still missing). Transform Each opens on the scale, move, rotate, reflect, Random, reference point, Transform Objects and Preview it was last confirmed with (kept with the UI state; Copy never is), and its Copy button, left of Cancel, transforms a copy of each object as the [Scale multiple objects](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/scale-multiple-objects.html) help page has it; the Copy checkbox is gone (#1732; the remembered values follow a maintainer comment on the issue, not the help page). Its Scale section has the Relative and Absolute radio buttons the same page describes: percentages of each object's size, or the width and height it becomes (`object.transformEach` `relative`, which Transform Again repeats); Absolute measures each object's own box, and the scales act along its axes about that box's reference point, so a turned shape keeps its shape and objects of different sizes come out alike; the fields show the width and height the selected objects share and read "Mixed" when they differ or a side is 0 (a line's), each object measured by its own box, rotated with it, as the Transform panel and the Control bar show it (sizes they show alike count as the same), and a size typed into them sets every object to it (a side left Mixed keeps its size), our choices where the page leaves them open; a live Repeat scales its spacing by the geometric mean of the two factors, so its Absolute size is approximate. The link beside the two scales keeps them in proportion, as the shape dialogs' Width and Height link does (`__constrain`, kept with the dialog's values; where it sits is our choice, the public pages don't establish it). The panel lists Scale, Move and Rotate, then the Options in two columns (Transform Objects, Transform Patterns, Scale Strokes & Effects, Scale Corners; Reflect X, Reflect Y, Random), the Reference Point, and Preview at the left of the button row, level with Copy, Cancel and OK. Transform Again uses the Copy, Transform Patterns, Scale Strokes & Effects and Scale Corners choices of the transform it repeats; after a bounding-box handle drag on area type, it resizes the type area again and the type keeps its size (`object.transformAgain`). With anchors selected with Direct Selection, Move, Rotate, Scale, Reflect, Shear and Transform Again (the commands, their dialogs and the four tools' drags) transform only those anchors, their handles with them, about the centre of the box around them unless a point was clicked; a copy still copies the whole object (#1408; behaviour reference: [adjust path segments](https://helpx.adobe.com/illustrator/using/adjust-path-segments.html); the default reference point and the copy are our choices). The Move, Rotate, Scale, Reflect and Shear dialogs have a Preview checkbox, off when they open: while it is on the canvas follows the values, Cancel rolls it back and OK is still one undo step; Up/Down step the Rotate and Shear angles and the Scale percentages by 1, Shift by 10 (#1412). The five dialogs and Transform Each have Transform Objects beside Transform Patterns: off, the art stays and only its pattern tiles transform (`objects` on the transform commands), and Transform Again repeats the choice (#1448; behaviour reference: [scale objects](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/scale-objects.html); the checkboxes are always enabled and the Scale page's pair is applied to all of them, our choices). Reflect's axis is Horizontal, Vertical or an angle (#1460; [reflect objects along an axis](https://helpx.adobe.com/illustrator/desktop/manage-objects/arrange-objects/reflect-objects-along-an-axis.html)). + Shear's axis is Horizontal, Vertical or Angle: the Shear dialog's Axis Angle field, and a numeric `axis` on `object.shear`, set a line on the page from -359° to 359° that the art slides along, apart from the shear angle; an axis angle outside that range is an error and nothing changes ([the help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/shear-objects.html) describes this angled axis and its range; counter-clockwise from horizontal and the field's 0° start are our choices). Tests: `shear_along_an_axis_at_an_angle`, `reflect_and_shear_reject_unknown_axes_without_changing_state` and `shear_takes_an_axis_angle`. - **Pen:** Alt pressed in the middle of dragging out an anchor splits its handles and keeps the curve already shaped into it (only the outgoing handle follows the pointer); Space held while dragging out an anchor moves it, handles and all. A press on the first anchor of the path being drawn closes it whatever the drag then does: the drag shapes the closing curve and the release closes the path wherever it ends (#501). The first anchor's incoming handle mirrors the pointer, and a click leaves it retracted and the anchor a corner. Its outgoing handle stays where it is on a corner, so the first segment keeps its shape, and on a smooth anchor it turns to stay in line at its own length; Alt makes the anchor a corner and leaves the outgoing handle where it was when Alt went down. The Smart Pen's closing drag does the same (fixes #6634; `path.close`'s `in` and `out`; behavior reference: [draw with the Pen, Curvature, or Pencil tool](https://web.archive.org/web/20220614224656/https://helpx.adobe.com/illustrator/using/drawing-pen-curvature-or-pencil.html), where a click or drag on the first anchor closes the path and Alt breaks the pairing of the closing anchor's handles; which handles the drag sets are our choices). Space held during the Pen's closing drag moves the first anchor, handles and all, as that page also describes (`path.close`'s `at`). Clicking the last anchor of the path being drawn retracts its outgoing handle (convert cursor), and dragging from it pulls out a new one on its own. Auto Add/Delete: over a selected path, a click on a segment adds an anchor and a click on an anchor deletes it (add and delete cursors); Shift held, or Preferences › General › Disable Auto Add/Delete, starts a new path instead. Alt held over a handle end or an anchor of a selected path (the one being drawn too) works as the Anchor Point tool, with its convert cursor: dragging a handle moves it alone, clicking a smooth anchor makes it a corner, dragging an anchor pulls out new symmetric handles, dragging a segment reshapes it; drawing then goes on. Cmd (Ctrl) held drags with the selection tool chosen last, Direct Selection until one is (handles, anchors and segments of the path being drawn or another), and the Pen then goes on drawing its path while that stays selected; the pointer shows that tool's while Cmd is held. The same holds for agents (`pointer_gesture` with `mods.cmd`), as the borrowing now lives in the engine (#494). A drag's preview (the Pen's, the Anchor Point tool's, Direct Selection's handles and anchors) follows every position the pointer is seen at (#834): the canvas sends the tool a drag whenever the pointer's document position differs from the last one it sent, not only when egui's frame delta is non-zero (zero when a compositor coalesces motion and in the frame the pointer comes back into the window after leaving it), and a move that arrives in the release's own frame shapes the preview before the release commits it, once the press has dragged. With the Pen, a press that moves under 3 screen pixels is a click (a corner without handles), and a Precise Cursors command toggles the existing preference and can take a shortcut (#1663). Choosing the Pen again while it draws a path (P, a click on its button, `tool.select`) ends the path as Escape does: the path stays open and selected (a path inside a compound path leaves the compound path selected), the Pen stays chosen, and the next click starts a new path. The [help page](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/draw-shapes/preview-paths-drawn.html) describes P doing this with the preview off; doing it with Rubber Band on and for the button and `tool.select` are VectorCraft's own rules. - **Direct Selection (#1278):** clicking a segment picks its connection, with hollow endpoint anchors and only that curve's direction handles. Delete leaves the neighboring curves and appearance intact, opens/splits contours in one undo step, and another Delete removes the remaining selected path. A whole-path drag and deliberate anchor selection keep their existing behavior; egui frames and native control/art checked, OS mouse/visual QA pending. Where anchors of overlapping objects coincide, a click or drag takes the anchor of the selected object, also when another object lies over it (#1509, fixes #1508). Delete removes every selected anchor of a closed path (it used to remove the wrong ones), removes objects selected whole along with the selected anchors of others, and keeps the remainder selected so a second Delete removes it (#1674). In isolation mode Direct Selection and Group Selection pick only inside the isolated object (#1666). Escape cancels a Direct Selection drag (#1803, #1743). Double-clicking type (including type nested inside a group) switches to the Type tool and puts the caret at the clicked character.