From 9ecc8087c32b6bd408989d1b183fee76254d08f7 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 04:44:31 -0800 Subject: [PATCH] Shape tools: Backtick held while dragging leaves copies of the shape Holding Backtick while dragging out a rectangle, rounded rectangle, ellipse, polygon, star or line leaves a copy of the shape being drawn each time the pointer has moved 8 screen points with the key down, up to 128 copies a drag. Each copy is its own object, drawn as the drag showed it then. The release keeps the copies and the last shape as one undo step, and Escape takes them all back. The spacing and the limit are VectorCraft's own values. The `backquote` descriptions of `pointer_gesture` name the shape tools. Docs: docs/mcp.md, docs/target-app-parity.md. --- crates/engine/src/tests/shapetools.rs | 66 ++++++++++ crates/mcp/src/tools/definitions.rs | 4 +- crates/tools/src/shape.rs | 86 ++++++++++++- crates/tools/src/shape/tests.rs | 167 ++++++++++++++++++++++++++ docs/mcp.md | 14 +++ docs/target-app-parity.md | 1 + 6 files changed, 334 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/tests/shapetools.rs b/crates/engine/src/tests/shapetools.rs index 3c7d34a4fe..572c637dd5 100644 --- a/crates/engine/src/tests/shapetools.rs +++ b/crates/engine/src/tests/shapetools.rs @@ -149,6 +149,72 @@ fn a_shape_tool_turns_the_shape_from_just_outside_a_corner() { assert_eq!(angle(&s, id), 0.0, "rounding does not turn it"); } +/// How many objects the first layer holds. +fn objects(s: &Session) -> usize { + s.doc().unwrap().doc.layers[0].children().map(|c| c.len()).unwrap_or_default() +} + +/// Feed the pointer events `(kind, x, y, backtick held)` to the active tool, with no modifier. +fn quote_gesture(s: &mut Session, events: &[(PointerKind, f64, f64, bool)]) { + for (k, x, y, held) in events { + s.pointer(&PointerEvent { backquote: *held, ..PointerEvent::new(*k, *x, *y) }, view()).unwrap(); + } +} + +/// A Rectangle tool drag from (50, 50) with Backtick held from (100, 100) to (140, 100), let go +/// before (160, 120), all moved by `o` along both axes: two copies, 70 × 50 and 90 × 50 pt, and +/// the 110 × 70 pt rectangle it ends with. With `release`, the drag is let go; without, it is +/// still in progress. +fn trail(s: &mut Session, o: f64, release: bool) { + use PointerKind::{Down, Drag, Up}; + quote_gesture( + s, + &[ + (Down, 50.0 + o, 50.0 + o, false), + (Drag, 100.0 + o, 100.0 + o, true), + (Drag, 120.0 + o, 100.0 + o, true), + (Drag, 140.0 + o, 100.0 + o, true), + ], + ); + quote_gesture(s, &[(Drag, 160.0 + o, 120.0 + o, false)]); + if release { + quote_gesture(s, &[(Up, 160.0 + o, 120.0 + o, false)]); + } +} + +/// The sizes of the first layer's objects, back to front. +fn sizes(s: &Session) -> Vec<(f64, f64)> { + let ids: Vec = s.doc().unwrap().doc.layers[0].children().map(|c| c.iter().map(|n| n.id).collect()).unwrap_or_default(); + ids.into_iter().map(|id| bounds(s, id)).map(|r| (r.width(), r.height())).collect() +} + +/// Backtick held while a rectangle is dragged out leaves copies of it along the drag: each its own +/// object, and the release keeps them with the last rectangle as one undo step, with Real-time +/// Drawing and Editing on or off. Escape takes the copies back with the shape being drawn. +#[test] +fn a_backtick_drag_leaves_copies_of_the_shape_as_one_undo_step() { + for real_time in [true, false] { + let mut s = new_doc(); + s.execute("prefs.set", &json!({"key": "realTimeDrawing", "value": real_time})).unwrap(); + s.select_tool("rectangle", view()).unwrap(); + let steps = undo_steps(&s); + trail(&mut s, 0.0, true); + assert_eq!(sizes(&s), vec![(70.0, 50.0), (90.0, 50.0), (110.0, 70.0)], "real time {real_time}"); + assert_eq!(undo_steps(&s), steps + 1, "one undo step"); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(objects(&s), 0, "Undo takes all three back"); + s.execute("edit.redo", &json!({})).unwrap(); + assert_eq!(objects(&s), 3, "Redo puts all three back"); + // Escape takes back the copies and the shape being drawn, away from the selection. + let steps = undo_steps(&s); + trail(&mut s, 200.0, false); + s.tool_key(ToolKey::Escape, NONE, view()).unwrap(); + quote_gesture(&mut s, &[(PointerKind::Up, 360.0, 320.0, false)]); + assert_eq!(objects(&s), 3, "real time {real_time}: nothing new"); + assert_eq!(undo_steps(&s), steps, "no step"); + } +} + /// The Selection tool takes the centre point of an unfilled shape too: a drag there moves it /// instead of starting a marquee. #[test] diff --git a/crates/mcp/src/tools/definitions.rs b/crates/mcp/src/tools/definitions.rs index e549c2a362..1b86095c6e 100644 --- a/crates/mcp/src/tools/definitions.rs +++ b/crates/mcp/src/tools/definitions.rs @@ -209,7 +209,7 @@ pub fn tool_definitions() -> Vec { "x": num("Document x (pt)"), "y": num("Document y (pt)"), "mods": mods_schema(), - "backquote": {"type": "boolean", "description": "Backquote held for this event: Selection and transform tool drags transform only pattern paint"}, + "backquote": {"type": "boolean", "description": "Backquote held for this event: Selection and transform tool drags transform only pattern paint; Rectangle, Rounded Rectangle, Ellipse, Polygon, Star and Line Segment drags leave copies of the shape being drawn"}, "pressure": num("Pen pressure 0..1 (default 1): the Liquify tools' intensity with Use Pressure Pen on, and the pressure the Paintbrush records"), "tiltX": num("Pen tilt in degrees −90..90, positive leaning right (document axes); with tiltY, the tilt the Paintbrush records for Tilt and Bearing brushes. One without the other is 0"), "tiltY": num("Pen tilt in degrees −90..90, positive leaning down the page"), @@ -218,7 +218,7 @@ pub fn tool_definitions() -> Vec { }), &["kind", "x", "y"]), }, "mods": mods_schema(), - "backquote": {"type": "boolean", "description": "Default backquote held state for events: Selection and transform tool drags transform only pattern paint"}, + "backquote": {"type": "boolean", "description": "Default backquote held state for events: Selection and transform tool drags transform only pattern paint; Rectangle, Rounded Rectangle, Ellipse, Polygon, Star and Line Segment drags leave copies of the shape being drawn"}, }), &["events"], ), diff --git a/crates/tools/src/shape.rs b/crates/tools/src/shape.rs index 5a4bb93cb7..b185de4c27 100644 --- a/crates/tools/src/shape.rs +++ b/crates/tools/src/shape.rs @@ -9,6 +9,10 @@ //! to Tangent on, a line pressed on one convex curved path and dragged near another lands on a //! common tangent of the two, both its ends moving to the touch points ([`TangentLine`]). //! Escape cancels the drag and puts back the options its keys and Ctrl/Cmd changed. +//! Backtick (`` ` ``, the grave accent) held while dragging leaves a copy of the shape being drawn +//! every [`COPY_SPACING`] screen points the pointer travels, up to [`MAX_COPIES`] in one drag; the +//! release keeps the copies and the last shape as one undo step +//! (). //! //! The selection keeps its bounding box and its Live Shape widgets on show with the Rectangle, //! Rounded Rectangle, Ellipse, Polygon and Star tools, so a shape just drawn can be adjusted at @@ -38,6 +42,14 @@ use crate::{Action, Cursor, Mods, Overlay, PointerEvent, PointerKind, Tool, Tool /// value stop there too. pub const MAX_CORNER_RADIUS: f64 = 1296.0; +/// How far (screen points) the pointer travels with Backtick held between two copies a shape drag +/// leaves: VectorCraft's own spacing. +pub const COPY_SPACING: f64 = 8.0; + +/// The most copies one shape drag with Backtick held leaves, besides the shape it ends with: +/// VectorCraft's own limit. +pub const MAX_COPIES: usize = 128; + /// How far (screen points, along each axis) from a bounding-box handle's centre a shape tool's /// press scales the selection: half the drawn handle square, which is 6 points wide at the default /// Selection & Anchor Display › Size 3 and a point wider or narrower per step. The Selection tool @@ -124,6 +136,12 @@ pub struct ShapeTool { /// The move of the selection snapped to a point, a guide or the grid at its last step: the /// arrow turns hollow, as the Selection tool's does. snapped: bool, + /// The copies the drag has left with Backtick held, oldest first: each shape's command and + /// params as the drag showed it when the copy was left. + copies: Vec<(String, Value)>, + /// While Backtick is held in a drag, the pointer position the next copy is measured from: where + /// the last copy was left, or where the drag first had the key down. + copy_from: Option, } /// The options that keys and Ctrl/Cmd change while a shape is dragged out. @@ -177,9 +195,56 @@ impl ShapeTool { guides: vec![], measure: None, snapped: false, + copies: vec![], + copy_from: None, } } + /// With Backtick `held` at pointer `raw`, leave a copy of the shape the drag shows (`cmd` and + /// `params`) once the pointer is [`COPY_SPACING`] screen points from the last copy, or from + /// where the key was first held. A shape with no width, height or length, one the same as the + /// last copy, and any past [`MAX_COPIES`] are not left. Without the key, the next copy is + /// measured from where it goes down again. + fn leave_copy(&mut self, cx: &ToolContext, raw: Point, held: bool, cmd: &str, params: &Value) { + if !held { + self.copy_from = None; + return; + } + let Some(from) = self.copy_from else { + self.copy_from = Some(raw); + return; + }; + let (x, y) = screen_offset(cx, raw - from); + if x.hypot(y) < COPY_SPACING || self.copies.len() >= MAX_COPIES || !draws_something(cmd, params) { + return; + } + self.copy_from = Some(raw); + if self.copies.last().is_some_and(|(c, p)| c == cmd && p == params) { + return; + } + self.copies.push((cmd.to_owned(), params.clone())); + } + + /// The preview of the shape `cmd` with `params`: with copies left, a `command.batch` that draws + /// them and then the shape, unless it has no size or is the same as the last copy. + fn preview(&self, cmd: String, params: Value) -> Action { + if self.copies.is_empty() { + return Action::Preview(cmd, params); + } + let step = |c: &str, p: &Value| json!({ "command": c, "params": p }); + let mut commands: Vec = self.copies.iter().map(|(c, p)| step(c, p)).collect(); + if draws_something(&cmd, ¶ms) && self.copies.last().is_none_or(|(c, p)| *c != cmd || *p != params) { + commands.push(step(&cmd, ¶ms)); + } + Action::Preview("command.batch".into(), json!({ "label": self.label(), "commands": commands })) + } + + /// Forget the copies of the drag that ended. + fn clear_copies(&mut self) { + self.copies.clear(); + self.copy_from = None; + } + fn drag_options(&self) -> DragOptions { DragOptions { sides: self.sides, points: self.points, corner_radius: self.corner_radius, star_ratio: self.star_ratio } } @@ -500,6 +565,19 @@ impl ShapeTool { } } +/// Does the shape command `cmd` with `params` draw something: a box with a width and a height, a +/// polygon or star with a radius, a line with a length? +fn draws_something(cmd: &str, params: &Value) -> bool { + let n = |k: &str| params.get(k).and_then(Value::as_f64).unwrap_or(0.0); + match cmd { + // The drag gives a polygon or star a radius of at least 0.01 pt, even on its centre. + "shape.polygon" => n("radius") > 0.01, + "shape.star" => n("radius1") > 0.01, + "shape.line" => (n("x2") - n("x1")).hypot(n("y2") - n("y1")) > 0.0, + _ => n("width").abs() > 0.0 && n("height").abs() > 0.0, + } +} + /// The box a drag from `start` to `p` draws (from its centre with Alt, square with Shift), /// measured along the page axes turned by Constrain Angle `base`: the box in those axes, and the /// axes (`None` for the page's own: 0° or a whole turn, where the box is on the page exactly). @@ -597,6 +675,7 @@ impl Tool for ShapeTool { self.began = false; self.inner = None; self.before_drag = None; + self.clear_copies(); vec![] } PointerKind::Drag => { @@ -653,7 +732,8 @@ impl Tool for ShapeTool { }; let (a, b) = tangent.unwrap_or((s, ev.pos)); let (c, v) = self.command_at(a, b, ev.mods, cx.constrain_angle); - out.push(Action::Preview(c, v)); + self.leave_copy(cx, raw, ev.backquote, &c, &v); + out.push(self.preview(c, v)); out } PointerKind::Up => { @@ -662,6 +742,7 @@ impl Tool for ShapeTool { self.tangent_line.clear(); self.inner = None; self.before_drag = None; + self.clear_copies(); if self.began { self.began = false; vec![Action::Commit] @@ -724,11 +805,12 @@ impl Tool for ShapeTool { }; if changed { let (c, v) = self.command_at(s, self.last, self.mods, cx.constrain_angle); - vec![Action::Preview(c, v)] + vec![self.preview(c, v)] } else if key == ToolKey::Escape { self.start = None; self.began = false; self.inner = None; + self.clear_copies(); if let Some(o) = self.before_drag.take() { self.restore_drag_options(o); } diff --git a/crates/tools/src/shape/tests.rs b/crates/tools/src/shape/tests.rs index 1aadbf7dee..494ed226c1 100644 --- a/crates/tools/src/shape/tests.rs +++ b/crates/tools/src/shape/tests.rs @@ -1372,3 +1372,170 @@ fn a_move_from_the_centre_point_snaps_and_shows_the_hollow_arrow() { assert!(matches!(a.last(), Some(Action::Preview(_, v)) if v["matrix"][4] == json!(10.0)), "{a:?}"); assert_eq!(t.cursor(&c, Point::new(160.0, 150.0), Mods::default()), Cursor::Arrow); } + +/// A drag event to `(x, y)` with Backtick held or not. +fn quote_drag(x: f64, y: f64, held: bool) -> PointerEvent { + PointerEvent { backquote: held, ..PointerEvent::new(PointerKind::Drag, x, y) } +} + +/// The shapes the last preview in `a` draws, as their commands and params: the steps of a +/// `command.batch`, or the one shape. The bool says whether it was a batch. +fn previewed_shapes(a: &[Action]) -> (bool, Vec<(String, Value)>) { + match a.last() { + Some(Action::Preview(c, v)) if c == "command.batch" => { + assert!(v.get("commands").and_then(Value::as_array).is_some(), "{v}"); + let steps = v["commands"].as_array().into_iter().flatten(); + (true, steps.map(|s| (s["command"].as_str().unwrap_or_default().to_owned(), s["params"].clone())).collect()) + } + Some(Action::Preview(c, v)) => (false, vec![(c.clone(), v.clone())]), + _ => panic!("no preview: {a:?}"), + } +} + +/// The widths of the rectangles the last preview in `a` draws, and whether it was a batch. +fn previewed_widths(a: &[Action]) -> (bool, Vec) { + let (batch, shapes) = previewed_shapes(a); + (batch, shapes.iter().map(|(_, p)| p["width"].as_f64().unwrap_or(f64::NAN)).collect()) +} + +/// Backtick held while a rectangle is dragged out leaves a copy every 8 screen points the pointer +/// travels from where the key was first held or the last copy was left; the shape being drawn +/// still follows the pointer. A key press without pointer travel leaves none, letting go stops +/// the copies and keeps those left, and pressing it again starts measuring afresh. The release +/// commits once. +#[test] +fn backtick_drag_leaves_copies_of_the_rectangle_being_drawn() { + let (d, _) = doc_with_rect(); + let s = Selection::default(); + let p = paint(); + let c = ToolContext { smart_guides: false, ..cx(&d, &s, &p) }; + let mut t = ShapeTool::new("rectangle"); + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 10.0, 10.0)); + assert_eq!(previewed_widths(&t.pointer(&c, "e_drag(50.0, 30.0, false))), (false, vec![40.0])); + // The key goes down with the pointer still: no copy. + assert_eq!(previewed_widths(&t.pointer(&c, "e_drag(50.0, 30.0, true))), (false, vec![40.0])); + // 4 pt of travel is short of the spacing. + assert_eq!(previewed_widths(&t.pointer(&c, "e_drag(54.0, 30.0, true))), (false, vec![44.0])); + // 10 pt: a copy, the same as the shape shown, so the batch draws it once. + assert_eq!(previewed_widths(&t.pointer(&c, "e_drag(60.0, 30.0, true))), (true, vec![50.0])); + assert_eq!(previewed_widths(&t.pointer(&c, "e_drag(70.0, 30.0, true))), (true, vec![50.0, 60.0])); + // 5 pt past the last copy: none left, and the live shape follows. + assert_eq!(previewed_widths(&t.pointer(&c, "e_drag(75.0, 30.0, true))), (true, vec![50.0, 60.0, 65.0])); + // Let go of the key: the copies stay and no more are left. + assert_eq!(previewed_widths(&t.pointer(&c, "e_drag(90.0, 30.0, false))), (true, vec![50.0, 60.0, 80.0])); + assert_eq!(previewed_widths(&t.pointer(&c, "e_drag(120.0, 30.0, false))), (true, vec![50.0, 60.0, 110.0])); + // Pressed again: measured from where it went down. + assert_eq!(previewed_widths(&t.pointer(&c, "e_drag(125.0, 30.0, true))), (true, vec![50.0, 60.0, 115.0])); + assert_eq!(previewed_widths(&t.pointer(&c, "e_drag(135.0, 30.0, true))), (true, vec![50.0, 60.0, 125.0])); + assert_eq!(t.pointer(&c, &PointerEvent { backquote: true, ..PointerEvent::new(PointerKind::Up, 135.0, 30.0) }), vec![Action::Commit]); + // The next drag starts with no copies. + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 10.0, 10.0)); + assert_eq!(previewed_widths(&t.pointer(&c, "e_drag(50.0, 30.0, false))), (false, vec![40.0])); +} + +/// Every shape tool leaves copies of its own shape, drawn with the modifiers held when each copy +/// was left: Shift's square stays square, and Alt's from the centre stays centred. +#[test] +fn backtick_drag_leaves_copies_with_every_shape_tool_and_its_modifiers() { + let (d, _) = doc_with_rect(); + let s = Selection::default(); + let p = paint(); + let c = ToolContext { smart_guides: false, ..cx(&d, &s, &p) }; + for (id, cmd) in [ + ("rectangle", "shape.rectangle"), + ("roundedRectangle", "shape.rectangle"), + ("ellipse", "shape.ellipse"), + ("polygon", "shape.polygon"), + ("star", "shape.star"), + ("lineSegment", "shape.line"), + ] { + let mut t = ShapeTool::new(id); + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 100.0, 100.0)); + t.pointer(&c, "e_drag(140.0, 130.0, true)); + t.pointer(&c, "e_drag(160.0, 130.0, true)); + let (batch, shapes) = previewed_shapes(&t.pointer(&c, "e_drag(180.0, 140.0, true))); + assert!(batch, "{id}"); + assert_eq!(shapes.len(), 2, "{id}: two copies, the second the shape shown: {shapes:?}"); + assert!(shapes.iter().all(|(c, _)| c == cmd), "{id}: {shapes:?}"); + assert_ne!(shapes[0].1, shapes[1].1, "{id}: each copy as the drag showed it then"); + } + // Shift and Alt: each copy is the square drawn from the centre at that moment. + let shift_alt = Mods { shift: true, alt: true, ..Default::default() }; + let mut t = ShapeTool::new("rectangle"); + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 100.0, 100.0)); + t.pointer(&c, "e_drag(130.0, 120.0, true).with_mods(shift_alt)); + let (_, shapes) = previewed_shapes(&t.pointer(&c, "e_drag(150.0, 120.0, true).with_mods(shift_alt))); + let (_, r) = &shapes[0]; + assert_eq!(r["width"], r["height"], "square: {r}"); + assert_eq!(r["x"].as_f64().unwrap_or_default() + r["width"].as_f64().unwrap_or_default() / 2.0, 100.0, "centred: {r}"); +} + +/// ↑ during a polygon drag with copies left changes only the shape being drawn; Escape cancels +/// the copies with it, and the next drag starts without them. +#[test] +fn backtick_copies_keep_their_sides_and_escape_cancels_them() { + let (d, _) = doc_with_rect(); + let s = Selection::default(); + let p = paint(); + let c = ToolContext { smart_guides: false, ..cx(&d, &s, &p) }; + let mut t = ShapeTool::new("polygon"); + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 100.0, 100.0)); + t.pointer(&c, "e_drag(140.0, 100.0, true)); + t.pointer(&c, "e_drag(150.0, 100.0, true)); + let (batch, shapes) = previewed_shapes(&t.key(&c, ToolKey::Up, Mods::default())); + assert!(batch); + let sides: Vec<_> = shapes.iter().map(|(_, p)| p["sides"].clone()).collect(); + assert_eq!(sides, vec![json!(6), json!(7)], "the copy keeps its sides"); + assert_eq!(t.key(&c, ToolKey::Escape, Mods::default()), vec![Action::Cancel]); + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 100.0, 100.0)); + let (batch, _) = previewed_shapes(&t.pointer(&c, "e_drag(140.0, 100.0, false))); + assert!(!batch, "no copies after Escape"); +} + +/// No copy is left of a shape without a height or a length, and one drag leaves at most +/// [`MAX_COPIES`] copies while the shape being drawn still follows the pointer. +#[test] +fn backtick_copies_skip_empty_shapes_and_stop_at_the_limit() { + let (d, _) = doc_with_rect(); + let s = Selection::default(); + let p = paint(); + let c = ToolContext { smart_guides: false, ..cx(&d, &s, &p) }; + // A rectangle with no height: nothing is left. + let mut t = ShapeTool::new("rectangle"); + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 10.0, 10.0)); + for x in [30.0, 40.0, 50.0, 60.0] { + assert!(!previewed_shapes(&t.pointer(&c, "e_drag(x, 10.0, true))).0, "{x}"); + } + // A line back on its start: no copy there. + let mut t = ShapeTool::new("lineSegment"); + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 10.0, 10.0)); + t.pointer(&c, "e_drag(30.0, 10.0, true)); + assert!(!previewed_shapes(&t.pointer(&c, "e_drag(10.0, 10.0, true))).0); + // The limit. + let mut t = ShapeTool::new("rectangle"); + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 0.0, 0.0)); + t.pointer(&c, "e_drag(10.0, 10.0, true)); + let mut last = vec![]; + for i in 1..=(MAX_COPIES as u32 + 20) { + let at = 10.0 + f64::from(i) * 10.0; + last = t.pointer(&c, "e_drag(at, at, true)); + } + let (batch, widths) = previewed_widths(&last); + assert!(batch); + assert_eq!(widths.len(), MAX_COPIES + 1, "the copies and the shape being drawn"); + assert_eq!(widths.last(), Some(&(10.0 + f64::from(MAX_COPIES as u32 + 20) * 10.0)), "the shape follows the pointer"); +} + +/// The spacing is measured on screen: at 400% zoom, 2 pt of travel is 8 screen points. +#[test] +fn backtick_copy_spacing_is_measured_on_screen() { + let (d, _) = doc_with_rect(); + let s = Selection::default(); + let p = paint(); + let c = ToolContext { smart_guides: false, zoom: 4.0, ..cx(&d, &s, &p) }; + let mut t = ShapeTool::new("rectangle"); + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 10.0, 10.0)); + t.pointer(&c, "e_drag(20.0, 20.0, true)); + assert!(!previewed_shapes(&t.pointer(&c, "e_drag(21.5, 20.0, true))).0, "6 screen points"); + assert!(previewed_shapes(&t.pointer(&c, "e_drag(22.0, 20.0, true))).0, "8 screen points"); +} diff --git a/docs/mcp.md b/docs/mcp.md index c7aa202d3f..a47362dc4c 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -7008,6 +7008,20 @@ of it headless), gathered once per document state; the shape being drawn is neve With a 100 × 100 square at (100, 100), the first starts the rectangle on its corner (200, 200); the second puts the Pen's second anchor at (150, 431), in line with the square's centre. +With `backquote` true on a `drag` event, the `rectangle`, `roundedRectangle`, `ellipse`, `polygon`, `star` and +`lineSegment` tools leave a copy of the shape being drawn each time the pointer has moved 8 screen points since the +last copy, or since the first event with the key down; a key change with no pointer travel leaves none. Each copy is +the shape as that event showed it, with its modifiers and Up/Down counts, and is its own object. The `up` keeps the +copies and the last shape as one undo step, and Escape takes them all back. One drag leaves at most 128 copies, and a +shape with no width, height or length leaves none. The spacing and the limit are VectorCraft's own values; the +continuous duplicate itself is in the Keys for drawing table of +[the help page](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=469). With Smart +Guides off, this drag leaves a 70 × 50 and a 90 × 50 copy and the 110 × 70 rectangle: + +```json +{"name":"pointer_gesture","arguments":{"tool":"rectangle","events":[{"kind":"down","x":50,"y":50},{"kind":"drag","x":100,"y":100,"backquote":true},{"kind":"drag","x":120,"y":100,"backquote":true},{"kind":"drag","x":140,"y":100,"backquote":true},{"kind":"drag","x":160,"y":120},{"kind":"up","x":160,"y":120}]}} +``` + ## Type preferences - `placeholderText` (on by default): type the Type tools place (`pointer_gesture` with `type`, `areaType`…) starts with diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 0782bacab9..29c9d8c63a 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1196,6 +1196,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Shapes:** all shape tools (including Flare) and the line, arc, spiral and grid tools. Space held while dragging out a shape, line, arc, spiral or grid moves it at its current size. The Flare tool's center drag turns the rays by 0.1 radian at each drag update in which the pointer's document y grows, and back by as much at each one in which it falls, Shift held keeps their turn, and Space held during either of its drags moves the flare. While a grid is dragged out, Up/Down change its rows (concentric dividers) and Left/Right its columns (radial dividers). A click with a grid tool asks for the size, the divider counts and the grid options (#1377, in part): a skew for each set of dividers, Use Outside Rectangle As Frame or Create Compound Path From Ellipses, and Fill Grid; they are parameters of `shape.rectangularGrid` and `shape.polarGrid`, stay as the tool's options and apply to drags too. The curve a skew percentage follows and the direction of the radial skew are our own (the public documentation gives neither), and the dialogs have no reference point locator. An ellipse's Pie Start and End Angle and Invert Pie (Transform and Properties panels' Ellipse Properties, `object.setLiveShape {pieStart, pieEnd, invertPie}`) cut it as a pie (#812). With the bounding box showing, the Selection tool shows a selected ellipse's two pie widgets just outside it; dragging one sets its angle in one undo step and double-clicking one makes the ellipse whole again. A live polygon's Polygon Properties there: side count, angle, corner type and radius, radius, side length and Make Sides Equal once an uneven scale has made its sides differ (`object.setLiveShape {sides, polygonAngle, polygonRadius, sideLength, makeSidesEqual}`, part of #812); a star is a plain path, as in Illustrator. The Flare Tool Options last as the tool's options: the next flare dragged out uses them, a click's dialog shows them and double-clicking the tool opens them (part of #812). - **Shapes:** all shape tools (including Flare) and the line, arc, spiral and grid tools. Space held while dragging out a shape, line, arc, spiral or grid moves it at its current size. The Flare tool's center drag turns the rays with the pointer, Shift keeps them in their original orientation (unturned, or turned by a nonzero General › Constrain Angle), and Space held during either of its drags moves the flare. While a grid is dragged out, Up/Down change its rows (concentric dividers) and Left/Right its columns (radial dividers). A click with a grid tool asks for the size, the divider counts and the grid options (#1377, in part): a skew for each set of dividers, Use Outside Rectangle As Frame or Create Compound Path From Ellipses, and Fill Grid; they are parameters of `shape.rectangularGrid` and `shape.polarGrid`, stay as the tool's options and apply to drags too. The curve a skew percentage follows and the direction of the radial skew are our own (the public documentation gives neither), and the dialogs have no reference point locator. An ellipse's Pie Start and End Angle and Invert Pie (Transform and Properties panels' Ellipse Properties, `object.setLiveShape {pieStart, pieEnd, invertPie}`) cut it as a pie (#812). With the bounding box showing, the Selection tool shows a selected ellipse's two pie widgets just outside it; dragging one sets its angle in one undo step and double-clicking one makes the ellipse whole again. A live polygon's Polygon Properties there: side count, angle, corner type and radius, radius, side length and Make Sides Equal once an uneven scale has made its sides differ (`object.setLiveShape {sides, polygonAngle, polygonRadius, sideLength, makeSidesEqual}`, part of #812); a star is a plain path, as in Illustrator. The Flare Tool Options last as the tool's options: the next flare dragged out uses them, a click's dialog shows them and double-clicking the tool opens them (part of #812). - **Shapes:** all shape tools (including Flare) and the line, arc, spiral and grid tools. Space held while dragging out a shape, line, arc, spiral or grid moves it at its current size. The Flare tool's center drag turns the rays with the pointer, Shift keeps them in their original orientation, and Space held during either of its drags moves the flare. While a grid is dragged out, Up/Down change its rows (concentric dividers) and Left/Right its columns (radial dividers). A click with a grid tool asks for the size, the divider counts and the grid options (#1377, in part): a skew for each set of dividers, Use Outside Rectangle As Frame or Create Compound Path From Ellipses, and Fill Grid; they are parameters of `shape.rectangularGrid` and `shape.polarGrid`, stay as the tool's options and apply to drags too. The curve a skew percentage follows and the direction of the radial skew are our own (the public documentation gives neither), and the dialogs have no reference point locator. An ellipse's Pie Start and End Angle and Invert Pie (Transform and Properties panels' Ellipse Properties, `object.setLiveShape {pieStart, pieEnd, invertPie}`) cut it as a pie (#812). With the bounding box showing, the Selection tool shows a selected ellipse's two pie widgets just outside it; dragging one sets its angle in one undo step and double-clicking one makes the ellipse whole again. A live polygon's Polygon Properties there: side count, angle, corner type and radius, radius, side length and Make Sides Equal once an uneven scale has made its sides differ (`object.setLiveShape {sides, polygonAngle, polygonRadius, sideLength, makeSidesEqual}`, part of #812); a star is a plain path, as in Illustrator. The Flare Tool Options last as the tool's options: the next flare dragged out uses them, a click's dialog shows them and double-clicking the tool opens them (part of #812). + Backtick (`` ` ``) held while a rectangle, rounded rectangle, ellipse, polygon, star or line is dragged out leaves copies of the shape being drawn along the drag, each its own object: the continuous duplicate that the Keys for drawing table of [the help page](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=469) lists. Each copy is the shape as the drag showed it then, with its modifiers and Up/Down counts; the release keeps the copies and the last shape as one undo step, and Escape takes them all back. The spacing (a copy each time the pointer has moved 8 screen points with the key down, none for the key alone) and the limit of 128 copies a drag are VectorCraft's own values, and a shape with no width, height or length leaves no copy. The arc, spiral, grid and Flare tools do not leave copies (tests `backtick_drag_leaves_copies_of_the_rectangle_being_drawn` and, through the engine, `a_backtick_drag_leaves_copies_of_the_shape_as_one_undo_step`). Escape while a polygon, star or rounded rectangle is dragged out cancels it and puts back the side count, point count, corner radius or star ratio its Up/Down and Ctrl/Cmd changed, so the next drag, the tool's options and General › Corner Radius start from the values before the canceled drag; a drag that is let go keeps them, and an option set with `tool.setOption` during the drag stays. This is VectorCraft's own rule. While a grid is dragged out, F lowers `rowSkew` (rectangular) or `radialSkew` (polar) by 10 percentage points and V raises it by 10; X lowers `columnSkew` (rectangular) or `concentricSkew` (polar) by 10 and C raises it by 10. Plain and Shift presses work; with Alt, Ctrl or Cmd held they do not, as for the other letters a tool takes while dragging. Each press changes the skew once and updates the preview; values stay within ±500% and remain in the tool options after release. The [default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) (archived copy) list the four drag keys and a 10% change. The signs (positive values follow VectorCraft's existing skew convention, so F and X lower the stored value) and one change per press with key repeat ignored are our own rules. While an arc is dragged out, C switches it between open and closed, F switches its base between the X and Y axes in the same box, and Up/Down raise and lower its slope by 10 within −100…100; each press switches once, and the values stay as the Arc tool's options. The [default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) (archived copy) list C, F and Up/Down for an arc being dragged out. F as the base switch, the arrows changing the slope, the step of 10 and one switch per press are our own rules.