From d56bbb49fff492c8a506b8fbac48fdaeeb2af499 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Fri, 30 Oct 2026 03:37:43 +0700 Subject: [PATCH 001/163] Gradient Mesh: select several mesh points; move, color and opacity reach them all (#4207, #4208, #4170) --- crates/engine/src/cmd/live/commands.rs | 13 +- crates/engine/src/cmd/live/mesh.rs | 100 ++++++- crates/engine/src/cmd/opacitymask.rs | 29 +- crates/engine/src/cmd/paint.rs | 57 ++-- crates/engine/src/tests/editcolors.rs | 75 +++++ crates/engine/src/tests/live.rs | 57 ++++ crates/tools/src/context.rs | 14 + crates/tools/src/direct.rs | 84 ++++-- crates/tools/src/meshblend.rs | 45 ++- crates/tools/src/meshedit.rs | 362 ++++++++++++++++++++++--- crates/ui-egui/src/i18n/bg.tsv | 1 + crates/ui-egui/src/i18n/ca.tsv | 1 + crates/ui-egui/src/i18n/cs.tsv | 1 + crates/ui-egui/src/i18n/da.tsv | 1 + crates/ui-egui/src/i18n/de.tsv | 1 + crates/ui-egui/src/i18n/el.tsv | 1 + crates/ui-egui/src/i18n/es.tsv | 1 + crates/ui-egui/src/i18n/fi.tsv | 1 + crates/ui-egui/src/i18n/fr.tsv | 1 + crates/ui-egui/src/i18n/hu.tsv | 1 + crates/ui-egui/src/i18n/id.tsv | 1 + crates/ui-egui/src/i18n/it.tsv | 1 + crates/ui-egui/src/i18n/ja.tsv | 1 + crates/ui-egui/src/i18n/ka.tsv | 1 + crates/ui-egui/src/i18n/ko.tsv | 1 + crates/ui-egui/src/i18n/nl.tsv | 1 + crates/ui-egui/src/i18n/pl.tsv | 1 + crates/ui-egui/src/i18n/pt-br.tsv | 1 + crates/ui-egui/src/i18n/ru.tsv | 1 + crates/ui-egui/src/i18n/sv.tsv | 1 + crates/ui-egui/src/i18n/tr.tsv | 1 + crates/ui-egui/src/i18n/uk.tsv | 1 + crates/ui-egui/src/i18n/vi.tsv | 1 + crates/ui-egui/src/i18n/zh-hans.tsv | 1 + crates/ui-egui/src/i18n/zh-hant.tsv | 1 + docs/mcp.md | 25 +- docs/target-app-parity.md | 4 +- 37 files changed, 774 insertions(+), 116 deletions(-) diff --git a/crates/engine/src/cmd/live/commands.rs b/crates/engine/src/cmd/live/commands.rs index 82105b00ef..aec4e32d00 100644 --- a/crates/engine/src/cmd/live/commands.rs +++ b/crates/engine/src/cmd/live/commands.rs @@ -7,7 +7,7 @@ use super::envelope::{ env_edit_contents, env_expand, env_info, env_make_mesh, env_make_top, env_make_warp, env_options, env_release, env_reset_mesh, env_reset_warp, env_set_mesh_point, }; -use super::mesh::{mesh_add_line, mesh_create, mesh_delete_point, mesh_expand, mesh_move_point, mesh_set_color}; +use super::mesh::{mesh_add_line, mesh_create, mesh_delete_point, mesh_expand, mesh_move_point, mesh_move_points, mesh_set_color}; use super::{CommandSpec, always, cmd, has_doc, has_multi, has_selection}; pub fn specs() -> Vec { @@ -245,7 +245,7 @@ pub fn specs() -> Vec { "Set Mesh Point Color", [], None, - "{id, index, color, keepModel?: bool (as paint.setFill), opacity?: 0..1} colour of one mesh point", + "{id, index | points: [index…] | items: [{id, index | points}…], color?, keepModel?: bool (as paint.setFill), opacity?: 0..1} colour and/or opacity of gradient mesh points (one undo step; an index out of range changes nothing)", has_doc, mesh_set_color ), @@ -258,6 +258,15 @@ pub fn specs() -> Vec { has_doc, mesh_move_point ), + cmd!( + "object.mesh.movePoints", + "Move Mesh Points", + [], + None, + "{id, points: [index…] | items: [{id, index | points}…], dx, dy} move points of gradient meshes or mesh envelopes by (dx, dy), their handles with them (one undo step; an index out of range changes nothing)", + has_doc, + mesh_move_points + ), cmd!( "object.mesh.addLine", "Add Mesh Line", diff --git a/crates/engine/src/cmd/live/mesh.rs b/crates/engine/src/cmd/live/mesh.rs index 1d11080fb3..602e2e3e96 100644 --- a/crates/engine/src/cmd/live/mesh.rs +++ b/crates/engine/src/cmd/live/mesh.rs @@ -1,7 +1,9 @@ +use std::collections::{BTreeMap, BTreeSet}; + use super::common::{fix_ids, ids_json, is_mesh, replace_with, roots_param, selected_of}; use super::envelope::{outline_of, rows_cols}; use super::{ - Color, Document, EngineError, EnvelopeKind, GradientMesh, MeshAppearance, Node, NodeKind, Paint, Point, Result, Session, Value, bad, + Color, Document, EngineError, EnvelopeKind, GradientMesh, MeshAppearance, Node, NodeId, NodeKind, Paint, Point, Result, Session, Value, bad, check_numbers, color_value, f64_or, f64_req, finite_numbers, gradient_sampler, id_param, json, live, ok, str_param, }; @@ -106,25 +108,86 @@ fn image_mesh(d: &Document, im: &vectorcraft_doc::ImageObject, rows: u32, cols: } /// Run `f` on the gradient mesh `p.id` (one undo step `label`); with `envelopes`, a mesh -/// envelope's grid too (its points and handles are written back: editing fills in the handles). +/// envelope's grid too (see [`edit_grid`]). fn with_mesh(s: &mut Session, p: &Value, cmd: &str, label: &str, envelopes: bool, f: impl FnOnce(&mut GradientMesh) -> Result) -> Result { let id = id_param(p, "id").ok_or_else(|| bad(cmd, "missing `id`"))?; - let c = cmd.to_string(); - s.edit(label, move |d, _| match d.node_mut(id).map(|n| &mut n.kind) { + s.edit(label, move |d, _| edit_grid(d, id, cmd, envelopes, f)) +} + +/// Run `f` on the gradient mesh `id` of `d`; with `envelopes`, a mesh envelope's grid too (its +/// points and handles are written back: editing fills in the handles). +fn edit_grid(d: &mut Document, id: NodeId, cmd: &str, envelopes: bool, f: impl FnOnce(&mut GradientMesh) -> Result) -> Result { + match d.node_mut(id).map(|n| &mut n.kind) { Some(NodeKind::Mesh(m)) => f(m), Some(NodeKind::Envelope { kind, .. }) if envelopes && matches!(**kind, EnvelopeKind::Mesh { .. }) => { let EnvelopeKind::Mesh { rows, cols, points, handles } = &mut **kind else { - return Err(bad(&c, "not a gradient mesh or mesh envelope")); + return Err(bad(cmd, "not a gradient mesh or mesh envelope")); }; - let mut m = live::envelope_grid(*rows, *cols, points, handles).ok_or_else(|| bad(&c, "the envelope's mesh is malformed"))?; + let mut m = live::envelope_grid(*rows, *cols, points, handles).ok_or_else(|| bad(cmd, "the envelope's mesh is malformed"))?; let r = f(&mut m)?; (*rows, *cols) = (m.rows, m.cols); *points = m.points.iter().map(|q| q.p).collect(); *handles = m.points.iter().map(|q| q.handles).collect(); Ok(r) } - Some(_) => Err(bad(&c, if envelopes { "not a gradient mesh or mesh envelope" } else { "not a gradient mesh" })), + Some(_) => Err(bad(cmd, if envelopes { "not a gradient mesh or mesh envelope" } else { "not a gradient mesh" })), None => Err(EngineError::NoNode(id)), + } +} + +/// Most mesh points one command names, over all its meshes. +const MAX_POINTS: usize = 1 << 20; + +/// The mesh points `p` names: `{id, index}`, `{id, points: [index…]}` or `{items: [{id, index | +/// points}…]}`. Each mesh comes once, with its points in order and without repeats. +fn point_items(p: &Value, cmd: &str) -> Result)>> { + let one = |q: &Value| -> Result<(NodeId, BTreeSet)> { + let id = id_param(q, "id").ok_or_else(|| bad(cmd, "missing `id`"))?; + let points = match q.get("points") { + None | Some(Value::Null) => BTreeSet::from([index_param(q, "index", cmd)?]), + Some(Value::Array(v)) if v.len() <= MAX_POINTS => v + .iter() + .map(|i| index_of(i.as_f64().ok_or_else(|| bad(cmd, "`points` must be point indexes"))?, "points", cmd)) + .collect::>()?, + Some(_) => return Err(bad(cmd, "`points` must be a list of point indexes")), + }; + Ok((id, points)) + }; + let items: Vec<(NodeId, BTreeSet)> = match p.get("items") { + None | Some(Value::Null) => vec![one(p)?], + Some(Value::Array(v)) if v.len() <= MAX_POINTS => v.iter().map(one).collect::>()?, + Some(_) => return Err(bad(cmd, "`items` must be a list of {id, points}")), + }; + let mut merged: BTreeMap> = BTreeMap::new(); + for (id, points) in items { + merged.entry(id).or_default().extend(points); + } + if merged.values().map(BTreeSet::len).sum::() > MAX_POINTS { + return Err(bad(cmd, format!("at most {MAX_POINTS} points"))); + } + Ok(merged.into_iter().collect()) +} + +/// Run `f` on each mesh point `items` names, as one undo step `label` (an index out of range +/// fails it, changing nothing); with `envelopes`, on mesh envelopes' points too. +fn with_points( + s: &mut Session, + items: &[(NodeId, BTreeSet)], + cmd: &str, + label: &str, + envelopes: bool, + mut f: impl FnMut(&mut live::MeshPoint) -> Result<()>, +) -> Result<()> { + s.edit(label, |d, _| { + for (id, points) in items { + edit_grid(d, *id, cmd, envelopes, |m| { + for i in points { + f(m.points.get_mut(*i).ok_or_else(|| bad(cmd, "index out of range"))?)?; + } + Ok(()) + })?; + } + Ok(()) }) } @@ -140,7 +203,11 @@ pub(super) fn handle_param(p: &Value, cmd: &str) -> Result> { } pub(super) fn index_param(p: &Value, key: &str, cmd: &str) -> Result { - let i = f64_req(p, key, cmd)?; + index_of(f64_req(p, key, cmd)?, key, cmd) +} + +/// `i`, the value of `key`, as an index: a whole number ≥ 0. +fn index_of(i: f64, key: &str, cmd: &str) -> Result { if i < 0.0 { return Err(bad(cmd, "index must be ≥ 0")); } @@ -156,14 +223,13 @@ pub(super) fn mesh_set_color(s: &mut Session, p: &Value) -> Result { const C: &str = "object.mesh.setPointColor"; check_numbers(p, &["opacity"], C)?; crate::cmd::paint::check_keep_model(p, C)?; - let index = index_param(p, "index", C)?; + let items = point_items(p, C)?; let color = p.get("color").and_then(color_value).map(|c| crate::cmd::paint::new_color(s, p, c)); let opacity = p.get("opacity").and_then(Value::as_f64); if color.is_none() && opacity.is_none() { return Err(bad(C, "missing `color` or `opacity`")); } - with_mesh(s, p, C, "Mesh Point Color", false, |m| { - let pt = m.points.get_mut(index).ok_or_else(|| bad(C, "index out of range"))?; + with_points(s, &items, C, "Mesh Point Color", false, |pt| { if let Some(c) = color { pt.color = c; } @@ -191,6 +257,18 @@ pub(super) fn mesh_move_point(s: &mut Session, p: &Value) -> Result { ok() } +pub(super) fn mesh_move_points(s: &mut Session, p: &Value) -> Result { + const C: &str = "object.mesh.movePoints"; + let items = point_items(p, C)?; + let (dx, dy) = (f64_req(p, "dx", C)?, f64_req(p, "dy", C)?); + // `Session::edit` refuses a move past the canvas's coordinate range. + with_points(s, &items, C, "Move Mesh Points", true, |pt| { + pt.p = Point::new(pt.p.x + dx, pt.p.y + dy); + Ok(()) + })?; + ok() +} + pub(super) fn mesh_add_line(s: &mut Session, p: &Value) -> Result { const C: &str = "object.mesh.addLine"; let q = Point::new(f64_req(p, "x", C)?, f64_req(p, "y", C)?); diff --git a/crates/engine/src/cmd/opacitymask.rs b/crates/engine/src/cmd/opacitymask.rs index 50fcc349a2..d5a7f600dd 100644 --- a/crates/engine/src/cmd/opacitymask.rs +++ b/crates/engine/src/cmd/opacitymask.rs @@ -10,7 +10,7 @@ use std::collections::HashSet; use serde_json::{Value, json}; use vectorcraft_color::BlendMode; -use vectorcraft_doc::{Document, Knockout, Node, NodeId, OpacityMask, Selection}; +use vectorcraft_doc::{Document, Knockout, Node, NodeId, NodeKind, OpacityMask, Selection}; use super::maskedit::{begin, finish, mask_group, mask_parts, show_editing}; use super::pathops::{Beside, separate}; @@ -368,12 +368,19 @@ impl TransparencyInfo { } } - /// The opacity of the focused gradient mesh `point` (see `transparency.set`) instead of its - /// object's. - fn with_mesh_point(mut self, point: Option<(NodeId, usize, f32)>) -> Self { - if let Some((_, _, o)) = point { - self.opacity = Some((o as f64 * 10_000.0).round() / 100.0); - } + /// The opacity of the picked gradient mesh `points` (see `transparency.set`) instead of their + /// objects': `None` where they differ. + fn with_mesh_points(mut self, d: &Document, points: Option)>>) -> Self { + let Some(points) = points else { return self }; + let mut all = points.iter().flat_map(|(id, v)| { + let m = match d.node(*id).map(|n| &n.kind) { + Some(NodeKind::Mesh(m)) => Some(m), + _ => None, + }; + v.iter().filter_map(move |i| m?.points.get(*i)).map(|q| (q.opacity as f64 * 10_000.0).round() as i64) + }); + let first = all.next(); + self.opacity = first.filter(|f| all.all(|o| o == *f)).map(|o| o as f64 / 100.0); self } } @@ -404,8 +411,8 @@ impl Session { pub fn transparency_info(&self) -> TransparencyInfo { match (self.active(), transparency_targets(self, &Value::Null)) { (Some(st), Ok(ids)) => { - let point = super::paint::focused_mesh_point_of(self, &ids); - TransparencyInfo::of(&st.doc, ids).with_mesh_point(point) + let points = super::paint::picked_mesh_points_of(self, &ids); + TransparencyInfo::of(&st.doc, ids).with_mesh_points(&st.doc, points) } _ => TransparencyInfo::default(), } @@ -415,8 +422,8 @@ impl Session { fn info(s: &mut Session, p: &Value) -> Result { let st = s.doc()?; let ids = transparency_targets(s, p)?; - let point = super::paint::focused_mesh_point_of(s, &ids); - let i = TransparencyInfo::of(&st.doc, ids).with_mesh_point(point); + let points = super::paint::picked_mesh_points_of(s, &ids); + let i = TransparencyInfo::of(&st.doc, ids).with_mesh_points(&st.doc, points); Ok(json!({ "ids": i.ids.iter().map(|id| id.0).collect::>(), "opacity": i.opacity, diff --git a/crates/engine/src/cmd/paint.rs b/crates/engine/src/cmd/paint.rs index 005fedc2a4..c0ca01b673 100644 --- a/crates/engine/src/cmd/paint.rs +++ b/crates/engine/src/cmd/paint.rs @@ -462,9 +462,9 @@ pub(crate) fn apply_paint(s: &mut Session, p: &Value, paint: Paint, fill: bool) let selected = item.targets(s, p)?; let ids = super::graph::paint_targets(&s.doc()?.doc, &selected); let paint = if span { placed_across(&s.doc()?.doc, &ids, paint, p, fill) } else { paint }; - // The gradient mesh point last clicked with the Mesh tool or Direct Selection: a solid fill - // recolours just that point of its mesh. - let mesh_point = if fill && matches!(paint, Paint::Solid { .. }) { focused_mesh_point(s) } else { None }; + // The gradient mesh points picked with the Mesh tool or Direct Selection: a solid fill + // recolours just those points of their meshes. + let mesh_points = if fill && matches!(paint, Paint::Solid { .. }) { picked_mesh_points(s, &ids) } else { vec![] }; // Without `item`, unless the Appearance panel's active fill item takes the paint. let colorized = if fill && p.get("item").is_none() && item == ItemTarget::Top { colorized_images(&s.doc()?.doc, &ids, &paint).map_err(|e| bad(cmd, e))? @@ -486,11 +486,14 @@ pub(crate) fn apply_paint(s: &mut Session, p: &Value, paint: Paint, fill: bool) } if index.is_none() && let Paint::Solid { color, .. } = &paint - && let Some((_, i)) = mesh_point.filter(|(id, _)| *id == n.id) + && let Some((_, points)) = mesh_points.iter().find(|(id, _)| *id == n.id) && let NodeKind::Mesh(m) = &mut n.kind - && let Some(q) = m.points.get_mut(i) { - q.color = *color; + for i in points { + if let Some(q) = m.points.get_mut(*i) { + q.color = *color; + } + } return Ok(()); } if index.is_none() @@ -689,20 +692,31 @@ fn black_or_white(c: &Color) -> bool { } } -/// The mesh point the active tool has focused (its `meshPoint` option: the Mesh tool's or Direct -/// Selection's point last clicked). -fn focused_mesh_point(s: &Session) -> Option<(NodeId, usize)> { +/// The points the active tool has picked (its `meshPoints` option: the Mesh tool's or Direct +/// Selection's) on the gradient meshes among `ids`, in range, each mesh with its points. +fn picked_mesh_points(s: &Session, ids: &[NodeId]) -> Vec<(NodeId, Vec)> { let o = s.tool_options(); - let pt = o.get("meshPoint")?; - Some((NodeId(pt.get("id")?.as_u64()?), usize::try_from(pt.get("index")?.as_u64()?).ok()?)) + let (Some(picked), Ok(st)) = (o.get("meshPoints").and_then(Value::as_array), s.doc()) else { return vec![] }; + let mut out: Vec<(NodeId, Vec)> = vec![]; + for pt in picked { + let (Some(id), Some(index)) = (pt.get("id").and_then(Value::as_u64).map(NodeId), pt.get("index").and_then(Value::as_u64)) else { continue }; + let Ok(index) = usize::try_from(index) else { continue }; + if !ids.contains(&id) || !matches!(st.doc.node(id).map(|n| &n.kind), Some(NodeKind::Mesh(m)) if index < m.points.len()) { + continue; + } + match out.iter_mut().find(|(m, _)| *m == id) { + Some((_, v)) => v.push(index), + None => out.push((id, vec![index])), + } + } + out } -/// The focused mesh point (see [`focused_mesh_point`]) with its opacity, when `ids` is just the -/// gradient mesh it belongs to. -pub(crate) fn focused_mesh_point_of(s: &Session, ids: &[NodeId]) -> Option<(NodeId, usize, f32)> { - let (id, index) = focused_mesh_point(s).filter(|(id, _)| ids == [*id])?; - let NodeKind::Mesh(m) = &s.doc().ok()?.doc.node(id)?.kind else { return None }; - Some((id, index, m.points.get(index)?.opacity)) +/// The picked gradient mesh points (see [`picked_mesh_points`]) when each of `ids` is a gradient +/// mesh with points picked: the Transparency panel's opacity is theirs then. +pub(crate) fn picked_mesh_points_of(s: &Session, ids: &[NodeId]) -> Option)>> { + let v = picked_mesh_points(s, ids); + (!ids.is_empty() && ids.iter().all(|id| v.iter().any(|(m, _)| m == id))).then_some(v) } /// A type run's stroke; a painted stroke on a run without one gets 1 pt. @@ -848,15 +862,16 @@ fn transparency(s: &mut Session, p: &Value) -> Result { q.remove("item"); q.remove("id"); q.insert("ids".into(), json!(ids.iter().map(|id| id.0).collect::>())); - // The gradient mesh point last clicked with the Mesh tool or Direct Selection takes the - // opacity itself, so only the mesh around it fades (#4206). + // The gradient mesh points picked with the Mesh tool or Direct Selection take the opacity + // themselves, so only the mesh around them fades (#4206, #4170, #4208). if matches!(item, ItemTarget::Top) && let Some(o) = q.get("opacity").and_then(Value::as_f64) - && let Some((id, index, _)) = focused_mesh_point_of(s, &ids) + && let Some(points) = picked_mesh_points_of(s, &ids) { q.remove("opacity"); let opacity = f64::from(super::opacitymask::percent(o)); - s.execute("object.mesh.setPointColor", &json!({"id": id.0, "index": index, "opacity": opacity}))?; + let items: Vec = points.iter().map(|(id, v)| json!({"id": id.0, "points": v})).collect(); + s.execute("object.mesh.setPointColor", &json!({"items": items, "opacity": opacity}))?; if q.keys().all(|k| k == "ids") { return ok(); } diff --git a/crates/engine/src/tests/editcolors.rs b/crates/engine/src/tests/editcolors.rs index 511431c3cb..1f8e6bd40c 100644 --- a/crates/engine/src/tests/editcolors.rs +++ b/crates/engine/src/tests/editcolors.rs @@ -233,6 +233,81 @@ fn a_clicked_mesh_point_takes_the_opacity() { assert!(mesh_opacities(&s, m).iter().all(|a| *a == 1.0)); } +/// Mesh points picked together (Shift-clicks with the Mesh tool, a Direct Selection marquee) all +/// take a solid fill colour and the Transparency panel's opacity, and only they do; the panel +/// shows their opacity, blank when it differs; a drag of one moves them all as one undo step +/// (#4207, #4208, #4170). +#[test] +fn picked_mesh_points_take_the_fill_opacity_and_drag_together() { + let mut s = session(); + let m = rect(&mut s, json!("#ff0000")); + s.execute("object.mesh.create", &json!({"rows": 2, "cols": 2})).unwrap(); + s.execute("select.set", &json!({"ids": [m.0]})).unwrap(); + let v = ViewInfo::default(); + let point = |s: &Session, i: usize| { + let NodeKind::Mesh(g) = &s.doc().unwrap().doc.node(m).unwrap().kind else { panic!("not a mesh") }; + g.points[i].p + }; + let pointer = |s: &mut Session, kind: PointerKind, q: vectorcraft_geom::Point, shift: bool| { + let mut ev = PointerEvent::new(kind, q.x, q.y); + ev.mods.shift = shift; + s.pointer(&ev, v).unwrap(); + }; + let click = |s: &mut Session, i: usize, shift: bool| { + let q = point(s, i); + pointer(s, PointerKind::Down, q, shift); + pointer(s, PointerKind::Up, q, shift); + }; + let check = |s: &Session, picked: &[usize], hex: &str, opacity: f32, what: &str| { + let (c, o) = (mesh_colors(s, m), mesh_opacities(s, m)); + for i in 0..c.len() { + let on = picked.contains(&i); + assert_eq!(c[i].to_hex() == hex, on, "{what}: point {i} colour {c:?}"); + assert_eq!((o[i] - opacity).abs() < 1e-6, on, "{what}: point {i} opacity {o:?}"); + } + assert_eq!(s.doc().unwrap().doc.node(m).unwrap().opacity, 1.0, "{what}: the object stays opaque"); + }; + // The Mesh tool: a click, then Shift-clicks add points (and a second one takes one away). + s.select_tool("mesh", v).unwrap(); + click(&mut s, 1, false); + for i in [4, 8, 8] { + click(&mut s, i, true); + } + s.execute("paint.setFill", &json!({"color": "#0000ff"})).unwrap(); + let undo = s.doc().unwrap().history.undo.len(); + s.execute("transparency.set", &json!({"opacity": 40})).unwrap(); + check(&s, &[1, 4], "#0000ff", 0.4, "mesh tool"); + assert_eq!(s.doc().unwrap().history.undo.len(), undo + 1, "one undo step for both points"); + assert_eq!(s.transparency_info().opacity, Some(40.0), "the panel shows the points' opacity"); + s.execute("object.mesh.setPointColor", &json!({"id": m.0, "index": 4, "opacity": 0.9})).unwrap(); + assert_eq!(s.transparency_info().opacity, None, "mixed: blank"); + // Direct Selection: a marquee over the top-left patch picks its four points. + s.select_tool("directSelection", v).unwrap(); + let corner = point(&s, 0); + pointer(&mut s, PointerKind::Down, corner - vectorcraft_geom::Vec2::new(8.0, 8.0), false); + let far = point(&s, 4) + vectorcraft_geom::Vec2::new(5.0, 5.0); + pointer(&mut s, PointerKind::Drag, far, false); + pointer(&mut s, PointerKind::Up, far, false); + assert_eq!(s.doc().unwrap().selection.objects, [m], "the marquee selects the mesh"); + s.execute("paint.setFill", &json!({"color": "#00ff00"})).unwrap(); + s.execute("transparency.set", &json!({"opacity": 20})).unwrap(); + check(&s, &[0, 1, 3, 4], "#00ff00", 0.2, "marquee"); + // A drag of one picked point moves all four by the same offset, in one step. + let before: Vec<_> = (0..9).map(|i| point(&s, i)).collect(); + let undo = s.doc().unwrap().history.undo.len(); + let d = vectorcraft_geom::Vec2::new(4.0, 6.0); + pointer(&mut s, PointerKind::Down, before[4], false); + pointer(&mut s, PointerKind::Drag, before[4] + d, false); + pointer(&mut s, PointerKind::Up, before[4] + d, false); + for (i, was) in before.iter().enumerate() { + let want = if [0, 1, 3, 4].contains(&i) { *was + d } else { *was }; + assert!(point(&s, i).distance(want) < 1e-9, "point {i}: {:?} ≠ {want:?}", point(&s, i)); + } + assert_eq!(s.doc().unwrap().history.undo.len(), undo + 1, "one undo step"); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!((0..9).map(|i| point(&s, i)).collect::>(), before); +} + #[test] fn blend_moves_a_mesh_to_the_blended_colour() { let mut s = session(); diff --git a/crates/engine/src/tests/live.rs b/crates/engine/src/tests/live.rs index aa09ad88fe..d663db702c 100644 --- a/crates/engine/src/tests/live.rs +++ b/crates/engine/src/tests/live.rs @@ -851,6 +851,63 @@ fn mesh_point_colour_move_and_undo() { assert!(s.execute("object.mesh.setPointColor", &json!({"id": a.0, "index": 99, "color": "#000000"})).is_err()); } +/// `object.mesh.movePoints` moves just the points it names (their handles with them), over one or +/// several meshes, as one undo step; `object.mesh.setPointColor` colours and fades several points +/// alike. A bad index, a non-number or a move past the coordinate range fails and changes nothing +/// (#4207, #4208). +#[test] +fn mesh_points_move_and_colour_together() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 100.0, 100.0); + let b = rect(&mut s, 200.0, 0.0, 100.0, 100.0); + sel(&mut s, &[a, b]); + s.execute("object.mesh.create", &json!({"rows": 2, "cols": 2})).unwrap(); + let (ma, mb) = (mesh_of(&s, a), mesh_of(&s, b)); + let n = undo_len(&s); + s.execute("object.mesh.movePoints", &json!({"id": a.0, "points": [0, 4, 4], "dx": 10, "dy": -5})).unwrap(); + let m = mesh_of(&s, a); + for (i, (q, was)) in m.points.iter().zip(&ma.points).enumerate() { + let want = if i == 0 || i == 4 { Point::new(was.p.x + 10.0, was.p.y - 5.0) } else { was.p }; + assert_eq!((q.p, q.handles), (want, was.handles), "point {i}: moved once if named, its handles with it"); + } + assert_eq!(undo_len(&s), n + 1); + s.execute("object.mesh.movePoints", &json!({"items": [{"id": a.0, "points": [1]}, {"id": b.0, "index": 2}], "dx": 1, "dy": 1})).unwrap(); + assert_eq!(mesh_of(&s, a).points[1].p, Point::new(ma.points[1].p.x + 1.0, ma.points[1].p.y + 1.0)); + assert_eq!(mesh_of(&s, b).points[2].p, Point::new(mb.points[2].p.x + 1.0, mb.points[2].p.y + 1.0)); + assert_eq!(undo_len(&s), n + 2, "both meshes in one step"); + // A move that would take a point past the coordinate range fails. + assert!(s.execute("object.mesh.movePoints", &json!({"id": a.0, "points": [0], "dx": 1e308, "dy": 0})).is_err()); + assert_eq!(undo_len(&s), n + 2); + for _ in 0..2 { + s.execute("edit.undo", &json!({})).unwrap(); + } + assert_eq!((mesh_of(&s, a), mesh_of(&s, b)), (ma.clone(), mb.clone())); + // Several points take one colour and opacity, in one step. + s.execute("object.mesh.setPointColor", &json!({"id": a.0, "points": [2, 6], "color": "#0000ff", "opacity": 0.25})).unwrap(); + for (i, q) in mesh_of(&s, a).points.iter().enumerate() { + let named = i == 2 || i == 6; + assert_eq!((q.color.to_hex() == "#0000ff", q.opacity == 0.25), (named, named), "point {i}"); + } + assert_eq!(undo_len(&s), n + 1); + let n = undo_len(&s); + let before = (mesh_of(&s, a), mesh_of(&s, b)); + for p in [ + json!({"id": a.0, "points": [0, 99], "dx": 1, "dy": 1}), + json!({"items": [{"id": a.0, "points": [0]}, {"id": b.0, "points": [99]}], "dx": 1, "dy": 1}), + json!({"id": a.0, "points": [-1], "dx": 1, "dy": 1}), + json!({"id": a.0, "points": [1.5], "dx": 1, "dy": 1}), + json!({"id": a.0, "points": ["1"], "dx": 1, "dy": 1}), + json!({"id": a.0, "points": 1, "dx": 1, "dy": 1}), + json!({"id": a.0, "points": [0], "dx": "1", "dy": 1}), + json!({"items": 3, "dx": 1, "dy": 1}), + json!({"points": [0], "dx": 1, "dy": 1}), + ] { + assert!(s.execute("object.mesh.movePoints", &p).is_err(), "{p}"); + } + assert!(s.execute("object.mesh.setPointColor", &json!({"id": a.0, "points": [0, 9], "color": "#000000"})).is_err()); + assert_eq!(((mesh_of(&s, a), mesh_of(&s, b)), undo_len(&s)), (before, n), "nothing changed"); +} + #[test] fn mesh_add_line_and_delete_point() { let mut s = session(); diff --git a/crates/tools/src/context.rs b/crates/tools/src/context.rs index f1973dfd56..7773762f2e 100644 --- a/crates/tools/src/context.rs +++ b/crates/tools/src/context.rs @@ -282,6 +282,20 @@ impl ToolContext<'_> { pub fn star_radii_label(&self, outer: f64, inner: f64) -> String { format!("R1: {}\nR2: {}", self.len(outer), self.len(inner)) } + /// The move an arrow key nudges by: General › Keyboard Increment (ten times with Shift), + /// along General › Constrain Angle's axes; `None` for other keys. + pub fn arrow_nudge(&self, key: crate::ToolKey, mods: crate::Mods) -> Option { + use crate::ToolKey; + let step = self.keyboard_increment * if mods.shift { 10.0 } else { 1.0 }; + let d = match key { + ToolKey::Left => Point::new(-step, 0.0), + ToolKey::Right => Point::new(step, 0.0), + ToolKey::Up => Point::new(0.0, -step), + ToolKey::Down => Point::new(0.0, step), + _ => return None, + }; + Some(vectorcraft_geom::constrain_axes(self.constrain_angle).map_or(d, |axes| axes * d).to_vec2()) + } /// A move label: `dX: …` over `dY: …`. pub fn offset_label(&self, dx: f64, dy: f64) -> String { format!("dX: {}\ndY: {}", self.len(dx), self.len(dy)) diff --git a/crates/tools/src/direct.rs b/crates/tools/src/direct.rs index cb0a958f65..cba1c40b98 100644 --- a/crates/tools/src/direct.rs +++ b/crates/tools/src/direct.rs @@ -25,8 +25,11 @@ //! pointer ([`release_guide_at`]). //! Direct Selection also edits a blend's spine: drag its points (a key object on a point moves //! with it) and, once a point is clicked, its handles; and the points of selected gradient meshes -//! and mesh envelopes and their handles ([`MeshEdit`]; a solid fill colour recolours a gradient -//! mesh's point last clicked). Dragging a corner or an edge of area +//! and mesh envelopes and their handles ([`MeshEdit`]): Shift-clicks and the marquee pick several, +//! a click on a gradient mesh's line picks its two ends and one inside a patch the four points +//! around it, a drag of picked points moves them all, the arrow keys nudge them, and a solid fill +//! colour or the Transparency panel's opacity goes to a gradient mesh's picked points. Dragging a +//! corner or an edge of area //! type's frame reshapes the type area (`text.reshapeArea`): the text reflows at its size. A click //! on a frame anchor or a marquee selects frame anchors (Shift toggles them). While the selection //! holds only area type with selected frame anchors, those show filled, a drag of one of them moves @@ -49,7 +52,7 @@ use vectorcraft_geom::{Anchor, PathData, Point, Rect, Vec2}; use crate::bbox::move_delta; use crate::corners::{self, CornerDrag, over_widget}; use crate::guides::{HandleSnap, Leave, PointSnap, Targets}; -use crate::meshedit::MeshEdit; +use crate::meshedit::{MeshEdit, grid_of}; use crate::pathtype::{self, BracketDrag, over_bracket}; use crate::rulerguide::GuideEdit; use crate::select::{MoveSnap, hold_point, is_area_type, is_path_type, matrix_json, release_guide_at}; @@ -280,20 +283,17 @@ impl DirectSelectionTool { if !matches!(self.state, State::Idle) { return None; } - let step = cx.keyboard_increment * if mods.shift { 10.0 } else { 1.0 }; - let d = match key { - ToolKey::Left => Point::new(-step, 0.0), - ToolKey::Right => Point::new(step, 0.0), - ToolKey::Up => Point::new(0.0, -step), - ToolKey::Down => Point::new(0.0, step), - _ => return None, - }; + let d = cx.arrow_nudge(key, mods)?; let items = self.frame_anchors(cx); - if items.is_empty() { + (!items.is_empty()).then_some((items, d)) + } + + /// An arrow key's nudge of the picked points of the selected meshes. + fn mesh_nudge(&self, cx: &ToolContext, key: ToolKey, mods: Mods) -> Option> { + if !matches!(self.state, State::Idle) { return None; } - let d = vectorcraft_geom::constrain_axes(cx.constrain_angle).map_or(d, |axes| axes * d); - Some((items, d.to_vec2())) + self.mesh.nudge(cx, key, mods, &|id| cx.selection.contains(id)) } /// Is `key` the E that Group Selection takes while a marquee is being dragged? Direct @@ -583,6 +583,9 @@ impl Tool for DirectSelectionTool { /// entirely inside it, whole, and E pressed again makes it select what it selects by default. /// The arrow keys nudge the selected frame anchors of area type. fn key(&mut self, cx: &ToolContext, key: ToolKey, mods: Mods) -> Vec { + if let Some(out) = self.mesh_nudge(cx, key, mods) { + return out; + } if let Some((items, d)) = self.frame_nudge(cx, key, mods) { return vec![Action::Exec("text.reshapeArea".into(), reshape_params(&items, d)), Action::Notify(FRAME_PICKED.into())]; } @@ -609,7 +612,7 @@ impl Tool for DirectSelectionTool { if frame { vec![Action::Cancel, Action::Notify(FRAME_PICKED.into())] } else { vec![Action::Cancel] } } fn claims_key(&self, cx: &ToolContext, key: ToolKey) -> bool { - self.claims_letter(key) || self.frame_nudge(cx, key, Mods::default()).is_some() + self.claims_letter(key) || self.mesh_nudge(cx, key, Mods::default()).is_some() || self.frame_nudge(cx, key, Mods::default()).is_some() } fn notify(&mut self, cx: &ToolContext, what: &str) { if what == FRAME_PICKED { @@ -656,9 +659,12 @@ impl Tool for DirectSelectionTool { self.snapped = false; if let Some(g) = self.mesh.hit(cx, &cx.selection.objects, p) { self.state = State::Mesh; - return self.mesh.press(cx, g); + return self.mesh.press(cx, &cx.selection.objects, g, p, ev.mods.shift); + } + // Shift keeps the picked mesh points: it adds to the selection. + if !ev.mods.shift { + self.mesh.unfocus(); } - self.mesh.unfocus(); if let Some((id, si, ai, out)) = hit_handle(cx, p, point) { self.state = State::Handle { id, si, ai, out }; self.handle_snap = HandleSnap::default(); @@ -772,7 +778,7 @@ impl Tool for DirectSelectionTool { (PointerKind::Drag, State::Mesh) => self.mesh.drag_to(p).unwrap_or_default(), (PointerKind::Up, State::Mesh) => { self.state = State::Idle; - self.mesh.release().unwrap_or_default() + self.mesh.release(cx).unwrap_or_default() } (PointerKind::Drag, State::Marquee { start, toggle, enclosed, .. }) => { self.state = State::Marquee { start, cur: p, toggle, enclosed }; @@ -820,7 +826,7 @@ impl Tool for DirectSelectionTool { State::Corner(c) => c.overlays(cx), _ => { let mut out = self.spine_overlays(cx); - out.extend(self.mesh.overlays(cx)); + out.extend(self.mesh.overlays(cx, &|id| cx.selection.contains(id))); if !self.group { out.extend(frame_overlays(cx, &self.frame_anchors(cx))); out.extend(pathtype::overlays(cx)); @@ -1131,6 +1137,24 @@ impl DirectSelectionTool { h.ancestry.push(part); h.leaf = part; } + // On a gradient mesh a click picks the point, the mesh line's two ends or the four points + // around the patch under it (Shift toggles them), and selects the mesh; a drag moves the + // picked points. + if !ev.mods.alt + && let Some(NodeKind::Mesh(m)) = cx.doc.node(h.leaf).map(|n| &n.kind) + && let Some(points) = crate::meshedit::part_points(m, p, cx.point_tol(), tol) + { + let id = h.leaf; + let mut out = match (ev.mods.shift, cx.selection.contains(id)) { + (true, false) => vec![Action::Exec("select.add".into(), json!({"ids": [id.0]}))], + (false, false) => vec![Action::Exec("select.set".into(), json!({"ids": [id.0]}))], + _ => vec![], + }; + self.frame.clear(); + self.state = State::Mesh; + out.extend(self.mesh.press_points(cx, &cx.selection.objects, id, &points, p, ev.mods.shift)); + return out; + } // A segment pick keeps its endpoints available for movement without selecting // the anchors themselves. Dragging reshapes a curve, else moves it. Alt picks // the whole path (and Alt-drag copies it), as with Group Selection. @@ -1344,6 +1368,26 @@ impl DirectSelectionTool { }); framed.retain(|(id, _)| editable(*id)); } + // Direct Selection: the mesh points inside the rect are picked (with Shift, toggled), and + // their meshes selected whole; with Shift a mesh is toggled only when it gains its first + // picked point or loses its last one. + let mut meshed: Vec = vec![]; + if !self.group { + let mut inside: Vec<(NodeId, usize)> = vec![]; + walk_pickable(cx.doc, cx.isolation, |n| { + if editable(n.id) + && let Some(grid) = grid_of(n) + { + inside.extend(grid.points.iter().enumerate().filter(|(_, q)| r.contains(q.p)).map(|(i, _)| (n.id, i))); + } + }); + for (id, any) in self.mesh.marquee(&inside, toggle) { + meshed.push(id); + if !toggle || cx.selection.contains(id) != any { + sel.push((id, vec![])); + } + } + } let mut marked: BTreeMap> = if toggle { self.frame_anchors(cx).into_iter().map(|(id, v)| (id, v.into_iter().collect())).collect() } else { BTreeMap::new() }; for (id, inside) in &framed { @@ -1363,7 +1407,7 @@ impl DirectSelectionTool { // the marquee touches them, as with the Selection tool (#927). for id in vectorcraft_doc::hit::marquee(cx.doc, r, cx.isolation, true) { let whole = cx.doc.node(id).is_some_and(|n| !matches!(n.kind, NodeKind::Path { .. } | NodeKind::Compound { .. })); - if whole && !sel.iter().any(|(s, _)| *s == id) && !framed.iter().any(|(f, _)| *f == id) { + if whole && !sel.iter().any(|(s, _)| *s == id) && !framed.iter().any(|(f, _)| *f == id) && !meshed.contains(&id) { sel.push((id, vec![])); } } diff --git a/crates/tools/src/meshblend.rs b/crates/tools/src/meshblend.rs index 0ac4242679..68c1e41327 100644 --- a/crates/tools/src/meshblend.rs +++ b/crates/tools/src/meshblend.rs @@ -8,9 +8,11 @@ //! the click); click inside a mesh or a mesh envelope → `object.mesh.addLine` (a gradient mesh's //! new point takes the current fill color in its own model, unless Shift); drag a mesh point, //! or a handle of the point last clicked → `object.mesh.movePoint` previews ([`MeshEdit`]); -//! Alt-click a mesh point → `object.mesh.deletePoint`. Clicking a gradient mesh's point selects -//! the mesh, and the next solid fill color recolors just that point. Escape during a drag -//! cancels it. +//! Shift-click mesh points to pick several (Shift-click a picked one to drop it): a drag of one +//! moves them all (`object.mesh.movePoints`) and the arrow keys nudge them. Alt-click a mesh +//! point → `object.mesh.deletePoint`. Clicking a gradient mesh's point selects the mesh, and the +//! next solid fill color or Transparency panel opacity goes to just the picked points. Escape +//! during a drag cancels it. use serde_json::json; use vectorcraft_color::Paint; @@ -190,6 +192,11 @@ impl MeshTool { fn grab_at(&self, cx: &ToolContext, p: Point) -> Option { self.edit.hit(cx, &Self::meshes(cx), p) } + + /// An arrow key's nudge of the picked points. + fn nudge(&self, cx: &ToolContext, key: ToolKey, mods: Mods) -> Option> { + self.edit.nudge(cx, key, mods, &|_| true) + } } impl Tool for MeshTool { @@ -200,18 +207,23 @@ impl Tool for MeshTool { let p = ev.pos; match ev.kind { PointerKind::Down => { - if let Some(g) = self.grab_at(cx, p) { + let meshes = Self::meshes(cx); + if let Some(g) = self.edit.hit(cx, &meshes, p) { if ev.mods.alt && g.handle.is_none() { self.edit.unfocus(); return vec![Action::Exec("object.mesh.deletePoint".into(), json!({"id": g.id.0, "index": g.index}))]; } // A gradient mesh's point is picked for the next fill colour, so its mesh is - // what gets selected. + // what gets selected (with Shift, added to the selection). let mut out = vec![]; - if cx.selection.objects != [g.id] && cx.doc.node(g.id).is_some_and(|n| matches!(n.kind, NodeKind::Mesh(_))) { - out.push(Action::Exec("select.set".into(), json!({"ids": [g.id.0]}))); + if cx.doc.node(g.id).is_some_and(|n| matches!(n.kind, NodeKind::Mesh(_))) { + if ev.mods.shift && !cx.selection.contains(g.id) { + out.push(Action::Exec("select.add".into(), json!({"ids": [g.id.0]}))); + } else if !ev.mods.shift && cx.selection.objects != [g.id] { + out.push(Action::Exec("select.set".into(), json!({"ids": [g.id.0]}))); + } } - out.extend(self.edit.press(cx, g)); + out.extend(self.edit.press(cx, &meshes, g, p, ev.mods.shift)); return out; } self.edit.unfocus(); @@ -242,7 +254,7 @@ impl Tool for MeshTool { vec![] } PointerKind::Drag => self.edit.drag_to(p).unwrap_or_default(), - PointerKind::Up => self.edit.release().unwrap_or_default(), + PointerKind::Up => self.edit.release(cx).unwrap_or_default(), _ => vec![], } } @@ -256,7 +268,7 @@ impl Tool for MeshTool { } } } - out.extend(self.edit.overlays(cx)); + out.extend(self.edit.overlays(cx, &|_| true)); out } fn cursor(&self, cx: &ToolContext, p: Point, mods: Mods) -> Cursor { @@ -273,16 +285,19 @@ impl Tool for MeshTool { self.edit.dragging() } /// Escape during a drag of a mesh point or handle cancels it: the point goes back and the - /// release does nothing. - fn key(&mut self, _cx: &ToolContext, key: ToolKey, _mods: Mods) -> Vec { + /// release does nothing. The arrow keys nudge the picked points. + fn key(&mut self, cx: &ToolContext, key: ToolKey, mods: Mods) -> Vec { if key != ToolKey::Escape { - return vec![]; + return self.nudge(cx, key, mods).unwrap_or_default(); } self.edit.cancel().unwrap_or_default() } - fn deactivate(&mut self, _cx: &ToolContext) -> Vec { + fn claims_key(&self, cx: &ToolContext, key: ToolKey) -> bool { + self.nudge(cx, key, Mods::default()).is_some() + } + fn deactivate(&mut self, cx: &ToolContext) -> Vec { self.edit.unfocus(); - self.edit.release().unwrap_or_default() + self.edit.release(cx).unwrap_or_default() } } diff --git a/crates/tools/src/meshedit.rs b/crates/tools/src/meshedit.rs index 39f8adcdb7..b3904efe41 100644 --- a/crates/tools/src/meshedit.rs +++ b/crates/tools/src/meshedit.rs @@ -1,16 +1,21 @@ -//! Dragging mesh points and their handles on the canvas, shared by the Mesh tool and Direct -//! Selection: gradient meshes and mesh envelopes alike (`object.mesh.movePoint`). Clicking a -//! point focuses it: its handles show and can be dragged too, and on a gradient mesh a solid fill -//! colour recolours it (the tool's `meshPoint` option). +//! Picking and dragging mesh points and their handles on the canvas, shared by the Mesh tool and +//! Direct Selection: gradient meshes and mesh envelopes alike. A click on a point picks it alone +//! and focuses it: its handles show and can be dragged too. Shift-clicks add points to the picked +//! ones or take them away, and Direct Selection's marquee and its clicks on a gradient mesh's line +//! or patch pick points too ([`part_points`]). The picked points show filled; a drag of one of +//! them moves them all (`object.mesh.movePoint` for one, `object.mesh.movePoints` for several) +//! and the arrow keys nudge them. On a gradient mesh a solid fill colour recolours them and the +//! Transparency panel's opacity fades them (the tool's `meshPoints` option). use std::borrow::Cow; +use std::collections::BTreeSet; use serde_json::{Value, json}; use vectorcraft_doc::live::{GradientMesh, envelope_grid}; use vectorcraft_doc::{EnvelopeKind, Node, NodeId, NodeKind}; use vectorcraft_geom::{Point, Vec2}; -use crate::{Action, Overlay, ToolContext}; +use crate::{Action, Mods, Overlay, ToolContext, ToolKey}; const FEEDBACK: [u8; 3] = [0x4f, 0x9d, 0xff]; @@ -27,6 +32,29 @@ pub fn grid_of(n: &Node) -> Option> { } } +/// The points of gradient mesh `m` a Direct Selection click at `p` picks: the point within +/// `point_tol`, else the two ends of the mesh line within `line_tol`, else the four points around +/// the patch under `p`. +pub fn part_points(m: &GradientMesh, p: Point, point_tol: f64, line_tol: f64) -> Option> { + if let Some(i) = m.point_near(p, point_tol) { + return Some(vec![i]); + } + // `lines` lists the rows' edges, then the columns' (and nothing for a malformed mesh). + let (rows, cols) = (m.rows.max(1) as usize, m.cols.max(1) as usize); + if let Some((si, ..)) = m.lines().nearest(p).filter(|n| n.4 <= line_tol) { + let across = (rows + 1) * cols; + return Some(if si < across { + let (r, c) = (si / cols, si % cols); + vec![m.idx(r, c), m.idx(r, c + 1)] + } else { + let (c, r) = ((si - across) / rows, (si - across) % rows); + vec![m.idx(r, c), m.idx(r + 1, c)] + }); + } + let (r, c, ..) = m.locate(p)?; + Some(vec![m.idx(r, c), m.idx(r, c + 1), m.idx(r + 1, c), m.idx(r + 1, c + 1)]) +} + /// What a press on a mesh grabs: the mesh, the point and (on the focused point) a handle. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct MeshGrab { @@ -35,21 +63,46 @@ pub struct MeshGrab { pub handle: Option, } +/// Mesh points, each mesh with its points. +type MeshPoints = Vec<(NodeId, Vec)>; + /// An in-progress mesh point or handle drag. struct ActiveDrag { grab: MeshGrab, - /// Where the grabbed point or handle was when the drag began. + /// Where the press was. + start: Point, + /// Where the grabbed point or handle was when the drag began (where the press was, on a mesh + /// line or patch). origin: Point, /// The current drag position (preview target); set on the first `drag_to`. at: Option, + /// The picked points, when the drag moves several of them by its offset; empty when it moves + /// `grab` alone to the pointer. + many: MeshPoints, } -/// Point and handle drags on meshes. +/// The params of `object.mesh.movePoints` moving `items` by `d`. +fn move_params(items: &[(NodeId, Vec)], d: Vec2) -> Value { + match items { + [(id, points)] => json!({"id": id.0, "points": points, "dx": d.x, "dy": d.y}), + _ => { + let items: Vec = items.iter().map(|(id, v)| json!({"id": id.0, "points": v})).collect(); + json!({"items": items, "dx": d.x, "dy": d.y}) + } + } +} + +/// Mesh point picks and point and handle drags on meshes. #[derive(Default)] pub struct MeshEdit { /// The point last clicked: its handles show and can be dragged. focus: Option<(NodeId, usize)>, + /// The picked points (the focused one among them). + picked: BTreeSet<(NodeId, usize)>, drag: Option, + /// Pressed without Shift on points already picked among others: a click (no drag) picks + /// these alone, as a drag moves every picked point. + click: Option<(NodeId, Vec)>, } impl MeshEdit { @@ -72,23 +125,84 @@ impl MeshEdit { }) } - /// Start dragging `grab` (its point takes the focus). - pub fn press(&mut self, cx: &ToolContext, grab: MeshGrab) -> Vec { - self.focus = Some((grab.id, grab.index)); - let mut origin = Point::ZERO; - if let Some(grid) = cx.doc.node(grab.id).and_then(grid_of) - && let Some(q) = grid.points.get(grab.index) - { - origin = if let Some(h) = grab.handle { q.p + q.handles[h] } else { q.p }; + /// The picked points that still apply: of editable meshes `shown` accepts, in range. + fn live(&self, cx: &ToolContext, shown: &dyn Fn(NodeId) -> bool) -> MeshPoints { + let editable = cx.doc.editable(); + let mut out: Vec<(NodeId, usize, Vec)> = vec![]; + for &(id, i) in &self.picked { + if out.last().is_none_or(|(last, ..)| *last != id) { + let len = if shown(id) && editable(id) { cx.doc.node(id).and_then(grid_of).map_or(0, |g| g.points.len()) } else { 0 }; + out.push((id, len, vec![])); + } + if let Some((_, len, v)) = out.last_mut() + && i < *len + { + v.push(i); + } } - self.drag = Some(ActiveDrag { grab, origin, at: None }); - vec![Action::Begin("Move Mesh Point".into())] + out.into_iter().filter(|(.., v)| !v.is_empty()).map(|(id, _, v)| (id, v)).collect() + } + + /// A press at `p` on `grab`, among the meshes `ids`: a handle drag, or a point picked as + /// [`Self::press_points`] picks it. + pub fn press(&mut self, cx: &ToolContext, ids: &[NodeId], grab: MeshGrab, p: Point, shift: bool) -> Vec { + let Some(h) = grab.handle else { return self.press_points(cx, ids, grab.id, &[grab.index], p, shift) }; + let Some(q) = cx.doc.node(grab.id).and_then(grid_of).and_then(|g| g.points.get(grab.index).cloned()) else { return vec![] }; + let origin = q.p + q.handles.get(h).copied().unwrap_or_default(); + self.start(ActiveDrag { grab, start: p, origin, at: None, many: vec![] }) + } + + /// A press at `p` on the points `points` of mesh `id` (one point, a mesh line's ends or a + /// patch's corners), among the meshes `ids`. Shift takes them away from the picked points when + /// all of them are picked (no drag), else adds them; without it they are picked alone unless + /// all of them already are. A drag then moves every picked point. + pub fn press_points(&mut self, cx: &ToolContext, ids: &[NodeId], id: NodeId, points: &[usize], p: Point, shift: bool) -> Vec { + let keys: Vec<(NodeId, usize)> = points.iter().map(|i| (id, *i)).collect(); + let all = keys.iter().all(|k| self.picked.contains(k)); + self.click = None; + if shift && all { + for k in &keys { + self.picked.remove(k); + } + self.focus = self.focus.filter(|f| !keys.contains(f)); + return vec![]; + } + if !shift && !all { + self.picked.clear(); + } + self.picked.extend(keys.iter().copied()); + self.focus = keys.first().copied().filter(|_| keys.len() == 1); + let many = self.live(cx, &|m| m == id || ids.contains(&m)); + let count: usize = many.iter().map(|(_, v)| v.len()).sum(); + if count == 0 { + return vec![]; + } + if !shift && all && count > keys.len() { + self.click = Some((id, points.to_vec())); + } + let grab = MeshGrab { id, index: points.first().copied().unwrap_or_default(), handle: None }; + // One point goes where the pointer takes it; a line or a patch moves by the drag's offset. + let origin = match points { + [i] => cx.doc.node(id).and_then(grid_of).and_then(|g| g.points.get(*i).map(|q| q.p)).unwrap_or(p), + _ => p, + }; + let many = if count == 1 && keys.len() == 1 { vec![] } else { many }; + self.start(ActiveDrag { grab, start: p, origin, at: None, many }) + } + + fn start(&mut self, d: ActiveDrag) -> Vec { + let label = if d.many.is_empty() { "Move Mesh Point" } else { "Move Mesh Points" }; + self.drag = Some(d); + vec![Action::Begin(label.into())] } /// The preview of a drag to `p` (`None` when nothing is being dragged). pub fn drag_to(&mut self, p: Point) -> Option> { let d = self.drag.as_mut()?; d.at = Some(p); + if !d.many.is_empty() { + return Some(vec![Action::Preview("object.mesh.movePoints".into(), move_params(&d.many, p - d.origin))]); + } let g = d.grab; let mut params = json!({"id": g.id.0, "index": g.index, "x": p.x, "y": p.y}); if let Some(h) = g.handle { @@ -97,13 +211,21 @@ impl MeshEdit { Some(vec![Action::Preview("object.mesh.movePoint".into(), params)]) } - /// End a drag (`None` when nothing was being dragged). - pub fn release(&mut self) -> Option> { - self.drag.take().map(|_| vec![Action::Commit]) + /// End a drag (`None` when nothing was being dragged). A click on one of several picked + /// points picks it alone. + pub fn release(&mut self, cx: &ToolContext) -> Option> { + let d = self.drag.take()?; + if let Some((id, points)) = self.click.take() + && d.at.is_none_or(|a| a.distance(d.start) < cx.tol(3.0)) + { + self.picked = points.into_iter().map(|i| (id, i)).collect(); + } + Some(vec![Action::Commit]) } /// Cancel a drag: the point or handle goes back (`None` when nothing was being dragged). pub fn cancel(&mut self) -> Option> { + self.click = None; self.drag.take().map(|_| vec![Action::Cancel]) } @@ -111,26 +233,69 @@ impl MeshEdit { self.drag.is_some() } - /// Forget the focused point. + /// Forget the focused and the picked points. pub fn unfocus(&mut self) { - self.focus = None; + (self.focus, self.click) = (None, None); + self.picked.clear(); } - /// `{meshPoint: {id, index}|null}`: the focused point, which a solid fill colour recolours - /// (`paint.setFill` on a gradient mesh). + /// A marquee's picks: the points `inside` it are picked (with `toggle`, those picked are + /// taken away and the others added). Returns each mesh with points inside and whether any of + /// its points are picked now. + pub fn marquee(&mut self, inside: &[(NodeId, usize)], toggle: bool) -> Vec<(NodeId, bool)> { + if !toggle { + self.picked.clear(); + } + for k in inside { + if !(toggle && self.picked.remove(k)) { + self.picked.insert(*k); + } + } + self.focus = self.picked.first().copied().filter(|_| self.picked.len() == 1); + let mut meshes: Vec = inside.iter().map(|(id, _)| *id).collect(); + meshes.dedup(); + meshes.into_iter().map(|id| (id, self.picked.range((id, 0)..=(id, usize::MAX)).next().is_some())).collect() + } + + /// An arrow key's nudge of the picked points of the meshes `shown` accepts + /// (`object.mesh.movePoints`); `None` during a drag, for other keys or without picked points. + pub fn nudge(&self, cx: &ToolContext, key: ToolKey, mods: Mods, shown: &dyn Fn(NodeId) -> bool) -> Option> { + if self.drag.is_some() { + return None; + } + let d = cx.arrow_nudge(key, mods)?; + let live = self.live(cx, shown); + (!live.is_empty()).then(|| vec![Action::Exec("object.mesh.movePoints".into(), move_params(&live, d))]) + } + + /// `{meshPoints: [{id, index}…]}`: the picked points, which a solid fill colour recolours + /// (`paint.setFill`) and the Transparency panel's opacity fades (`transparency.set`) on a + /// gradient mesh. pub fn options(&self) -> Value { - json!({"meshPoint": self.focus.map(|(id, index)| json!({"id": id.0, "index": index}))}) + json!({"meshPoints": self.picked.iter().map(|(id, index)| json!({"id": id.0, "index": index})).collect::>()}) } - /// The focused point's handles (lines and ends). - pub fn overlays(&self, cx: &ToolContext) -> Vec { - let Some((id, index)) = self.focus else { return vec![] }; - let Some(grid) = cx.doc.node(id).and_then(grid_of) else { return vec![] }; - let Some(q) = grid.points.get(index) else { return vec![] }; - let mut out = vec![Overlay::Anchor { p: q.p, color: FEEDBACK, filled: true, size: 5.0 }]; - for h in q.handles.iter().filter(|h| h.hypot() > 1e-6) { - out.push(Overlay::Line { a: q.p, b: q.p + *h, color: FEEDBACK, dashed: false }); - out.push(Overlay::Handle { p: q.p + *h, color: FEEDBACK }); + /// The picked points of the meshes `shown` accepts, filled, and the focused point's handles + /// (lines and ends). + pub fn overlays(&self, cx: &ToolContext, shown: &dyn Fn(NodeId) -> bool) -> Vec { + let mut out = vec![]; + for (id, points) in self.live(cx, shown) { + let Some(grid) = cx.doc.node(id).and_then(grid_of) else { continue }; + out.extend(points.iter().filter_map(|i| grid.points.get(*i)).map(|q| Overlay::Anchor { + p: q.p, + color: FEEDBACK, + filled: true, + size: 5.0, + })); + } + if let Some((id, index)) = self.focus.filter(|(id, _)| shown(*id)) + && let Some(grid) = cx.doc.node(id).and_then(grid_of) + && let Some(q) = grid.points.get(index) + { + for h in q.handles.iter().filter(|h| h.hypot() > 1e-6) { + out.push(Overlay::Line { a: q.p, b: q.p + *h, color: FEEDBACK, dashed: false }); + out.push(Overlay::Handle { p: q.p + *h, color: FEEDBACK }); + } } if cx.measurement_labels && let Some(d) = &self.drag @@ -262,4 +427,133 @@ mod tests { assert!(t.overlays(&on).iter().any(|o| matches!(o, Overlay::Measure { text, .. } if text == &want))); assert!(!t.overlays(&off).iter().any(|o| matches!(o, Overlay::Measure { .. }))); } + + /// A 2×2 gradient mesh over the 100..200 square, its points 50 apart. + fn doc_with_mesh() -> (Document, NodeId) { + let (mut d, a) = doc_with_rect(); + d.remove(a).unwrap(); + let id = d.alloc_id(); + let m = GradientMesh::from_surface(2, 2, &|u, v| Point::new(100.0 + 100.0 * u, 100.0 + 100.0 * v), &|_, _| vectorcraft_color::Color::WHITE); + let l = d.layers[0].id; + d.insert(Some(l), 0, Node::new(id, NodeKind::Mesh(m))).unwrap(); + (d, id) + } + + /// The picked points of `t`, as its `meshPoints` option lists them. + fn picked(t: &dyn Tool) -> Vec { + t.options()["meshPoints"].as_array().unwrap().iter().map(|p| p["index"].as_u64().unwrap() as usize).collect() + } + + fn shift(kind: PointerKind, x: f64, y: f64) -> PointerEvent { + let mut e = PointerEvent::new(kind, x, y); + e.mods.shift = true; + e + } + + /// With the Mesh tool and Direct Selection, Shift-clicks pick several mesh points (and take a + /// picked one away); they show filled, a drag of one moves them all as one move, the arrow keys + /// nudge them, and a click on one of them picks it alone (#4207). + #[test] + fn shift_clicks_pick_mesh_points_that_drag_and_nudge_together() { + let (d, m) = doc_with_mesh(); + let mut s = Selection::default(); + s.set([m]); + let p = paint(); + let c = cx(&d, &s, &p); + let at = |x: f64, y: f64| grid_of(d.node(m).unwrap()).unwrap().point_near(Point::new(x, y), 1.0).unwrap(); + let sorted = |mut v: Vec| { + v.sort(); + v + }; + let (a, b, e) = (at(100.0, 100.0), at(200.0, 150.0), at(150.0, 100.0)); + let tools: [(&str, Box); 2] = + [("mesh", crate::meshblend::create("mesh").unwrap()), ("directSelection", Box::new(crate::direct::DirectSelectionTool::new(false)))]; + for (what, mut t) in tools { + assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Down, 100.0, 100.0)), vec![Action::Begin("Move Mesh Point".into())], "{what}"); + t.pointer(&c, &PointerEvent::new(PointerKind::Up, 100.0, 100.0)); + assert_eq!(t.pointer(&c, &shift(PointerKind::Down, 200.0, 150.0)), vec![Action::Begin("Move Mesh Points".into())], "{what}"); + t.pointer(&c, &shift(PointerKind::Up, 200.0, 150.0)); + assert_eq!(picked(&*t), sorted(vec![a, b]), "{what}"); + let filled = t.overlays(&c).iter().filter(|o| matches!(o, Overlay::Anchor { filled: true, .. })).count(); + assert_eq!(filled, 2, "{what}: the picked points show filled"); + // A drag of either moves both. + assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Down, 100.0, 100.0)), vec![Action::Begin("Move Mesh Points".into())], "{what}"); + assert_eq!( + t.pointer(&c, &PointerEvent::new(PointerKind::Drag, 110.0, 95.0)), + vec![Action::Preview("object.mesh.movePoints".into(), json!({"id": m.0, "points": sorted(vec![a, b]), "dx": 10.0, "dy": -5.0}))], + "{what}" + ); + assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Up, 110.0, 95.0)), vec![Action::Commit], "{what}"); + assert_eq!(picked(&*t), sorted(vec![a, b]), "{what}: a drag keeps them picked"); + // Shift-clicking a picked point takes it away, without a drag. + assert!(t.pointer(&c, &shift(PointerKind::Down, 200.0, 150.0)).is_empty(), "{what}"); + t.pointer(&c, &shift(PointerKind::Up, 200.0, 150.0)); + assert_eq!(picked(&*t), [a], "{what}"); + // The arrow keys nudge the picked points. + assert!(t.claims_key(&c, ToolKey::Right), "{what}"); + assert_eq!( + t.key(&c, ToolKey::Right, Mods::default()), + vec![Action::Exec("object.mesh.movePoints".into(), json!({"id": m.0, "points": [a], "dx": 1.0, "dy": 0.0}))], + "{what}" + ); + // A click on one of several picked points picks it alone. + t.pointer(&c, &shift(PointerKind::Down, 150.0, 100.0)); + t.pointer(&c, &shift(PointerKind::Up, 150.0, 100.0)); + assert_eq!(picked(&*t), sorted(vec![a, e]), "{what}"); + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 100.0, 100.0)); + assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Up, 100.0, 100.0)), vec![Action::Commit], "{what}"); + assert_eq!(picked(&*t), [a], "{what}"); + } + } + + /// Direct Selection's marquee picks the mesh points inside it and selects their mesh (Shift + /// toggles them); a click on a mesh line picks its two ends and one inside a patch the four + /// points around it, selecting the mesh, and a drag from there moves them (#4207). + #[test] + fn direct_selection_picks_mesh_points_by_marquee_line_and_patch() { + let (d, m) = doc_with_mesh(); + let mut s = Selection::default(); + s.set([m]); + let p = paint(); + let c = cx(&d, &s, &p); + let at = |x: f64, y: f64| grid_of(d.node(m).unwrap()).unwrap().point_near(Point::new(x, y), 1.0).unwrap(); + let set = |v: &[(f64, f64)]| { + let mut v: Vec = v.iter().map(|(x, y)| at(*x, *y)).collect(); + v.sort(); + v + }; + let mut t = crate::direct::DirectSelectionTool::new(false); + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 90.0, 90.0)); + t.pointer(&c, &PointerEvent::new(PointerKind::Drag, 160.0, 120.0)); + let out = t.pointer(&c, &PointerEvent::new(PointerKind::Up, 160.0, 120.0)); + assert!( + matches!(out.first(), Some(Action::Exec(cmd, q)) if cmd == "select.anchorsMany" && q["items"] == json!([{"id": m.0, "anchors": []}])), + "{out:?}" + ); + assert_eq!(picked(&t), set(&[(100.0, 100.0), (150.0, 100.0)])); + // Shift: the picked points inside leave, the others join; the mesh stays selected. + t.pointer(&c, &shift(PointerKind::Down, 90.0, 90.0)); + t.pointer(&c, &shift(PointerKind::Drag, 110.0, 160.0)); + let out = t.pointer(&c, &shift(PointerKind::Up, 110.0, 160.0)); + assert!(matches!(out.first(), Some(Action::Exec(cmd, q)) if cmd == "select.anchorsMany" && q["items"] == json!([])), "{out:?}"); + assert_eq!(picked(&t), set(&[(150.0, 100.0), (100.0, 150.0)])); + // A mesh line: its two ends. + assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Down, 125.0, 150.0)), vec![Action::Begin("Move Mesh Points".into())]); + t.pointer(&c, &PointerEvent::new(PointerKind::Up, 125.0, 150.0)); + assert_eq!(picked(&t), set(&[(100.0, 150.0), (150.0, 150.0)])); + // A patch: the four points around it, which a drag moves by its offset. + assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Down, 175.0, 175.0)), vec![Action::Begin("Move Mesh Points".into())]); + let four = set(&[(150.0, 150.0), (200.0, 150.0), (150.0, 200.0), (200.0, 200.0)]); + assert_eq!( + t.pointer(&c, &PointerEvent::new(PointerKind::Drag, 185.0, 180.0)), + vec![Action::Preview("object.mesh.movePoints".into(), json!({"id": m.0, "points": four, "dx": 10.0, "dy": 5.0}))] + ); + t.pointer(&c, &PointerEvent::new(PointerKind::Up, 185.0, 180.0)); + // A mesh that isn't selected yet gets selected. + let none = Selection::default(); + let c = cx(&d, &none, &p); + let out = t.pointer(&c, &PointerEvent::new(PointerKind::Down, 125.0, 125.0)); + assert_eq!(out, vec![Action::Exec("select.set".into(), json!({"ids": [m.0]})), Action::Begin("Move Mesh Points".into())]); + assert_eq!(picked(&t), set(&[(100.0, 100.0), (150.0, 100.0), (100.0, 150.0), (150.0, 150.0)])); + } } diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index e5a6fe5a20..a496b97beb 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -1860,6 +1860,7 @@ font-technology Variable Променливи Move in Perspective Преместване в перспектива Move Locked and Hidden Artwork with Artboard Преместване на заключени и скрити обекти с работната област Move Mesh Point Преместване на точка от мрежата + Move Mesh Points Преместване на точки от мрежата Move Plane Преместване на равнина Move Plane to Match Object Преместване на равнината според обекта Move Rows Преместване на редове diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index d721532cf3..bd918d326a 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -2419,6 +2419,7 @@ Move Library Item to Group Mou l’element de la biblioteca al grup Move Locked and Hidden Artwork with Artboard Mou la il·lustració bloquejada i oculta amb el tauler Move Mesh Point Mou el punt de malla + Move Mesh Points Mou els punts de malla Move Panel Mou el panell Move Plane Mou el pla Move Plane and Copy Objects Mou el pla i copia els objectes diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 0c33de6afa..63a9223cef 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -3314,6 +3314,7 @@ theme Appearance Motiv Make Envelope Vytvořit obálku Move Envelope Mesh Point Přesunout bod sítě obálky Move Mesh Point Přesunout bod sítě + Move Mesh Points Přesunout body sítě Move Spine Point Přesunout bod páteře Reshape Spine Segment Přetvarovat segment páteře Reset with Mesh Obnovit sítí diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 4e8f3d233a..312f807129 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -3072,6 +3072,7 @@ theme Appearance Udseende Make Envelope Opret konvolut Move Envelope Mesh Point Flyt konvolut-meshpunkt Move Mesh Point Flyt meshpunkt + Move Mesh Points Flyt meshpunkter Move Spine Point Flyt rygradpunkt Reshape Spine Segment Omform rygradsegment Reset with Mesh Nulstil med mesh diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 74feb99bfd..19e8c766f0 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -1915,6 +1915,7 @@ file-filter Templates Vorlagen Move in Perspective In Perspektive verschieben Move Locked and Hidden Artwork with Artboard Gesperrte und ausgeblendete Grafik mit Zeichenfläche verschieben Move Mesh Point Gitterpunkt verschieben + Move Mesh Points Gitterpunkte verschieben Move Plane Perspektivebene verschieben Move Plane to Match Object Perspektivebene an Objekt ausrichten Move Rows Zeilen verschieben diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index eb0fee4b5d..9c4647fc4e 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -2675,6 +2675,7 @@ theme Appearance Εμφάνιση Move in Perspective Μετακίνηση σε προοπτική Move Locked and Hidden Artwork with Artboard Μετακίνηση κλειδωμένων και κρυφών σχεδίων μαζί με τον πίνακα σχεδίασης Move Mesh Point Μετακίνηση σημείου πλέγματος + Move Mesh Points Μετακίνηση σημείων πλέγματος Move Plane Μετακίνηση επιπέδου προοπτικής Move Plane to Match Object Μετακίνηση επιπέδου προοπτικής ώστε να ταιριάζει στο αντικείμενο Move Rows Μετακίνηση γραμμών diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index c7ae0fec78..64c34fbc00 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -1913,6 +1913,7 @@ font-technology Variable Variables Move in Perspective Mover en perspectiva Move Locked and Hidden Artwork with Artboard Mover ilustración bloqueada y oculta con la mesa de trabajo Move Mesh Point Mover punto de malla + Move Mesh Points Mover puntos de malla Move Plane Mover plano Move Plane to Match Object Mover plano para que coincida con el objeto Move Rows Mover filas diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index a4235d8c36..bf54f52655 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -3253,6 +3253,7 @@ theme Appearance Ulkoasu Make Envelope Tee kuori Move Envelope Mesh Point Siirrä kuoren verkkopistettä Move Mesh Point Siirrä verkkopistettä + Move Mesh Points Siirrä verkkopisteitä Move Spine Point Siirrä selkärangan pistettä Reshape Spine Segment Muotoile selkärangan segmentti uudelleen Reset with Mesh Palauta verkolla diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 53d1678341..eef0404d50 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -1912,6 +1912,7 @@ font-technology Variable Variables Move in Perspective Déplacer en perspective Move Locked and Hidden Artwork with Artboard Déplacer les illustrations verrouillées et masquées avec le plan de travail Move Mesh Point Déplacer le point de filet + Move Mesh Points Déplacer les points de filet Move Plane Déplacer le plan Move Plane to Match Object Déplacer le plan pour l’aligner sur l’objet Move Rows Déplacer les lignes diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 20dd32810b..19d2d85ee2 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -2418,6 +2418,7 @@ file-filter Templates Sablonok Move Library Item to Group Könyvtárelem áthelyezése csoportba Move Locked and Hidden Artwork with Artboard Zárolt és rejtett grafika mozgatása a rajztáblával Move Mesh Point Hálópont áthelyezése + Move Mesh Points Hálópontok áthelyezése Move Panel Panel áthelyezése Move Plane Sík áthelyezése Move Plane to Match Object Sík igazítása az objektumhoz diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index dab8acf356..e65b361904 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -3072,6 +3072,7 @@ theme Appearance Tampilan Make Envelope Buat envelope Move Envelope Mesh Point Pindahkan titik mesh envelope Move Mesh Point Pindahkan titik mesh + Move Mesh Points Pindahkan titik-titik mesh Move Spine Point Pindahkan titik spine Reshape Spine Segment Bentuk ulang segmen spine Reset with Mesh Atur ulang dengan mesh diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 782ac23017..5326bb34c4 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -1940,6 +1940,7 @@ file-filter Templates Modelli Move in Perspective Sposta in prospettiva Move Locked and Hidden Artwork with Artboard Sposta grafica bloccata e nascosta con la tavola da disegno Move Mesh Point Sposta punto trama + Move Mesh Points Sposta punti trama Move Plane Sposta piano Move Plane to Match Object Sposta piano in base all'oggetto Move Rows Sposta righe diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index fa545683e0..927b8d3b80 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -2082,6 +2082,7 @@ font-technology Variable バリアブル Move Guide ガイドを移動 Move Locked and Hidden Artwork with Artboard ロックおよび非表示のアートワークをアートボードと一緒に移動 Move Mesh Point メッシュポイントを移動 + Move Mesh Points メッシュポイントを移動 Move Plane 面を移動 Move Rows 行を移動 Move Slices スライスを移動 diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 02fa7cbc5c..dbcaeca5da 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -2885,6 +2885,7 @@ theme Appearance იერსახე Make Envelope გარსის შექმნა Move Envelope Mesh Point გარსის ბადის წერტილის გადაადგილება Move Mesh Point ბადის წერტილის გადაადგილება + Move Mesh Points ბადის წერტილების გადაადგილება Move Spine Point ხერხემლის წერტილის გადაადგილება Reshape Spine Segment ხერხემლის სეგმენტის ფორმის შეცვლა Reset with Mesh ბადით ჩამოყრა diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 1d9b827afd..81c87fdaee 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -2077,6 +2077,7 @@ font-technology Variable 가변 Move Guide 안내선 이동 Move Locked and Hidden Artwork with Artboard 잠기거나 숨겨진 아트워크를 아트보드와 함께 이동 Move Mesh Point 메시 포인트 이동 + Move Mesh Points 메시 포인트 이동 Move Plane 평면 이동 Move Rows 행 이동 Move Slices 슬라이스 이동 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 74debd4a17..3ec76a559e 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -3086,6 +3086,7 @@ theme Appearance Vormgeving Make Envelope Omtrek maken Move Envelope Mesh Point Maaspunt van omtrek verplaatsen Move Mesh Point Maaspunt verplaatsen + Move Mesh Points Maaspunten verplaatsen Move Spine Point Aspunt verplaatsen Reshape Spine Segment Segment van de as opnieuw vormgeven Reset with Mesh Opnieuw instellen met maas diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index c1051905b9..e2b44fb043 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -3194,6 +3194,7 @@ theme Appearance Wygląd Make Envelope Utwórz kopertę Move Envelope Mesh Point Przesuń punkt siatki koperty Move Mesh Point Przesuń punkt siatki + Move Mesh Points Przesuń punkty siatki Move Spine Point Przesuń punkt grzbietu Reshape Spine Segment Zmień kształt segmentu grzbietu Reset with Mesh Resetuj z siatką diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 401402b14f..878bf119f5 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -1597,6 +1597,7 @@ Move Guide Mover Guia Move Locked and Hidden Artwork with Artboard Mover Arte Bloqueada e Oculta com a Mesa de Trabalho Move Mesh Point Mover Ponto de Malha + Move Mesh Points Mover Pontos de Malha Move Plane Mover Plano Move Plane to Match Object Mover Plano para Corresponder ao Objeto Move Slices Mover Fatias diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index f458e20f72..90f7a8f5ed 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -1938,6 +1938,7 @@ file-filter Templates Шаблоны Move in Perspective Переместить в перспективе Move Locked and Hidden Artwork with Artboard Перемещать заблокированный и скрытый рисунок вместе с монтажной областью Move Mesh Point Переместить точку сетки + Move Mesh Points Переместить точки сетки Move Plane Переместить плоскость Move Plane to Match Object Переместить плоскость по объекту Move Rows Переместить строки diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 1109687660..d8f16d7c8c 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -1860,6 +1860,7 @@ font-technology Variable Variabla Move in Perspective Flytta i perspektiv Move Locked and Hidden Artwork with Artboard Flytta låst och dold grafik med ritytan Move Mesh Point Flytta nätpunkt + Move Mesh Points Flytta nätpunkter Move Plane Flytta plan Move Plane to Match Object Flytta plan så att det matchar objekt Move Rows Flytta rader diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index c8327c9432..85822e4587 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -1757,6 +1757,7 @@ font-technology Variable Değişken Move in Perspective Perspektifte Hareket Et Move Locked and Hidden Artwork with Artboard Çalışma Yüzeyi ile Kilitli ve Gizli Resimleri Taşıma Move Mesh Point Mesh Noktasını Taşı + Move Mesh Points Mesh Noktalarını Taşı Move Plane Düzlemi Taşı Move Plane to Match Object Nesneyi Eşleştirecek Düzlemi Taşı Move Rows Satırları Taşı diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 097b252520..69d617b9b8 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -1934,6 +1934,7 @@ file-filter Templates Шаблони Move in Perspective Перемістити у перспективі Move Locked and Hidden Artwork with Artboard Переміщати заблокований та прихований малюнок разом із монтажною областю Move Mesh Point Перемістити точку сітки + Move Mesh Points Перемістити точки сітки Move Plane Перемістити площину Move Plane to Match Object Перемістити площину об’єктом Move Rows Перемістити рядки diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index a902698a0a..4d9c255831 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -2227,6 +2227,7 @@ file-filter Templates Mẫu Move Library Item to Group Di chuyển mục thư viện vào nhóm Move Locked and Hidden Artwork with Artboard Di chuyển tác phẩm đã khóa và ẩn cùng bảng vẽ Move Mesh Point Di chuyển điểm lưới + Move Mesh Points Di chuyển các điểm lưới Move Panel Di chuyển bảng Move Plane Di chuyển mặt phẳng Move Plane to Match Object Di chuyển mặt phẳng khớp với đối tượng diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index ac5e9fcae7..8aed395a34 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -1811,6 +1811,7 @@ file-filter Templates 模板 Move in Perspective 在透视中移动 Move Locked and Hidden Artwork with Artboard 随画板移动锁定和隐藏图稿 Move Mesh Point 移动网格点 + Move Mesh Points 移动网格点 Move Plane 移动平面 Move Plane to Match Object 移动平面以符合对象 Move Slices 移动切片 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index ff6da5768d..0d2172acf6 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2729,6 +2729,7 @@ file-filter Templates 範本 Move in Perspective 在透視中移動 Move Locked and Hidden Artwork with Artboard 移動工作區域時一併移動鎖定與隱藏的圖稿 Move Mesh Point 移動網格點 + Move Mesh Points 移動網格點 Move Plane 移動平面 Move Plane to Match Object 移動平面以符合物件 Move Rows 移動列 diff --git a/docs/mcp.md b/docs/mcp.md index 0e38a883dd..be148d897d 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -1249,7 +1249,7 @@ the Transparency panel's values, with `null` where the objects differ. Making a empty mask and enters mask editing: art drawn then becomes the mask, and the mask commands act on the masked object until `transparency.stopEditingOpacityMask`. While a mask is edited, `object.exitIsolation` (Esc, the isolation bar's back arrow, Exit Isolation Mode) leaves mask editing the same way, in one undo step. Saves and exports never include -the editing layer. +the editing layer. With gradient mesh points picked, `opacity` goes to those points (see Picking several mesh points). ```json {"name":"run_command","arguments":{"command":"transparency.set","params":{"ids":[12],"opacity":40,"blend":"Multiply"}}} @@ -5599,6 +5599,29 @@ Envelope Options. {"name":"run_command","arguments":{"command":"object.mesh.movePoint","params":{"id":12,"index":4,"x":220,"y":140,"handle":0}}} ``` +## Picking several mesh points + +The Mesh tool and Direct Selection pick mesh points on gradient meshes and mesh envelopes. A click picks one point +(its handles show); Shift-click adds a point or takes a picked one away. Direct Selection's marquee picks the points +inside it (Shift toggles them) and selects their meshes; its click on a gradient mesh's line picks the line's two +ends, and a click inside a patch picks the four points around it. The picked points show filled. Dragging one of them +moves them all as one undo step (`object.mesh.movePoints`), a click on one of several picked points picks it alone, +and the arrow keys nudge them by the keyboard increment. The active tool lists them in its options +(`tool.setOption {}` returns them as `meshPoints: [{id, index}…]`). On gradient meshes a solid fill colour (`paint.setFill`, from the +Color panel, Swatches or the Eyedropper) recolours just the picked points, and when every target of +`transparency.set` is a gradient mesh with points picked, its `opacity` fades those points instead of the objects +(`transparency.info` then shows their opacity, `null` when it differs). Both are one undo step. + +`object.mesh.movePoints {id, points: [index…], dx, dy}` (or `{items: [{id, points}…], dx, dy}` over several meshes) +moves points by (dx, dy), their handles with them; `object.mesh.setPointColor` takes `points` or `items` the same +way to colour or fade several points at once. An index out of range, an index that is not a whole number ≥ 0, or a +move past the coordinate range fails and changes nothing. + +```json +{"name":"run_command","arguments":{"command":"object.mesh.movePoints","params":{"id":12,"points":[0,4],"dx":10,"dy":-5}}} +{"name":"run_command","arguments":{"command":"object.mesh.setPointColor","params":{"id":12,"points":[0,4],"color":"#3366ff","opacity":0.5}}} +``` + ## Shortcut sets from other apps `shortcutSet.read {path? | data? | dataBase64?, name?}` reads a shortcut set another app saved as text (a `.kys` file diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index bf7f1c7c32..a5067aff81 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1,6 +1,6 @@ # Parity with Adobe Illustrator -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Drawing aids: Character panel menu › Show Snap to Glyph Options shows the Snap to Glyph section (Baseline, x-height, Glyph Bounds, Proximity Guides, Angular Guides, Anchor Point; `view.snapToGlyph.options`) (#4232); scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Colour, gradients & mesh: several gradient mesh points can be picked (Shift-clicks with the Mesh tool and Direct Selection, Direct Selection's marquee, its click on a mesh line or inside a patch); a drag or the arrow keys move them all (`object.mesh.movePoints`), and a solid fill colour or the Transparency panel's opacity goes to each of them (#4207, #4208, #4170); scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026) ## Feature submission evidence @@ -874,6 +874,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Image Trace, simpler contour walk:** `contour::trace_mask` works out each turn from the pixels during the walk, with no precomputed direction table and no assertion; identical loops to the previous walk on every 4 × 4 mask (see [quality notes](image-trace-quality.md#a-simpler-contour-walk)). - **Image Trace, measured:** `crates/trace/tests/quality` traces drawings made from known vector art with every preset and [`image-trace-quality.md`](image-trace-quality.md) records the numbers against the baseline. Black and White, Grayscale and Color place each edge by the blend of the pixels across it (to a fraction of a pixel on anti-aliased and blurred images; hard-edged images are read as staircases) and fit outlines as Flat Logo does. *Measured* on each preset's own inputs, all sizes and variants: Default's outlines went from 0.31 px off on average to 0.09 (largest 1.51 to 1.02), Black and White Logo's from 0.27 to 0.06 with 0.3 kinks per trace where it had 15, and the gaps between abutting paths from 64 px to 22. On clean curved shapes Black and White Logo is 0.02 px off (the open tracer measured beside it: 0.20). The palette is made of the picture's own colours (blends along edges take none of it, colours that noise made of one colour merge, a blend pixel goes to one of the two colours it lies between; #1504): 16 Colors on flat art, all variants, went from 70 paths to 4.2 and from 5.1 px off to 0.13, with no path left in a colour the art doesn't have (5.9 before). Photos are smoothed within their tones before they are quantised and stacked layers go by lightness (#1516): High Fidelity Photo went from 3,653 paths to 121 with its colour error down from 2.30 to 1.75, and a 16 megapixel photo-like image is traced in 3.5 s where 4 megapixels were refused. Since then, by the same harness: outlines are cut at their junctions and each shared piece is fitted once (#1535: gaps and overlaps between abutting paths 22 to 50 px of area down to under 2); layers are traced within the box of their pixels and a few at a time (#1546: a 16 megapixel photo 3.9 GB to 0.9 GB); black and white are read against the image's own black and the paper near each edge (#1563, for thin lines in blurred and scanned art); Ignore Color and the Auto Color and Outline presets (#1574); Snap Curves To Lines levels lines within 2.5 degrees of level or upright (#1593, the angle our choice); Create: Strokes puts centre lines in the middle of their ink and makes them as wide as it (#1595: Outline 0.295 to 0.052 px from the true centre line, 18.4 to 2.7 anchors a stroke); sharp corners whose pixel is mostly outside the shape stay corners (#1609: Default 69% to 76% kept). Three options, each off unless asked for as the legacy presets have them: Shapes (#1609: 57 to 62% of plain circles, ellipses, rectangles and regular polygons come out as live shapes, rounded rectangles rarely), Auto Grouping (#1618: paths grouped with what lies inside them, the same picture) and Gradients (#1627: linear gradients traced as one gradient-filled path; on gradient inputs 6 Colors' colour error 2.12 to 0.62 with 6.4 to 3.4 paths, none found in flat art). Snap Curves To Lines moves no end of a line by more than 1.6 px, so long lines a degree or two off stay as the image has them (#1647: Technical Drawing's largest distance 4.21 px to 1.46). Flat Logo takes the tones a scan's uneven paper makes of one colour for one colour (#1657: on scans 470 paths and 21 px off to 8.5 paths and 0.09 px). Shapes finds rounded rectangles and shapes in aliased, blurred and scanned art (#1845: 57 to 62% of the plain shapes up to 98 to 100%, no false shape but one line 2 px wide). Stroked lines get square caps where their ink is cut square, and a wide end that turned towards a corner goes back on its line (#1846: Outline's largest distance 2.94 px to 0.88, 14 anchors to 10). Each of the 14 documented presets has an enhanced version with Auto Grouping and, in all but High Fidelity Photo, Shapes (#1847), measured beside its preset: equal or better within 0.005 px and 1% of edge ΔE on every preset's own inputs (Default 0.091 to 0.083 px); Auto Grouping keeps traced order in its groups, which removed a light seam along the counters of letters. Gradients grows a gradient over the pixels noise and soft rims took off it (#1848: blurred and noisy linear gradients 3 to 11 paths beside the gradient down to 0.5 with 6 Colors, 24 to 56 down to 0.5 to 1.5 with High Fidelity Photo). Silhouettes is 0.52 px off because its threshold is 200 (0.11 px at 128). Still weak, by the same numbers: rounded rectangles and other line-and-arc outlines take 12 to 16 anchors (the fitter does not split lines from arcs), blurred and scanned polygons lose corners, hairlines under half a pixel are lost to the threshold, aliased art is about 0.25 px off, a scan's uneven paper splits into tones when more colours are asked for than the art has, stroke junctions stay at their skeleton pixels, a three-stop gradient in a small or scanned disc is not found, radial gradients stay bands (a draft, #1849, traces them; the documented option is for linear ones, so it waits for a decision), near-regular polygons a few dozen pixels across are made regular with Shapes (up to 0.5 px off), and aliased stroked lines are 0.8 px off at worst. - **Gradient mesh from an image:** Object › Create Gradient Mesh (`object.mesh.create`) on an embedded image makes a mesh of 1 to 50 rows and columns over the picture's rectangle, placed with the image's transform; each point takes the alpha-weighted average colour and the opacity of the area around it, and Appearance and Highlight apply. A linked image is refused with a message to embed it (#1676). Scores and hours unchanged. +- **Several mesh points at once (#4207, #4208, #4170):** the Mesh tool and Direct Selection pick several points of a gradient mesh or mesh envelope: Shift-click adds a point or takes a picked one away, Direct Selection's marquee picks the points inside it (Shift toggles them) and selects their meshes, and its click on a mesh line picks the line's two ends and one inside a patch the four points around it. The picked points show filled; dragging one moves them all as one undo step and the arrow keys nudge them (`object.mesh.movePoints {id, points, dx, dy}` or `{items, dx, dy}`), and a click on one of several picked points picks it alone. A solid fill colour (`paint.setFill`: Color panel, Swatches, Eyedropper) recolours every picked point, and the Transparency panel's Opacity fades them instead of the object, the panel showing their opacity (blank when it differs); `object.mesh.setPointColor` takes `points` or `items`. Public reference: [Edit mesh objects](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-meshes/edit-mesh-objects.html) (Shift selects multiple mesh points; a fill colour colours the selected point), [Macworld, gradient mesh](https://www.macworld.com/article/202693/gmesh2.html) (Direct Selection: a mesh line selects the points at both ends, a patch the points around it, Shift-click adds or removes points), [Peachpit](https://www.peachpit.com/articles/article.aspx?p=1638270) (each mesh point can have its own colour or transparency). Tests: `shift_clicks_pick_mesh_points_that_drag_and_nudge_together` and `direct_selection_picks_mesh_points_by_marquee_line_and_patch` in `crates/tools/src/meshedit.rs`, `picked_mesh_points_take_the_fill_opacity_and_drag_together` in `crates/engine/src/tests/editcolors.rs`, `mesh_points_move_and_colour_together` in `crates/engine/src/tests/live.rs`. Scores and hours unchanged. - **Image Trace Flat Logo mode:** a fourth mode beside Black and White, Grayscale and Color, for flat-colour logos. Each pixel is read as a blend of the logo's colours (found automatically or named), the blend is interpolated smoothly and every outline is placed where two colours are equally present, so edges are accurate to a fraction of a pixel. Outlines are then cleaned: corners the blur rounded are put back, near-straight runs and near-circular arcs become exact lines and arcs, the rest is fitted with as few Béziers as the tolerance allows, touching colours overlap by a hair so no gap opens, and an outline that strays from the raw contour is fitted plainly instead. Gradients and photos are refused with advice to use Color. Line art whose only solid area is white paper (strokes a pixel or two wide) takes its colours from the strokes' cores, with the lighter shades along a stroke's anti-aliased edge folded into its ink; a page whose ink (a channel at least 48 below white) covers under 1% of it traces to nothing, as blank paper does. *Measured* (a local experiment, not run in CI): a flat-colour logo's vector original was rendered down to a soft 199 × 100 px transparent PNG, traced, and the result compared with the original at 1600 px wide. The built-in colour presets (6 Colors, 16 Colors, High Fidelity Photo, Low Fidelity Photo) had a mean edge error of 2.5 to 3.4 px and region overlap of 0.88 to 0.91; Flat Logo had 0.78 px and 0.966 (0.48 px and 0.975 from a crisp source), in about 0.1 s. Limits: flat-colour art only; needle-thin sharp tips are shortened by about 1.7 source pixels because the blur erases them; it works at no more than 1024 px on the long side (larger images are averaged down first); only one logo family has been scored against a vector original. - **Advanced art:** live Blends (steps/distance/smooth colour, editable spine, anchor-targeted Blend tool, faithful interpolation, knockout), Envelope Distort (warp/mesh/top object, Reset, full Envelope Options, mesh handles, Edit Contents; type, images, symbols, gradients, patterns and appearance distorted everywhere), Liquify tools with options and pen pressure, Puppet Warp with rotating pins, Perspective Grid with presets, movable planes and projected type (choosing a perspective tool shows the grid; Hide Grid hides it with the tool still chosen), Gradient Mesh, Shape Builder (stroke-only open paths and lines cut the regions they cross and enclose regions of their own, and regions they bound merge without seams where the lines cross at rounded coordinates (#893); filled open paths count as closed; erase mode while Alt/Option is held: a minus pointer, red highlights of what will go, a click or drag deletes the regions touched, the pieces of open lines and the edges (outline pieces between the points where paths meet, opening their paths there) it passes over, one undo step, `shapeBuilder.merge {erase}` and `shapeBuilder.regions` edges over MCP), Live Paint (every path an edge, open lines included), Image Trace (12 presets, colour layers traced in parallel; a trace past two million anchor points is refused with advice rather than running out of memory, an image over 64 megapixels is traced scaled down to that size (aspect kept, paths at the image's own size) and one over 192 megapixels is refused, and a selection too large to outline shows its bounds (#525); Object › Image Trace › Make and Make and Expand trace at once with the Default preset, #543; with an image selected the Control bar and the Properties panel show Image Trace, whose arrow traces with any preset, Mask (`object.maskImage`: a clipping path on the image's outline, selected so its handles crop), Crop Image (a crop box on the image, starting on its part over the artboard, dragged by its handles or inside it, the outside dimmed, with X/Y/W/H, Apply and Cancel in the Control bar, Enter and Escape, #734; `object.cropImage {rect}` for agents, `{trim: true}` cuts an image to its pixels that aren't fully transparent, pixel for pixel) and Embed or Unembed in place of Fill and Stroke; with an Image Trace object selected, its Preset (choosing another traces again), View, the Image Trace panel and Expand, plus Release in Properties; the five View modes (Tracing Result, with Outlines, Outlines, Outlines with Source Image, Source Image) redraw a trace on screen without tracing again, are saved with it and `imageTrace.setView` sets them, while exports and Expand keep the result; the panel's Advanced section is a header that stays open or closed as it was left (part of #641); Color mode's Palette: Limited, Full Tone (as many colours as the tones need, Less … More), Automatic (flat art with its own colours, else Full Tone; a heuristic) and Document Library (the most used colours of the document's swatches or a swatch library, filled with the swatch colours as they are), part of #641; Advanced › Create: Fills and/or Strokes, where lines up to the Stroke width trace as stroked centre lines (distance transform, thinning, a skeleton graph with spurs pruned, curve fitting; one width per line; without Fills, wider areas become stroked outlines), part of #641), pattern swatches with pattern editing mode, live Repeat (radial/grid/mirror). A single selected mirror repeat shows a prominent axis with a center move handle and two rotation handles. Drag the line or center to change spacing, or an end to change angle; Shift snaps rotation to 45°. The original artwork stays in place, the reflected copy previews live, Escape cancels and each drag takes one undo step through `object.repeat.options`. Controls follow zoom/view rotation and hide with edges or the bounding box. Engine and headless canvas regressions passed for gestures, history and visibility; native move, rotation and Escape screenshots were reviewed. [Public mirror-repeat reference](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/set-mirror-repeat-options.html). A single selected grid repeat shows a handle below the grid for rows, one right of it for columns and one past its bottom-right corner for both, and sliders between its first two columns and rows for the horizontal and vertical spacing; the source keeps its size, each drag is one undo step and Escape cancels it ([public grid-repeat reference](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/set-grid-repeat-options.html), #2691). Object › Expand turns radial, grid and mirror repeats into groups of their instances (#1765, #1756). Choosing the Blend tool again while it is active (its toolbar button, W or `tool.select`) finishes the blend: the object clicked first is dropped and the next click no longer adds to the blend just made, so the click after it starts a new blend ([Blending objects](https://web.archive.org/web/20241217212108/https://helpx.adobe.com/illustrator/using/blending-objects.html)). @@ -1203,6 +1204,7 @@ applies to fills). Tests: `color::gradient::tests` (perceptual midpoint, expansi | Date | Change | Summary | |---|---|---| +| 2026-10-30 | minor | Colour, gradients & mesh: several gradient mesh points can be picked (Shift-clicks with the Mesh tool and Direct Selection, Direct Selection's marquee, its click on a mesh line or inside a patch); a drag or the arrow keys move them all (`object.mesh.movePoints`), and a solid fill colour or the Transparency panel's opacity goes to each of them (#4207, #4208, #4170); scores unchanged. | | 2026-10-30 | minor | Drawing aids: Character panel menu › Show Snap to Glyph Options shows the Snap to Glyph section (Baseline, x-height, Glyph Bounds, Proximity Guides, Angular Guides, Anchor Point; `view.snapToGlyph.options`) (#4232); evidence added; score and hours unchanged (estimated). | | 2026-10-30 | minor | Selection, transform & align tools: Align panel menu › Align to Glyph Bounds › Point Text and Area Text align and distribute type by the ink of its glyphs (#4231); evidence added; score and hours unchanged (estimated). | | 2026-10-30 | minor | Blob Brush and Eraser Tool Options: Size follows the pen pressure, Fixed or Pressure with a Variation (#4590, #3961); scores and estimates unchanged | From f1211e7c89af6cfbda37075cee9bbebc1c3de9c1 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Fri, 30 Oct 2026 04:21:46 +0700 Subject: [PATCH 002/163] Separations Preview: hidden plates leave raster images too (#4153) --- crates/render/src/blobs.rs | 1 + crates/render/src/frame.rs | 2 + crates/render/src/fx/renderer.rs | 1 + crates/render/src/images.rs | 8 +- crates/render/src/ink.rs | 1 + crates/render/src/pattern.rs | 1 + crates/render/src/proof.rs | 151 ++++++++++++++++++++++----- crates/render/src/renderer.rs | 8 +- crates/render/src/renderer/images.rs | 30 ++++-- crates/render/src/renderer/text.rs | 4 + crates/render/src/tests/colorize.rs | 119 +++++++++++++++++++-- docs/target-app-parity.md | 4 +- 12 files changed, 287 insertions(+), 43 deletions(-) diff --git a/crates/render/src/blobs.rs b/crates/render/src/blobs.rs index 9fa1b5da07..4ff88e36be 100644 --- a/crates/render/src/blobs.rs +++ b/crates/render/src/blobs.rs @@ -19,6 +19,7 @@ pub(crate) fn blob_key(blob: &vectorcraft_doc::ImageBlob) -> (images::ImageKey, tint: None, ink: Ink::Display, luts: (lut.as_ref().map_or(0, |l| l.1), 0), + plates: 0, mip: 0, }; (key, lut.map(|l| l.0), id.size) diff --git a/crates/render/src/frame.rs b/crates/render/src/frame.rs index 92f288643c..51592da7e3 100644 --- a/crates/render/src/frame.rs +++ b/crates/render/src/frame.rs @@ -127,6 +127,8 @@ pub(crate) struct Frame<'a> { pub(crate) opts: &'a RenderOptions, /// What colours paint as: screen colours, or one ink plane of a CMYK document (see [`ink`]). pub(crate) ink: Ink, + /// With Separations Preview, the tables placed images show the visible plates through. + pub(crate) plates: Option<&'a crate::proof::PlateLut>, } impl Frame<'_> { diff --git a/crates/render/src/fx/renderer.rs b/crates/render/src/fx/renderer.rs index 6e6fa1cabd..53a17b25db 100644 --- a/crates/render/src/fx/renderer.rs +++ b/crates/render/src/fx/renderer.rs @@ -716,6 +716,7 @@ mod tests { px: 1.0, opts: &opts, ink: Ink::Display, + plates: None, }; let mut ctx = frame.offscreen_context(100, 100); let mut r = Renderer::new(); diff --git a/crates/render/src/images.rs b/crates/render/src/images.rs index a22bb6c5e2..841d56469a 100644 --- a/crates/render/src/images.rs +++ b/crates/render/src/images.rs @@ -4,7 +4,8 @@ //! pixels cached per renderer, a 24-megapixel photo would take 96 MB in each. Here they are kept //! once, keyed by the image's content (not the document's key for it, which another document may //! use for other pixels) and by what was made of them: greyscale (outline mode), recoloured by a -//! colour adjustment, separated into ink planes, or shrunk ([`RenderOptions::image_mips`](crate::RenderOptions::image_mips)). +//! colour adjustment, separated into ink planes, shown through Separations Preview's plates, or +//! shrunk ([`RenderOptions::image_mips`](crate::RenderOptions::image_mips)). //! //! The store holds at most [`ImageStore::budget`] bytes, dropping the least recently used entries //! beyond that, except ones still held elsewhere (a render context drawing them): dropping those @@ -92,6 +93,9 @@ pub(crate) struct ImageKey { /// Generations of the colour tables the pixels were made with (0 = none): a CMYK image's /// display table, and the separation table of ink planes (see `ink`). pub luts: (u64, u64), + /// Generation of the Separations Preview table the pixels show the visible plates through + /// (`proof::PlateLut`; 0 = none). + pub plates: u64, /// Halved this many times ([`half`]). pub mip: u8, } @@ -414,7 +418,7 @@ mod tests { use super::*; fn key(content: &str) -> ImageKey { - ImageKey { content: content.into(), adjust: None, grey: false, tint: None, ink: Ink::Display, luts: (0, 0), mip: 0 } + ImageKey { content: content.into(), adjust: None, grey: false, tint: None, ink: Ink::Display, luts: (0, 0), plates: 0, mip: 0 } } #[test] diff --git a/crates/render/src/ink.rs b/crates/render/src/ink.rs index 2239d82cbc..d4a5629e56 100644 --- a/crates/render/src/ink.rs +++ b/crates/render/src/ink.rs @@ -530,6 +530,7 @@ mod tests { tint: None, ink: Ink::Display, luts: (0, 0), + plates: 0, mip: 0, }; let pm = diff --git a/crates/render/src/pattern.rs b/crates/render/src/pattern.rs index f4ea1d0597..c8f202cbea 100644 --- a/crates/render/src/pattern.rs +++ b/crates/render/src/pattern.rs @@ -181,6 +181,7 @@ fn rasterize(r: &mut Renderer, doc: &Document, def: &PatternDef, region: Rect, w px: 1.0 / v.determinant().abs().sqrt().max(1e-12), opts: &opts, ink, + plates: None, }; for a in &def.art { r.draw_arc(&mut ctx, &frame, a); diff --git a/crates/render/src/proof.rs b/crates/render/src/proof.rs index e308e2b4fa..0eb25b720e 100644 --- a/crates/render/src/proof.rs +++ b/crates/render/src/proof.rs @@ -8,7 +8,9 @@ //! renders as greyscale ink coverage (black = 100%); with several, the visible inks are //! composited through the proof profile, spots multiplied on top. Colours linked to the //! Registration swatch print their tint on every plate, spot plates included. -//! Placed raster images are not separated (limitation). +//! Placed raster images show their pixels' process inks the same way ([`plate_image`]): a CMYK +//! image its own inks, an RGB one its pixels separated through the color settings. They carry +//! no spot ink; a colorized image takes its color's plates, as a fill of it does. //! * **Overprint Preview** (and Separations Preview, which implies it): fills and strokes that //! overprint ([`vectorcraft_doc::FillLayer::overprint`], characters' too) are drawn with //! Darken, which approximates their inks printing over the inks below: a zero ink lets the @@ -19,51 +21,150 @@ use std::borrow::Cow; use std::collections::HashMap; -use std::sync::{Arc, RwLock, Weak}; +use std::sync::atomic::{AtomicU64, Ordering}; +use std::sync::{Arc, Mutex, OnceLock, RwLock, Weak}; -use vectorcraft_color::cms::{self, Cms, PROCESS_PLATES}; +use vectorcraft_color::cms::{self, Cms, CmykLut, PROCESS_PLATES, ProofLut, lab}; pub use vectorcraft_color::cms::{Intent, ProofSetup, ProofTarget}; use vectorcraft_color::{Color, Swatch, SwatchGroup}; pub use vectorcraft_doc::inks::{Inks, Link, Plate, inks, map_document_colors, map_node_colors, plates, spot_color}; use vectorcraft_doc::overprint::darken_overprints; -use vectorcraft_doc::{Document, Node, NodeId, Shared}; +use vectorcraft_doc::{Document, ImageBlob, Node, NodeId, Shared}; +use vello_cpu::Pixmap; +use vello_cpu::color::PremulRgba8; use crate::RenderOptions; +use crate::blobs::lookup; +use crate::images::{self, ImageKey}; /// Whether overprinting shows: Overprint Preview, or Separations Preview (which implies it). pub(crate) fn overprints(opts: &RenderOptions) -> bool { opts.overprint_preview || opts.proof.as_ref().is_some_and(|p| p.separations.is_some()) } +/// What the `visible` plates print of `ink`, as display sRGB, without the spot inks over several +/// plates: with one plate visible its ink as a grey (black = 100%), else the visible process inks +/// through the proof profile. +fn plate_rgb(c: &Cms, proof: &ProofSetup, visible: &[String], ink: &Inks) -> [f32; 3] { + if let [one] = visible { + return [1.0 - ink.on_plate(one); 3]; + } + let mut cmyk = ink.cmyk; + for (i, p) in PROCESS_PLATES.iter().enumerate() { + if !visible.iter().any(|v| v == p) { + cmyk[i] = 0.0; + } + } + c.proof_cmyk_to_srgb(cmyk, proof) +} + fn plate_color(doc: &Document, c: &Cms, proof: &ProofSetup, visible: &[String], color: &Color, link: Link) -> Color { let ink = inks(doc, c, color, link, proof.intent); - let rgb = if visible.len() == 1 { - [1.0 - ink.on_plate(&visible[0]); 3] - } else { - let mut cmyk = ink.cmyk; - for (i, p) in PROCESS_PLATES.iter().enumerate() { - if !visible.iter().any(|v| v == p) { - cmyk[i] = 0.0; + let mut rgb = plate_rgb(c, proof, visible, &ink); + // Over several plates the visible spot inks print on top. + for name in visible.iter().filter(|v| visible.len() != 1 && !PROCESS_PLATES.contains(&v.as_str())) { + let t = ink.spot_tint(name); + if t > 0.0 + && let Some(sc) = spot_color(doc, name) + { + let s = c.display_rgb(&sc); + for i in 0..3 { + rgb[i] *= 1.0 - t * (1.0 - s[i]); } } - let mut rgb = c.proof_cmyk_to_srgb(cmyk, proof); - for name in visible.iter().filter(|v| !PROCESS_PLATES.contains(&v.as_str())) { - let t = ink.spot_tint(name); - if t > 0.0 - && let Some(sc) = spot_color(doc, name) - { - let s = c.display_rgb(&sc); - for i in 0..3 { - rgb[i] *= 1.0 - t * (1.0 - s[i]); - } - } - } - rgb - }; + } let [r, g, b] = c.srgb_to_rgb(rgb); Color::Rgb { r, g, b } } +/// Separations Preview's tables for placed images: what the visible plates show of display pixels +/// and of a CMYK image's own inks ([`plate_rgb`]), for one proof setup, color settings and set of +/// profiles. Each table is made when an image first needs it. +pub(crate) struct PlateLut { + proof: ProofSetup, + cms: Arc, + /// [`cms::profiles_generation`]. + profiles: u64, + /// What pixels shown through these tables are kept under ([`ImageKey::plates`]): never reused. + pub(crate) generation: u64, + /// Display sRGB → display sRGB. + rgb: OnceLock, + /// Inks → XYZ (inks mix close to linearly in light, as in `ink::InkLut`). + cmyk: OnceLock, +} + +impl PlateLut { + /// What the visible plates show of process inks `cmyk`, as display sRGB. + fn shown(&self, cmyk: [f32; 4]) -> [f32; 3] { + let visible = self.proof.separations.as_deref().unwrap_or_default(); + plate_rgb(&self.cms, &self.proof, visible, &Inks { cmyk, spot: None, registration: false }) + } +} + +/// The tables [`plate_lut`] handed out last, the newest last: a few, so renderers drawing with +/// different proof setups don't make them again and again. +static PLATE_LUTS: Mutex>> = Mutex::new(Vec::new()); +/// The last [`PlateLut::generation`] handed out. +static PLATE_GENERATION: AtomicU64 = AtomicU64::new(0); + +/// The tables placed images show Separations Preview's visible plates through with `opts`, or +/// `None` when it is off. +pub(crate) fn plate_lut(opts: &RenderOptions) -> Option> { + let proof = opts.proof.as_ref().filter(|p| p.separations.is_some())?; + let (c, profiles) = (cms::active(), cms::profiles_generation()); + let mut luts = PLATE_LUTS.lock().unwrap_or_else(|e| e.into_inner()); + if let Some(l) = luts.iter().find(|l| Arc::ptr_eq(&l.cms, &c) && l.profiles == profiles && l.proof == *proof) { + return Some(l.clone()); + } + if luts.len() >= 4 { + luts.remove(0); + } + let generation = PLATE_GENERATION.fetch_add(1, Ordering::Relaxed) + 1; + let l = Arc::new(PlateLut { proof: proof.clone(), cms: c, profiles, generation, rgb: OnceLock::new(), cmyk: OnceLock::new() }); + luts.push(l.clone()); + Some(l) +} + +/// Image pixels `pm` (kept as `key`, from `blob` when it is a document's image as it is) as the +/// visible plates show them through `lut`, kept with the images, and their key: a CMYK image shows +/// its own inks, other pixels their inks separated with the proof's intent. `touch` marks them +/// used there. +pub(crate) fn plate_image(lut: &PlateLut, key: &ImageKey, pm: &Pixmap, blob: Option<&ImageBlob>, touch: bool) -> (ImageKey, Arc) { + let want = ImageKey { plates: lut.generation, ..key.clone() }; + if let Some(p) = lookup(&want, touch) { + return (want, p); + } + let size = (u32::from(pm.width()), u32::from(pm.height())); + let raw = blob.filter(|_| key.luts.0 != 0 && key.adjust.is_none() && !key.grey).and_then(ImageBlob::cmyk).filter(|i| (i.width, i.height) == size); + let mut out = pm.clone(); + match raw { + Some(inks) => { + let t = lut.cmyk.get_or_init(|| { + CmykLut::build(|inks| { + let [x, y, z] = lab::srgb_to_xyz(lut.shown(inks)); + [x, y, z, 0.0] + }) + }); + for (o, p) in out.data_mut().iter_mut().zip(inks.data.as_chunks::<4>().0) { + let [x, y, z, _] = t.apply(p.map(|v| f32::from(v) / 255.0)); + let [r, g, b] = lab::xyz_to_srgb([x, y, z]).map(|v| (v.clamp(0.0, 1.0) * 255.0).round() as u8); + *o = PremulRgba8 { r, g, b, a: 255 }; + } + } + None => { + let t = lut.rgb.get_or_init(|| ProofLut::build(|rgb| lut.shown(lut.cms.srgb_to_cmyk(rgb, lut.proof.intent)))); + for px in out.data_mut().iter_mut().filter(|p| p.a > 0) { + let a = f32::from(px.a); + let un = |v: u8| (f32::from(v) / a).min(1.0); + let [r, g, b] = t.apply([un(px.r), un(px.g), un(px.b)]).map(|v| (v.clamp(0.0, 1.0) * a).round() as u8); + (px.r, px.g, px.b) = (r, g, b); + } + } + } + let out = images::store().insert(want.clone(), Arc::new(out)); + (want, out) +} + /// The art a renderer drew with Overprint Preview or Separations Preview, kept for its next frame /// ([`prepare`]): the document's layers and symbol art as they were, each beside the art drawn for /// it, and what that art was made with. The kept nodes keep their addresses: no other node gets diff --git a/crates/render/src/renderer.rs b/crates/render/src/renderer.rs index 7d7b72d564..2688818144 100644 --- a/crates/render/src/renderer.rs +++ b/crates/render/src/renderer.rs @@ -115,7 +115,8 @@ impl Renderer { let px = 1.0 / view.determinant().abs().sqrt().max(1e-12); let screen = if opts.rich_black { Ink::RichBlack } else { Ink::Display }; let symbols = doc.symbol_boxes().quick(); - let frame = Frame { mt: threads > 0, doc, symbols: &symbols, view, visible, px, opts, ink: screen }; + let plates = proof::plate_lut(opts); + let frame = Frame { mt: threads > 0, doc, symbols: &symbols, view, visible, px, opts, ink: screen, plates: plates.as_deref() }; self.begin_frame(); // View Opacity Mask: the mask's coverage in greyscale instead of the artwork. if let Some(m) = opts.mask_view.and_then(|id| doc.node(id)).and_then(|n| n.extras().mask.as_deref()) { @@ -306,7 +307,7 @@ impl Renderer { let mut ctx = single_threaded_context(w, h); let opts = RenderOptions::default(); let symbols = doc.symbol_boxes().quick(); - let frame = Frame { mt: false, doc, symbols: &symbols, view, visible, px, opts: &opts, ink: Ink::Display }; + let frame = Frame { mt: false, doc, symbols: &symbols, view, visible, px, opts: &opts, ink: Ink::Display, plates: None }; self.begin_frame(); (self.knockout, self.nested, self.backdrop, self.picture) = (false, 0, None, None); self.clip_paths.clear(); @@ -349,7 +350,8 @@ impl Renderer { ctx.fill_rect(&kurbo::Rect::new(0.0, 0.0, w as f64, w as f64)); } let symbols = doc.symbol_boxes().quick(); - let frame = Frame { mt: false, doc, symbols: &symbols, view, visible: b.inflate(1.0, 1.0), px: 1.0 / s, opts, ink: Ink::Display }; + let frame = + Frame { mt: false, doc, symbols: &symbols, view, visible: b.inflate(1.0, 1.0), px: 1.0 / s, opts, ink: Ink::Display, plates: None }; self.begin_frame(); (self.knockout, self.nested, self.backdrop, self.picture) = (false, 0, None, None); self.clip_paths.clear(); diff --git a/crates/render/src/renderer/images.rs b/crates/render/src/renderer/images.rs index c52e5bc241..3b53dda0c6 100644 --- a/crates/render/src/renderer/images.rs +++ b/crates/render/src/renderer/images.rs @@ -1,6 +1,6 @@ use super::{ Affine, Arc, BezPath, Document, FillRule, Frame, HashMap, Ink, Node, Pixmap, Rect, RenderContext, Renderer, Shape, blob_key, blob_pixmap, - fill_rule, image_mip, ink, lookup, mip_level, peniko, vello_cpu, + fill_rule, image_mip, ink, lookup, mip_level, peniko, proof, vello_cpu, }; use crate::images; @@ -74,8 +74,13 @@ impl Renderer { Some(rgb) => colorized_pixmap(key, &pm, rgb, !mips), None => (key, pm), }; - // A colorized image is already in the frame's ink ([`image_tint`]). + // A colorized image is already in the frame's ink ([`image_tint`]), and with + // Separations Preview its color is already the visible plates' (`proof::prepare`). let (key, pm) = if outline || tint.is_some() { (key, pm) } else { ink::ink_image(&key, &pm, f.ink, f.doc.image_blob(im), !mips) }; + let (key, pm) = match f.plates.filter(|_| !outline && tint.is_none()) { + Some(lut) => proof::plate_image(lut, &key, &pm, f.doc.image_blob(im), !mips), + None => (key, pm), + }; if mips { image_mip(&key, pm, unit) } else { pm } }) }; @@ -249,8 +254,7 @@ impl Renderer { m: Affine, ) -> Option> { let (key, (w, h)) = self.image_key(f.doc, key, own, grey)?; - let key = images::ImageKey { tint, ..key }; - let key = if grey || tint.is_some() { key } else { ink::ink_key(&key, f.ink) }; + let key = shown_key(f, key, grey, tint); let level = mip_level(m, w, h); if level == 0 { return None; @@ -272,8 +276,7 @@ impl Renderer { m: Affine, ) -> Option> { let (key, (w, h)) = self.image_key(f.doc, key, own, grey)?; - let key = images::ImageKey { tint, ..key }; - let key = if grey || tint.is_some() { key } else { ink::ink_key(&key, f.ink) }; + let key = shown_key(f, key, grey, tint); let level = mip_level(m, w, h); let s = images::store(); let at = |l: u8| s.peek(&images::ImageKey { mip: l, ..key.clone() }); @@ -293,6 +296,21 @@ impl Renderer { } } +/// The key [`Renderer::draw_image_in`] gives the pixels it draws of image pixels `key`: in +/// greyscale with `grey` (the outline view's) or colorized with `tint` as they are, else painted +/// with the frame's ink and shown through its Separations Preview plates. +fn shown_key(f: &Frame, key: images::ImageKey, grey: bool, tint: Option<[u8; 3]>) -> images::ImageKey { + let key = images::ImageKey { tint, ..key }; + if grey || tint.is_some() { + return key; + } + let key = ink::ink_key(&key, f.ink); + match f.plates { + Some(lut) => images::ImageKey { plates: lut.generation, ..key }, + None => key, + } +} + /// Image pixels `pm` (kept as `key`) colorized with `rgb` ([`images::colorized`]), kept with the /// images, and their key. `touch` marks them used there. fn colorized_pixmap(key: images::ImageKey, pm: &Pixmap, rgb: [u8; 3], touch: bool) -> (images::ImageKey, Arc) { diff --git a/crates/render/src/renderer/text.rs b/crates/render/src/renderer/text.rs index c478861ea9..675247efda 100644 --- a/crates/render/src/renderer/text.rs +++ b/crates/render/src/renderer/text.rs @@ -246,6 +246,10 @@ impl Renderer { fn draw_glyph_image(&mut self, ctx: &mut RenderContext, f: &Frame, image: &vectorcraft_text::GlyphImage, xf: Affine) { let Some((key, pm)) = blob_pixmap(&image.blob, true) else { return }; let (key, pm) = ink::ink_image(&key, &pm, f.ink, Some(&image.blob), true); + let (key, pm) = match f.plates { + Some(lut) => proof::plate_image(lut, &key, &pm, Some(&image.blob), true), + None => (key, pm), + }; let unit = f.view * xf * Affine::scale_non_uniform(image.width as f64, image.height as f64); let pm = image_mip(&key, pm, unit); let sx = image.width as f64 / pm.width().max(1) as f64; diff --git a/crates/render/src/tests/colorize.rs b/crates/render/src/tests/colorize.rs index e2b42be56a..15eb3c5a02 100644 --- a/crates/render/src/tests/colorize.rs +++ b/crates/render/src/tests/colorize.rs @@ -1,5 +1,5 @@ //! Grayscale and 1-bit images colorized by a fill color draw in that color, white pixels -//! transparent. +//! transparent; and how Separations Preview shows images. use crate::*; use vectorcraft_color::{Color, Paint}; @@ -153,14 +153,121 @@ fn separations_preview_shows_the_image_on_its_spot_plate() { let mut n = Node::new(d.alloc_id(), NodeKind::Image(Box::new(im))); n.extras_mut().colorize = Some(Box::new(Paint::Solid { color: ink, swatch: Some("Ink".into()), tint: 1.0 })); d.insert(Some(d.layers[0].id), 0, n).unwrap(); - let shown = |plates: &[&str]| { - let proof = proof::ProofSetup { separations: Some(plates.iter().map(|p| p.to_string()).collect()), ..Default::default() }; - let opts = RenderOptions { proof: Some(proof), overprint_preview: true, smooth_images: false, ..Default::default() }; - Renderer::new().render(&d, 40, 20, Affine::IDENTITY, &opts).pixel(10, 10) - }; + let shown = |plates: &[&str]| Renderer::new().render(&d, 40, 20, Affine::IDENTITY, &separations(plates)).pixel(10, 10); let on = shown(&["Ink"]); // One plate shows as black ink. assert!(on[..3].iter().all(|v| *v < 128), "the Ink plate shows the image, got {on:?}"); let off = shown(&["Cyan", "Magenta", "Yellow", "Black"]); assert!(off[..3].iter().all(|v| *v >= 250), "the process plates show paper, got {off:?}"); } + +/// Separations Preview showing `plates`, as the canvas draws it. +fn separations(plates: &[&str]) -> RenderOptions { + let proof = proof::ProofSetup { separations: Some(plates.iter().map(|p| p.to_string()).collect()), ..Default::default() }; + RenderOptions { proof: Some(proof), overprint_preview: true, smooth_images: false, ..Default::default() } +} + +/// A 10 pt tall page of `mode`: the image of `blob` (`size` pixels, `scale` pt a pixel) at the +/// origin, then from `x0` a 10 pt square of each of `fills`. +fn image_and_fills(mode: vectorcraft_doc::ColorMode, blob: ImageBlob, (width, height): (u32, u32), scale: f64, x0: f64, fills: &[Color]) -> Document { + let mut d = Document::new_with_mode(x0 + 10.0 * fills.len() as f64, 10.0, mode); + let layer = Some(d.layers[0].id); + d.images.insert("pic".into(), blob); + let im = ImageObject { key: "pic".into(), width, height, xf: Affine::scale(scale), link: None, placement: Default::default(), pixels: None }; + let n = Node::new(d.alloc_id(), NodeKind::Image(Box::new(im))); + d.insert(layer, 0, n).unwrap(); + for (i, c) in fills.iter().enumerate() { + let x = x0 + 10.0 * i as f64; + let square = + Node::path(d.alloc_id(), shapes::rectangle(Rect::new(x, 0.0, x + 10.0, 10.0)), Appearance::basic(Paint::solid(*c), Paint::None, 0.0)); + d.insert(layer, i + 1, square).unwrap(); + } + d +} + +/// An RGB PNG of `width` × `height` `pixels`. +fn rgb_png(width: u32, height: u32, pixels: &[[u8; 3]]) -> Vec { + let img = image::RgbImage::from_raw(width, height, pixels.concat()).unwrap(); + let mut png = vec![]; + img.write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png).unwrap(); + png +} + +/// Whether `a` and `b` differ by at most `tolerance` in every channel. +fn near(a: [u8; 4], b: [u8; 4], tolerance: u8) -> bool { + a.iter().zip(b).all(|(x, y)| x.abs_diff(y) <= tolerance) +} + +/// Separations Preview shows an RGB image's pixels as the visible plates print them, as it shows +/// fills of the same colors (#4153): with only Cyan visible a cyan pixel shows as dark ink and a +/// red one as paper; with Cyan hidden, or only Magenta and Yellow, as the fills do. With the +/// preview off the image keeps its own pixels. +#[test] +fn separations_preview_shows_an_rgb_images_process_inks() { + let (cyan, red) = (Color::rgb(0.0, 1.0, 1.0), Color::rgb(1.0, 0.0, 0.0)); + let blob = ImageBlob::new("image/png", rgb_png(2, 1, &[[0, 255, 255], [255, 0, 0]])); + let d = image_and_fills(vectorcraft_doc::ColorMode::Rgb, blob, (2, 1), 10.0, 20.0, &[cyan, red]); + let render = |opts: &RenderOptions| Renderer::new().render(&d, 40, 10, Affine::IDENTITY, opts); + let off = render(&RenderOptions { smooth_images: false, ..Default::default() }); + assert_eq!((off.pixel(5, 5), off.pixel(15, 5)), ([0, 255, 255, 255], [255, 0, 0, 255]), "the preview off: the image's own pixels"); + for plates in [&["Cyan"][..], &["Magenta", "Yellow", "Black"], &["Magenta", "Yellow"], &["Cyan", "Magenta", "Yellow", "Black"]] { + let shown = render(&separations(plates)); + for (image, fill) in [(5, 25), (15, 35)] { + let (a, b) = (shown.pixel(image, 5), shown.pixel(fill, 5)); + assert!(near(a, b, 3), "{plates:?}: the image pixel at {image} shows as the fill does, {a:?} vs {b:?}"); + } + } + let cyan_only = render(&separations(&["Cyan"])); + let (c, r) = (cyan_only.pixel(5, 5), cyan_only.pixel(15, 5)); + assert!(c[0] < 128 && c[0] == c[1] && c[1] == c[2], "the cyan pixel shows its cyan ink as a grey, got {c:?}"); + assert!(r[..3].iter().all(|v| *v >= 230), "red carries next to no cyan ink, got {r:?}"); +} + +/// A CMYK image shows its own inks on the plates, not inks separated again from its display +/// colors: as a fill of the same inks does. +#[test] +fn separations_preview_shows_a_cmyk_images_own_inks() { + let ink = [0u8, 102, 255, 25]; + let blob = ImageBlob::cmyk_tiff(&vectorcraft_doc::cmyk::Inks::new(2, 2, ink.repeat(4)).unwrap()).unwrap(); + let fill = Color::cmyk(0.0, 0.4, 1.0, 25.0 / 255.0); + let d = image_and_fills(vectorcraft_doc::ColorMode::Cmyk, blob, (2, 2), 5.0, 10.0, &[fill]); + for (plates, grey) in [ + (&["Cyan"][..], Some(255)), + (&["Magenta"], Some(153)), + (&["Black"], Some(230)), + (&["Magenta", "Yellow"], None), + (&["Cyan", "Yellow", "Black"], None), + ] { + let shown = Renderer::new().render(&d, 20, 10, Affine::IDENTITY, &separations(plates)); + let (a, b) = (shown.pixel(5, 5), shown.pixel(15, 5)); + assert!(near(a, b, 3), "{plates:?}: the image shows as the fill does, {a:?} vs {b:?}"); + if let Some(v) = grey { + assert!(near(a, [v, v, v, 255], 2), "{plates:?}: the plate's own ink as a grey, got {a:?}"); + } + } +} + +/// Showing other plates draws the image again through them, its shrunk copies too, and the image +/// drawn without the preview keeps its own pixels: each plate set's pixels are kept apart. +#[test] +fn separations_preview_keeps_an_images_pixels_per_plate_set() { + let cyan = Color::rgb(0.0, 1.0, 1.0); + let blob = ImageBlob::new("image/png", rgb_png(40, 40, &[[0, 255, 255]; 1600])); + let d = image_and_fills(vectorcraft_doc::ColorMode::Rgb, blob, (40, 40), 0.25, 10.0, &[cyan]); + let mips = |o: RenderOptions| RenderOptions { image_mips: true, ..o }; + let off = mips(RenderOptions { smooth_images: false, ..Default::default() }); + let mut r = Renderer::new(); + let mut seen = vec![]; + for _ in 0..2 { + for opts in [off.clone(), mips(separations(&["Cyan"])), mips(separations(&["Magenta", "Yellow", "Black"])), off.clone()] { + let shown = r.render(&d, 20, 10, Affine::IDENTITY, &opts); + let (a, b) = (shown.pixel(5, 5), shown.pixel(15, 5)); + assert!(near(a, b, 3), "{:?}: the shrunk image shows as the fill does, {a:?} vs {b:?}", opts.proof.map(|p| p.separations)); + seen.push(a); + } + } + assert_eq!(seen[0], [0, 255, 255, 255], "the preview off: the image's own pixels"); + assert_eq!(seen[3], seen[0], "and again after the preview"); + assert_ne!(seen[1], seen[2], "each plate set filters the image anew"); + assert_eq!(seen[..4], seen[4..], "frames drawn from kept copies draw the same"); +} diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index a5067aff81..f17eb16b66 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1,6 +1,6 @@ # Parity with Adobe Illustrator -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Colour, gradients & mesh: several gradient mesh points can be picked (Shift-clicks with the Mesh tool and Direct Selection, Direct Selection's marquee, its click on a mesh line or inside a patch); a drag or the arrow keys move them all (`object.mesh.movePoints`), and a solid fill colour or the Transparency panel's opacity goes to each of them (#4207, #4208, #4170); scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Print, colour management, separations: Separations Preview's plates apply to placed and embedded raster images (#4153); scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026) ## Feature submission evidence @@ -1027,6 +1027,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Placed documents' bitmaps on screen: when a bitmap made in the background is ready, the desktop app renders the canvas again only where the objects that show its file are, when the frame shown was rendered on the UI thread and that part is at most half the canvas. Bitmaps drawn or made since a frame began are kept for that frame past the 512 MiB budget, up to 2 GiB, so a view showing more than the budget does not make them again in every frame. A bitmap that would take them past 2 GiB is not kept, and its file draws exactly at that zoom. A bitmap that can't be made (the file can't be read and there is no preview) shows the light placeholder and is not asked for again. Each ready bitmap used to render the whole canvas again, and bitmaps past the budget and bitmaps that could not be made were asked for again in every frame (`crates/render/src/tests/placed_document.rs`). - Linked PDF and `.ai` pages: File › Place with Link (the default) places a page of a PDF, `.ai` or `.ait` file read as PDF pages as a placed document, as it links an image, the page and its box (`crop`) kept with the link: Links check, update and relink it, Break Link and Object › Expand give the group placing it without Link gives, every output draws the page's vectors, and Package copies the file. Without Link, or with a password or `textAs: "outlines"`, the page is embedded. EPS and PostScript `.ai` files are still embedded (`crates/engine/src/tests/placed_document.rs`). - File › Place with Bounding Box (`file.place {crop: "bounding"}`) measures the art that shows, with its strokes and effects, as an export does: hidden objects, guides and template layers do not count, a group whose only part on the page or artboard is hidden is not placed, and symbol instances are measured by their art, for `at`, `rect`, the place cursor and `file.place.info` (`crates/engine/src/tests/place.rs`). + - Separations Preview shows placed and embedded raster images on the visible plates, as it shows vector art (#4153): an RGB image's pixels are separated into process inks with the proof setup's intent, a CMYK image shows its own inks, a hidden plate's ink leaves the image, and with one plate visible the image shows that plate's ink as a grey. Raster images carry no spot ink, so a spot plate shown alone shows them as paper; a colorized image shows its color's plates. Emoji and other bitmap glyphs follow the same rule. The plate-filtered pixels and their reduced-size copies are kept apart from the image's own pixels, for each set of visible plates, proof setup and color settings, and with the preview off nothing changes. Evidence: `tests::colorize::separations_preview_shows_an_rgb_images_process_inks`, `separations_preview_shows_a_cmyk_images_own_inks`, `separations_preview_keeps_an_images_pixels_per_plate_set`. Print preview fidelity remains the open gap, so scores and hours are unchanged. - Desktop print transport uses `craft-print` for CUPS and modern Windows. Sheet composition, copies, separations and colour management remain in VectorCraft. The Print dialog's Media list also carries the Japanese papers — JIS B4 257 × 364 mm, JIS B5 182 × 257 mm and JIS B6 128 × 182 mm beside the ISO B4/B5 (250 × 353 and 176 × 250 mm, kept so settings and presets saved before them keep their paper), and はがき 100 × 148 mm, 往復はがき 148 × 200 mm, 封筒 長形3号 120 × 235 mm, 長形4号 90 × 225 mm, 角形2号 240 × 332 mm, 角形3号 216 × 277 mm and 四六判 127 × 188 mm; the JSON id or the dialog label names a paper, any case and spacing (`B5 (JIS)` or `b5jis`) (`crates/pdf/src/print/settings.rs`, `crates/pdf/src/tests/print.rs`). The print-preview and physical-device fidelity gaps remain, so print scores and hours are unchanged. - A PDF, PDF-compatible `.ai` or `.ait` opened from its pages or its editing copy opens with the File Info that its XMP packet and its document information dictionary give: the author, description, keywords, copyright status, notice and URL, and the created and modified dates, the XMP packet's value where both give one; the title is not changed (`crates/pdf/src/tests/file_info.rs`, `crates/engine/src/tests/fileinfo.rs`). - PDF export and PDF-compatible `.ai` and `.ait` saves write the document's File Info created date as the file's creation date, or the time of writing when the document has none, and the time of writing as its modification date; the page information mark still prints the time of writing (`crates/engine/src/tests/fileinfo.rs`, `crates/pdf/src/tests.rs`, `crates/pdf/src/tests/marks.rs`). @@ -1204,6 +1205,7 @@ applies to fills). Tests: `color::gradient::tests` (perceptual midpoint, expansi | Date | Change | Summary | |---|---|---| +| 2026-10-30 | minor | Print, colour management, separations: Separations Preview's plates apply to placed and embedded raster images, a CMYK image's own inks included (#4153); evidence added; score and hours unchanged (estimated). | | 2026-10-30 | minor | Colour, gradients & mesh: several gradient mesh points can be picked (Shift-clicks with the Mesh tool and Direct Selection, Direct Selection's marquee, its click on a mesh line or inside a patch); a drag or the arrow keys move them all (`object.mesh.movePoints`), and a solid fill colour or the Transparency panel's opacity goes to each of them (#4207, #4208, #4170); scores unchanged. | | 2026-10-30 | minor | Drawing aids: Character panel menu › Show Snap to Glyph Options shows the Snap to Glyph section (Baseline, x-height, Glyph Bounds, Proximity Guides, Angular Guides, Anchor Point; `view.snapToGlyph.options`) (#4232); evidence added; score and hours unchanged (estimated). | | 2026-10-30 | minor | Selection, transform & align tools: Align panel menu › Align to Glyph Bounds › Point Text and Area Text align and distribute type by the ink of its glyphs (#4231); evidence added; score and hours unchanged (estimated). | From 6fe71df1cfa016ccf8438e3e7e89bdb6dfab07e5 Mon Sep 17 00:00:00 2001 From: Don Omondi <282319807+mockydevs@users.noreply.github.com> Date: Fri, 30 Oct 2026 00:32:16 +0300 Subject: [PATCH 003/163] Fix #4233: Direct Selection drags art onto Asset Export and the other panels Art dragged off the canvas reached the panels (Asset Export, Graphic Styles, Swatches, Symbols) only from the Selection tool: drag_art_out checked for that tool by id. With the Direct Selection or Group Selection tool the move stayed on the canvas, so nothing dropped. Those tools now hand over a move too when every selected object is selected whole (a press on its fill). A drag of anchor points or segments, which they also call Move, stays a reshape and isn't handed to the panels. --- crates/ui-egui/src/canvas/drag.rs | 10 ++++- crates/ui-egui/src/canvas/tests.rs | 65 ++++++++++++++++++++++++++++++ docs/ui-parity.md | 1 + 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/canvas/drag.rs b/crates/ui-egui/src/canvas/drag.rs index bfc3a070f7..c35effb6fd 100644 --- a/crates/ui-egui/src/canvas/drag.rs +++ b/crates/ui-egui/src/canvas/drag.rs @@ -172,12 +172,18 @@ pub(super) fn drop_press(app: &mut VectorcraftApp, ui: &Ui, view: vectorcraft_en /// the selected art ([`widgets::PanelDrag::Art`]): the art waits where it last moved on the /// canvas, and a panel it is released on takes it (the Graphic Styles panel makes a style of it). /// Back on the canvas, [`Drag::Art`] takes the move up again where the pointer is (#2826). +/// The Direct and Group Selection tools hand over art they move whole too (#4233); a move of +/// anchor points or segments stays a reshape. pub(super) fn drag_art_out(app: &VectorcraftApp, ui: &Ui, resp: &egui::Response, p: Pos2) -> bool { - let Some(st) = app.session.active().filter(|_| app.session.tool_id() == "selection") else { return false }; - // The Selection tool's interaction while it moves (or Alt-copies) the selection. + let tool = app.session.tool_id(); + let Some(st) = app.session.active().filter(|_| matches!(tool, "selection" | "directSelection" | "groupSelection")) else { return false }; + // The tool's interaction while it moves (or Alt-copies) the selection. if !st.interaction.as_ref().is_some_and(|i| i.label == "Move" || i.label == "Copy") { return false; } + if tool != "selection" && st.selection.objects.iter().any(|id| st.selection.partial(*id).is_some() || st.selection.segments.contains_key(id)) { + return false; + } // A floating panel in an OS window of its own takes the art too: craft-ui hands that window // the pointer while it is over it, and this window sees the pointer go. craft_ui::docking::route_app_drag(ui.ctx(), crate::panel_docking::area_id()); diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 6a30f248f1..110e3bd5c4 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -5298,6 +5298,71 @@ fn art_moved_off_the_canvas_waits_and_drops_on_the_panel() { assert_eq!(st.history.undo.len(), undo); } +/// #4233: the Direct and Group Selection tools hand art they move whole to the panels too (Asset +/// Export, Graphic Styles…), as the Selection tool does; the move waits and nothing is recorded. +#[test] +fn art_moved_whole_off_the_canvas_with_direct_selection_drops_on_the_panel() { + for tool in ["directSelection", "groupSelection"] { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.session.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + let id = app.session.execute("shape.rectangle", &json!({"x": 50, "y": 50, "width": 100, "height": 100})).unwrap()["id"].as_u64().unwrap(); + let id = vectorcraft_doc::NodeId(id); + app.session.execute("select.none", &json!({})).unwrap(); + app.select_tool(tool); + let ctx = egui::Context::default(); + frame(&mut app, &ctx, vec![]); + let xf = Xf::new(app.canvas_rect.unwrap(), app.view().unwrap()); + let before = app.session.active().unwrap().doc.clone(); + let undo = app.session.active().unwrap().history.undo.len(); + let button = |pos: Pos2, pressed: bool| egui::Event::PointerButton { + pos, + button: egui::PointerButton::Primary, + pressed, + modifiers: Default::default(), + }; + // Pressed on the fill: the rectangle is selected whole. + let start = xf.to_screen(Point::new(100.0, 100.0)); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(start), button(start, true)]); + assert_eq!(app.session.active().unwrap().selection.whole(), [id], "{tool}: selected whole"); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(start + vec2(40.0, 0.0))]); + assert!(app.session.active().unwrap().interaction.is_some(), "{tool}: the move is live"); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(pos2(850.0, 100.0))]); + assert!(app.session.active().unwrap().interaction.is_some(), "{tool}: the move waits, not cancels"); + assert_eq!(egui::DragAndDrop::payload::(&ctx).as_deref(), Some(&widgets::PanelDrag::Art(vec![id])), "{tool}"); + frame(&mut app, &ctx, vec![button(pos2(850.0, 100.0), false)]); + let st = app.session.active().unwrap(); + assert!(st.interaction.is_none(), "{tool}"); + assert_eq!(*st.doc, *before, "{tool}: the move goes back"); + assert_eq!(st.history.undo.len(), undo, "{tool}: nothing recorded"); + } +} + +/// An anchor point the Direct Selection tool drags off the canvas isn't art for the panels: the +/// reshape goes on and no art drag starts (#4233). +#[test] +fn an_anchor_dragged_off_the_canvas_is_not_handed_to_the_panels() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.session.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + let id = app.session.execute("shape.rectangle", &json!({"x": 50, "y": 50, "width": 100, "height": 100})).unwrap()["id"].as_u64().unwrap(); + app.select_tool("directSelection"); + app.session.execute("select.anchors", &json!({"id": id, "anchors": [[0, 0]]})).unwrap(); + let ctx = egui::Context::default(); + frame(&mut app, &ctx, vec![]); + let xf = Xf::new(app.canvas_rect.unwrap(), app.view().unwrap()); + let button = + |pos: Pos2, pressed: bool| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + let corner = xf.to_screen(Point::new(50.0, 50.0)); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(corner), button(corner, true)]); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(corner + vec2(20.0, 0.0))]); + assert!(app.session.active().unwrap().selection.partial(vectorcraft_doc::NodeId(id)).is_some(), "an anchor is picked"); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(pos2(850.0, 100.0))]); + assert!( + !matches!(egui::DragAndDrop::payload::(&ctx).as_deref(), Some(widgets::PanelDrag::Art(_))), + "no art drag for an anchor" + ); + frame(&mut app, &ctx, vec![button(pos2(850.0, 100.0), false)]); +} + /// #2826: a move taken over a panel waits where it left the canvas, and goes on with the /// pointer when it comes back — it isn't dropped or put back. #[test] diff --git a/docs/ui-parity.md b/docs/ui-parity.md index ae4795c2ae..4c615393a5 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -363,6 +363,7 @@ separate. Scores and hours unchanged. [Behavior and command details](development |---|---|---| | 2026-10-30 | minor | Character panel menu › Show Snap to Glyph Options shows the Snap to Glyph section (Baseline, x-height, Glyph Bounds, Proximity Guides, Angular Guides, Anchor Point; `view.snapToGlyph.options`) (#4232); scores and estimates unchanged | | 2026-10-30 | minor | Align panel menu › Align to Glyph Bounds › Point Text and Area Text align and distribute type by the ink of its glyphs (#4231); the Character and Properties panels' controls for it are not done; scores and estimates unchanged | +| 2026-10-30 | minor | Art moved whole with the Direct Selection or Group Selection tool and dragged off the canvas goes to the panels (Asset Export, Graphic Styles, Swatches, Symbols) as with the Selection tool; anchor points and segments dragged off stay a reshape (#4233). Tests in `crates/ui-egui/src/canvas/tests.rs`; scores and estimates unchanged | | 2026-10-30 | minor | Blob Brush and Eraser Tool Options: Size follows the pen pressure, Fixed or Pressure with a Variation (#4590, #3961); scores and estimates unchanged | | 2026-10-30 | minor | Blob Brush Tool Options: Size follows the pen pressure, Fixed or Pressure with a Variation (#4590); scores and estimates unchanged | | 2026-10-29 | minor | Pathfinder: live compound shapes (#4522): the panel menu's Make, Release and Expand Compound Shape, Alt-clicking a Shape Mode, a selected member's Shape Mode and the Expand button act; scores and estimates unchanged | From 4fe7e0ae6b5e20d9c5e291aa220e89df3617f83d Mon Sep 17 00:00:00 2001 From: Don Omondi <282319807+mockydevs@users.noreply.github.com> Date: Fri, 30 Oct 2026 00:12:45 +0300 Subject: [PATCH 004/163] Fix #4469: Direct Selection's task bar offers the path's anchor actions With the Direct Selection tool active (after the bar's Edit Path, or switching to it) and a path selected whole, the Contextual Task Bar kept the Selection tool's Edit Path, Offset Path and Simplify: its anchor actions showed only for anchors picked out one by one. The public overview lists, for a path the Direct Selection tool selects, Simplify and the anchor actions. A path selected whole now offers Corner and Smooth (path.convertAnchors converts every anchor of a fully selected path), Connect for an open path, and Simplify. Remove Anchor Points and Cut Path need anchors picked out and still wait for them. Edit Path, which only switches to the tool already in use, is left out, for compound paths too. --- crates/ui-egui/src/canvas/task_bar.rs | 17 ++++++- crates/ui-egui/src/tests/taskbar.rs | 71 +++++++++++++++++++++++++++ docs/ui-parity.md | 3 +- 3 files changed, 89 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/canvas/task_bar.rs b/crates/ui-egui/src/canvas/task_bar.rs index 461730c6ed..61c9719878 100644 --- a/crates/ui-egui/src/canvas/task_bar.rs +++ b/crates/ui-egui/src/canvas/task_bar.rs @@ -93,6 +93,10 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, xf: &Xf) { // (). // These run the same commands as the Control bar's anchor buttons. let anchors = !st.selection.anchors.is_empty(); + // With the Direct Selection tool, a path selected whole offers its anchor points' actions + // too, as the reference app's bar does for any path that tool selects (same page), and Edit + // Path, which only switches to that tool, is left out (#4469). + let direct = app.session.tool_id() == "directSelection"; if anchors { items.push((tl!("Remove Anchor Points"), "pen-tool-delete", "path.removeAnchors", none())); items.push((tl!("Connect"), "dc-join", "path.join", none())); @@ -122,7 +126,9 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, xf: &Xf) { items.push((tl!("Isolate"), "square-dashed", "object.isolate", none())); } } else if is_compound { - items.push(edit_path()); + if !direct { + items.push(edit_path()); + } items.push((tl!("Release Compound Path"), "ungroup", "object.compoundPath.release", none())); } else if let Some(kind) = text { items.push((tl!("Create Outlines"), "type", "type.createOutlines", none())); @@ -134,6 +140,15 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, xf: &Xf) { } } else if is_image { // Offset Path and Simplify don't apply to an image. + } else if !anchors && direct { + // Corner and Smooth convert every anchor of a path selected whole; Remove and Cut + // need anchors picked out, so they wait for them. + if open_path { + items.push((tl!("Connect"), "dc-join", "path.join", none())); + } + items.push((tl!("Corner"), "dc-anchor", TASK_BAR_TO_CORNER, none())); + items.push((tl!("Smooth"), "dc-anchor-smooth", TASK_BAR_TO_SMOOTH, none())); + items.push((tl!("Simplify"), "spline", "object.path.simplify", none())); } else if !anchors { if open_path { items.push((tl!("Join"), "dc-join", "path.join", none())); diff --git a/crates/ui-egui/src/tests/taskbar.rs b/crates/ui-egui/src/tests/taskbar.rs index e1563c339e..27c49ac5e3 100644 --- a/crates/ui-egui/src/tests/taskbar.rs +++ b/crates/ui-egui/src/tests/taskbar.rs @@ -163,3 +163,74 @@ fn type_converts_between_point_and_area_type() { click(&mut app, "Convert To Point Type"); assert!(matches!(text_kind(&app), TextKind::Point)); } + +/// The path's anchors (its first subpath). +fn anchors(app: &VectorcraftApp, id: u64) -> Vec { + match kind(app, id) { + NodeKind::Path { path, .. } => path.subpaths[0].anchors.clone(), + k => panic!("not a path: {k:?}"), + } +} + +/// With the Direct Selection tool, a path selected whole offers its anchor points' actions instead +/// of Edit Path and Offset Path (#4469), as after the bar's own Edit Path. +#[test] +fn direct_selection_of_a_whole_path_offers_its_anchor_actions() { + let mut app = app(); + let line = id(app.run("path.create", json!({"anchors": [{"x": 50, "y": 200}, {"x": 150, "y": 80}, {"x": 250, "y": 200}]})).unwrap()); + select(&mut app, &[line]); + click(&mut app, "Edit Path"); + assert_eq!(app.session.tool_id(), "directSelection"); + assert!(app.session.active().unwrap().selection.anchors.is_empty(), "the path is selected whole"); + let (_, texts) = bar(&mut app); + for label in ["Connect", "Corner", "Smooth", "Simplify", "Duplicate"] { + assert!(has(&texts, label), "{label}: {texts:?}"); + } + for label in ["Edit Path", "Offset Path", "Join", "Remove Anchor Points", "Cut Path"] { + assert!(!has(&texts, label), "{label}: {texts:?}"); + } + // Smooth and Corner convert every anchor of the path, one undo step each. + click(&mut app, "Smooth"); + let a = anchors(&app, line); + assert_eq!(a[1].kind, vectorcraft_geom::AnchorKind::Smooth, "{a:?}"); + assert!(a[1].has_in() && a[1].has_out(), "{a:?}"); + click(&mut app, "Corner"); + assert!(anchors(&app, line).iter().all(|a| !a.has_in() && !a.has_out()), "{:?}", anchors(&app, line)); + app.run("edit.undo", json!({})).unwrap(); + assert!(anchors(&app, line)[1].has_in(), "Corner undoes in one step"); + // Connect closes the open path; a closed one isn't offered it. + click(&mut app, "Connect"); + assert!(matches!(kind(&app, line), NodeKind::Path { path, .. } if path.is_closed())); + let (_, texts) = bar(&mut app); + assert!(!has(&texts, "Connect") && has(&texts, "Corner"), "{texts:?}"); +} + +/// Anchors picked out with the Direct Selection tool keep the full set: Remove and Cut need them. +#[test] +fn direct_selected_anchors_still_offer_remove_and_cut() { + let mut app = app(); + let line = id(app.run("path.create", json!({"anchors": [{"x": 50, "y": 200}, {"x": 150, "y": 80}, {"x": 250, "y": 200}]})).unwrap()); + app.run("tool.select", json!({"tool": "directSelection"})).unwrap(); + app.run("select.anchors", json!({"id": line, "anchors": [[0, 1]]})).unwrap(); + let (_, texts) = bar(&mut app); + for label in ["Remove Anchor Points", "Connect", "Cut Path", "Corner", "Smooth"] { + assert!(has(&texts, label), "{label}: {texts:?}"); + } + assert!(!has(&texts, "Edit Path"), "{texts:?}"); +} + +/// A compound path under the Direct Selection tool isn't offered Edit Path, which would only switch +/// to the tool already in use; the Selection tool still offers it. +#[test] +fn a_compound_path_under_direct_selection_drops_edit_path() { + let mut app = app(); + let a = id(app.run("shape.rectangle", json!({"x": 40, "y": 40, "width": 120, "height": 100})).unwrap()); + let b = id(app.run("shape.ellipse", json!({"x": 70, "y": 60, "width": 50, "height": 50})).unwrap()); + select(&mut app, &[a, b]); + let c = id(app.run("object.compoundPath.make", json!({})).unwrap()); + click(&mut app, "Edit Path"); + assert_eq!(app.session.tool_id(), "directSelection"); + select(&mut app, &[c]); + let (_, texts) = bar(&mut app); + assert!(has(&texts, "Release Compound Path") && !has(&texts, "Edit Path"), "{texts:?}"); +} diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 4c615393a5..1e2bfa46bf 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Character panel menu › Show Snap to Glyph Options shows the Snap to Glyph section (Baseline, x-height, Glyph Bounds, Proximity Guides, Angular Guides, Anchor Point; `view.snapToGlyph.options`) (#4232); scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Contextual Task Bar: with the Direct Selection tool, a path selected whole offers Corner, Smooth (every anchor), Connect (open paths) and Simplify instead of Edit Path and Offset Path, as the public overview lists for that tool (); a compound path under that tool no longer offers Edit Path (#4469); scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x) ## Feature submission evidence @@ -361,6 +361,7 @@ separate. Scores and hours unchanged. [Behavior and command details](development | Date | Change | Summary | |---|---|---| +| 2026-10-30 | minor | Contextual Task Bar: with the Direct Selection tool, a path selected whole offers Corner, Smooth (every anchor), Connect (open paths) and Simplify instead of Edit Path and Offset Path, as the public overview lists for that tool (); a compound path under that tool no longer offers Edit Path (#4469). Tests in `crates/ui-egui/src/tests/taskbar.rs`; scores and estimates unchanged | | 2026-10-30 | minor | Character panel menu › Show Snap to Glyph Options shows the Snap to Glyph section (Baseline, x-height, Glyph Bounds, Proximity Guides, Angular Guides, Anchor Point; `view.snapToGlyph.options`) (#4232); scores and estimates unchanged | | 2026-10-30 | minor | Align panel menu › Align to Glyph Bounds › Point Text and Area Text align and distribute type by the ink of its glyphs (#4231); the Character and Properties panels' controls for it are not done; scores and estimates unchanged | | 2026-10-30 | minor | Art moved whole with the Direct Selection or Group Selection tool and dragged off the canvas goes to the panels (Asset Export, Graphic Styles, Swatches, Symbols) as with the Selection tool; anchor points and segments dragged off stay a reshape (#4233). Tests in `crates/ui-egui/src/canvas/tests.rs`; scores and estimates unchanged | From 1c43827df1847ad2234039fdd4106f7c2c87404c Mon Sep 17 00:00:00 2001 From: Don Omondi <282319807+mockydevs@users.noreply.github.com> Date: Fri, 30 Oct 2026 00:13:30 +0300 Subject: [PATCH 005/163] docs: record #4469 in the UI history without touching the status line Keeps this branch's doc change apart from the other open UI-parity edit, so the two merge in either order. --- docs/ui-parity.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 1e2bfa46bf..d525a05f49 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Contextual Task Bar: with the Direct Selection tool, a path selected whole offers Corner, Smooth (every anchor), Connect (open paths) and Simplify instead of Edit Path and Offset Path, as the public overview lists for that tool (); a compound path under that tool no longer offers Edit Path (#4469); scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Character panel menu › Show Snap to Glyph Options shows the Snap to Glyph section (Baseline, x-height, Glyph Bounds, Proximity Guides, Angular Guides, Anchor Point; `view.snapToGlyph.options`) (#4232); scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x) ## Feature submission evidence @@ -361,8 +361,8 @@ separate. Scores and hours unchanged. [Behavior and command details](development | Date | Change | Summary | |---|---|---| -| 2026-10-30 | minor | Contextual Task Bar: with the Direct Selection tool, a path selected whole offers Corner, Smooth (every anchor), Connect (open paths) and Simplify instead of Edit Path and Offset Path, as the public overview lists for that tool (); a compound path under that tool no longer offers Edit Path (#4469). Tests in `crates/ui-egui/src/tests/taskbar.rs`; scores and estimates unchanged | | 2026-10-30 | minor | Character panel menu › Show Snap to Glyph Options shows the Snap to Glyph section (Baseline, x-height, Glyph Bounds, Proximity Guides, Angular Guides, Anchor Point; `view.snapToGlyph.options`) (#4232); scores and estimates unchanged | +| 2026-10-30 | minor | Contextual Task Bar: with the Direct Selection tool, a path selected whole offers Corner, Smooth (every anchor), Connect (open paths) and Simplify instead of Edit Path and Offset Path, as the public overview lists for that tool (); a compound path under that tool no longer offers Edit Path (#4469). Tests in `crates/ui-egui/src/tests/taskbar.rs`; scores and estimates unchanged | | 2026-10-30 | minor | Align panel menu › Align to Glyph Bounds › Point Text and Area Text align and distribute type by the ink of its glyphs (#4231); the Character and Properties panels' controls for it are not done; scores and estimates unchanged | | 2026-10-30 | minor | Art moved whole with the Direct Selection or Group Selection tool and dragged off the canvas goes to the panels (Asset Export, Graphic Styles, Swatches, Symbols) as with the Selection tool; anchor points and segments dragged off stay a reshape (#4233). Tests in `crates/ui-egui/src/canvas/tests.rs`; scores and estimates unchanged | | 2026-10-30 | minor | Blob Brush and Eraser Tool Options: Size follows the pen pressure, Fixed or Pressure with a Variation (#4590, #3961); scores and estimates unchanged | From 9095cdf926657b6d56e902ca6e0dbc5aa3267a4d Mon Sep 17 00:00:00 2001 From: Don Omondi <282319807+mockydevs@users.noreply.github.com> Date: Fri, 30 Oct 2026 00:01:09 +0300 Subject: [PATCH 006/163] Fix #4625: UI settings survive a relaunch and a second window Two ways the next launch came back with settings from before: - The workspace, panels, toolbars and other settings kept only in the UI state were written only on quitting (Preferences OK already saved at once, #1747). A session ended any other way lost them. The app now saves within 2 seconds of a change, and only when something changed. - Each launch is its own process, so two windows are common (opening a second file from the file manager). A window wrote back the whole state it started from when it quit, so the one quitting last put back the settings it read at its start, even with nothing changed in it. A window now saves only what it changed since it last read or saved, merged into the file as it is: each UI field, and each engine preference on its own. A setting both windows changed takes the last save. The status line, open dialog and other fields a start resets neither trigger a save nor replace another window's. --- apps/vectorcraft/src/app.rs | 5 +- apps/vectorcraft/src/prefs.rs | 190 ++++++++++++++++++++++++++++++++-- docs/ui-parity.md | 3 +- 3 files changed, 189 insertions(+), 9 deletions(-) diff --git a/apps/vectorcraft/src/app.rs b/apps/vectorcraft/src/app.rs index 2847004b34..05c756a0c0 100644 --- a/apps/vectorcraft/src/app.rs +++ b/apps/vectorcraft/src/app.rs @@ -1,6 +1,6 @@ #[cfg(all(target_os = "macos", feature = "accessibility", feature = "wgpu"))] use super::gpu; -use super::prefs::save_prefs; +use super::prefs::{save_prefs, save_prefs_soon}; #[cfg(all(windows, not(target_vendor = "win7")))] use super::windows_stylus; use super::{App, VectorcraftApp, file_access, window}; @@ -71,6 +71,9 @@ impl eframe::App for App { // (the system shutting down, the process ended or crashing) used to lose them (#1747). if self.app.take_prefs_changed() { file_access::unconfined(|| save_prefs(&self.app)); + } else { + // The workspace, panels and other UI settings change without the dialog (#4625). + file_access::unconfined(|| save_prefs_soon(&self.app)); } // Not while a file dialog's sheet has the keyboard: its name field's composition would go. #[cfg(target_os = "macos")] diff --git a/apps/vectorcraft/src/prefs.rs b/apps/vectorcraft/src/prefs.rs index 56ea30f21f..728fe9ba8d 100644 --- a/apps/vectorcraft/src/prefs.rs +++ b/apps/vectorcraft/src/prefs.rs @@ -84,24 +84,200 @@ pub(crate) fn load_prefs(app: &mut VectorcraftApp, saved: Option(&b).ok()); + let merged = match (base.as_ref(), on_disk) { + (Some(base), Some(on_disk)) => merge_changes(base, &mine, on_disk), + _ => mine.clone(), + }; + let _ = std::fs::create_dir_all(p.parent().unwrap_or(std::path::Path::new("."))); + let Ok(bytes) = serde_json::to_vec_pretty(&merged) else { return }; + // Preferences are best effort: a failed write keeps the previous file, and the changes are + // tried again on the next save. + if fileio::write_atomic(&p, &bytes).is_ok() { + set_saved_base(Some(mine)); } } +/// How often [`save_prefs_soon`] looks for changes to save. +const SAVE_EVERY: std::time::Duration = std::time::Duration::from_secs(2); + +/// Save the preferences at most every [`SAVE_EVERY`] while the app runs, when something changed: +/// the workspace, panels, toolbars and the other UI settings kept only in the UI state were saved +/// only on quitting, so a session ended any other way (the window closed by the system, the +/// process ended or crashing) started the next one from the settings before it (#4625). +pub(crate) fn save_prefs_soon(app: &VectorcraftApp) { + static LAST: std::sync::Mutex> = std::sync::Mutex::new(None); + let Ok(mut last) = LAST.lock() else { return }; + if last.is_some_and(|t| t.elapsed() < SAVE_EVERY) { + return; + } + *last = Some(std::time::Instant::now()); + drop(last); + save_prefs(app); +} + +/// The preferences as this window last read or saved them (`None`: not read yet). +static SAVED_BASE: std::sync::Mutex> = std::sync::Mutex::new(None); + +fn saved_base() -> Option { + SAVED_BASE.lock().ok().and_then(|b| b.clone()) +} + +fn set_saved_base(value: Option) { + if let Ok(mut b) = SAVED_BASE.lock() { + *b = value; + } +} + +/// Fields of the UI state that a start resets ([`vectorcraft_ui_egui::UiState::sanitized`]): a +/// change to them alone isn't saved, and they are never merged over another window's. +const PASSING: &[&str] = &["status", "dialog", "flyout", "palette_open", "palette_query", "about", "open_panel"]; + +/// Do `a` and `b` hold the same preferences, leaving out what a start resets ([`PASSING`])? +fn same_lasting(a: &serde_json::Value, b: &serde_json::Value) -> bool { + match (a.as_object(), b.as_object()) { + (Some(a), Some(b)) => { + let keys: std::collections::BTreeSet<&String> = a.keys().chain(b.keys()).filter(|k| !PASSING.contains(&k.as_str())).collect(); + keys.into_iter().all(|k| a.get(k) == b.get(k)) + } + _ => a == b, + } +} + +/// `on_disk` with what changed from `base` to `mine` put over it: each top-level field of the UI +/// state, and each engine preference (`engine_prefs`) on its own, so two windows that change +/// different settings keep both. A field both changed takes this window's value (it saves last). +fn merge_changes(base: &serde_json::Value, mine: &serde_json::Value, on_disk: serde_json::Value) -> serde_json::Value { + use serde_json::Value; + let (Some(base), Some(mine), Value::Object(mut out)) = (base.as_object(), mine.as_object(), on_disk) else { + return mine.clone(); + }; + let keys: std::collections::BTreeSet<&String> = base.keys().chain(mine.keys()).collect(); + for key in keys { + if PASSING.contains(&key.as_str()) { + if let Some(v) = mine.get(key) { + out.entry(key.clone()).or_insert_with(|| v.clone()); + } + continue; + } + let (was, now) = (base.get(key), mine.get(key)); + if was == now { + continue; + } + if key == "engine_prefs" + && let (Some(Value::Object(was)), Some(Value::Object(now)), Some(Value::Object(theirs))) = (was, now, out.get_mut(key)) + { + let names: std::collections::BTreeSet<&String> = was.keys().chain(now.keys()).collect(); + for name in names { + match (was.get(name), now.get(name)) { + (a, b) if a == b => {} + (_, Some(v)) => { + theirs.insert(name.clone(), v.clone()); + } + (_, None) => { + theirs.remove(name); + } + } + } + continue; + } + match now { + Some(v) => { + out.insert(key.clone(), v.clone()); + } + None => { + out.remove(key); + } + } + } + Value::Object(out) +} + /// The preferences file's contents: the UI state with the engine preferences. +#[cfg(test)] pub(crate) fn prefs_bytes(app: &VectorcraftApp) -> serde_json::Result> { + serde_json::to_vec_pretty(&prefs_value(app)?) +} + +/// [`prefs_bytes`] as JSON. +fn prefs_value(app: &VectorcraftApp) -> serde_json::Result { let mut ui = app.ui.clone(); ui.engine_prefs = app.session.prefs.to_json(); - serde_json::to_vec_pretty(&ui) + serde_json::to_value(&ui) +} + +#[cfg(test)] +mod tests { + use serde_json::json; + + use super::{merge_changes, same_lasting}; + + /// Two windows open at once (#4625): the one that saves last keeps the other's changes and + /// adds its own, instead of putting back the preferences it started from. + #[test] + fn a_window_saves_only_what_it_changed_over_another_windows_save() { + let base = json!({"workspace": "Essentials", "toolbar": true, "engine_prefs": {"uiAccent": "blue", "uiScaling": 1.0}}); + // The other window switched the workspace and the accent, and saved. + let on_disk = json!({"workspace": "Painting", "toolbar": true, "engine_prefs": {"uiAccent": "violet", "uiScaling": 1.0}}); + // This one changed only the UI scaling. + let mine = json!({"workspace": "Essentials", "toolbar": true, "engine_prefs": {"uiAccent": "blue", "uiScaling": 1.25}}); + let merged = merge_changes(&base, &mine, on_disk); + assert_eq!(merged, json!({"workspace": "Painting", "toolbar": true, "engine_prefs": {"uiAccent": "violet", "uiScaling": 1.25}})); + } + + #[test] + fn a_setting_both_windows_changed_takes_the_last_saved() { + let base = json!({"workspace": "Essentials", "engine_prefs": {"uiAccent": "blue"}}); + let on_disk = json!({"workspace": "Painting", "engine_prefs": {"uiAccent": "violet"}}); + let mine = json!({"workspace": "Typography", "engine_prefs": {"uiAccent": "green"}}); + assert_eq!(merge_changes(&base, &mine, on_disk), json!({"workspace": "Typography", "engine_prefs": {"uiAccent": "green"}})); + } + + #[test] + fn fields_added_or_removed_by_this_window_are_saved() { + let base = json!({"docking": {"root": 1}, "engine_prefs": {"old": 1}}); + let on_disk = json!({"docking": {"root": 1}, "recent_files": ["a.svg"], "engine_prefs": {"old": 1}}); + let mine = json!({"dock_width": 300.0, "engine_prefs": {"new": 2}}); + assert_eq!(merge_changes(&base, &mine, on_disk), json!({"dock_width": 300.0, "recent_files": ["a.svg"], "engine_prefs": {"new": 2}})); + } + + /// The status line and open dialogs reset at start: they don't make a save, and they don't + /// replace another window's. + #[test] + fn what_a_start_resets_is_left_out() { + let base = json!({"status": "", "dialog": null, "workspace": "Essentials"}); + let mine = json!({"status": "Saved", "dialog": {"kind": "preferences"}, "workspace": "Essentials"}); + assert!(same_lasting(&base, &mine)); + let on_disk = json!({"status": "Opened", "dialog": null, "workspace": "Painting"}); + let mine = json!({"status": "Saved", "dialog": {"kind": "preferences"}, "workspace": "Essentials", "toolbar": false}); + let merged = merge_changes(&base, &mine, on_disk); + assert_eq!(merged, json!({"status": "Opened", "dialog": null, "workspace": "Painting", "toolbar": false})); + assert!(!same_lasting(&base, &mine)); + } + + #[test] + fn a_file_that_is_not_an_object_is_replaced() { + let base = json!({"workspace": "Essentials"}); + let mine = json!({"workspace": "Painting"}); + assert_eq!(merge_changes(&base, &mine, json!([1, 2])), mine); + } } diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d525a05f49..2d8c7eaefa 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Character panel menu › Show Snap to Glyph Options shows the Snap to Glyph section (Baseline, x-height, Glyph Bounds, Proximity Guides, Angular Guides, Anchor Point; `view.snapToGlyph.options`) (#4232); scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Preferences: the workspace, panels, toolbars and other UI settings are saved within 2 seconds of a change instead of only on quitting, and a window saves only what it changed, merged into the file as another VectorCraft window left it, so a second window closing last no longer puts back the settings it started with (#4625); scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x) ## Feature submission evidence @@ -361,6 +361,7 @@ separate. Scores and hours unchanged. [Behavior and command details](development | Date | Change | Summary | |---|---|---| +| 2026-10-30 | minor | Preferences: the workspace, panels, toolbars and other UI settings are saved within 2 seconds of a change instead of only on quitting, and a window saves only what it changed, merged into the file as another VectorCraft window left it, so a second window closing last no longer puts back the settings it started with (#4625). Tests `prefs::tests` in `apps/vectorcraft`; scores and estimates unchanged | | 2026-10-30 | minor | Character panel menu › Show Snap to Glyph Options shows the Snap to Glyph section (Baseline, x-height, Glyph Bounds, Proximity Guides, Angular Guides, Anchor Point; `view.snapToGlyph.options`) (#4232); scores and estimates unchanged | | 2026-10-30 | minor | Contextual Task Bar: with the Direct Selection tool, a path selected whole offers Corner, Smooth (every anchor), Connect (open paths) and Simplify instead of Edit Path and Offset Path, as the public overview lists for that tool (); a compound path under that tool no longer offers Edit Path (#4469). Tests in `crates/ui-egui/src/tests/taskbar.rs`; scores and estimates unchanged | | 2026-10-30 | minor | Align panel menu › Align to Glyph Bounds › Point Text and Area Text align and distribute type by the ink of its glyphs (#4231); the Character and Properties panels' controls for it are not done; scores and estimates unchanged | From 68ad249efdd650a8ba4228756ce3110ceca78520 Mon Sep 17 00:00:00 2001 From: Don Omondi <282319807+mockydevs@users.noreply.github.com> Date: Thu, 29 Oct 2026 23:40:31 +0300 Subject: [PATCH 007/163] Fix #3510: editing data past 512 MiB opens with its layers where memory allows A layered .ai or Illustrator EPS whose editing data (embedded rasters, mostly) unpacks past 512 MiB opened as its PDF part or printed page, in one layer, with "it decompresses to more than 512 MB" (#4628 on 0.17.0 hit the older 256 MiB limit the same way). The limit is now an eighth of installed memory, from 512 MiB (what every 64-bit build read before) to 2 GiB: 1 GiB on an 8 GiB machine, 2 GiB on 16 GiB or more. Reading takes about as much memory again as the data (1.1 GB of data with 24 embedded 4096 x 4096 images peaked 1.1 GB above the start), so the ceiling keeps a small file that unpacks without end from taking a large machine's memory. 32-bit and web builds keep 256 MiB. vectorcraft_render::installed_memory exposes the reading the image cache already sizes itself from. --- crates/eps/src/import/ai.rs | 41 +++++++++++++++++++-------- crates/eps/src/import/ai/tests.rs | 46 ++++++++++++++++++++++++++++++- crates/render/src/images.rs | 9 ++++++ crates/render/src/lib.rs | 2 +- docs/file-format-parity.md | 3 +- 5 files changed, 86 insertions(+), 15 deletions(-) diff --git a/crates/eps/src/import/ai.rs b/crates/eps/src/import/ai.rs index b1a2112495..291171f783 100644 --- a/crates/eps/src/import/ai.rs +++ b/crates/eps/src/import/ai.rs @@ -13,7 +13,7 @@ //! groups, paths, colours, gradients, images) with newer ones (transparency, hidden objects) and //! dictionaries (names, artboards, type). `lex` scans it, `read` builds the document. //! -//! Reading is bounded: the data decompresses to at most [`MAX_DATA`], and the reader caps nesting, +//! Reading is bounded: the data decompresses to at most [`max_data`], and the reader caps nesting, //! objects and points. Anything it doesn't read is an error: the caller opens the file the way it //! did before (the printed page, or the PDF), with a warning saying why. @@ -39,10 +39,27 @@ pub(crate) use read::{slot_frame, slot_of}; #[cfg(test)] mod tests; -/// Largest editing data read, decompressed (bytes). Files with embedded rasters reach 340 MB (a -/// 30 MB poker box template unpacks to 322 MiB), so 64-bit builds read twice the old 256 MiB; a -/// 32-bit address space (wasm) keeps it. -pub const MAX_DATA: u64 = if cfg!(target_pointer_width = "64") { 512 << 20 } else { 256 << 20 }; +/// Least editing data read, decompressed (bytes), whatever the machine: 512 MiB on 64-bit builds (a +/// 30 MB poker box template with embedded rasters unpacks to 322 MiB), 256 MiB in a 32-bit address +/// space (wasm). +pub const MIN_DATA: u64 = if cfg!(target_pointer_width = "64") { 512 << 20 } else { 256 << 20 }; +/// Most editing data read on any machine (bytes). Reading takes about as much memory again as the +/// data (1.1 GB of data with 24 embedded 4096 x 4096 images peaked 1.1 GB above the start). +pub const MAX_DATA: u64 = if cfg!(target_pointer_width = "64") { 2 << 30 } else { 256 << 20 }; + +/// Largest editing data read, decompressed (bytes): an eighth of installed memory, from +/// [`MIN_DATA`] to [`MAX_DATA`], so a file whose embedded rasters unpack past 512 MiB keeps its +/// layers on a machine with room for it (#3510), while a small file that unpacks without end +/// still stops early. +pub fn max_data() -> u64 { + static LIMIT: std::sync::OnceLock = std::sync::OnceLock::new(); + *LIMIT.get_or_init(|| data_limit(vectorcraft_render::installed_memory())) +} + +/// [`max_data`] on a machine with `memory` bytes installed (`None`: not known). +fn data_limit(memory: Option) -> u64 { + memory.map_or(MIN_DATA, |m| (m / 8).clamp(MIN_DATA, MAX_DATA)) +} /// Largest Zstandard window accepted (a frame asking for more is damaged data). const MAX_ZSTD_WINDOW: u64 = 64 << 20; /// Most Zstandard frames read (the app writes one). @@ -81,13 +98,13 @@ fn eps_section(section: &[u8]) -> Result, String> { } header.extend_from_slice(line); header.extend_from_slice(b"\n"); - if header.len() as u64 > MAX_DATA { + if header.len() as u64 > max_data() { return Err(too_large()); } } let Some(codec) = codec else { // Not compressed: the section is the data, as it is (images' samples are binary). - if section.len() as u64 > MAX_DATA { + if section.len() as u64 > max_data() { return Err(too_large()); } return Ok(section.to_vec()); @@ -96,7 +113,7 @@ fn eps_section(section: &[u8]) -> Result, String> { for line in lines { let body = line.strip_prefix(b"%").unwrap_or(line); text.push_str(std::str::from_utf8(body).map_err(|_| damaged("its ASCII85 encoding"))?); - if text.len() as u64 > MAX_DATA { + if text.len() as u64 > max_data() { return Err(too_large()); } } @@ -105,21 +122,21 @@ fn eps_section(section: &[u8]) -> Result, String> { } let packed = ps::ascii85_decode(&text).ok_or_else(|| damaged("its ASCII85 encoding"))?; let mut data = header; - data.extend(codec.decode(&packed, MAX_DATA.saturating_sub(data.len() as u64))?); + data.extend(codec.decode(&packed, max_data().saturating_sub(data.len() as u64))?); Ok(data) } /// The editing data of a `.ai` file: its `AIPrivateData` streams joined (`raw`), decompressed. The /// compressed data may follow header comments that aren't. pub fn decode_private(raw: &[u8]) -> Result, String> { - if raw.len() as u64 > MAX_DATA { + if raw.len() as u64 > max_data() { return Err(too_large()); } for (marker, codec) in [(&b"%AI24_ZStandard_Data"[..], Codec::Zstd), (b"%AI12_CompressedData", Codec::Zlib)] { if let Some(at) = find(raw, marker) { let (header, body) = raw.split_at(at); let mut data = header.to_vec(); - data.extend(codec.decode(body.get(marker.len()..).unwrap_or_default(), MAX_DATA.saturating_sub(header.len() as u64))?); + data.extend(codec.decode(body.get(marker.len()..).unwrap_or_default(), max_data().saturating_sub(header.len() as u64))?); return Ok(data); } } @@ -172,5 +189,5 @@ fn damaged(what: &str) -> String { } fn too_large() -> String { - format!("it decompresses to more than {} MB", MAX_DATA >> 20) + format!("it decompresses to more than {} MB", max_data() >> 20) } diff --git a/crates/eps/src/import/ai/tests.rs b/crates/eps/src/import/ai/tests.rs index 5077a30f23..f6ae839577 100644 --- a/crates/eps/src/import/ai/tests.rs +++ b/crates/eps/src/import/ai/tests.rs @@ -1266,7 +1266,51 @@ fn editing_data_past_256_mib_is_read() { assert!(raw.len() < 1 << 20, "zeros compress"); let data = decode_private(&raw).unwrap(); assert_eq!(data.len(), body.len()); - assert!(too_large().contains("512 MB")); + assert_eq!(too_large(), format!("it decompresses to more than {} MB", max_data() >> 20)); +} + +/// The limit is an eighth of installed memory, never under the 512 MiB every 64-bit build read +/// before and never over 2 GiB (#3510). +#[cfg(target_pointer_width = "64")] +#[test] +fn the_editing_data_limit_follows_installed_memory() { + const GIB: u64 = 1 << 30; + assert_eq!(data_limit(None), 512 << 20, "unknown memory keeps the old limit"); + assert_eq!(data_limit(Some(2 * GIB)), 512 << 20); + assert_eq!(data_limit(Some(4 * GIB)), 512 << 20); + assert_eq!(data_limit(Some(8 * GIB)), GIB); + assert_eq!(data_limit(Some(12 * GIB)), 3 * GIB / 2); + assert_eq!(data_limit(Some(16 * GIB)), 2 * GIB); + assert_eq!(data_limit(Some(256 * GIB)), 2 * GIB, "capped, so a tiny file can't take all of a big machine"); + assert!((MIN_DATA..=MAX_DATA).contains(&max_data())); +} + +/// On a machine with 8 GiB or more, editing data past the old 512 MiB limit opens with its layers +/// (#3510, #4628): a layered file whose rasters unpack to 600 MiB. +#[cfg(target_pointer_width = "64")] +#[test] +fn editing_data_past_512_mib_is_read_where_memory_allows() { + if max_data() < 601 << 20 { + return; + } + let mut body = stream(&format!("{}{}", layer(&rect_path(0.0, 0.0, 10.0, 10.0)), layer(&rect_path(20.0, 20.0, 30.0, 30.0)))).into_bytes(); + let filler = vec![b'%'; (600 << 20) - body.len()]; + let at = body.windows(14).position(|w| w == b"%%PageTrailer\n").unwrap(); + body.splice(at..at, filler); + let raw = [&b"%AI12_CompressedData"[..], &crate::ps::deflate(&body)].concat(); + let data = decode_private(&raw).unwrap(); + assert_eq!(data.len(), body.len()); + drop(body); + let r = read(&data).unwrap(); + assert_eq!(r.doc.layers.len(), 2, "both layers are read"); +} + +/// Past the limit the data is still refused, so the file opens as its PDF part with a note. +#[test] +fn editing_data_past_the_limit_is_refused() { + let raw = [&b"%AI12_CompressedData"[..], &crate::ps::deflate(b"%%")].concat(); + assert!(Codec::Zlib.decode(raw.get(20..).unwrap(), 1).is_err()); + assert!(Codec::Zlib.decode(raw.get(20..).unwrap(), 2).is_ok()); } #[test] diff --git a/crates/render/src/images.rs b/crates/render/src/images.rs index 841d56469a..a187be25e7 100644 --- a/crates/render/src/images.rs +++ b/crates/render/src/images.rs @@ -42,6 +42,15 @@ fn budget_for(memory: u64) -> usize { usize::try_from(memory / 8).unwrap_or(usize::MAX).min(IMAGE_CACHE_MAX) } +/// Installed memory in bytes, `None` where it isn't known (the web, other systems). Other crates +/// size their own budgets from it. +pub fn installed_memory() -> Option { + #[cfg(target_arch = "wasm32")] + return None; + #[cfg(not(target_arch = "wasm32"))] + physical_memory() +} + /// Installed memory in bytes (`MemTotal` in `/proc/meminfo`). #[cfg(target_os = "linux")] fn physical_memory() -> Option { diff --git a/crates/render/src/lib.rs b/crates/render/src/lib.rs index d76c1a52ce..7de2aa0ab2 100644 --- a/crates/render/src/lib.rs +++ b/crates/render/src/lib.rs @@ -40,7 +40,7 @@ use lru::FrameCache; pub use brush_fx::instance_art; pub use changed::{Changed, changed, placed_area, view_pixels}; pub use effects::stroke::width_outline; -pub use images::{IMAGE_CACHE_MAX, image_cache_bytes, newly_undecodable, set_image_cache_budget}; +pub use images::{IMAGE_CACHE_MAX, image_cache_bytes, installed_memory, newly_undecodable, set_image_cache_budget}; pub use live::expand_live; pub use pattern::render_pattern_swatch; pub use vectorcraft_effects as effects; diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 7299944c39..e9c5c2a1f4 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File format parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-26 · **Change:** minor (Affinity import: attached Recolor Adjustment (RcRA) layers are imported as color overlays, #4420) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-29 · **Change:** minor (`.ai` and Illustrator EPS import: the editing data is read up to an eighth of installed memory, 512 MiB to 2 GiB, #3510, #4628) · **Target:** Adobe Illustrator 2026 (30.x) Every format Illustrator opens, places, saves or exports, against VectorCraft's format table (`FORMATS`, `OPEN_EXTS`, `PLACE_EXTS` in `crates/engine/src/cmd/fileio/formats.rs`). Illustrator's list comes from its public @@ -131,6 +131,7 @@ the app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPri | Date | Change | Summary | |---|---|---| +| 2026-10-29 | minor | `.ai` and Illustrator EPS import: the editing data is read up to an eighth of installed memory, from 512 MiB to 2 GiB on 64-bit builds (it was 512 MiB on every machine), so a layered file whose embedded rasters unpack past 512 MiB keeps its layers, groups and text on a machine with 8 GiB or more instead of opening as its page or PDF part (#3510, #4628). Measured: 1.1 GB of editing data peaked 1.1 GB above the start; data past the limit is still refused (a 2 MB file unpacking to 2.2 GB stops in under a second). 32-bit and web builds keep 256 MiB. Own-fixture tests `import::ai::tests::editing_data_past_512_mib_is_read_where_memory_allows`, `the_editing_data_limit_follows_installed_memory`; scores and hours unchanged | | 2026-10-29 | minor | Affinity import: attached Recolor Adjustment (RcRA) layers import as color overlays with HSL lightness (#4420); scores unchanged. | | 2026-10-26 | minor | EPS Save and Save As: an opened EPS saves back to its own path as EPS, keeping the chosen artboard's page frame and transparent margins and the complete editable VectorCraft document; Save's TIFF preview is capped at 1024 px (Export keeps 2048); partly read, preview-only or damaged-editing-data sources still need confirmation before they are overwritten; Save As leaves out the export-only crop and selection options. Synthetic regressions in `tests::save` (engine and UI) and `dialogs::save_options::tests`, listed under [EPS Save and source protection](#eps-save-and-source-protection); it does not write Illustrator's own editing data (#868), and G9's real-file import fidelity is unchanged; scores and hours unchanged | | 2026-10-25 | minor | `.ai` import: the editing data is read up to 512 MiB on 64-bit builds (the limit was 256 MiB), so a file whose embedded rasters unpack to 300 MiB or more keeps its layers, groups and text instead of opening as its PDF part (part of #3510); 32-bit and web builds keep 256 MiB. Own-fixture test `import::ai::tests::editing_data_past_256_mib_is_read`; scores and hours unchanged | From bcd6f653692cc909844b96363d8988a56df1d49d Mon Sep 17 00:00:00 2001 From: bflatastic Date: Fri, 30 Oct 2026 05:06:52 +0700 Subject: [PATCH 008/163] Preferences: audit which options act (G12) Every Preferences dialog option is read by shipped code, by its field or its key, except five, each waiting on a subsystem of its own: Open Documents As Tabs (documents in floating windows, G7), Units > East Asian Type, Hyphenation > Default Language, Scratch Disks, and the legacy vector clipboard. Highlight Alternate Glyphs, Real-time Drawing and the Devices options, still listed as stored-only, act. Docs only. --- docs/gaps.md | 19 +++++++++++++------ docs/target-app-parity.md | 8 +++++--- docs/ui-parity.md | 5 +++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/docs/gaps.md b/docs/gaps.md index cb8145e59c..f98756311f 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Gaps -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-29 · **Change:** minor (G12: Pathfinder: live compound shapes (#4522): the panel menu's Make, Release and Expand Compound Shape, Alt-clicking a Shape Mode, a selected member's Shape Mode and the Expand button act; no entry closed, estimate unchanged) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (G12: Preferences audit (#394): 5 options are stored but not acted on (Open Documents As Tabs, Units › East Asian Type, Hyphenation › Default Language, Scratch Disks, Legacy vector clipboard), each waiting on a subsystem; Highlight Alternate Glyphs, Real-time Drawing and the Devices options act; estimate unchanged) · **Target:** Adobe Illustrator 2026 (30.x) ## Feature submission evidence @@ -392,11 +392,17 @@ from G14 and the budget run of G15: **~170–270 h** one agent, ~50–80 h wall - **Done (2026-10-21, #394):** General › Constrain Angle turns the arrow keys' axes (guides stay on the page's), holds Shift drags of the Selection, Direct Selection, Free Transform, Slice Selection, Reshape and Measure tools and the Pen's handles to the turned axes, and new rectangles, rounded rectangles, ellipses, grids, point and area type, Shift-drawn polygons and stars and the shape size dialogs are drawn along it with their bounding box turned; 0° and whole turns are exactly as before, quarter turns exact (). Arcs, spirals, flares and the Pen's new paths are not turned yet. Estimate unchanged. **2026-10-24:** General › Corner Radius is the Rounded Rectangle tool's radius: the tool takes the preference when chosen and when it changes while the tool is active (or lent a selection tool for a drag), and the radius ↑/↓ set while drawing one, or a Tool Options value, becomes the preference, clamped to its 0–1296 pt range (). Estimate unchanged. - **Done (2026-10-17):** Background Export shows its progress in a dialog with Cancel and Continue in Background (#2564), on the shared cancel token (#2546); a cancelled export writes no file. Save As, Export for Screens and Export Selection don't show it yet. Estimate unchanged. - **Done:** quick Image Trace presets trace at once and leave the panel as it was; the Image Trace button (Control bar, Properties) opens the controls with Threshold and Advanced (Paths, Corners, Noise), as the public documentation describes (). Other context-specific Properties gaps remain. - -- **Missing:** ~14 Preferences options stored but not acted on (#394: Open -- **Done:** quick Image Trace presets reveal Threshold and Advanced controls (Paths, Corners, Noise); Properties can reopen them. Other context-specific Properties gaps remain. -- **Missing:** ~15 Preferences options stored but not acted on (#394: Highlight Alternate Glyphs, Open - Documents As Tabs, Real-time Drawing, hyphenation language, devices…), Properties panel per +- **Audited (2026-10-30, #394):** every Preferences dialog option but the five below is read by shipped code, by + its field or its key; Highlight Alternate Glyphs (the canvas's render options), Real-time Drawing and Editing + (tool previews wait for the commit), Show Tool Tips, Anti-aliased Artwork, Use Precise Cursors and Devices › + Enable Touch Workspace and Touch Gestures included. +- **Missing:** 5 Preferences options stored but not acted on (#394), each waiting on a subsystem of its own: + User Interface › Open Documents As Tabs (off would open documents in floating windows; one window per + document is G7), Units › East Asian Type (nothing is measured in it yet, and the Q and Ha units aren't in the + unit lists), Hyphenation › Default Language (hyphenation is English-only, with no per-language dictionaries), + Plug-ins & Scratch Disks › Primary and Secondary (documents are kept in memory; nothing pages to disk), and + Clipboard Handling › Legacy vector clipboard with its Preserve Paths / Preserve Appearance and Overprints choice + (Illustrator's own clipboard flavour, which has no public specification). Also Properties panel per context, context menus beyond the canvas, Layers panel row menus and Collect for Export, SVG Interactivity. - **Impact:** settings that silently do nothing erode trust. - **Estimate:** 13–20 h. @@ -647,6 +653,7 @@ trap, and the defaults (0.25 pt, 100%, 40%) are VectorCraft's own, the pages giv | Date | Change | Summary | |---|---|---| +| 2026-10-30 | minor | G12: Preferences audit (#394): 5 options are stored but not acted on (Open Documents As Tabs, Units › East Asian Type, Hyphenation › Default Language, Scratch Disks, Legacy vector clipboard), each waiting on a subsystem; Highlight Alternate Glyphs, Real-time Drawing and the Devices options act. Estimate unchanged. | | 2026-10-29 | minor | G10: the Linux Flatpak on GNOME stops the clipboard retry storm (retried with a growing wait, logged once). Estimate unchanged. | | 2026-10-29 | minor | G12: Pathfinder: live compound shapes (#4522): the panel menu's Make, Release and Expand Compound Shape, Alt-clicking a Shape Mode, a selected member's Shape Mode and the Expand button act. No entry closed, estimates unchanged. | | 2026-10-29 | minor | G8: a blend makes at most 100,000 steps in all, the steps of blends nested in its keys and steps included; past it each pair of keys keeps the same share of its steps (#3579). No entry closed, estimates unchanged. | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index f17eb16b66..21db9d99d8 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1,6 +1,6 @@ # Parity with Adobe Illustrator -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Print, colour management, separations: Separations Preview's plates apply to placed and embedded raster images (#4153); scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (UI chrome: Preferences audit (#394), 5 options stored but not acted on; scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026) ## Feature submission evidence @@ -149,7 +149,7 @@ dominate; 3D, graphs and automation are specialist). They sum to 105. Feature de | Export for Screens, Asset Export, slices, Save for Web | 3 | 85% | anti-aliasing ghost borders (#983); TIFF choices and settings are implemented | 2–4 | estimated | | Print, colour management, separations, flattener | 3 | 80% | print preview fidelity | 2–4 | estimated | | Automation (Actions, Variables, scripting, batch) | 3 | 60% | a scripting surface (Illustrator: JavaScript/ExtendScript), Batch, image and graph variables, dataset import/export | 8–14 | estimated; MCP `add_text` exposes existing vertical type; score and hours unchanged | -| UI chrome (panels, Properties, workspaces, preferences) | 6 | 80% | Properties per context, ~15 Preferences options stored but unused (#394; Corner Radius acts since 2026-10-24), SVG Interactivity, context menus beyond the canvas, accessibility | 13–20 | estimated; floating panels in OS windows of their own on the desktop (#4135), score and hours unchanged; macOS save Format menu implemented (#866), score and hours unchanged; Eyedropper cursor and precise setting checked (#1269), OS visual QA unverified; numeric-field focus and normal text drags regression-tested (#1326, in part); movements below the click threshold still select all; artboard navigation synchronizes the tool selection before destructive actions; status messages and readouts use stable responsive allocations sized for localized labels and ordinary coordinates (sample widths cached by language/unit/DPI; regression and contributor original-file evidence below; scores/hours unchanged) | +| UI chrome (panels, Properties, workspaces, preferences) | 6 | 80% | Properties per context, 5 Preferences options stored but unused (#394, audited 2026-10-30: Open Documents As Tabs, East Asian Type units, hyphenation Default Language, Scratch Disks, legacy vector clipboard), SVG Interactivity, context menus beyond the canvas, accessibility | 13–20 | estimated; floating panels in OS windows of their own on the desktop (#4135), score and hours unchanged; macOS save Format menu implemented (#866), score and hours unchanged; Eyedropper cursor and precise setting checked (#1269), OS visual QA unverified; numeric-field focus and normal text drags regression-tested (#1326, in part); movements below the click threshold still select all; artboard navigation synchronizes the tool selection before destructive actions; status messages and readouts use stable responsive allocations sized for localized labels and ordinary coordinates (sample widths cached by language/unit/DPI; regression and contributor original-file evidence below; scores/hours unchanged) | | Libraries, Links, Package | 2 | 82% | shared libraries, linked graphics, gradients and patterns as library items (no cloud by design) | 2–3 | estimated | | Generative AI (Text to Vector, Generative Recolor, Shape Fill, Concept to Vector, Prompt to Edit, Rewrite Text) | 2 | 0% | a pluggable provider and the panels; needs an owner decision on models | 30–60 | measured (absent) | | **Feature depth** | **105** | **~75%** | | **~250–420** | | @@ -598,8 +598,9 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Preferences that act (#394, in part): Show Tool Tips, Double Click To Isolate, Zoom with Mouse Wheel (the wheel zooms about the pointer, Shift-wheel scrolls up and down, Cmd/Ctrl-wheel sideways; Alt/Option-wheel and a trackpad pinch zoom about the pointer either way), Use Precise Cursors; Selection & Anchor Display › Tolerance (objects, anchors and handles), Object Selection by Path Only, Command Click to Select Objects Behind (cycling down the stack), Zoom to Selection, anchor Size, Highlight anchors on mouse over; Type › Number of Recent Fonts (up to 15); Guides & Grid › guide and grid Color and Style (lines or dots) and Grids In Back. Then Snap to Point (its distance, for moves, drawn points and reference points), Move Locked and Hidden Artwork with Artboard, Enable Rubber Band for the Pen and Curvature tools, Handles style, Show handles when multiple anchors are selected, Hide Corner Widget for angles greater than; General › Transform Pattern Tiles (the transforms' and dialogs' Transform Patterns, Align and Distribute, art moved or duplicated with an artboard, and objects moved whole with direct-selected anchors) and Select Same Tint %; Type › Size/Leading, Tracking and Baseline Shift increments (`type.step`, Cmd+Shift+. and Cmd+Shift+, for the size, the Type tool's Alt+arrows), Enable Missing Glyph Protection and Fill New Type Objects With Placeholder Text. Then Smart Guides › Color, Alignment Guides, Anchor/Path Labels, Measurement Labels, Transform Tools, Object Highlighting (with Smart Guides on) and Snapping Tolerance (4 px by default, for every smart guide snap), then Construction Guides and their Angles (#506: a drawn point near a line at one of those angles through the point it leaves from lands on it). Then Type › Type Object Selection by Path Only (type is picked on the baseline of any of its lines, area type's frame or the path of type on a path, no longer anywhere in its bounds; the Type tools and the Eyedropper still take a click among the characters). Then General › Anti-aliased Artwork (off, the canvas draws the art with hard edges). Then Guides & Grid › Show Pixel Grid (Above 600% Zoom), a line at every document pixel over the art in Pixel Preview, turning with a rotated view as the document grid now does too. Then General › Show The Home Screen When No Documents Are Open (off, closing the last document leaves an empty window; the Home button still opens the screen). Then Units › Numbers Without Units Are Points (on by default: a number typed with no unit into a field in picas is read in points, a typed unit still wins; dimmed unless a unit is Picas). Then User Interface › Auto-Collapse Iconic Panels (off by default: on, a click away from a panel popped out of the icon column puts it away). Then Performance › Animated Zoom (on, with GPU Performance, which it needs and which dims it when off: the Zoom tool dragged sideways zooms about the press, right in and left out, and held still zooms on, Alt out; off, a drag zooms to the area dragged across, now drawn as a marquee), User Interface › Large Tabs (taller document tabs) and Scale Cursor Proportional to UI (off, the tool cursors keep their size whatever the UI Scaling), and File Handling › Display Bitmaps as Anti-aliased Images in Pixel Preview (off by default: Pixel Preview draws images with each pixel taking its nearest image pixel). Type › Auto Size New Area Type works too (new area type gets Auto Size). They reach agents too (`prefs.set`, then `pointer_gesture` or `press_key`; `ui.wheel` on the control channel). Then Smart Guides › Spacing Guides (moves space the selection evenly with its row or column, see Drawing aids). Then Hyphenation › Exceptions (comma-separated words that never break, or break only at their hyphens; `prefs.set` and restore push them into the hyphenator, #394). Then Type › Show Font Names in English (off, font menus label a family by its native-language name when the font has one; documents still use the English family, #394). Then General › Display Print Size at 100% Zoom (off by default: View › Actual Size is one document point per screen point; on, one document inch fills 96 screen points, an inch at the reference density display scaling is set against; `view.actualSize` / `prefs.set`, #394). Then Guides & Grid › Gridline every and Subdivisions (changing either sets the grid of every open document; new and opened documents take that grid too, except a native file and the native document an SVG, PDF, `.ai` or EPS file carries, which open with the grid they were saved with; `file.new`, `document.open`, `file.newFromTemplate`, `file.revert`, #394). Then Appearance of Black › On Screen (Display All Blacks Accurately by default: pure CMYK black shows through the CMYK profile, a dark grey; Display All Blacks as Rich Black shows it on the canvas as RGB black, also in CMYK documents drawn by ink planes, while rich blacks, black tints and images show as before; `RenderOptions::rich_black`, #394). Then Appearance of Black › Printing / Exporting (Output All Blacks Accurately by default; Output All Blacks as Rich Black draws pure CMYK black as RGB black in RGB raster exports and Print as Bitmap; CMYK ink exports and the document stay unchanged; `prefs.blackOutput` / `richBlack`, #394). Then Units › Identify Objects By (Object Name by default: Layers, Variables and Layer Options show and edit free names; XML ID shows and edits AI-style XML ids, `_` for a space and `_xHH_` escapes, and `layer.setProps` / rename refuse invalid ids; the document still stores the object name, #394). Then Type › Highlight Alternate Glyphs (off by default: on, pink behind OpenType substitutions on screen — ligatures, contextual forms; Document Setup's Highlight Substituted Glyphs stays separate; `prefs.set`, #394). About 14 stored options still do nothing yet (the rest of #394: East Asian Type units, Open Documents As Tabs, Real-time Drawing and Editing, GPU Performance beyond Animated Zoom, hyphenation language, scratch disks, the legacy clipboard, Touch Workspace). - Preferences that act (#394, in part): Show Tool Tips, Double Click To Isolate, Zoom with Mouse Wheel (the wheel zooms about the pointer, Shift-wheel scrolls up and down, Cmd/Ctrl-wheel sideways; Alt/Option-wheel and a trackpad pinch zoom about the pointer either way), Use Precise Cursors; Selection & Anchor Display › Tolerance (objects, anchors and handles), Object Selection by Path Only, Command Click to Select Objects Behind (cycling down the stack), Zoom to Selection, anchor Size, Highlight anchors on mouse over; Type › Number of Recent Fonts (up to 15); Guides & Grid › guide and grid Color and Style (lines or dots) and Grids In Back. Then Snap to Point (its distance, for moves, drawn points and reference points), Move Locked and Hidden Artwork with Artboard, Enable Rubber Band for the Pen and Curvature tools, Handles style, Show handles when multiple anchors are selected, Hide Corner Widget for angles greater than; General › Transform Pattern Tiles (the transforms' and dialogs' Transform Patterns, Align and Distribute, art moved or duplicated with an artboard, and objects moved whole with direct-selected anchors) and Select Same Tint %; Type › Size/Leading, Tracking and Baseline Shift increments (`type.step`, Cmd+Shift+. and Cmd+Shift+, for the size, the Type tool's Alt+arrows), Enable Missing Glyph Protection and Fill New Type Objects With Placeholder Text. Then Smart Guides › Color, Alignment Guides, Anchor/Path Labels, Measurement Labels, Transform Tools, Object Highlighting (with Smart Guides on) and Snapping Tolerance (4 px by default, for every smart guide snap), then Construction Guides and their Angles (#506: a drawn point near a line at one of those angles through the point it leaves from lands on it). Then Type › Type Object Selection by Path Only (type is picked on the baseline of any of its lines, area type's frame or the path of type on a path, no longer anywhere in its bounds; the Type tools and the Eyedropper still take a click among the characters). Then General › Anti-aliased Artwork (off, the canvas draws the art with hard edges). Then Guides & Grid › Show Pixel Grid (Above 600% Zoom), a line at every document pixel over the art in Pixel Preview, turning with a rotated view as the document grid now does too. Then General › Show The Home Screen When No Documents Are Open (off, closing the last document leaves an empty window; the Home button still opens the screen). Then Units › Numbers Without Units Are Points (on by default: a number typed with no unit into a field in picas is read in points, a typed unit still wins; dimmed unless a unit is Picas). Then User Interface › Auto-Collapse Iconic Panels (off by default: on, a click away from a panel popped out of the icon column puts it away). Then Performance › Animated Zoom (on, with GPU Performance, which it needs and which dims it when off: the Zoom tool dragged sideways zooms about the press, right in and left out, and held still zooms on, Alt out; off, a drag zooms to the area dragged across, now drawn as a marquee), User Interface › Large Tabs (taller document tabs) and Scale Cursor Proportional to UI (off, the tool cursors keep their size whatever the UI Scaling), and File Handling › Display Bitmaps as Anti-aliased Images in Pixel Preview (off by default: Pixel Preview draws images with each pixel taking its nearest image pixel). Type › Auto Size New Area Type works too (new area type gets Auto Size). They reach agents too (`prefs.set`, then `pointer_gesture` or `press_key`; `ui.wheel` on the control channel). Then Smart Guides › Spacing Guides (moves space the selection evenly with its row or column, see Drawing aids). Then Hyphenation › Exceptions (comma-separated words that never break, or break only at their hyphens; `prefs.set` and restore push them into the hyphenator, #394). Then Type › Show Font Names in English (off, font menus label a family by its native-language name when the font has one; documents still use the English family, #394). Then General › Display Print Size at 100% Zoom (off by default: View › Actual Size is one document point per screen point; on, one document inch fills 96 screen points, an inch at the reference density display scaling is set against; `view.actualSize` / `prefs.set`, #394). Then Guides & Grid › Gridline every and Subdivisions (changing either sets the grid of every open document; new and opened documents take that grid too, except a native file and the native document an SVG, PDF, `.ai` or EPS file carries, which open with the grid they were saved with; `file.new`, `document.open`, `file.newFromTemplate`, `file.revert`, #394). Then Appearance of Black › On Screen (Display All Blacks Accurately by default: pure CMYK black shows through the CMYK profile, a dark grey; Display All Blacks as Rich Black shows it on the canvas as RGB black, also in CMYK documents drawn by ink planes, while rich blacks, black tints and images show as before; `RenderOptions::rich_black`, #394). Then Appearance of Black › Printing / Exporting (Output All Blacks Accurately by default; Output All Blacks as Rich Black draws pure CMYK black as RGB black in RGB raster exports and Print as Bitmap; CMYK ink exports and the document stay unchanged; `prefs.blackOutput` / `richBlack`, #394). Then Units › Identify Objects By (Object Name by default: Layers, Variables and Layer Options show and edit free names; XML ID shows and edits AI-style XML ids, `_` for a space and `_xHH_` escapes, and `layer.setProps` / rename refuse invalid ids; the document still stores the object name, #394). Then Type › Highlight Alternate Glyphs (on by default: pink behind OpenType substitutions on screen — ligatures, contextual forms; Document Setup's Highlight Substituted Glyphs stays separate; `prefs.set`, #394). About 14 stored options still do nothing yet (the rest of #394: East Asian Type units, Open Documents As Tabs, Real-time Drawing and Editing, GPU Performance beyond Animated Zoom, hyphenation language, scratch disks, the legacy clipboard, Touch Workspace). - The desktop app keeps the Color panel's Show Options or Hide Options between sessions, and `ui.colorPanel` sets its mode and options as its panel menu does. - - Preferences that act (#394, in part): Show Tool Tips, Double Click To Isolate, Zoom with Mouse Wheel (the wheel zooms about the pointer, Shift-wheel scrolls up and down, Cmd/Ctrl-wheel sideways; Alt/Option-wheel and a trackpad pinch zoom about the pointer either way), Use Precise Cursors; Selection & Anchor Display › Tolerance (objects, anchors and handles), Object Selection by Path Only, Command Click to Select Objects Behind (cycling down the stack), Zoom to Selection, anchor Size, Highlight anchors on mouse over; Type › Number of Recent Fonts (up to 15); Guides & Grid › guide and grid Color and Style (lines or dots) and Grids In Back. Then Snap to Point (its distance, for moves, drawn points and reference points), Move Locked and Hidden Artwork with Artboard, Enable Rubber Band for the Pen and Curvature tools, Handles style, Show handles when multiple anchors are selected, Hide Corner Widget for angles greater than; General › Transform Pattern Tiles (the transforms' and dialogs' Transform Patterns, Align and Distribute, art moved or duplicated with an artboard, and objects moved whole with direct-selected anchors) and Select Same Tint %; Type › Size/Leading, Tracking and Baseline Shift increments (`type.step`, Cmd+Shift+. and Cmd+Shift+, for the size, the Type tool's Alt+arrows), Enable Missing Glyph Protection and Fill New Type Objects With Placeholder Text. Then Smart Guides › Color, Alignment Guides, Anchor/Path Labels, Measurement Labels, Transform Tools, Object Highlighting (with Smart Guides on) and Snapping Tolerance (4 px by default, for every smart guide snap), then Construction Guides and their Angles (#506: a drawn point near a line at one of those angles through the point it leaves from lands on it). Then Type › Type Object Selection by Path Only (type is picked on the baseline of any of its lines, area type's frame or the path of type on a path, no longer anywhere in its bounds; the Type tools and the Eyedropper still take a click among the characters). Then General › Anti-aliased Artwork (off, the canvas draws the art with hard edges). Then Guides & Grid › Show Pixel Grid (Above 600% Zoom), a line at every document pixel over the art in Pixel Preview, turning with a rotated view as the document grid now does too. Then General › Show The Home Screen When No Documents Are Open (off, closing the last document leaves an empty window; the Home button still opens the screen). Then Units › Numbers Without Units Are Points (on by default: a number typed with no unit into a field in picas is read in points, a typed unit still wins; dimmed unless a unit is Picas). Then User Interface › Auto-Collapse Iconic Panels (off by default: on, a click away from a panel popped out of the icon column puts it away). Then Performance › Animated Zoom (on, with GPU Performance, which it needs and which dims it when off: the Zoom tool dragged sideways zooms about the press, right in and left out, and held still zooms on, Alt out; off, a drag zooms to the area dragged across, now drawn as a marquee), User Interface › Large Tabs (taller document tabs) and Scale Cursor Proportional to UI (off, the tool cursors keep their size whatever the UI Scaling), and File Handling › Display Bitmaps as Anti-aliased Images in Pixel Preview (off by default: Pixel Preview draws images with each pixel taking its nearest image pixel). Type › Auto Size New Area Type works too (new area type gets Auto Size). They reach agents too (`prefs.set`, then `pointer_gesture` or `press_key`; `ui.wheel` on the control channel). Then Smart Guides › Spacing Guides (moves space the selection evenly with its row or column, see Drawing aids). Then Hyphenation › Exceptions (comma-separated words that never break, or break only at their hyphens; `prefs.set` and restore push them into the hyphenator, #394). Then Type › Show Font Names in English (off, font menus label a family by its native-language name when the font has one; documents still use the English family, #394). Then General › Display Print Size at 100% Zoom (off by default: View › Actual Size is one document point per screen point; on, one document inch fills 96 screen points, an inch at the reference density display scaling is set against; `view.actualSize` / `prefs.set`, #394). Then Guides & Grid › Gridline every and Subdivisions (changing either sets the grid of every open document; new and opened documents take that grid too, except a native file and the native document an SVG, PDF, `.ai` or EPS file carries, which open with the grid they were saved with; `file.new`, `document.open`, `file.newFromTemplate`, `file.revert`, #394). Then Appearance of Black › On Screen (Display All Blacks Accurately by default: pure CMYK black shows through the CMYK profile, a dark grey; Display All Blacks as Rich Black shows it on the canvas as RGB black, also in CMYK documents drawn by ink planes, while rich blacks, black tints and images show as before; `RenderOptions::rich_black`, #394). Then Appearance of Black › Printing / Exporting (Output All Blacks Accurately by default; Output All Blacks as Rich Black draws pure CMYK black as RGB black in RGB raster exports and Print as Bitmap; CMYK ink exports and the document stay unchanged; `prefs.blackOutput` / `richBlack`, #394). Then Units › Identify Objects By (Object Name by default: Layers, Variables and Layer Options show and edit free names; XML ID shows and edits AI-style XML ids, `_` for a space and `_xHH_` escapes, and `layer.setProps` / rename refuse invalid ids; the document still stores the object name, #394). About 15 stored options still do nothing yet (the rest of #394: Highlight Alternate Glyphs, East Asian Type units, Open Documents As Tabs, Real-time Drawing and Editing, GPU Performance beyond Animated Zoom, hyphenation language, scratch disks, the legacy clipboard, Touch Workspace). + - Preferences that act (#394, in part): Show Tool Tips, Double Click To Isolate, Zoom with Mouse Wheel (the wheel zooms about the pointer, Shift-wheel scrolls up and down, Cmd/Ctrl-wheel sideways; Alt/Option-wheel and a trackpad pinch zoom about the pointer either way), Use Precise Cursors; Selection & Anchor Display › Tolerance (objects, anchors and handles), Object Selection by Path Only, Command Click to Select Objects Behind (cycling down the stack), Zoom to Selection, anchor Size, Highlight anchors on mouse over; Type › Number of Recent Fonts (up to 15); Guides & Grid › guide and grid Color and Style (lines or dots) and Grids In Back. Then Snap to Point (its distance, for moves, drawn points and reference points), Move Locked and Hidden Artwork with Artboard, Enable Rubber Band for the Pen and Curvature tools, Handles style, Show handles when multiple anchors are selected, Hide Corner Widget for angles greater than; General › Transform Pattern Tiles (the transforms' and dialogs' Transform Patterns, Align and Distribute, art moved or duplicated with an artboard, and objects moved whole with direct-selected anchors) and Select Same Tint %; Type › Size/Leading, Tracking and Baseline Shift increments (`type.step`, Cmd+Shift+. and Cmd+Shift+, for the size, the Type tool's Alt+arrows), Enable Missing Glyph Protection and Fill New Type Objects With Placeholder Text. Then Smart Guides › Color, Alignment Guides, Anchor/Path Labels, Measurement Labels, Transform Tools, Object Highlighting (with Smart Guides on) and Snapping Tolerance (4 px by default, for every smart guide snap), then Construction Guides and their Angles (#506: a drawn point near a line at one of those angles through the point it leaves from lands on it). Then Type › Type Object Selection by Path Only (type is picked on the baseline of any of its lines, area type's frame or the path of type on a path, no longer anywhere in its bounds; the Type tools and the Eyedropper still take a click among the characters). Then General › Anti-aliased Artwork (off, the canvas draws the art with hard edges). Then Guides & Grid › Show Pixel Grid (Above 600% Zoom), a line at every document pixel over the art in Pixel Preview, turning with a rotated view as the document grid now does too. Then General › Show The Home Screen When No Documents Are Open (off, closing the last document leaves an empty window; the Home button still opens the screen). Then Units › Numbers Without Units Are Points (on by default: a number typed with no unit into a field in picas is read in points, a typed unit still wins; dimmed unless a unit is Picas). Then User Interface › Auto-Collapse Iconic Panels (off by default: on, a click away from a panel popped out of the icon column puts it away). Then Performance › Animated Zoom (on, with GPU Performance, which it needs and which dims it when off: the Zoom tool dragged sideways zooms about the press, right in and left out, and held still zooms on, Alt out; off, a drag zooms to the area dragged across, now drawn as a marquee), User Interface › Large Tabs (taller document tabs) and Scale Cursor Proportional to UI (off, the tool cursors keep their size whatever the UI Scaling), and File Handling › Display Bitmaps as Anti-aliased Images in Pixel Preview (off by default: Pixel Preview draws images with each pixel taking its nearest image pixel). Type › Auto Size New Area Type works too (new area type gets Auto Size). They reach agents too (`prefs.set`, then `pointer_gesture` or `press_key`; `ui.wheel` on the control channel). Then Smart Guides › Spacing Guides (moves space the selection evenly with its row or column, see Drawing aids). Then Hyphenation › Exceptions (comma-separated words that never break, or break only at their hyphens; `prefs.set` and restore push them into the hyphenator, #394). Then Type › Show Font Names in English (off, font menus label a family by its native-language name when the font has one; documents still use the English family, #394). Then General › Display Print Size at 100% Zoom (off by default: View › Actual Size is one document point per screen point; on, one document inch fills 96 screen points, an inch at the reference density display scaling is set against; `view.actualSize` / `prefs.set`, #394). Then Guides & Grid › Gridline every and Subdivisions (changing either sets the grid of every open document; new and opened documents take that grid too, except a native file and the native document an SVG, PDF, `.ai` or EPS file carries, which open with the grid they were saved with; `file.new`, `document.open`, `file.newFromTemplate`, `file.revert`, #394). Then Appearance of Black › On Screen (Display All Blacks Accurately by default: pure CMYK black shows through the CMYK profile, a dark grey; Display All Blacks as Rich Black shows it on the canvas as RGB black, also in CMYK documents drawn by ink planes, while rich blacks, black tints and images show as before; `RenderOptions::rich_black`, #394). Then Appearance of Black › Printing / Exporting (Output All Blacks Accurately by default; Output All Blacks as Rich Black draws pure CMYK black as RGB black in RGB raster exports and Print as Bitmap; CMYK ink exports and the document stay unchanged; `prefs.blackOutput` / `richBlack`, #394). Then Units › Identify Objects By (Object Name by default: Layers, Variables and Layer Options show and edit free names; XML ID shows and edits AI-style XML ids, `_` for a space and `_xHH_` escapes, and `layer.setProps` / rename refuse invalid ids; the document still stores the object name, #394). Five stored options still do nothing yet (the audit below). - Preferences › Type › Highlight Substituted Fonts (on by default) paints pink behind text drawn in a substitute for a missing font in every document, and turning it off removes that highlight everywhere (`prefs.set highlightSubstitutedFonts`); Document Setup keeps Highlight Substituted Glyphs ([help](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/edit-text-without-replacing-missing-fonts.html)). + - Preferences audit (2026-10-30, #394): every Preferences dialog option is read by shipped code, by its field or its key, except User Interface › Open Documents As Tabs, Units › East Asian Type, Hyphenation › Default Language, Plug-ins & Scratch Disks › Primary and Secondary, and Clipboard Handling › Legacy vector clipboard and its mode, which are stored only; [gaps.md G12](gaps.md#g12-preferences-and-panels-that-dont-act-yet) says what each waits on. - Dialogs move by dragging their heading (the band down from the top edge, as a title bar), stay on screen and keep where they were moved for the session; the form dialogs' choices are dropdowns (Offset Path's Joins, Average's and Shear's and Reflect's axis), and Offset Path lists Offset, Joins, Miter Limit and previews (#423). - Dialogs open with their first field focused and its value selected: type a value and press Enter (Move, Rotate, Scale…). A dialog opened from a menu takes the keyboard focus every time it opens, not only the first (#1367), and one whose first field starts greyed out (Blend Options on Smooth Color, Layers Panel Options) gives the focus to that field once it is enabled (#1395). Number fields in panels, the Control bar and dialogs (preferences too) step with Up/Down, or with the mouse wheel over the focused field (#485: a notch a step; the panel under it then stays put, and an unfocused field leaves the wheel to scrolling) (Shift: ten, Ctrl/Cmd: a tenth of their unit), applied at once. - While Alt (Option on macOS) is held, the Flare Tool Options' Cancel button reads Reset, which puts every option back to the Flare tool's default and leaves the dialog open (`ui.dialogReset`). @@ -1205,6 +1206,7 @@ applies to fills). Tests: `color::gradient::tests` (perceptual midpoint, expansi | Date | Change | Summary | |---|---|---| +| 2026-10-30 | minor | UI chrome: G12: Preferences audit (#394): 5 options are stored but not acted on (Open Documents As Tabs, Units › East Asian Type, Hyphenation › Default Language, Scratch Disks, Legacy vector clipboard), each waiting on a subsystem; Highlight Alternate Glyphs, Real-time Drawing and the Devices options act; evidence added; score and hours unchanged (estimated). | | 2026-10-30 | minor | Print, colour management, separations: Separations Preview's plates apply to placed and embedded raster images, a CMYK image's own inks included (#4153); evidence added; score and hours unchanged (estimated). | | 2026-10-30 | minor | Colour, gradients & mesh: several gradient mesh points can be picked (Shift-clicks with the Mesh tool and Direct Selection, Direct Selection's marquee, its click on a mesh line or inside a patch); a drag or the arrow keys move them all (`object.mesh.movePoints`), and a solid fill colour or the Transparency panel's opacity goes to each of them (#4207, #4208, #4170); scores unchanged. | | 2026-10-30 | minor | Drawing aids: Character panel menu › Show Snap to Glyph Options shows the Snap to Glyph section (Baseline, x-height, Glyph Bounds, Proximity Guides, Angular Guides, Anchor Point; `view.snapToGlyph.options`) (#4232); evidence added; score and hours unchanged (estimated). | diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 2d8c7eaefa..0464fc1f51 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Preferences: the workspace, panels, toolbars and other UI settings are saved within 2 seconds of a change instead of only on quitting, and a window saves only what it changed, merged into the file as another VectorCraft window left it, so a second window closing last no longer puts back the settings it started with (#4625); scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (G12: Preferences audit (#394): 5 options are stored but not acted on (Open Documents As Tabs, Units › East Asian Type, Hyphenation › Default Language, Scratch Disks, Legacy vector clipboard), each waiting on a subsystem; Highlight Alternate Glyphs, Real-time Drawing and the Devices options act; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x) ## Feature submission evidence @@ -317,7 +317,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po | Swatch, graphic style and symbol library panels: each library opens in a panel of its own, several at once, that floats, groups, docks and closes like any panel; opening an open library brings its panel forward; Previous / Next Library change the library in place; the panel menu's Persistent reopens the panel at startup with its view and find field (a library loaded from a file is read again; when its file is missing the panel reopens showing the file's path with Locate Library…, and the status bar names the file) | done | #2603; panel ids `library::`, `ui.libraryPanel {panel, library?, view?, showFind?, persistent?}`, `ui.libraryPanel.locate {panel, path?}`; the library panels have no sort option, as before | | DXF export/import preserves intended curve closure | done | #1299; R13–2018 closed SPLINE bit set/read; an open curve ending at its start stays open; knots and control points unchanged; native CIRCLE/ARC export and CNC preset remain pending | | macOS save sheet: choose the format from a menu | done | #866; the save panel is VectorCraft's own `NSSavePanel` with its Format menu set before the sheet opens (`apps/vectorcraft/src/mac_save_format.rs`); #1855 had withdrawn the menu that was added after the sheet began, which made Save As, Save a Copy and the first Save show no sheet | -| Preferences: every option acts | partial | ~15 stored but unused (#394); General › Corner Radius drives the Rounded Rectangle tool and follows its ↑/↓ (2026-10-24) | +| Preferences: every option acts | partial | 5 stored but unused (#394, audited 2026-10-30): Open Documents As Tabs, Units › East Asian Type, Hyphenation › Default Language, Scratch Disks, Legacy vector clipboard; the rest act. General › Corner Radius drives the Rounded Rectangle tool and follows its ↑/↓ (2026-10-24) | | Preferences › General › Constrain Angle | done | arrow keys and Shift drags along the turned axes; the Rectangle, Rounded Rectangle, Ellipse and grid tools, point and area type and the shape size dialogs draw along them with the bounding box turned; Shift-drawn polygons and stars keep the turned base orientation; the Line Segment tool's Shift steps count from it (#394, ); arcs, spirals, flares and Pen paths are not turned | | Tabs panel: a stop drags from where the press landed, a stop just added included | done | #1458 | | Outline view keeps template layers in Preview, dimmed | done | #1486; a picture placed to be traced stays visible under the outlines | @@ -361,6 +361,7 @@ separate. Scores and hours unchanged. [Behavior and command details](development | Date | Change | Summary | |---|---|---| +| 2026-10-30 | minor | G12: Preferences audit (#394): 5 options are stored but not acted on (Open Documents As Tabs, Units › East Asian Type, Hyphenation › Default Language, Scratch Disks, Legacy vector clipboard), each waiting on a subsystem; Highlight Alternate Glyphs, Real-time Drawing and the Devices options act; scores and estimates unchanged | | 2026-10-30 | minor | Preferences: the workspace, panels, toolbars and other UI settings are saved within 2 seconds of a change instead of only on quitting, and a window saves only what it changed, merged into the file as another VectorCraft window left it, so a second window closing last no longer puts back the settings it started with (#4625). Tests `prefs::tests` in `apps/vectorcraft`; scores and estimates unchanged | | 2026-10-30 | minor | Character panel menu › Show Snap to Glyph Options shows the Snap to Glyph section (Baseline, x-height, Glyph Bounds, Proximity Guides, Angular Guides, Anchor Point; `view.snapToGlyph.options`) (#4232); scores and estimates unchanged | | 2026-10-30 | minor | Contextual Task Bar: with the Direct Selection tool, a path selected whole offers Corner, Smooth (every anchor), Connect (open paths) and Simplify instead of Edit Path and Offset Path, as the public overview lists for that tool (); a compound path under that tool no longer offers Edit Path (#4469). Tests in `crates/ui-egui/src/tests/taskbar.rs`; scores and estimates unchanged | From 60833ae800afaefa24193daa5ae1690d489c9f10 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Thu, 29 Oct 2026 18:51:06 -0400 Subject: [PATCH 009/163] packaging: Flatpak finds and prints to CUPS printers (#4634) * packaging: Flatpak finds and prints to CUPS printers The Print dialog listed no printers in the Flatpak: the runtime has libcups but not lpstat/lp, the sandbox couldn't reach the CUPS socket, and driverless network printers (lpstat -e) need Avahi. Bundle lpstat/lp/lpoptions from CUPS 2.4.20 (Apache-2.0, statically linked, licence installed) and grant --socket=cups and --system-talk-name=org.freedesktop.Avahi in both manifests. * packaging: Flatpak reads the user's CUPS settings (~/.cups, read-only) Review (CodeRabbit): without it the sandbox's lp/lpstat ignore the user's default printer and saved options (lpoptions) and a print server named in their client.conf. * packaging: Flatpak CUPS tools reach the host socket when client.conf names a custom path Review: Flatpak mounts the host's CUPS socket at /var/run/cups/cups.sock whatever path ~/.cups/client.conf or CUPS_SERVER names, so lp/lpstat/lpoptions now run through a wrapper that points a socket path missing in the sandbox there. Server names (remote servers) and sockets that exist are left alone. Tested in the sandbox: CUPS_SERVER=/run/custom/cups.sock lists the host's printers through the wrapper and none without it; a host name is passed through unchanged. * packaging: redirect a custom CUPS socket only when it is the one Flatpak mounted Review (CodeRabbit): Flatpak picks the socket it mounts at /var/run/cups/cups.sock with stricter rules than CUPS (flatpak-run-cups.c: a socket CUPS_SERVER, else the first line spelled exactly "ServerName /path" in ~/.cups/client.conf, else the default), while CUPS reads the keyword in any case and takes the last ServerName. The wrapper now redirects only when CUPS' socket is the one Flatpak chose, so a job can't reach a different server; otherwise CUPS fails on the missing path. * packaging: never redirect a CUPS_SERVER the sandbox was given Review (CodeRabbit): Flatpak picks the socket it mounts from the host's CUPS_SERVER, so one set by flatpak run --env or an override may not be what it mounted. The wrapper now leaves any CUPS_SERVER alone and redirects only a client.conf socket that matches Flatpak's choice; otherwise CUPS fails on the missing path instead of reaching a different server. * packaging: point CUPS at the mounted socket only when it is the one Flatpak chose, else fail Review (CodeRabbit): with a custom socket listed first and the default last in ~/.cups/client.conf, Flatpak mounts the custom one at /var/run/cups/cups.sock while CUPS picks the last line, finds that path, and talks to the custom server. The wrapper now compares CUPS' socket with Flatpak's choice even when the path exists: equal, CUPS is pointed at the mount; different, the tool fails with an error instead of reaching another server. --- .../ai.storyteller.vectorcraft.bundle.yml | 52 +++++++++++++++++++ .../flatpak/ai.storyteller.vectorcraft.yml | 52 +++++++++++++++++++ 2 files changed, 104 insertions(+) diff --git a/packaging/linux/flatpak/ai.storyteller.vectorcraft.bundle.yml b/packaging/linux/flatpak/ai.storyteller.vectorcraft.bundle.yml index 94aa4f3922..2ca1cd5650 100644 --- a/packaging/linux/flatpak/ai.storyteller.vectorcraft.bundle.yml +++ b/packaging/linux/flatpak/ai.storyteller.vectorcraft.bundle.yml @@ -24,6 +24,14 @@ finish-args: - --socket=fallback-x11 # GPU access for the wgpu renderer (Vulkan, or GL as a fallback). - --device=dri + # Printing: lpstat/lp (the cups-client module) reach the host's CUPS through its socket and + # find driverless network printers through Avahi (`lpstat -e`). Without these the Print + # dialog lists no printers. + - --socket=cups + - --system-talk-name=org.freedesktop.Avahi + # The user's CUPS settings, read-only: their default printer and saved options (lpoptions) + # and a print server named in their client.conf, which lp reaches over the network. + - --filesystem=~/.cups:ro # Network for the update check against GitHub releases. - --share=network # Cursor theme: without the cursor-shape protocol (e.g. GNOME 46) winit loads the theme itself. @@ -40,6 +48,50 @@ finish-args: - --filesystem=~/.fonts:ro # Deliberately not granted: home/host filesystem access beyond the read-only folders above. modules: + # CUPS client tools for craft-print: the runtime has libcups but not lpstat/lp/lpoptions. + # Linked statically against this release's libcups, so a runtime update can't break them; + # the socket path matches the host's, which --socket=cups mounts. + - name: cups-client + buildsystem: simple + build-commands: + - ./configure --prefix=/app --sysconfdir=/etc --localstatedir=/var --with-rundir=/run/cups + --with-domainsocket=/run/cups/cups.sock --disable-shared --with-components=libcups + --with-dnssd=avahi --with-tls=gnutls --disable-pam --disable-dbus + - make -C cups libs + - make -C systemv lp lpoptions lpstat + - install -Dm755 -t /app/libexec/cups systemv/lp systemv/lpoptions systemv/lpstat + - for tool in lp lpoptions lpstat; do install -Dm755 cups-socket.sh "/app/bin/$tool"; done + - install -Dm644 -t /app/share/licenses/cups LICENSE NOTICE + sources: + - type: archive + url: https://github.com/OpenPrinting/cups/releases/download/v2.4.20/cups-2.4.20-source.tar.gz + sha256: ab4d9cd7f3e58060091d2b24972223d6401675f11c49b65abf4f6ef31dea22ff + # Runs each tool. Flatpak mounts the host's CUPS socket at /var/run/cups/cups.sock, choosing + # it as flatpak-run-cups.c does from the host's CUPS_SERVER, else the first line spelled + # exactly `ServerName /path` in ~/.cups/client.conf, else the default; it mounts nothing + # when that socket is missing. CUPS reads the keyword in any case and takes the last + # ServerName. When CUPS' socket from client.conf is the one Flatpak chose, it is pointed at + # the mount; when it isn't, the tool fails rather than reach a different server. A + # CUPS_SERVER is left alone: one set by `flatpak run --env` may not be what was mounted. + - type: script + dest-filename: cups-socket.sh + commands: + - 'conf="$HOME/.cups/client.conf"' + - 'if [ -z "${CUPS_SERVER:-}" ] && [ -r "$conf" ]; then' + - ' server=$(sed -n ''s/^[[:space:]]*[Ss][Ee][Rr][Vv][Ee][Rr][Nn][Aa][Mm][Ee][[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p'' "$conf" | tail -n 1)' + - ' case "$server" in' + - ' /*)' + - ' mounted=$(sed -n ''s/^[[:space:]]*ServerName \(.*\)$/\1/p'' "$conf" | sed ''s/^[[:space:]]*//'' | grep -m 1 ''^/[^:]*$'')' + - ' if [ "$mounted" = "$server" ]; then' + - ' export CUPS_SERVER=/var/run/cups/cups.sock' + - ' else' + - ' echo "${0##*/}: ~/.cups/client.conf names the CUPS socket $server, but Flatpak gave this app ${mounted:-a different one}; give each socket one ServerName line, spelled ServerName" >&2' + - ' exit 1' + - ' fi' + - ' ;;' + - ' esac' + - 'fi' + - 'exec "/app/libexec/cups/${0##*/}" "$@"' - name: vectorcraft buildsystem: simple build-commands: diff --git a/packaging/linux/flatpak/ai.storyteller.vectorcraft.yml b/packaging/linux/flatpak/ai.storyteller.vectorcraft.yml index 4d740a8d98..5a61afbba9 100644 --- a/packaging/linux/flatpak/ai.storyteller.vectorcraft.yml +++ b/packaging/linux/flatpak/ai.storyteller.vectorcraft.yml @@ -22,6 +22,14 @@ finish-args: - --socket=wayland - --socket=fallback-x11 - --device=dri + # Printing: lpstat/lp (the cups-client module) reach the host's CUPS through its socket and + # find driverless network printers through Avahi (`lpstat -e`). Without these the Print + # dialog lists no printers. + - --socket=cups + - --system-talk-name=org.freedesktop.Avahi + # The user's CUPS settings, read-only: their default printer and saved options (lpoptions) + # and a print server named in their client.conf, which lp reaches over the network. + - --filesystem=~/.cups:ro # Network for the update check against GitHub releases. - --share=network # Cursor theme: without the cursor-shape protocol (e.g. GNOME 46) winit loads the theme itself. @@ -36,6 +44,50 @@ finish-args: build-options: append-path: /usr/lib/sdk/rust-stable/bin modules: + # CUPS client tools for craft-print: the runtime has libcups but not lpstat/lp/lpoptions. + # Linked statically against this release's libcups, so a runtime update can't break them; + # the socket path matches the host's, which --socket=cups mounts. + - name: cups-client + buildsystem: simple + build-commands: + - ./configure --prefix=/app --sysconfdir=/etc --localstatedir=/var --with-rundir=/run/cups + --with-domainsocket=/run/cups/cups.sock --disable-shared --with-components=libcups + --with-dnssd=avahi --with-tls=gnutls --disable-pam --disable-dbus + - make -C cups libs + - make -C systemv lp lpoptions lpstat + - install -Dm755 -t /app/libexec/cups systemv/lp systemv/lpoptions systemv/lpstat + - for tool in lp lpoptions lpstat; do install -Dm755 cups-socket.sh "/app/bin/$tool"; done + - install -Dm644 -t /app/share/licenses/cups LICENSE NOTICE + sources: + - type: archive + url: https://github.com/OpenPrinting/cups/releases/download/v2.4.20/cups-2.4.20-source.tar.gz + sha256: ab4d9cd7f3e58060091d2b24972223d6401675f11c49b65abf4f6ef31dea22ff + # Runs each tool. Flatpak mounts the host's CUPS socket at /var/run/cups/cups.sock, choosing + # it as flatpak-run-cups.c does from the host's CUPS_SERVER, else the first line spelled + # exactly `ServerName /path` in ~/.cups/client.conf, else the default; it mounts nothing + # when that socket is missing. CUPS reads the keyword in any case and takes the last + # ServerName. When CUPS' socket from client.conf is the one Flatpak chose, it is pointed at + # the mount; when it isn't, the tool fails rather than reach a different server. A + # CUPS_SERVER is left alone: one set by `flatpak run --env` may not be what was mounted. + - type: script + dest-filename: cups-socket.sh + commands: + - 'conf="$HOME/.cups/client.conf"' + - 'if [ -z "${CUPS_SERVER:-}" ] && [ -r "$conf" ]; then' + - ' server=$(sed -n ''s/^[[:space:]]*[Ss][Ee][Rr][Vv][Ee][Rr][Nn][Aa][Mm][Ee][[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p'' "$conf" | tail -n 1)' + - ' case "$server" in' + - ' /*)' + - ' mounted=$(sed -n ''s/^[[:space:]]*ServerName \(.*\)$/\1/p'' "$conf" | sed ''s/^[[:space:]]*//'' | grep -m 1 ''^/[^:]*$'')' + - ' if [ "$mounted" = "$server" ]; then' + - ' export CUPS_SERVER=/var/run/cups/cups.sock' + - ' else' + - ' echo "${0##*/}: ~/.cups/client.conf names the CUPS socket $server, but Flatpak gave this app ${mounted:-a different one}; give each socket one ServerName line, spelled ServerName" >&2' + - ' exit 1' + - ' fi' + - ' ;;' + - ' esac' + - 'fi' + - 'exec "/app/libexec/cups/${0##*/}" "$@"' - name: vectorcraft buildsystem: simple build-options: From d38e3b9015010044866c1aa21ba8d0f52ad048f5 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Thu, 29 Oct 2026 22:22:54 +0000 Subject: [PATCH 010/163] Close all gaps in solid-like dash pattern for odd-length dashes Found while testing crates/doc/src/blend.rs:197-201 (lerp_dash, solid_like) Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/doc/src/blend.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/doc/src/blend.rs b/crates/doc/src/blend.rs index 69ad127819..ced9472a74 100644 --- a/crates/doc/src/blend.rs +++ b/crates/doc/src/blend.rs @@ -196,7 +196,11 @@ pub fn lerp_paint(a: &Paint, b: &Paint, t: f32) -> Paint { /// so dashes open out of a solid line; patterns of different lengths repeat to a common one. fn lerp_dash(x: Option<&Dash>, y: Option<&Dash>, t: f64) -> Option { let solid_like = |d: &Dash| Dash { - pattern: d.pattern.chunks(2).flat_map(|c| [c.iter().sum::(), 0.0]).take(d.pattern.len().max(2)).collect(), + // An odd pattern repeats twice per period, so pair up the doubled one to keep every gap closed. + pattern: if d.pattern.len() % 2 == 1 { d.pattern.repeat(2) } else { d.pattern.clone() } + .chunks(2) + .flat_map(|c| [c.iter().sum::(), 0.0]) + .collect(), offset: d.offset, align_corners: d.align_corners, }; @@ -1423,6 +1427,12 @@ mod tests { assert_eq!(p.at(0.5), (1.0, 1.0)); } + #[test] + fn odd_dash_blends_to_solid_with_closed_gaps() { + let d = lerp_dash(Some(&Dash { pattern: vec![2.0, 3.0, 4.0], ..Default::default() }), None, 1.0).unwrap(); + assert!(d.pattern.iter().skip(1).step_by(2).all(|g| *g == 0.0), "{:?}", d.pattern); + } + #[test] fn copied_steps_get_new_members() { let rect = |x: f64| Arc::new(Node::path(NodeId(7), shapes::rectangle(Rect::new(x, 0.0, x + 10.0, 10.0)), Appearance::default())); From 2e3a4ec6049f45c2fe98e4b9b56b20f31be10d92 Mon Sep 17 00:00:00 2001 From: Don Omondi <282319807+mockydevs@users.noreply.github.com> Date: Fri, 30 Oct 2026 01:12:25 +0300 Subject: [PATCH 011/163] Fix #3911: EMF export writes a pattern fill as one shape per part of its tile A pattern fill was written to EMF as every tile's art, each tile in a clip of its own, with the brush made again for each part: a rotated two-colour stripe fill of a 360 x 260 pt rectangle took 473 fills, 246 clips and 122 KB. When the tiles can't overlap (a grid or brick tiling whose art stays in its tile), each tile's clip is left out where what it clips lies inside it already (a convex clip holding every control point of the fills), and the n-th fill of every tile becomes one path. The picture is the same: the tiles don't overlap, and the fill's own clip still trims them. That fill is now 2 fills and 1 clip, 61 KB; unrotated, 99 KB becomes 33 KB. Tiles that overlap, hex tilings, and tiles holding strokes, images or clips that cut are written as before, their parts off the page left out. --- crates/metafile/src/scene.rs | 225 ++++++++++++++++++++++++++++++++++- crates/metafile/src/tests.rs | 92 ++++++++++++++ docs/file-format-parity.md | 1 + 3 files changed, 313 insertions(+), 5 deletions(-) diff --git a/crates/metafile/src/scene.rs b/crates/metafile/src/scene.rs index db55fc71a3..587577f41c 100644 --- a/crates/metafile/src/scene.rs +++ b/crates/metafile/src/scene.rs @@ -7,6 +7,7 @@ use std::collections::HashMap; use std::sync::Arc; +use kurbo::PathEl; use vectorcraft_color::freeform::{painted_box, spread_scale}; use vectorcraft_color::{BlendMode, GradientKind, GradientPaint, Paint}; use vectorcraft_doc::{AppearanceItem, Dash, Document, ImageObject, LineCap, LineJoin, Node, NodeKind, StrokeLayer, SymbolBoxes}; @@ -35,6 +36,10 @@ const FLAT_PATTERNS: &str = "pattern fills are written as one colour"; const TOO_MANY_TILES: &str = "pattern fills past 250,000 tiles in all are written as one colour"; const TEXT_OUTLINES: &str = "type is written as outlines: it can't be searched, selected or read aloud as text"; const PATTERN_TILES: &str = "pattern fills are written as their tiles, one shape each"; +const PATTERN_SHAPES: &str = "pattern fills are written as their tiles, one shape for each part of the tile"; +/// How far (points) art may lie past a convex clip, or a pattern's art past its tile, and still +/// count as inside (what the device units round away). +const INSIDE_TOL: f64 = 1e-6; /// The warning for an image left out because it can't be decoded: the note raster exports give /// (`vectorcraft-engine`'s `rasterfx::undecoded_warning`). const UNDECODED: &str = "an image couldn't be decoded and is missing from the picture"; @@ -126,6 +131,9 @@ pub(crate) struct Scene<'a> { nest: u32, /// Pattern tiles left to write ([`MAX_TILES`]). tiles_left: usize, + /// Pattern tiles being written that may be merged: their parts aren't left out off the page, + /// so each tile draws the same parts (the fill's clip still trims them). + whole_tiles: bool, } impl<'a> Scene<'a> { @@ -142,6 +150,7 @@ impl<'a> Scene<'a> { opacity: 1.0, nest: 0, tiles_left: MAX_TILES, + whole_tiles: false, } } @@ -173,7 +182,7 @@ impl<'a> Scene<'a> { if !force && !n.visible { return; } - if !n.is_layer() { + if !n.is_layer() && !self.whole_tiles { match n.visual_bounds_with(&self.symbols) { Some(b) if !overlaps(b, self.region) => return, None if !n.is_container() => return, @@ -319,15 +328,37 @@ impl<'a> Scene<'a> { return; } self.tiles_left -= tiles.len(); - if !tiles.is_empty() { - self.warn(PATTERN_TILES); - } + // Tiles that can't overlap one another (grid and brick tilings whose art stays in + // its tile) may be merged: see `merge_tiles`. + let per_tile = self.doc.pattern(pattern).filter(|def| tiles_apart(def)).map(|def| def.art.len()); let outer = self.opacity; self.opacity *= opacity.clamp(0.0, 1.0); self.ops.push(Op::Clip { path: bp.clone(), rule }); self.nest += 1; - tiles.iter().for_each(|t| self.node(t, true)); + let mut chunks = Vec::new(); + let (whole, left) = (self.whole_tiles, self.tiles_left); + self.whole_tiles = per_tile.is_some(); + for (i, t) in tiles.iter().enumerate() { + if per_tile.is_some_and(|k| k > 0 && i % k == 0) { + chunks.push(self.ops.len()); + } + self.node(t, true); + } + self.whole_tiles = whole; + let merged = per_tile.is_some() && merge_tiles(&mut self.ops, &chunks); + // Tiles that couldn't merge are written as before, their parts off the page left out. + if per_tile.is_some() && !merged { + if let Some(&first) = chunks.first() { + self.ops.truncate(first); + } + // Patterns inside the tiles take from the budget once. + self.tiles_left = left; + tiles.iter().for_each(|t| self.node(t, true)); + } self.nest -= 1; + if !tiles.is_empty() { + self.warn(if merged { PATTERN_SHAPES } else { PATTERN_TILES }); + } self.ops.push(Op::Unclip); self.opacity = outer; } @@ -465,3 +496,187 @@ impl<'a> Scene<'a> { img } } + +/// Do the instances of `def` stay apart? A grid or brick tiling places its tiles side by side, so +/// art that stays in its tile never overlaps another instance's; hex tilings overlap their tiles. +fn tiles_apart(def: &vectorcraft_doc::PatternDef) -> bool { + use vectorcraft_doc::TileType; + let tiling = matches!(def.tile_type, TileType::Grid | TileType::BrickByRow { .. } | TileType::BrickByColumn { .. }); + let inside = def.art.iter().all(|a| painted_bounds(a).is_some_and(|b| def.tile.inflate(INSIDE_TOL, INSIDE_TOL).contains_rect(b))); + tiling && !def.art.is_empty() && inside +} + +/// The extent `n` paints: a clipping group's clip path, else its visual bounds. +fn painted_bounds(n: &Node) -> Option { + match &n.kind { + NodeKind::Group { children, clip: true } => children.first().and_then(|c| c.path_data()).map(|p| p.to_bezpath().bounding_box()), + _ => n.visual_bounds(), + } +} + +/// Write a pattern fill's tiles (`ops` from each start in `starts` to the next, the last to the +/// end) with fewer shapes, when every tile drew the same plain fills: each tile's clip is left out +/// where what it clips lies inside it already, then the n-th fill of every tile becomes one path. +/// The tiles don't overlap ([`tiles_apart`]), so the picture is the same. → whether they merged. +fn merge_tiles(ops: &mut Vec, starts: &[usize]) -> bool { + let Some(&first) = starts.first() else { return false }; + let ends = starts.iter().skip(1).copied().chain([ops.len()]); + let mut tiles: Vec> = Vec::with_capacity(starts.len()); + for (start, end) in starts.iter().copied().zip(ends) { + let Some(fills) = ops.get(start..end).and_then(plain_fills) else { return false }; + // A tile off the page draws nothing. + if !fills.is_empty() { + tiles.push(fills); + } + } + let Some((shape, rest)) = tiles.split_first() else { return false }; + let same = |t: &Vec<(BezPath, FillRule, [u8; 3])>| t.len() == shape.len() && t.iter().zip(shape).all(|(a, b)| (a.1, a.2) == (b.1, b.2)); + if shape.is_empty() || !rest.iter().all(same) { + return false; + } + let mut merged: Vec = shape.iter().map(|(_, rule, rgb)| Op::Fill { path: BezPath::new(), rule: *rule, rgb: *rgb }).collect(); + for tile in &tiles { + for (op, (path, _, _)) in merged.iter_mut().zip(tile) { + if let Op::Fill { path: all, .. } = op { + all.extend(path.elements().iter().copied()); + } + } + } + ops.truncate(first); + ops.extend(merged); + true +} + +/// A tile's ops as plain fills: fills, or fills inside one clip that lies around them all +/// already (a tile clipped to its cell). `None` for anything else (strokes, images, clips that cut). +fn plain_fills(ops: &[Op]) -> Option> { + let inner = match ops { + [Op::Clip { path, .. }, inner @ .., Op::Unclip] => { + let hull = convex_polygon(path)?; + inner + .iter() + .all(|op| matches!(op, Op::Fill { path, .. } if path.elements().iter().all(|el| el_points(el).all(|p| inside(&hull, p))))) + .then_some(inner)? + } + all => all, + }; + inner + .iter() + .map(|op| match op { + Op::Fill { path, rule, rgb } => Some((path.clone(), *rule, *rgb)), + _ => None, + }) + .collect() +} + +/// The points of a path element (a curve lies inside its control points' hull). +fn el_points(el: &PathEl) -> impl Iterator { + let pts: Vec = match *el { + PathEl::MoveTo(p) | PathEl::LineTo(p) => vec![p], + PathEl::QuadTo(a, b) => vec![a, b], + PathEl::CurveTo(a, b, c) => vec![a, b, c], + PathEl::ClosePath => vec![], + }; + pts.into_iter() +} + +/// `bp` as the corners of a convex polygon, counter-clockwise: one closed figure of straight +/// segments that turns one way. `None` for any other path. +fn convex_polygon(bp: &BezPath) -> Option> { + let mut pts = Vec::new(); + for (i, el) in bp.elements().iter().enumerate() { + match (i, el) { + (0, PathEl::MoveTo(p)) | (1.., PathEl::LineTo(p)) => pts.push(*p), + (1.., PathEl::ClosePath) if i + 1 == bp.elements().len() => {} + _ => return None, + } + } + if pts.len() > 1 && pts.first().zip(pts.last()).is_some_and(|(a, b)| (*a - *b).hypot() <= INSIDE_TOL) { + pts.pop(); + } + if pts.len() < 3 { + return None; + } + let n = pts.len(); + let turn = |i: usize| { + let (a, b, c) = (pts[i], pts[(i + 1) % n], pts[(i + 2) % n]); + (b - a).cross(c - b) + }; + let turns: Vec = (0..n).map(turn).collect(); + if turns.iter().any(|t| !t.is_finite()) { + return None; + } + if turns.iter().all(|t| *t >= -INSIDE_TOL) && turns.iter().any(|t| *t > INSIDE_TOL) { + Some(pts) + } else if turns.iter().all(|t| *t <= INSIDE_TOL) && turns.iter().any(|t| *t < -INSIDE_TOL) { + pts.reverse(); + Some(pts) + } else { + None + } +} + +/// Is `p` inside (or on) the counter-clockwise convex polygon `hull`? +fn inside(hull: &[Point], p: Point) -> bool { + let n = hull.len(); + (0..n).all(|i| { + let (a, b) = (hull[i], hull[(i + 1) % n]); + let edge = b - a; + let len = edge.hypot(); + len > 0.0 && edge.cross(p - a) / len >= -INSIDE_TOL + }) +} + +#[cfg(test)] +mod merge_tests { + use super::*; + + fn poly(pts: &[(f64, f64)]) -> BezPath { + let mut bp = BezPath::new(); + for (i, (x, y)) in pts.iter().enumerate() { + if i == 0 { bp.move_to((*x, *y)) } else { bp.line_to((*x, *y)) } + } + bp.close_path(); + bp + } + + #[test] + fn convex_polygons_in_either_direction_hold_what_is_inside_them() { + let square = [(0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (0.0, 10.0)]; + let reversed: Vec<(f64, f64)> = square.iter().rev().copied().collect(); + for pts in [&square[..], &reversed[..]] { + let hull = convex_polygon(&poly(pts)).unwrap(); + assert!(inside(&hull, Point::new(5.0, 5.0))); + assert!(inside(&hull, Point::new(10.0, 3.0)), "on an edge"); + assert!(!inside(&hull, Point::new(10.5, 3.0))); + } + // A rotated square too. + let diamond = convex_polygon(&poly(&[(5.0, 0.0), (10.0, 5.0), (5.0, 10.0), (0.0, 5.0)])).unwrap(); + assert!(inside(&diamond, Point::new(5.0, 5.0)) && !inside(&diamond, Point::new(1.0, 1.0))); + } + + #[test] + fn concave_curved_and_open_clips_are_not_convex_polygons() { + assert!(convex_polygon(&poly(&[(0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (5.0, 5.0), (0.0, 10.0)])).is_none(), "concave"); + let mut curved = BezPath::new(); + curved.move_to((0.0, 0.0)); + curved.curve_to((5.0, -5.0), (10.0, -5.0), (10.0, 0.0)); + curved.line_to((5.0, 10.0)); + curved.close_path(); + assert!(convex_polygon(&curved).is_none(), "curved"); + let mut two = poly(&[(0.0, 0.0), (1.0, 0.0), (1.0, 1.0)]); + two.extend(poly(&[(5.0, 5.0), (6.0, 5.0), (6.0, 6.0)])); + assert!(convex_polygon(&two).is_none(), "two figures"); + assert!(convex_polygon(&poly(&[(0.0, 0.0), (1.0, 1.0), (2.0, 2.0)])).is_none(), "a line"); + } + + /// A tile whose fill reaches past its clip keeps the clip, so the tiles aren't merged. + #[test] + fn a_clip_that_cuts_its_fill_is_kept() { + let clip = Op::Clip { path: poly(&[(0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (0.0, 10.0)]), rule: FillRule::NonZero }; + let past = Op::Fill { path: poly(&[(0.0, 0.0), (12.0, 0.0), (12.0, 10.0), (0.0, 10.0)]), rule: FillRule::NonZero, rgb: [255, 0, 0] }; + assert!(plain_fills(&[clip.clone(), past, Op::Unclip]).is_none()); + let within = Op::Fill { path: poly(&[(0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (0.0, 10.0)]), rule: FillRule::NonZero, rgb: [255, 0, 0] }; + assert_eq!(plain_fills(&[clip, within, Op::Unclip]).map(|f| f.len()), Some(1)); + } +} diff --git a/crates/metafile/src/tests.rs b/crates/metafile/src/tests.rs index 104d9596ad..25bb51277f 100644 --- a/crates/metafile/src/tests.rs +++ b/crates/metafile/src/tests.rs @@ -430,3 +430,95 @@ fn patterns_inside_pattern_tiles_share_one_tile_budget() { let (ops, _) = crate::scene::Scene::new(&d, d.artboards[0].rect, true).run(); assert!(ops.len() < 300_000, "{} operations", ops.len()); } + +/// A 24 pt tile clipped to itself, red on its left half and white on its right: the striped +/// pattern of #3911. +fn stripes(name: &str, extra: Option) -> PatternDef { + let cell = Rect::new(0.0, 0.0, 24.0, 24.0); + let clip = Node::new( + NodeId(0), + NodeKind::Path { path: shapes::rectangle(cell), rule: vectorcraft_geom::FillRule::NonZero, live: None, clipping: true, guide: false }, + ); + let mut children = vec![ + Arc::new(clip), + Arc::new(path(shapes::rectangle(Rect::new(0.0, 0.0, 12.0, 24.0)), red(), Paint::None, 0.0)), + Arc::new(path(shapes::rectangle(Rect::new(12.0, 0.0, 24.0, 24.0)), Paint::solid(Color::rgb8(255, 255, 255)), Paint::None, 0.0)), + ]; + children.extend(extra.map(Arc::new)); + let group = Node::new(NodeId(0), NodeKind::Group { children, clip: true }); + let mut def = PatternDef::new(name, vec![Arc::new(group)]); + def.tile = cell; + def +} + +/// A 360 × 260 pt rectangle filled with `def`, turned 45°. +fn striped_doc(def: PatternDef) -> Document { + let paint = Paint::Pattern { pattern: def.name.clone(), xf: Affine::rotate(std::f64::consts::FRAC_PI_4) }; + let mut d = doc_with(400.0, 300.0, vec![path(shapes::rectangle(Rect::new(20.0, 20.0, 380.0, 280.0)), paint, Paint::None, 0.0)]); + d.patterns.push(def); + d +} + +fn fills(ops: &[crate::scene::Op]) -> Vec<(&vectorcraft_geom::BezPath, [u8; 3])> { + ops.iter() + .filter_map(|op| match op { + crate::scene::Op::Fill { path, rgb, .. } => Some((path, *rgb)), + _ => None, + }) + .collect() +} + +fn clips(ops: &[crate::scene::Op]) -> usize { + ops.iter().filter(|op| matches!(op, crate::scene::Op::Clip { .. })).count() +} + +/// #3911: a pattern whose tiles stay apart is written as one shape for each part of its tile, +/// clipped once to what it fills, instead of every tile's parts in a clip of their own. +#[test] +fn pattern_tiles_that_stay_apart_are_one_shape_for_each_part() { + let d = striped_doc(stripes("stripes", None)); + let (ops, warnings) = crate::scene::Scene::new(&d, d.artboards[0].rect, true).run(); + let f = fills(&ops); + assert_eq!(f.iter().map(|(_, rgb)| *rgb).collect::>(), [[255, 0, 0], [255, 255, 255]], "red, then white"); + assert_eq!(clips(&ops), 2, "the page's clip and one to the filled rectangle"); + // Every tile's half is in the merged shape: one figure for each tile, red and white alike. + let figures = |bp: &vectorcraft_geom::BezPath| bp.elements().iter().filter(|e| matches!(e, kurbo::PathEl::MoveTo(_))).count(); + let tiles = d.pattern("stripes").unwrap().instances_in(Affine::rotate(std::f64::consts::FRAC_PI_4), Rect::new(20.0, 20.0, 380.0, 280.0)).len(); + assert!(tiles > 200, "{tiles} tiles"); + assert_eq!((figures(f[0].0), figures(f[1].0)), (tiles, tiles)); + assert!(warnings.iter().any(|w| w.contains("one shape for each part of the tile")), "{warnings:?}"); + // The EMF: two fills and one saved clip, about half the bytes the tiles took apart. + let bytes = emf(&d).bytes; + let k = kinds(&emf_records(&bytes)); + assert_eq!((count(&k, 62), count(&k, 33)), (2, 2), "FILLPATH and SAVEDC records"); +} + +/// Art reaching past its tile overlaps the next tile's, so the tiles keep their own shapes and +/// clips, in paint order. +#[test] +fn pattern_art_past_its_tile_keeps_each_tile_apart() { + let mut def = stripes("wide", None); + // The tile is smaller than the art: neighbours overlap. + def.tile = Rect::new(0.0, 0.0, 20.0, 20.0); + let d = striped_doc(def); + let (ops, warnings) = crate::scene::Scene::new(&d, d.artboards[0].rect, true).run(); + assert!(fills(&ops).len() > 400, "{} fills", fills(&ops).len()); + assert!(clips(&ops) > 200, "each tile's clip stays"); + assert!(warnings.iter().any(|w| w.contains("one shape each")), "{warnings:?}"); +} + +/// Hex tilings overlap their tiles' boxes, and a stroke may reach past a clip: both keep each +/// tile apart. +#[test] +fn hex_tilings_and_stroked_tiles_keep_each_tile_apart() { + let mut hex = stripes("hex", None); + hex.tile_type = vectorcraft_doc::TileType::HexByRow; + let d = striped_doc(hex); + let (ops, _) = crate::scene::Scene::new(&d, d.artboards[0].rect, true).run(); + assert!(fills(&ops).len() > 400, "hex: {} fills", fills(&ops).len()); + + let line = path(shapes::rectangle(Rect::new(4.0, 4.0, 20.0, 20.0)), Paint::None, blue(), 2.0); + let d = striped_doc(stripes("stroked", Some(line))); + let (ops, _) = crate::scene::Scene::new(&d, d.artboards[0].rect, true).run(); + assert!(fills(&ops).len() > 400 && clips(&ops) > 200, "stroked: {} fills, {} clips", fills(&ops).len(), clips(&ops)); +} diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index e9c5c2a1f4..945b64db4a 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -133,6 +133,7 @@ the app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPri |---|---|---| | 2026-10-29 | minor | `.ai` and Illustrator EPS import: the editing data is read up to an eighth of installed memory, from 512 MiB to 2 GiB on 64-bit builds (it was 512 MiB on every machine), so a layered file whose embedded rasters unpack past 512 MiB keeps its layers, groups and text on a machine with 8 GiB or more instead of opening as its page or PDF part (#3510, #4628). Measured: 1.1 GB of editing data peaked 1.1 GB above the start; data past the limit is still refused (a 2 MB file unpacking to 2.2 GB stops in under a second). 32-bit and web builds keep 256 MiB. Own-fixture tests `import::ai::tests::editing_data_past_512_mib_is_read_where_memory_allows`, `the_editing_data_limit_follows_installed_memory`; scores and hours unchanged | | 2026-10-29 | minor | Affinity import: attached Recolor Adjustment (RcRA) layers import as color overlays with HSL lightness (#4420); scores unchanged. | +| 2026-10-30 | minor | EMF export: a pattern fill whose tiles stay apart (grid and brick tilings, art inside its tile) is written as one shape for each part of the tile, clipped once to what it fills, instead of every tile in a clip of its own; the picture is the same. A rotated two-colour stripe fill goes from 473 shapes and 246 clips to 2 shapes and 1 clip (122 KB to 61 KB; unrotated 99 KB to 33 KB). Tiles that overlap, hex tilings and tiles with strokes, images or nested clips are written as before (#3911). Tests in `crates/metafile/src/tests.rs` and `scene::merge_tests`; scores and hours unchanged | | 2026-10-26 | minor | EPS Save and Save As: an opened EPS saves back to its own path as EPS, keeping the chosen artboard's page frame and transparent margins and the complete editable VectorCraft document; Save's TIFF preview is capped at 1024 px (Export keeps 2048); partly read, preview-only or damaged-editing-data sources still need confirmation before they are overwritten; Save As leaves out the export-only crop and selection options. Synthetic regressions in `tests::save` (engine and UI) and `dialogs::save_options::tests`, listed under [EPS Save and source protection](#eps-save-and-source-protection); it does not write Illustrator's own editing data (#868), and G9's real-file import fidelity is unchanged; scores and hours unchanged | | 2026-10-25 | minor | `.ai` import: the editing data is read up to 512 MiB on 64-bit builds (the limit was 256 MiB), so a file whose embedded rasters unpack to 300 MiB or more keeps its layers, groups and text instead of opening as its PDF part (part of #3510); 32-bit and web builds keep 256 MiB. Own-fixture test `import::ai::tests::editing_data_past_256_mib_is_read`; scores and hours unchanged | | 2026-10-25 | minor | `.ai` import: the `--` placeholder of a radial gradient's highlight (`-- -- angle length Bh`, a gradient without one) and the `XC` operator after a linked image's file name no longer send the whole file to its PDF part, so files with them keep their layers, groups and live text (#4176). A `--` anywhere else is still an operator the reader doesn't know. Own-fixture tests in `import::ai::tests`; scores and hours unchanged | From 23ba6ae4c117ba9d4efea718823f052631d54191 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Fri, 30 Oct 2026 05:50:25 +0700 Subject: [PATCH 012/163] Path: Average & Join with a corner or smooth choice, Cmd+Alt+Shift+J (G1) --- crates/engine/src/cmd/path.rs | 152 ++++++++++++++++++------ crates/engine/src/tests/draw2.rs | 82 +++++++++++++ crates/ui-egui/src/dialogs.rs | 2 +- crates/ui-egui/src/dialogs/path_ops.rs | 28 ++++- crates/ui-egui/src/dialogs/tests.rs | 1 + crates/ui-egui/src/i18n/bg.tsv | 5 + crates/ui-egui/src/i18n/ca.tsv | 5 + crates/ui-egui/src/i18n/cs.tsv | 5 + crates/ui-egui/src/i18n/da.tsv | 5 + crates/ui-egui/src/i18n/de.tsv | 5 + crates/ui-egui/src/i18n/el.tsv | 5 + crates/ui-egui/src/i18n/es.tsv | 5 + crates/ui-egui/src/i18n/fi.tsv | 5 + crates/ui-egui/src/i18n/fr.tsv | 5 + crates/ui-egui/src/i18n/hu.tsv | 5 + crates/ui-egui/src/i18n/id.tsv | 5 + crates/ui-egui/src/i18n/it.tsv | 5 + crates/ui-egui/src/i18n/ja.tsv | 5 + crates/ui-egui/src/i18n/ka.tsv | 5 + crates/ui-egui/src/i18n/ko.tsv | 5 + crates/ui-egui/src/i18n/nl.tsv | 5 + crates/ui-egui/src/i18n/pl.tsv | 5 + crates/ui-egui/src/i18n/pt-br.tsv | 5 + crates/ui-egui/src/i18n/ru.tsv | 5 + crates/ui-egui/src/i18n/sv.tsv | 5 + crates/ui-egui/src/i18n/tests.rs | 1 + crates/ui-egui/src/i18n/tr.tsv | 5 + crates/ui-egui/src/i18n/uk.tsv | 5 + crates/ui-egui/src/i18n/vi.tsv | 5 + crates/ui-egui/src/i18n/zh-hans.tsv | 5 + crates/ui-egui/src/i18n/zh-hant.tsv | 5 + crates/ui-egui/src/menus/invoke.rs | 3 + crates/ui-egui/src/menus/tree.rs | 1 + crates/ui-egui/src/menus/ui_commands.rs | 2 +- crates/ui-egui/src/shortcuts/tests.rs | 40 +++++++ crates/ui-egui/src/state.rs | 4 + docs/gaps.md | 5 +- docs/mcp.md | 5 +- docs/target-app-parity.md | 5 +- docs/ui-parity.md | 5 +- 40 files changed, 411 insertions(+), 50 deletions(-) diff --git a/crates/engine/src/cmd/path.rs b/crates/engine/src/cmd/path.rs index c285fd15e9..24757213b9 100644 --- a/crates/engine/src/cmd/path.rs +++ b/crates/engine/src/cmd/path.rs @@ -98,6 +98,15 @@ pub fn specs() -> Vec { has_selection, average ), + cmd!( + "path.averageJoin", + "Average & Join…", + ["Object", "Path"], + Some("Cmd+Alt+Shift+J"), + "{to: \"corner\"|\"smooth\" (the joined anchor: corner retracts both handles, smooth pulls handles in line with the neighbours), ids?: [path, ...] (default: the selection; a compound path ID expands to its open member paths)} move two open path ends to their midpoint and join them there, as one undo step: the two direct-selected anchors when they are open path ends, else the nearest ends of the two open paths in ids or the selection (or both ends of one open path, closing it) → the joined path stays selected", + has_selection, + average_join + ), cmd!( "path.convertAnchors", "Convert Anchor Points", @@ -802,29 +811,11 @@ fn join(s: &mut Session, p: &Value) -> Result { } } }; - if ida == idb { - if sa == sb { - s.edit("Join", |d, sel| { - close_subpath_in_node(d, ida, sa, join_kind)?; - sel.set([compound_or_self(d, ida)]); - Ok(()) - })?; - } else { - s.edit("Join", |d, sel| { - join_subpaths_in_node(d, ida, (sa, sb), (rx, ry), join_kind)?; - sel.set([compound_or_self(d, ida)]); - Ok(()) - })?; - } - return ok(); - } else { - s.edit("Join", |d, sel| { - join_two(d, ida, idb, (sa, sb), (rx, ry), join_kind)?; - sel.set([compound_or_self(d, ida)]); - Ok(()) - })?; - return ok(); - } + s.edit("Join", |d, sel| { + sel.set([join_pair(d, (ida, sa), (idb, sb), (rx, ry), join_kind)?]); + Ok(()) + })?; + return ok(); } let ids = selected_paths(s)?; @@ -865,21 +856,11 @@ fn join(s: &mut Session, p: &Value) -> Result { if let Some((rx, ry)) = ends && open_subs.len() == 2 { - let (a, sa) = open_subs[0]; - let (b, sb) = open_subs[1]; - if a == b { - s.edit("Join", |d, sel| { - join_subpaths_in_node(d, a, (sa, sb), (rx, ry), join_kind)?; - sel.set([compound_or_self(d, a)]); - Ok(()) - })?; - } else { - s.edit("Join", |d, sel| { - join_two(d, a, b, (sa, sb), (rx, ry), join_kind)?; - sel.set([compound_or_self(d, a)]); - Ok(()) - })?; - } + let (a, b) = (open_subs[0], open_subs[1]); + s.edit("Join", |d, sel| { + sel.set([join_pair(d, a, b, (rx, ry), join_kind)?]); + Ok(()) + })?; return ok(); } @@ -992,6 +973,17 @@ fn join_two(d: &mut Document, a: NodeId, b: NodeId, (sa, sb): (usize, usize), (r Ok(()) } +/// Join subpath `sa` of path `a` and subpath `sb` of path `b` oriented as [`join_two`] takes them +/// (one subpath: close it). Returns what to select: the joined path, or its compound path. +fn join_pair(d: &mut Document, (a, sa): (NodeId, usize), (b, sb): (NodeId, usize), r: (bool, bool), join_kind: Option) -> Result { + if a == b { + join_subpaths_in_node(d, a, (sa, sb), r, join_kind)?; + } else { + join_two(d, a, b, (sa, sb), r, join_kind)?; + } + Ok(compound_or_self(d, a)) +} + pub(super) type AnchorTargets = Vec<(NodeId, Vec<(usize, usize)>)>; pub(super) fn anchor_targets(s: &Session) -> Result { @@ -1039,6 +1031,90 @@ fn average(s: &mut Session, p: &Value) -> Result { ok() } +/// An open path end: (path, subpath, anchor). +type End = (NodeId, usize, usize); + +/// Average & Join: the two ends Average moves to their midpoint, joined there as Join joins them. +fn average_join(s: &mut Session, p: &Value) -> Result { + const C: &str = "path.averageJoin"; + let smooth = match str_param(p, "to") { + Some("smooth") => true, + Some("corner") => false, + _ => return Err(bad(C, "`to` must be \"corner\" or \"smooth\"")), + }; + let ends = average_join_ends(s, p, C)?; + let [a, b] = ends.ok_or_else(|| bad(C, "select two open path ends, or two open paths, to average and join"))?; + let doc = &s.doc()?.doc; + let point = |(id, si, ai): End| doc.node(id)?.path_data()?.subpaths.get(si)?.anchors.get(ai).map(|a| a.p); + let (Some(pa), Some(pb)) = (point(a), point(b)) else { return Err(bad(C, "join needs open paths")) }; + let mid = pa.midpoint(pb); + // The first end must come last in its subpath, the second first (as `ends` takes them in Join). + let r = (a.2 == 0, b.2 != 0); + s.edit("Average & Join", |d, sel| { + for (id, si, ai) in [a, b] { + if let Some(anchor) = path_mut(d, id)?.anchor_mut(si, ai) { + anchor.translate(mid - anchor.p); + } + } + sel.set([join_pair(d, (a.0, a.1), (b.0, b.1), r, Some(smooth))?]); + Ok(()) + })?; + ok() +} + +/// The two ends Average & Join brings together: the two direct-selected anchors when they are +/// open path ends; else, of the paths in `ids` or the selected ones, the nearest ends of their two +/// open subpaths, or both ends of their one. `None` when there are no such two ends, or when they +/// are the two ends of a line, which the midpoint would collapse. +fn average_join_ends(s: &Session, p: &Value, c: &str) -> Result> { + let st = s.doc()?; + let doc = &st.doc; + let subpath = |id: NodeId, si: usize| doc.node(id)?.path_data()?.subpaths.get(si).filter(|sp| !sp.closed && !sp.anchors.is_empty()); + let last = |sp: &SubPath| sp.anchors.len().saturating_sub(1); + let ids = ids_param(p, "ids"); + let ends = if ids.is_none() && !st.selection.anchors.is_empty() { + let picked: Vec = st.selection.anchors.iter().flat_map(|(&id, set)| set.iter().map(move |&(si, ai)| (id, si, ai))).collect(); + match picked.as_slice() { + &[a, b] if [a, b].iter().all(|&(id, si, ai)| subpath(id, si).is_some_and(|sp| ai == 0 || ai == last(sp))) => [a, b], + _ => return Ok(None), + } + } else { + let paths = match ids { + None => selected_paths(s)?, + Some(ids) => { + let mut out = vec![]; + for id in ids { + match doc.node(id).map(|n| (n, &n.kind)) { + Some((_, NodeKind::Path { .. })) => out.push(id), + Some((n, NodeKind::Compound { .. })) => out.extend(open_members(n)), + _ => return Err(bad(c, format!("{} isn't a path", id.0))), + } + } + out + } + }; + let open: Vec<(NodeId, usize, &SubPath)> = paths + .iter() + .filter_map(|&id| Some((id, doc.node(id)?.path_data()?))) + .flat_map(|(id, pd)| { + pd.subpaths.iter().enumerate().filter(|(_, sp)| !sp.closed && !sp.anchors.is_empty()).map(move |(si, sp)| (id, si, sp)) + }) + .collect(); + match *open.as_slice() { + [(id, si, sp)] => [(id, si, 0), (id, si, last(sp))], + [(ia, sa, x), (ib, sb, y)] => { + let Some((rx, ry)) = nearest_ends(x, y) else { return Ok(None) }; + [(ia, sa, if rx { 0 } else { last(x) }), (ib, sb, if ry { last(y) } else { 0 })] + } + _ => return Ok(None), + } + }; + // A subpath's two ends: it needs an anchor between them to close around. + let [a, b] = ends; + let line = (a.0, a.1) == (b.0, b.1) && subpath(a.0, a.1).is_none_or(|sp| sp.anchors.len() <= 2); + Ok((!line).then_some(ends)) +} + fn convert_anchors(s: &mut Session, p: &Value) -> Result { const C: &str = "path.convertAnchors"; let smooth = match str_param(p, "to") { diff --git a/crates/engine/src/tests/draw2.rs b/crates/engine/src/tests/draw2.rs index d4094b382c..15d1b27f9a 100644 --- a/crates/engine/src/tests/draw2.rs +++ b/crates/engine/src/tests/draw2.rs @@ -2723,6 +2723,88 @@ fn join_takes_the_paths_and_the_ends_to_join() { } } +/// Average & Join (Cmd+Alt+Shift+J): the two ends meet at their midpoint and become one anchor of +/// one path, a corner or a smooth point as asked, in one undo step; from two selected paths (their +/// nearest ends) or from two direct-selected ends (the ends picked, not the nearest). +#[test] +fn average_join_meets_at_the_midpoint_as_a_corner_or_smooth_point() { + let pts = |s: &Session, id: NodeId| path(s, id).subpaths[0].anchors.iter().map(|x| (x.p.x, x.p.y)).collect::>(); + for (to, picks) in [("corner", false), ("smooth", false), ("corner", true), ("smooth", true)] { + let mut s = session(); + let a = line(&mut s, 0.0, 0.0, 100.0, 0.0); + let b = line(&mut s, 110.0, 40.0, 200.0, 40.0); + let want = if picks { + // a's first and b's last, the far ends. + s.execute("select.anchors", &json!({"id": a.0, "anchors": [[0, 0]], "mode": "set"})).unwrap(); + s.execute("select.anchors", &json!({"id": b.0, "anchors": [[0, 1]], "mode": "add"})).unwrap(); + [(100.0, 0.0), (100.0, 20.0), (110.0, 40.0)] + } else { + s.select(|_, sel| sel.set([a, b])).unwrap(); + [(0.0, 0.0), (105.0, 20.0), (200.0, 40.0)] + }; + let undo = s.doc().unwrap().history.undo.len(); + s.execute("path.averageJoin", &json!({ "to": to })).unwrap(); + assert_eq!(pts(&s, a), want, "{to} picks:{picks}"); + assert!(s.doc().unwrap().doc.node(b).is_none(), "b was joined into a"); + assert_eq!(s.doc().unwrap().selection.objects, [a]); + let joined = path(&s, a).subpaths[0].anchors[1]; + let (din, dout) = (joined.h_in - joined.p, joined.h_out - joined.p); + if to == "corner" { + assert!(din.hypot() < 1e-9 && dout.hypot() < 1e-9, "a corner has no handles: {joined:?}"); + } else { + assert!(din.hypot() > 1.0 && dout.hypot() > 1.0 && din.cross(dout).abs() < 1e-6 && din.dot(dout) < 0.0, "smooth: {joined:?}"); + } + assert_eq!(s.doc().unwrap().history.undo.len(), undo + 1, "one undo step"); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(pts(&s, a), [(0.0, 0.0), (100.0, 0.0)]); + assert_eq!(pts(&s, b), [(110.0, 40.0), (200.0, 40.0)]); + } +} + +/// Average & Join closes one open path at the midpoint of its ends, and refuses a bad `to` and a +/// selection without two open ends to join (a closed path, three paths, one picked end, a line's +/// two ends), leaving the document as it was; `ids` names the paths over the selection. +#[test] +fn average_join_closes_one_path_and_refuses_what_it_cannot_join() { + let mut s = session(); + let v = NodeId(s.execute("path.create", &json!({"d": "M0 0 L50 100 L100 10"})).unwrap()["id"].as_u64().unwrap()); + s.select(|_, sel| sel.set([v])).unwrap(); + s.execute("path.averageJoin", &json!({"to": "corner"})).unwrap(); + let pd = path(&s, v); + assert!(pd.subpaths[0].closed); + assert_eq!(pd.subpaths[0].anchors.iter().map(|x| (x.p.x, x.p.y)).collect::>(), [(50.0, 5.0), (50.0, 100.0)]); + + let mut s = session(); + let a = line(&mut s, 0.0, 0.0, 100.0, 0.0); + let b = line(&mut s, 110.0, 0.0, 200.0, 0.0); + let c = line(&mut s, 210.0, 0.0, 300.0, 0.0); + let r = rect(&mut s, 0.0, 50.0, 10.0, 10.0); + let before = s.doc().unwrap().doc.clone(); + let corner = json!({"to": "corner"}); + let cases = [ + (vec![a, b], None, json!({})), + (vec![a, b], None, json!({"to": "round"})), + (vec![r], None, corner.clone()), + (vec![a, b, c], None, corner.clone()), + (vec![a], None, corner.clone()), + (vec![r], None, json!({"to": "corner", "ids": [a.0, 999]})), + (vec![r], None, json!({"to": "corner", "ids": [r.0, a.0]})), + (vec![a, b], Some(json!({"id": a.0, "anchors": [[0, 0]], "mode": "set"})), corner.clone()), + (vec![a, b], Some(json!({"id": a.0, "anchors": [[0, 0], [0, 1]], "mode": "set"})), corner.clone()), + ]; + for (picked, anchors, p) in cases { + s.select(|_, sel| sel.set(picked.clone())).unwrap(); + if let Some(anchors) = anchors { + s.execute("select.anchors", &anchors).unwrap(); + } + assert!(s.execute("path.averageJoin", &p).is_err(), "{picked:?} {p}"); + assert_eq!(s.doc().unwrap().doc, before, "{picked:?} {p}: nothing changed"); + } + s.select(|_, sel| sel.set([r])).unwrap(); + s.execute("path.averageJoin", &json!({"to": "corner", "ids": [b.0, c.0]})).unwrap(); + assert_eq!(path(&s, b).subpaths[0].anchors.iter().map(|x| (x.p.x, x.p.y)).collect::>(), [(110.0, 0.0), (205.0, 0.0), (300.0, 0.0)]); +} + /// `path.join {ends}` on selected paths honors the requested ends, not the nearest pair. #[test] fn join_selected_paths_honors_ends_parameter() { diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index 3ca9da699c..659a2c793d 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -273,7 +273,7 @@ registry! { NewDocument: [new_document::KIND] => new_document::SPEC, Shape: ["rectangle", "roundedRectangle", "ellipse", "polygon", "star", "lineSegment", "arc", "spiral", "rectangularGrid", "polarGrid"] => shapes::SPEC, Transform: ["move", "rotate", "scale", "reflect", "shear"] => transform::SPEC, - PathOp: ["average", "offsetPath", "simplify", "splitIntoGrid"] => path_ops::SPEC, + PathOp: ["average", "averageJoin", "offsetPath", "simplify", "splitIntoGrid"] => path_ops::SPEC, DocumentSetup: ["documentSetup"] => document_setup::SPEC, ArtboardOptions: [artboard_options::KIND] => artboard_options::SPEC, ExportForScreens: ["exportForScreens"] => export_for_screens::SPEC, diff --git a/crates/ui-egui/src/dialogs/path_ops.rs b/crates/ui-egui/src/dialogs/path_ops.rs index 102c87043b..3a62eae1f4 100644 --- a/crates/ui-egui/src/dialogs/path_ops.rs +++ b/crates/ui-egui/src/dialogs/path_ops.rs @@ -1,4 +1,4 @@ -//! Path dialogs: Average, and Offset Path, Simplify and Split Into Grid with Preview. +//! Path dialogs: Average, Average & Join, and Offset Path, Simplify and Split Into Grid with Preview. use serde_json::{Value, json}; use vectorcraft_doc::{NodeId, NodeKind, Unit}; @@ -23,6 +23,7 @@ const ORIGINAL_IDS: &str = "__ids"; fn title(kind: &str) -> &'static str { match kind { "average" => tl!("Average"), + "averageJoin" => tl!("Average & Join"), "offsetPath" => tl!("Offset Path"), "simplify" => tl!("Simplify"), _ => tl!("Split Into Grid"), @@ -33,6 +34,7 @@ fn title(kind: &str) -> &'static str { fn command(d: &Dialog) -> (&'static str, Value) { match d.kind.as_str() { "average" => ("path.average", json!({"axis": d.str("axis")})), + "averageJoin" => ("path.averageJoin", json!({"to": d.str("to")})), "offsetPath" => { ("object.path.offsetPath", json!({"offset": d.f64("offset", 10.0), "joins": d.str("joins"), "miterLimit": d.f64("miterLimit", 4.0)})) } @@ -44,7 +46,7 @@ fn command(d: &Dialog) -> (&'static str, Value) { } } -/// The undo label of the dialogs that preview on the canvas (all but Average). +/// The undo label of the dialogs that preview on the canvas (all but Average and Average & Join). fn previewed(kind: &str) -> Option<&'static str> { match kind { "offsetPath" => Some("Offset Path"), @@ -108,6 +110,20 @@ fn split_grid(ui: &mut egui::Ui, d: &mut Dialog, unit: Unit) { form::check(ui, d, "addGuides", tl!("Add Guides")); } +/// Average & Join's Points: Corner or Smooth, the joined anchor. "Points:" in the "anchor" +/// context: the plain row is a star's number of points. +fn join_points(ui: &mut egui::Ui, d: &mut Dialog) { + let to = d.str("to"); + ui.horizontal(|ui| { + form::row_label(ui, crate::i18n::tr_ctx(crate::i18n::current(), "anchor", "Points:")); + for (value, label) in [("corner", "Corner"), ("smooth", "Smooth")] { + if crate::widgets::radio(ui, label, to == value, true) { + d.fields.insert("to".into(), json!(value)); + } + } + }); +} + /// The fields the Simplify dialog opens with at `tolerance` (points): the slider's tolerance when /// its More Options opens the dialog. pub(crate) fn simplify_dialog(tolerance: f64) -> Value { @@ -160,6 +176,8 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { split_grid(ui, d, unit); } else if d.kind == "simplify" { simplify_fields(ui, d, unit); + } else if d.kind == "averageJoin" { + join_points(ui, d); } else { form::grid(ui, d, unit); } @@ -189,7 +207,11 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { fn confirm(app: &mut VectorcraftApp, d: &Dialog) -> Result { let (id, params) = command(d); if previewed(&d.kind).is_none() { - return run_and_close(app, id, params); + let r = run_and_close(app, id, params)?; + if d.kind == "averageJoin" { + app.ui.average_join = json!({"to": d.str("to")}); + } + return Ok(r); } let r = form::commit_preview(app, id, params)?; // Simplify: with retain ticked, the menu item opens this dialog on these fields next time; with it diff --git a/crates/ui-egui/src/dialogs/tests.rs b/crates/ui-egui/src/dialogs/tests.rs index 849de13260..66f37e10f3 100644 --- a/crates/ui-egui/src/dialogs/tests.rs +++ b/crates/ui-egui/src/dialogs/tests.rs @@ -105,6 +105,7 @@ fn every_dialog_draws() { for (kind, fields) in [ ("move", json!({"dx": "0 pt", "dy": "0 pt"})), ("average", json!({"axis": "both"})), + ("averageJoin", json!({"to": "corner"})), (crate::unsaved::KIND, json!({"index": 0, "name": "Untitled-1", "then": "close"})), ("newWorkspace", json!({"name": "Mine"})), ("shortcuts", json!({})), diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index a496b97beb..acb56f53ec 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -5584,3 +5584,8 @@ axis Y Axis Y ос Glyph Bounds Граници на глифа Proximity Guides Водачи за близост Angular Guides Ъглови водачи +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Усредняване и свързване… + Average & Join Усредняване и свързване +anchor Points: Точки: +@msg select two open path ends, or two open paths, to average and join изберете два края на отворени пътища или два отворени пътя за усредняване и свързване diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index bd918d326a..08b9074719 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -5685,3 +5685,8 @@ theme Appearance Aparença Glyph Bounds Límits del glif Proximity Guides Guies de proximitat Angular Guides Guies angulars +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Mitjana i unió… + Average & Join Mitjana i unió +anchor Points: Punts: +@msg select two open path ends, or two open paths, to average and join selecciona dos extrems de traçats oberts, o dos traçats oberts, per fer-ne la mitjana i unir-los diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 63a9223cef..91bdee122b 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -5694,3 +5694,8 @@ axis Y Axis osa Y Glyph Bounds Hranice glyfů Proximity Guides Vodítka blízkosti Angular Guides Úhlová vodítka +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Zprůměrovat a spojit… + Average & Join Zprůměrovat a spojit +anchor Points: Body: +@msg select two open path ends, or two open paths, to average and join vyberte dva konce otevřených cest nebo dvě otevřené cesty ke zprůměrování a spojení diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 312f807129..5c01df3c6c 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -5599,3 +5599,8 @@ axis Y Axis Y-akse Glyph Bounds Glyfafgrænsning Proximity Guides Nærhedshjælpelinjer Angular Guides Vinkelhjælpelinjer +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Gennemsnit og forbind… + Average & Join Gennemsnit og forbind +anchor Points: Punkter: +@msg select two open path ends, or two open paths, to average and join markér to ender af åbne stier eller to åbne stier, der skal udlignes til gennemsnit og forbindes diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 19e8c766f0..b58127892a 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -5276,3 +5276,8 @@ axis Y Axis Y-Achse Glyph Bounds Glyphenbegrenzung Proximity Guides Näherungshilfslinien Angular Guides Winkelhilfslinien +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Durchschnitt berechnen und zusammenfügen… + Average & Join Durchschnitt berechnen und zusammenfügen +anchor Points: Punkte: +@msg select two open path ends, or two open paths, to average and join wählen Sie zwei Enden offener Pfade oder zwei offene Pfade aus, um sie zu mitteln und zusammenzufügen diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 9c4647fc4e..0b3fbeb454 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -5646,3 +5646,8 @@ axis Y Axis Άξονας Y Glyph Bounds Όρια γλυφής Proximity Guides Οδηγοί εγγύτητας Angular Guides Γωνιακοί οδηγοί +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Μέσος όρος και ένωση… + Average & Join Μέσος όρος και ένωση +anchor Points: Σημεία: +@msg select two open path ends, or two open paths, to average and join επιλέξτε δύο άκρα ανοιχτών διαδρομών ή δύο ανοιχτές διαδρομές για μέσο όρο και ένωση diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 64c34fbc00..b47bae620c 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -5636,3 +5636,8 @@ axis Y Axis Eje Y Glyph Bounds Límites del glifo Proximity Guides Guías de proximidad Angular Guides Guías angulares +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Promediar y unir… + Average & Join Promediar y unir +anchor Points: Puntos: +@msg select two open path ends, or two open paths, to average and join selecciona dos extremos de trazados abiertos, o dos trazados abiertos, para promediarlos y unirlos diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index bf54f52655..5c04f9d8d4 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -5725,3 +5725,8 @@ axis Y Axis Y-akseli Glyph Bounds Merkin rajat Proximity Guides Läheisyysapuviivat Angular Guides Kulma-apuviivat +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Keskiarvota ja liitä… + Average & Join Keskiarvota ja liitä +anchor Points: Pisteet: +@msg select two open path ends, or two open paths, to average and join valitse kaksi avoimen polun päätä tai kaksi avointa polkua keskiarvotettaviksi ja liitettäviksi diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index eef0404d50..09381076c3 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -5693,3 +5693,8 @@ axis Y Axis Axe Y Glyph Bounds Limites du glyphe Proximity Guides Repères de proximité Angular Guides Repères angulaires +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Alignement et jonction… + Average & Join Alignement et jonction +anchor Points: Points : +@msg select two open path ends, or two open paths, to average and join sélectionnez deux extrémités de tracés ouverts, ou deux tracés ouverts, à aligner et joindre diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 19d2d85ee2..97da7b1e70 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -5680,3 +5680,8 @@ axis Y Axis Y tengely Glyph Bounds Glifahatárok Proximity Guides Közelségi segédvonalak Angular Guides Szög-segédvonalak +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Átlagolás és összekapcsolás… + Average & Join Átlagolás és összekapcsolás +anchor Points: Pontok: +@msg select two open path ends, or two open paths, to average and join jelölj ki két nyitott útvonalvéget vagy két nyitott útvonalat az átlagoláshoz és összekapcsoláshoz diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index e65b361904..e58b45121b 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -5599,3 +5599,8 @@ axis Y Axis Sumbu Y Glyph Bounds Batas glif Proximity Guides Panduan kedekatan Angular Guides Panduan sudut +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Rata-rata dan sambungkan… + Average & Join Rata-rata dan sambungkan +anchor Points: Titik: +@msg select two open path ends, or two open paths, to average and join pilih dua ujung jalur terbuka, atau dua jalur terbuka, untuk dirata-ratakan dan disambungkan diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 5326bb34c4..7ad8c5e396 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -5310,3 +5310,8 @@ axis Y Axis Asse Y Glyph Bounds Limiti del glifo Proximity Guides Guide di prossimità Angular Guides Guide angolari +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Media e unisci… + Average & Join Media e unisci +anchor Points: Punti: +@msg select two open path ends, or two open paths, to average and join seleziona due estremità di tracciati aperti, o due tracciati aperti, da mediare e unire diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 927b8d3b80..a1ff8c8805 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -5372,3 +5372,8 @@ axis Y Axis Y 軸 Glyph Bounds 字形の境界 Proximity Guides 近接ガイド Angular Guides 角度ガイド +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… 平均と連結… + Average & Join 平均と連結 +anchor Points: ポイント: +@msg select two open path ends, or two open paths, to average and join 平均と連結には、オープンパスの端点を 2 つ、またはオープンパスを 2 つ選択してください diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index dbcaeca5da..d2d6669b3c 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -5683,3 +5683,8 @@ swatch Bright Violet კაშკაშა იისფერი Glyph Bounds გლიფის საზღვრები Proximity Guides სიახლოვის დამხმარე ხაზები Angular Guides კუთხური დამხმარე ხაზები +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… საშუალო და შეერთება… + Average & Join საშუალო და შეერთება +anchor Points: წერტილები: +@msg select two open path ends, or two open paths, to average and join მონიშნეთ ღია ტრაექტორიების ორი ბოლო ან ორი ღია ტრაექტორია საშუალოსა და შეერთებისთვის diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 81c87fdaee..3ba2c74eaa 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -5273,3 +5273,8 @@ axis Y Axis Y축 Glyph Bounds 글리프 경계 Proximity Guides 근접 안내선 Angular Guides 각도 안내선 +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… 평균 및 결합… + Average & Join 평균 및 결합 +anchor Points: 포인트: +@msg select two open path ends, or two open paths, to average and join 평균 및 결합할 열린 패스의 끝점 두 개 또는 열린 패스 두 개를 선택하세요 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 3ec76a559e..318126cbf3 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -5643,3 +5643,8 @@ axis Y Axis Y-as Glyph Bounds Glyphbegrenzing Proximity Guides Nabijheidshulplijnen Angular Guides Hoekhulplijnen +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Gemiddelde en verbinden… + Average & Join Gemiddelde en verbinden +anchor Points: Punten: +@msg select two open path ends, or two open paths, to average and join selecteer twee uiteinden van open paden, of twee open paden, om te middelen en te verbinden diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index e2b44fb043..8cf23270bd 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -5548,3 +5548,8 @@ axis Y Axis Oś Y Glyph Bounds Granice glifów Proximity Guides Linie bliskości Angular Guides Linie kątowe +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Uśrednij i połącz… + Average & Join Uśrednij i połącz +anchor Points: Punkty: +@msg select two open path ends, or two open paths, to average and join zaznacz dwa końce otwartych ścieżek lub dwie otwarte ścieżki do uśrednienia i połączenia diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 878bf119f5..c698419f17 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -5611,3 +5611,8 @@ axis Y Axis Eixo Y Glyph Bounds Limites do Glifo Proximity Guides Guias de Proximidade Angular Guides Guias Angulares +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Média e união… + Average & Join Média e união +anchor Points: Pontos: +@msg select two open path ends, or two open paths, to average and join selecione duas extremidades de traçados abertos, ou dois traçados abertos, para calcular a média e unir diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 90f7a8f5ed..7db0f6a50a 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -5672,3 +5672,8 @@ theme Appearance Оформление Glyph Bounds Границы глифа Proximity Guides Направляющие близости Angular Guides Угловые направляющие +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Усреднить и соединить… + Average & Join Усреднить и соединить +anchor Points: Точки: +@msg select two open path ends, or two open paths, to average and join выделите два конца открытых контуров или два открытых контура для усреднения и соединения diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index d8f16d7c8c..d5e0c7c23a 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -5718,3 +5718,8 @@ axis Y Axis Y-axel Glyph Bounds Glyfgränser Proximity Guides Närhetsstödlinjer Angular Guides Vinkelstödlinjer +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Medelvärde och foga samman… + Average & Join Medelvärde och foga samman +anchor Points: Punkter: +@msg select two open path ends, or two open paths, to average and join markera två ändar av öppna banor, eller två öppna banor, att medelvärdesberäkna och foga samman diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index 118ffba7af..4b6da23561 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -1925,6 +1925,7 @@ const RENDER_SITE_ROWS: &[(&str, &str)] = &[ ("file-filter", "PDF-compatible .ai"), ("file-filter", "VectorCraft Template"), ("file-filter", "Templates"), + ("anchor", "Points:"), ("diagnostics", "render"), ("diagnostics", "ui"), ("", "Preset {number}"), diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 85822e4587..d3566fbd8a 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -5652,3 +5652,8 @@ axis Y Axis Y ekseni Glyph Bounds Glif Sınırları Proximity Guides Yakınlık Kılavuzları Angular Guides Açısal Kılavuzlar +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Ortalama ve katıl… + Average & Join Ortalama ve katıl +anchor Points: Noktalar: +@msg select two open path ends, or two open paths, to average and join ortalaması alınıp katılmak için iki açık yol ucu veya iki açık yol seçin diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 69d617b9b8..1aec37d5f0 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -5290,3 +5290,8 @@ axis Y Axis Вісь Y Glyph Bounds Межі гліфа Proximity Guides Напрямні близькості Angular Guides Кутові напрямні +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Усереднити і з’єднати… + Average & Join Усереднити і з’єднати +anchor Points: Точки: +@msg select two open path ends, or two open paths, to average and join виділіть два кінці відкритих контурів або два відкриті контури для усереднення і з’єднання diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 4d9c255831..205fac49c3 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -5292,3 +5292,8 @@ axis Y Axis Trục Y Glyph Bounds Giới hạn glyph Proximity Guides Đường căn lân cận Angular Guides Đường căn góc +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… Trung bình và nối… + Average & Join Trung bình và nối +anchor Points: Điểm: +@msg select two open path ends, or two open paths, to average and join hãy chọn hai đầu của đường dẫn mở, hoặc hai đường dẫn mở, để lấy trung bình và nối diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 8aed395a34..49ee6d3052 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -5533,3 +5533,8 @@ axis Y Axis Y 轴 Glyph Bounds 字形边界 Proximity Guides 邻近参考线 Angular Guides 角度参考线 +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… 平均并连接… + Average & Join 平均并连接 +anchor Points: 点: +@msg select two open path ends, or two open paths, to average and join 请选择两个开放路径的端点或两条开放路径以进行平均并连接 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 0d2172acf6..c957c07ee8 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -5329,3 +5329,8 @@ axis Y Axis Y 軸 Glyph Bounds 字符邊界 Proximity Guides 鄰近參考線 Angular Guides 角度參考線 +# Average & Join (Object › Path, Cmd+Alt+Shift+J). + Average & Join… 平均並連接… + Average & Join 平均並連接 +anchor Points: 點: +@msg select two open path ends, or two open paths, to average and join 請選取兩個開放路徑的端點或兩條開放路徑以進行平均並連接 diff --git a/crates/ui-egui/src/menus/invoke.rs b/crates/ui-egui/src/menus/invoke.rs index 337023f037..75f7462c7e 100644 --- a/crates/ui-egui/src/menus/invoke.rs +++ b/crates/ui-egui/src/menus/invoke.rs @@ -47,6 +47,9 @@ pub(super) fn menu_dialog(app: &VectorcraftApp, id: &str) -> Option<(&'static st "object.reflect" => ("reflect", json!({"axis": "vertical", "angle": 90})), "object.shear" => ("shear", json!({"angle": 0, "axis": "horizontal"})), "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()), + "path.averageJoin" => ("averageJoin", json!({"to": "corner"})), // Offset Path opens on the values it was last confirmed with. "object.path.offsetPath" if app.ui.offset_path.is_object() => ("offsetPath", app.ui.offset_path.clone()), "object.path.offsetPath" => ("offsetPath", json!({"offset": "10 pt", "joins": "miter", "miterLimit": 4})), diff --git a/crates/ui-egui/src/menus/tree.rs b/crates/ui-egui/src/menus/tree.rs index 1f1bb7f0ce..4ce87a6dd0 100644 --- a/crates/ui-egui/src/menus/tree.rs +++ b/crates/ui-egui/src/menus/tree.rs @@ -218,6 +218,7 @@ pub fn menu_tree_named(english_names: bool) -> Vec<(&'static str, Vec)> { vec![ c("Join", "path.join"), c("Average…", "path.average"), + c("Average & Join…", "path.averageJoin"), Sep, c("Outline Stroke", "object.path.outlineStroke"), c("Offset Path…", "object.path.offsetPath"), diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 4e5943a4ac..51ba642c1e 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -904,7 +904,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "ui.menuDialog", "Menu Dialog", "", - "{command: object.move|object.rotate|object.scale|object.reflect|object.shear|object.transformEach|path.average|object.path.offsetPath|object.path.simplify|object.path.smooth|object.path.splitIntoGrid|object.vectorHalftone|artboard.rearrange|object.envelope.makeWithWarp|object.envelope.resetWithWarp|object.envelope.makeWithMesh|object.envelope.resetWithMesh|object.envelope.options} open the dialog that command's menu item opens (dialog kind: move, rotate, scale, reflect, shear, transformEach, …, vectorHalftone, rearrangeArtboards, envelopeWarp, envelopeMesh, envelopeOptions; Scale and Transform Each have `corners` and `strokes`, from the preferences, which OK updates; Transform Each opens on the values it was last confirmed with (not `copy`), and its Copy button confirms with `copy: true`; the envelope dialogs start from the selected envelope, Make opens as Reset (`reset: true`) while one is selected)", + "{command: object.move|object.rotate|object.scale|object.reflect|object.shear|object.transformEach|path.average|path.averageJoin|object.path.offsetPath|object.path.simplify|object.path.smooth|object.path.splitIntoGrid|object.vectorHalftone|artboard.rearrange|object.envelope.makeWithWarp|object.envelope.resetWithWarp|object.envelope.makeWithMesh|object.envelope.resetWithMesh|object.envelope.options} open the dialog that command's menu item opens (dialog kind: move, rotate, scale, reflect, shear, transformEach, …, vectorHalftone, rearrangeArtboards, envelopeWarp, envelopeMesh, envelopeOptions; Scale and Transform Each have `corners` and `strokes`, from the preferences, which OK updates; Transform Each opens on the values it was last confirmed with (not `copy`), and its Copy button confirms with `copy: true`; the envelope dialogs start from the selected envelope, Make opens as Reset (`reset: true`) while one is selected)", ), ( "ui.widthPointEdit", diff --git a/crates/ui-egui/src/shortcuts/tests.rs b/crates/ui-egui/src/shortcuts/tests.rs index 8fa766f8c8..e97b526f92 100644 --- a/crates/ui-egui/src/shortcuts/tests.rs +++ b/crates/ui-egui/src/shortcuts/tests.rs @@ -234,6 +234,46 @@ fn cmd_alt_shift_3_hides_unselected_artwork() { assert_eq!(shown(&app), [true, true], "nothing is hidden in isolation mode"); } +/// Cmd+Alt+Shift+J opens Average & Join's dialog, Points: Corner the first time. Cancel changes +/// nothing; OK averages the selected lines' nearest ends and joins them there; the dialog opens +/// again on the choice confirmed last. +#[test] +fn cmd_alt_shift_j_opens_average_and_join() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.session.execute("file.new", &json!({"width": 200, "height": 200})).unwrap(); + assert_eq!(crate::menus::shortcut_of("path.averageJoin"), Some("Cmd+Alt+Shift+J")); + let line = |app: &mut VectorcraftApp, x1: f64, x2: f64| { + app.session.execute("shape.line", &json!({"x1": x1, "y1": 10, "x2": x2, "y2": 10})).unwrap()["id"].as_u64().unwrap() + }; + let (a, b) = (line(&mut app, 10.0, 50.0), line(&mut app, 60.0, 100.0)); + app.session.execute("select.set", &json!({"ids": [a, b]})).unwrap(); + let before = app.session.doc().unwrap().doc.clone(); + let j = || egui::Event::Key { + key: Key::J, + physical_key: None, + pressed: true, + repeat: false, + modifiers: Modifiers::COMMAND | Modifiers::ALT | Modifiers::SHIFT, + }; + frame(&mut app, vec![j()]); + let d = app.ui.dialog.as_ref().expect("the dialog opened"); + assert_eq!((d.kind.as_str(), d.str("to").as_str()), ("averageJoin", "corner")); + crate::dialogs::cancel(&mut app); + assert!(app.ui.dialog.is_none()); + assert_eq!(app.session.doc().unwrap().doc, before, "Cancel changes nothing"); + frame(&mut app, vec![j()]); + app.ui.dialog.as_mut().expect("the dialog opened again").fields.insert("to".into(), json!("smooth")); + crate::dialogs::confirm(&mut app).unwrap(); + assert!(app.ui.dialog.is_none()); + let doc = &app.session.doc().unwrap().doc; + assert!(doc.node(vectorcraft_doc::NodeId(b)).is_none(), "joined into one path"); + let path = doc.node(vectorcraft_doc::NodeId(a)).unwrap().path_data().unwrap(); + let pts: Vec<(f64, f64)> = path.subpaths[0].anchors.iter().map(|x| (x.p.x, x.p.y)).collect(); + assert_eq!(pts, [(10.0, 10.0), (55.0, 10.0), (100.0, 10.0)]); + frame(&mut app, vec![j()]); + assert_eq!(app.ui.dialog.as_ref().map(|d| d.str("to")).as_deref(), Some("smooth"), "the choice confirmed last"); +} + /// Cmd+Shift+B while the Type tool edits text is Type › Bold, not Hide Bounding Box (#724). #[test] fn cmd_shift_b_while_typing_is_bold_not_the_bounding_box() { diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index e7460b7e8d..843915bbdc 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -541,6 +541,9 @@ pub struct UiState { /// dialog opens on them (#1152). #[serde(default)] pub offset_path: Value, + /// The Average & Join fields confirmed last (`to`; null: never used): its dialog opens on them. + #[serde(default)] + pub average_join: Value, /// The Simplify dialog's fields confirmed last with "Open this dialog with these settings next /// time" ticked (null: not ticked): Object › Path › Simplify opens the dialog on them instead /// of the Simplify slider. @@ -878,6 +881,7 @@ impl Default for UiState { dxf_options: Value::Null, eps_options: Value::Null, offset_path: Value::Null, + average_join: Value::Null, simplify: Value::Null, move_options: Value::Null, transform_each: Value::Null, diff --git a/docs/gaps.md b/docs/gaps.md index f98756311f..8816d7209c 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Gaps -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (G12: Preferences audit (#394): 5 options are stored but not acted on (Open Documents As Tabs, Units › East Asian Type, Hyphenation › Default Language, Scratch Disks, Legacy vector clipboard), each waiting on a subsystem; Highlight Alternate Glyphs, Real-time Drawing and the Devices options act; estimate unchanged) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (G1: Average & Join with a corner or smooth choice, Cmd+Alt+Shift+J, done; estimate unchanged) · **Target:** Adobe Illustrator 2026 (30.x) ## Feature submission evidence @@ -131,7 +131,7 @@ from G14 and the budget run of G15: **~170–270 h** one agent, ~50–80 h wall - **Done (#1251):** Eyedropper source reads are independent of locks and isolation, including Shift/Shift+Alt and gradient stops. Source and selection preservation, unchanged Alt reverse/selection restrictions, hidden art and Undo/Redo have regression coverage. This addresses the reported behavior, with no new full-parity measurement. - **Done (#1253):** adding paint to an unpainted zero-width stroke restores the existing 1 pt default, including new-art defaults and Swap Fill/Stroke. The real Eyedropper inheritance sequence, targeted appearance items, preserved widths and Undo/Redo have regression coverage. - **Done:** a busy cursor while a file opens off the UI thread or a labelled background save or export runs (`Cursor::Busy` in `crates/tools/src/cursors.toml`). Heavy synchronous effect previews remain open. -- **Missing:** Average and Join in one step, with a corner or smooth choice for the joined anchor. `path.average` and `path.join` are separate commands and Join has no such choice (coinciding anchors merge into one since #1533). [ui-parity.md](ui-parity.md) listed "Join with corner/smooth choice" as done until 2026-10-13. About 1–2 h (estimated), inside the estimate below. +- **Done:** Average and Join in one step, with a corner or smooth choice for the joined anchor: Object › Path › Average & Join… (`path.averageJoin {to: "corner"|"smooth"}`, Cmd+Alt+Shift+J, Ctrl+Alt+Shift+J on Windows) moves the two direct-selected open path ends, or the nearest ends of two selected open paths (both ends of one, closing it), to their midpoint and joins them there in one undo step. The public [Default keyboard shortcuts](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) page lists the shortcut as "Create corner or smooth join" ("Select the paths" on Windows, "Select the anchor point" on macOS). The dialog (Points: Corner / Smooth) opens on Corner and then on the choice confirmed last in the session: VectorCraft's reading, as the page doesn't say. Inside the estimate below. - **Implemented (#1760):** Effect › Warp has a shared style selector with original previews, orientation buttons and percent sliders. Existing effects retain their stack slot and target. Focused checks passed and original captures were reviewed; optional Properties integration and remembered defaults remain outside this change. - **Done (#2120):** Smart Guides line extension: dragging the end of a straight segment with Direct Selection or Curvature, the point snaps to the segment's own direction at any angle and the guide runs along it from the other end. Inside the estimate below. - **Done (#1692):** Tab in the Color Picker moves through one color model's fields before the next. Completed upstream before the layout change (#2008). @@ -653,6 +653,7 @@ trap, and the defaults (0.25 pt, 100%, 40%) are VectorCraft's own, the pages giv | Date | Change | Summary | |---|---|---| +| 2026-10-30 | minor | G1: Object › Path › Average & Join… (`path.averageJoin`, Cmd+Alt+Shift+J) moves two open path ends to their midpoint and joins them there, the joined anchor a corner or a smooth point as its dialog's Points choice asks, in one undo step; the "Average and Join in one step" entry is done. Estimate unchanged | | 2026-10-30 | minor | G12: Preferences audit (#394): 5 options are stored but not acted on (Open Documents As Tabs, Units › East Asian Type, Hyphenation › Default Language, Scratch Disks, Legacy vector clipboard), each waiting on a subsystem; Highlight Alternate Glyphs, Real-time Drawing and the Devices options act. Estimate unchanged. | | 2026-10-29 | minor | G10: the Linux Flatpak on GNOME stops the clipboard retry storm (retried with a growing wait, logged once). Estimate unchanged. | | 2026-10-29 | minor | G12: Pathfinder: live compound shapes (#4522): the panel menu's Make, Release and Expand Compound Shape, Alt-clicking a Shape Mode, a selected member's Shape Mode and the Expand button act. No entry closed, estimates unchanged. | diff --git a/docs/mcp.md b/docs/mcp.md index be148d897d..466ecd0fa7 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2582,7 +2582,10 @@ or pulls handles out in line with the neighbouring anchors (a smooth anchor keep on top of each other, and an open path becomes one path per piece. Each cut leaves one of its two anchors selected, so `path.moveAnchors {dx, dy}` (or a Direct Selection drag) pulls the path apart there; `path.join {}` (Connect Selected End Points) joins the ends again; `path.join {ids: [a, b], ends: ["last", "first"]}` joins the ends asked for -(the Pen's join, #776: drawing on from one open path, a click on another's end makes them one path). `path.convertAnchor {id, subpath?, anchor, to, x?, y?}` and +(the Pen's join, #776: drawing on from one open path, a click on another's end makes them one path). `path.averageJoin {to: "corner"|"smooth", ids?}` +(Average & Join, Cmd+Alt+Shift+J) moves two ends to their midpoint and joins them there, the joined anchor a corner or a smooth point, in one +undo step: the two direct-selected anchors when they are open path ends, else the nearest ends of the two open paths in `ids` or the +selection (both ends of one, closing it); anything else is refused. `path.convertAnchor {id, subpath?, anchor, to, x?, y?}` and `path.split {id, subpath?, anchor}` do the same to one anchor (the Anchor Point and Scissors tools); the Pen with Alt held over a selected path's handle, anchor or segment works as the Anchor Point tool. `press_key` Escape between two `pointer_gesture` calls of an Anchor Point drag cancels it: the path goes back and no undo step is added. `path.reshapeSegment {id, diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 21db9d99d8..2da678317e 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1,6 +1,6 @@ # Parity with Adobe Illustrator -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (UI chrome: Preferences audit (#394), 5 options stored but not acted on; scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Tools: Average & Join with a corner or smooth choice, Cmd+Alt+Shift+J; scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026) ## Feature submission evidence @@ -699,7 +699,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Live Corners:** drag a live rectangle's corner widgets (Selection or Direct Selection) to round all corners, with a radius readout; with Direct Selection, select corner anchors to show and round just those corners (#381). Each corner keeps its own radius and kind (Round, Inverted Round, Chamfer): Alt-click a widget to cycle the kind, double-click it for the Corners dialog, and the Properties and Transform radius fields set the selected corners (`object.setLiveShape {corners, radius, kind}`). A link toggle behind Corner Radius (the `singleCornerRadius` preference) switches the panels to a field for each corner of a live rectangle: Top Left, Top Right, Bottom Right and Bottom Left. Corners stay circular when the rectangle is scaled unevenly or along its own sides when rotated (the radius keeps its size, or scales by the mean scale with Scale Corners on); only a shear distorts them. On a rectangle that isn't square every corner is the same circle: a radius past half the shorter side stops there for all of them, the widgets sit on the corners as drawn and turn the edited corners red at that limit, CSS export writes the drawn radii, and rectangles saved stretched by older versions get circular corners when their corners are next set (#442). Live Corners work on any path's corners too, as on a rectangle's (#511): a star's, a live polygon's (which also shows them to the Selection tool, has a Corner Radius field in the Properties and Transform panels and keeps its radius as its sides change) and a pen path's, wherever two sides meet at an angle at an anchor that isn't smooth: curved sides too, trimmed to what the cut leaves of them (#1144). Direct Selection shows the widgets of every corner, or of the corners holding selected anchors; each corner is a circle tangent to both sides, drawn no larger than takes its cut halfway along its shorter side; a path keeps its uncut outline so its corners stay editable, and the same command, dialog, angle preference and View › Hide Corner Widget apply. With Direct Selection a click on a widget (no drag) selects its corner, as a click on the corner's anchor does, so the next drag on it rounds that corner alone; Shift-click toggles it (#1239). While a corner widget is dragged with the Selection tool the bounding box hides, so the rounding shows against the path alone (#1229). A round corner next to a curved side curves smoothly instead of sticking out of the shape (#1547, fixes #1512). View › Hide Edges hides the Live Corners widgets, the bounding box and the type widget, and the selection tools then do not answer a press on them or change the cursor over them. - **Blend spine Anchor Point tool (#2544):** on a selected blend, dragging a spine corner makes symmetric Smooth handles; the tool displays and picks existing spine handles when switched to, drags one independently or retracts it on click, and clicking a point with handles retracts both. The spine is edited live without moving its key objects. Windows native canvas checks and screenshots reviewed: symmetric and independent handles, corner/retraction, Shift constraints and perpendicular reshaping, tool switching, key preservation, Undo/Redo, save/reopen, hidden handles and overlapping Path/Blend priority (PR #2643). Behaviour reference: [public path-editing documentation](https://helpx.adobe.com/illustrator/using/adjust-path-segments.html). - - **Path editing (#494):** the handles shown are the handles that drag: Direct Selection drags those of a path selected as a whole (as the Pen leaves it), the Anchor Point tool and Pen+Alt no longer grab handles that Show handles when multiple anchors are selected hides, a handle shorter than the tolerance leaves its anchor to be picked, and the anchor tools pick within Selection & Anchor Display › Tolerance. A dragged segment keeps a smooth anchor at either end smooth. With Direct Selection, the Pen, the Curvature and the anchor tools, a path selected as a whole shows all its anchors selected, and the Control bar and the Properties panel offer Convert (corner, smooth) for them too; Remove and Cut wait for anchors direct-selected (#504). A handle drag gathers its snap targets once per drag (it took 21 ms per pointer move on a 20,000-path document, now 1 ms; `vectorcraft-cli perf` measures handle and segment drags on a 5,000-anchor path). Join merges the selected anchor points that lie on one another, as after Average, into one anchor (#1582, fixes #1533); Average and Join in one step, with a corner or smooth choice for the joined anchor, is missing ([gap 1](gaps.md)). + - **Path editing (#494):** the handles shown are the handles that drag: Direct Selection drags those of a path selected as a whole (as the Pen leaves it), the Anchor Point tool and Pen+Alt no longer grab handles that Show handles when multiple anchors are selected hides, a handle shorter than the tolerance leaves its anchor to be picked, and the anchor tools pick within Selection & Anchor Display › Tolerance. A dragged segment keeps a smooth anchor at either end smooth. With Direct Selection, the Pen, the Curvature and the anchor tools, a path selected as a whole shows all its anchors selected, and the Control bar and the Properties panel offer Convert (corner, smooth) for them too; Remove and Cut wait for anchors direct-selected (#504). A handle drag gathers its snap targets once per drag (it took 21 ms per pointer move on a 20,000-path document, now 1 ms; `vectorcraft-cli perf` measures handle and segment drags on a 5,000-anchor path). Join merges the selected anchor points that lie on one another, as after Average, into one anchor (#1582, fixes #1533); Object › Path › Average & Join… (`path.averageJoin`, Cmd+Alt+Shift+J, the "Create corner or smooth join" shortcut of [Default keyboard shortcuts](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)) moves two open path ends to their midpoint and joins them there, a corner or smooth point as its dialog's Points choice asks, in one undo step. - **Graphs:** Column, Stacked Column, Bar, Stacked Bar, Line, Area, Scatter, Pie and Radar graph tools with Graph Data and Graph Type. A series starts in greyscale; Group Selection's fill and stroke are kept separately on the graph and reapplied when its data, type or size changes, and through save, open and undo. Graph Type's Override Calculated Values (both `axisMin` and `axisMax`) uses exactly that value-axis range, split into the tick count (5 when automatic). Line graphs take Edge-to-Edge Lines (off by default: the points sit at the centres of their categories; graphs saved before the option keep their edge-to-edge lines), and radar graphs follow Mark Data Points and Connect Data Points. Blank cells (an empty CSV cell or `null`) are values left out, not zeros: columns, bars and stacked segments skip them, lines and scatter lines break around them and the value axis ignores them, while area, pie and radar draw them as 0; a number in straight quotes is a label, and the data window writes it back quoted. Graph types combine: Graph Type on series picked with Group Selection (or `series` indexes) draws them as their own type, with column, stacked column, line and area mixing on the vertical value axis and bar and stacked bar on the horizontal one; stacked columns take one slot of the cluster, lines draw in front of columns and areas behind. The value axis goes on the left, the right or both sides (column, stacked column, line, area and scatter graphs; bar graphs keep theirs along the bottom), and Separate Scales gives the series assigned to the right axis a scale of their own with its own tick values. Each value axis takes tick marks of no, short or full (across the plot) length and a count per division, and a prefix and suffix for its numbers; the category axis takes tick marks too (none by default), at or between its labels. Graph designs: Object › Graph › Design lists the designs with a preview of the selected one, and New Design (the selected art), Rename, Delete Design, Paste Design (a copy back to edit) and Select Unused, and Marker draws the data points and legend swatches of line, scatter and radar series with a design, scaled so its backmost object fills the default marker's square. Graph Data transposes rows and columns and switches a scatter graph's x and y, and a `|` in a category or series label starts a new line. Pie graphs take Legends in Wedges, Position (Even, Ratio sized by area, Stacked on one centre) and Sort (None, All, First). Graph Type takes column and cluster widths up to 1000% (overlapping past 100%) with First Row and First Column in Front (First Row orders each series' categories; across series the series order decides, so series stay one group each for Group Selection), draws filled lines, adds drop shadows behind columns, bars, lines and wedges, and puts the legend in rows across the top. Text formatted with the Character or Appearance controls, on the whole graph or on labels picked with Group Selection, is kept per kind of label (value axis numbers, category labels, legend labels) through the graph being drawn again. Object › Graph › Data opens a worksheet: cells picked with a click and edited above the sheet (Tab moves right, Enter down, the arrows between cells), Import Data from a tab-separated text file, Transpose, Switch x/y, Cell Style (decimals shown, column width), Revert and Apply. `graph.setData` returns and takes the data as CSV with each value written exactly, not rounded to two decimals, so applying the returned CSV changes nothing (#1485). - **Graph column designs:** Object › Graph › Column (`graph.column`) draws the columns, bars or stacked segments and the legend swatch of the series picked with Group Selection with a graph design: Vertically Scaled stretches it to each column's length, Uniformly Scaled scales it both ways and centers it, Repeating stacks a copy for each Each Design Represents value and chops or scales the last one (For Fractions), and Sliding keeps the part above the design's guide line in proportion and stretches the part below. The dialog lists the designs with a preview; the choice is saved with the graph and follows the design's rename and delete. Type in a column design that holds a `%` followed by two digits shows each column's value in place of the `%` and the digits: the first digit is the least number of places before the decimal point (zeros are added in front; 0 gives as many as the value needs), and the second digit sets the places after it, rounded. Unless it is inside a group that clips or has its own opacity or appearance, or inside a blend, compound shape, envelope, repeat or intertwined objects, the type keeps its size and is drawn once per column in a repeating design. The legend swatch leaves it out. @@ -1206,6 +1206,7 @@ applies to fills). Tests: `color::gradient::tests` (perceptual midpoint, expansi | Date | Change | Summary | |---|---|---| +| 2026-10-30 | minor | Tools: Object › Path › Average & Join… (`path.averageJoin`, Cmd+Alt+Shift+J) moves two open path ends to their midpoint and joins them there, the joined anchor a corner or a smooth point as its dialog's Points choice asks, in one undo step; evidence added; scores and hours unchanged (estimated). | | 2026-10-30 | minor | UI chrome: G12: Preferences audit (#394): 5 options are stored but not acted on (Open Documents As Tabs, Units › East Asian Type, Hyphenation › Default Language, Scratch Disks, Legacy vector clipboard), each waiting on a subsystem; Highlight Alternate Glyphs, Real-time Drawing and the Devices options act; evidence added; score and hours unchanged (estimated). | | 2026-10-30 | minor | Print, colour management, separations: Separations Preview's plates apply to placed and embedded raster images, a CMYK image's own inks included (#4153); evidence added; score and hours unchanged (estimated). | | 2026-10-30 | minor | Colour, gradients & mesh: several gradient mesh points can be picked (Shift-clicks with the Mesh tool and Direct Selection, Direct Selection's marquee, its click on a mesh line or inside a patch); a drag or the arrow keys move them all (`object.mesh.movePoints`), and a solid fill colour or the Transparency panel's opacity goes to each of them (#4207, #4208, #4170); scores unchanged. | diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 0464fc1f51..83749a120f 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (G12: Preferences audit (#394): 5 options are stored but not acted on (Open Documents As Tabs, Units › East Asian Type, Hyphenation › Default Language, Scratch Disks, Legacy vector clipboard), each waiting on a subsystem; Highlight Alternate Glyphs, Real-time Drawing and the Devices options act; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Average & Join with a corner or smooth choice, Cmd+Alt+Shift+J; one row done; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x) ## Feature submission evidence @@ -95,7 +95,7 @@ tools, never checked side by side) isn't captured row by row. | Pencil: Fidelity, Keep selected, Alt to Smooth, edit selected paths, close by proximity | done | Fidelity goes down to 0.01 pt in the dialog, the tool and `path.freehand` (the Smooth tool keeps 0.05); its slider runs across the Tool Options row on a logarithmic rail from 0.01 to 20 pt, the field shows hundredths, and the slider's and the field's arrow keys step hundredths up to 0.1 pt, tenths up to 1 pt and whole points above (Shift ×10) (#3328); Alt key toggles to Smooth Tool (#2001); Shift held at the press draws a straight line at 45° steps from the Constrain Angle, and Alt held at the press (with Alt key toggles to Smooth Tool off) a straight line at any angle (#3799), with a straight-line cursor while Shift or Alt is held before the press, and a path-continuation cursor over an end of a selected open path, where the line continues the path; Edit Selected Paths continues a selected path from an end and, from a stroke that starts and ends on a selected path, redraws the section between (the shorter way round a closed path, #2850); with Keep selected (Pencil and Paintbrush, on by default) off, the path a stroke draws or continues is not selected afterwards; a filled Pencil path keeps a stroke of None (#1804, part of #1679); while a freehand stroke is drawn back to within Close Paths When Ends Are Within of its start, the Pencil and the Paintbrush show the closing cursor, and a release there closes the path | | Pencil: Fidelity, Keep selected, Alt to Smooth, edit selected paths, close by proximity | done | Alt key toggles to Smooth Tool (#2001); Shift held at the press draws a straight line at 45° steps from the Constrain Angle, and Alt held at the press (with Alt key toggles to Smooth Tool off) a straight line at any angle (#3799), with a straight-line cursor while Shift or Alt is held before the press, and a path-continuation cursor over an end of a selected open path, where the line continues the path; Edit Selected Paths continues a selected path from an end and, from a stroke that starts and ends on a selected path, redraws the section between (the shorter way round a closed path, #2850); with Keep selected (Pencil and Paintbrush, on by default) off, the path a stroke draws or continues is not selected afterwards; a filled Pencil path keeps a stroke of None (#1804, part of #1679); while a freehand stroke is drawn back to within Close Paths When Ends Are Within of its start, the Pencil and the Paintbrush show the closing cursor, and a release there closes the path; a Pencil stroke from an end of one selected open path to an end of another connects the two into one path | | Join tool scrubbing, Average, Join | done | Join merges the direct-selected anchors lying on one another along a path, as after Average, into one (#1533) | -| Average and Join in one step, with a corner or smooth choice for the joined anchor | partial | `path.join` accepts `to: corner|smooth` on the merged anchor; Average and Join are still separate commands; [gap 1](gaps.md) | +| Average and Join in one step, with a corner or smooth choice for the joined anchor | done | Object › Path › Average & Join… (`path.averageJoin`, Cmd+Alt+Shift+J, "Create corner or smooth join" in [Default keyboard shortcuts](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)): two open path ends meet at their midpoint and join, a corner or smooth point as the dialog's Points choice asks (Corner first, then the last choice), in one undo step | | Smooth tool smooths only the stretch of path under the drag | done | #1512 | | Drawing modes apply to pastes: Draw Inside takes Paste, Paste in Place and Paste on All Artboards inside the object; Draw Behind puts Paste in Place and Paste on All Artboards behind the selection; Shift+D cycles past Draw Behind with any selection ([drawing modes](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/learn-drawing-basics/drawing-modes-overview.html)) | done | #3705; `pasting_in_draw_inside_puts_the_copies_inside_the_object`, `paste_in_place_in_draw_behind_goes_behind_the_selection`, `shift_d_goes_past_draw_behind_whatever_is_selected` | | Simplify (slider, auto, corner angle threshold), of a whole path or of the part of it selected with Direct Selection ([manually simplify paths](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-paths/manually-simplify-paths.html)) | done | Tolerance, default-on Preview and original/new point counts (#1272); Corner Point Angle Threshold, Convert to Straight Lines and Show Original Path; the slider under the selection with Auto-Simplify and More Options, opening at the Auto-Simplify level for the selection with that result previewed, and the dialog's option to open it directly with its last settings. With anchors or segments direct-selected, the slider, Auto-Simplify and the dialog refit only each run of selected segments between its end anchors, a closed path's run across its start point included; the rest of the path stays exactly as it was (`tests/simplify_part.rs`, `simplify_slider_and_dialog_simplify_only_the_direct_selected_part_of_a_path`) | @@ -361,6 +361,7 @@ separate. Scores and hours unchanged. [Behavior and command details](development | Date | Change | Summary | |---|---|---| +| 2026-10-30 | minor | Object › Path › Average & Join… (`path.averageJoin`, Cmd+Alt+Shift+J) moves two open path ends to their midpoint and joins them there, the joined anchor a corner or a smooth point as its dialog's Points choice asks, in one undo step; one row done; scores and estimates unchanged. | | 2026-10-30 | minor | G12: Preferences audit (#394): 5 options are stored but not acted on (Open Documents As Tabs, Units › East Asian Type, Hyphenation › Default Language, Scratch Disks, Legacy vector clipboard), each waiting on a subsystem; Highlight Alternate Glyphs, Real-time Drawing and the Devices options act; scores and estimates unchanged | | 2026-10-30 | minor | Preferences: the workspace, panels, toolbars and other UI settings are saved within 2 seconds of a change instead of only on quitting, and a window saves only what it changed, merged into the file as another VectorCraft window left it, so a second window closing last no longer puts back the settings it started with (#4625). Tests `prefs::tests` in `apps/vectorcraft`; scores and estimates unchanged | | 2026-10-30 | minor | Character panel menu › Show Snap to Glyph Options shows the Snap to Glyph section (Baseline, x-height, Glyph Bounds, Proximity Guides, Angular Guides, Anchor Point; `view.snapToGlyph.options`) (#4232); scores and estimates unchanged | From 859de8b03b0be0b343fca22450061456b8d9d4ef Mon Sep 17 00:00:00 2001 From: bflatastic Date: Fri, 30 Oct 2026 06:46:37 +0700 Subject: [PATCH 013/163] Direct Selection: a marquee over part of a segment selects it (#4654) --- crates/tools/src/direct.rs | 43 +++++++++++++++++++++++++++++++- crates/tools/src/direct/tests.rs | 22 ++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/crates/tools/src/direct.rs b/crates/tools/src/direct.rs index cba1c40b98..6fe4819c94 100644 --- a/crates/tools/src/direct.rs +++ b/crates/tools/src/direct.rs @@ -530,6 +530,28 @@ fn anchors_json(v: &[AnchorRef]) -> Value { Value::Array(v.iter().map(|(s, a)| json!([s, a])).collect()) } +/// The segments of `path` that marquee `r` crosses with neither of their anchors inside it, as +/// (subpath, segment) pairs: the reference app selects a segment that a marquee is dragged "over +/// part of" (). +fn crossed_segments(path: &PathData, r: Rect) -> Vec { + let mut out = vec![]; + for (si, sp) in path.subpaths.iter().enumerate() { + let n = sp.anchors.len(); + let count = if sp.closed { n } else { n.saturating_sub(1) }; + for seg in 0..count { + let (Some(a), Some(b)) = (sp.anchors.get(seg), sp.anchors.get((seg + 1) % n)) else { continue }; + if r.contains(a.p) || r.contains(b.p) { + continue; + } + let piece = PathData::single(vectorcraft_geom::SubPath::new(vec![a.clone(), b.clone()], false)); + if vectorcraft_geom::hit::intersects_rect(&piece, r) { + out.push((si, seg)); + } + } + } + out +} + /// A segment of a path under the pointer. struct SegmentHit { si: usize, @@ -1412,10 +1434,29 @@ impl DirectSelectionTool { } } sel.retain(|(id, _)| editable(*id)); + // Direct Selection: a segment the marquee crosses with neither of its anchors inside it is + // selected, as a click on it selects it (#4654). + let mut crossed: Vec<(NodeId, Vec)> = vec![]; + if !self.group { + walk_pickable(cx.doc, cx.isolation, |n| { + if let NodeKind::Path { path, .. } = &n.kind + && editable(n.id) + { + let segs = crossed_segments(path, r); + if !segs.is_empty() { + crossed.push((n.id, segs)); + } + } + }); + } self.frame = marked; let items: Vec = sel.iter().map(|(id, v)| json!({"id": id.0, "anchors": anchors_json(v)})).collect(); let art = Action::Exec("select.anchorsMany".into(), json!({"items": items, "mode": if toggle { "toggle" } else { "set" }})); - let mut out: Vec = std::iter::once(art).chain(crate::rulerguide::marquee_select(cx, r, false)).collect(); + let mode = if toggle { "toggle" } else { "add" }; + let segments = crossed + .iter() + .map(|(id, segs)| Action::Exec("select.segments".into(), json!({"id": id.0, "segments": anchors_json(segs), "mode": mode}))); + let mut out: Vec = std::iter::once(art).chain(segments).chain(crate::rulerguide::marquee_select(cx, r, false)).collect(); if !self.frame.is_empty() { out.push(Action::Notify(FRAME_PICKED.into())); } diff --git a/crates/tools/src/direct/tests.rs b/crates/tools/src/direct/tests.rs index d191085091..d3f394d99f 100644 --- a/crates/tools/src/direct/tests.rs +++ b/crates/tools/src/direct/tests.rs @@ -565,6 +565,28 @@ fn marquee_selects_anchors() { assert_eq!(a, vec![Action::Exec("select.anchorsMany".into(), json!({"items": [{"id": id.0, "anchors": [[0, 1]]}], "mode": "set"}))]); } +/// #4654: a marquee over part of a segment, with neither of its anchors inside, selects that +/// segment as a click on it does; with Shift it toggles it. Group Selection selects objects. +#[test] +fn a_marquee_over_part_of_a_segment_selects_it() { + let (d, id) = doc_with_rect(); + let (s, p) = (Selection::default(), paint()); + let cx = cx(&d, &s, &p); + // Across the middle of the square's top edge, (100, 100)–(200, 100). + let drag = |t: &mut DirectSelectionTool, m: Mods| { + t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 140.0, 80.0).with_mods(m)); + t.pointer(&cx, &PointerEvent::new(PointerKind::Drag, 160.0, 120.0).with_mods(m)); + t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 160.0, 120.0).with_mods(m)) + }; + let segment = |mode: &str| Action::Exec("select.segments".into(), json!({"id": id.0, "segments": [[0, 0]], "mode": mode})); + let mut t = DirectSelectionTool::new(false); + assert_eq!(drag(&mut t, Mods::default()), vec![Action::Exec("select.anchorsMany".into(), json!({"items": [], "mode": "set"})), segment("add")]); + let shift = Mods { shift: true, ..Mods::default() }; + assert_eq!(drag(&mut t, shift).get(1), Some(&segment("toggle"))); + let mut g = DirectSelectionTool::new(true); + assert!(!drag(&mut g, Mods::default()).iter().any(|a| matches!(a, Action::Exec(c, _) if c == "select.segments"))); +} + #[test] fn marquee_selects_ruler_guides() { let (mut d, id) = doc_with_rect(); From 8fcc58d134dc0072d45f9ab1da0cc9acb1419077 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Fri, 30 Oct 2026 06:47:27 +0700 Subject: [PATCH 014/163] Docs: a Direct Selection marquee selects the segments it crosses (#4654) --- docs/target-app-parity.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 2da678317e..3f16df15ad 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1,6 +1,6 @@ # Parity with Adobe Illustrator -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Tools: Average & Join with a corner or smooth choice, Cmd+Alt+Shift+J; scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Direct Selection: a marquee over part of a path segment, with neither of its anchors inside, selects the segment (#4654); scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026) ## Feature submission evidence @@ -638,6 +638,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Shaper:** uneven squares and rectangles become live rectangles even when drawing begins mid-edge. Recognition uses uniformly spaced samples and closed-loop corners, fits rectangle edges/angles rather than requiring a nearly perfect bounding-box fill, and includes the pointer-release position. Rectangles/squares and ellipses snap to 45° steps, hexagons to 90°, and triangles point up or down; lines keep their free angle even with Shift. Shaper Groups retain the live originals, merge regions with the gesture-origin fill, punch fills independently from strokes, remove boundaries on exiting scribbles and trim protruding stroke pieces. Source moves/resizes re-evaluate the result in the same undo step; double-click enters construction editing, and with the Shaper or Selection tool a click on the arrow widget beside a Shaper Group's original shapes switches the group between Face Selection and Construction mode. Native save/reopen, face recoloring, Release and Expand are covered. Finer gesture heuristics remain. In Construction mode, a Selection-tool drag that drops an original shape wholly outside the bounds of the group's original shapes takes it out of the group in the move's undo step (Remove from Shaper Group, `shaper.releaseSource`): the shape becomes a path above the group and stays selected, and a group left with no shapes is removed. Engine tests drag a shape out of a two-shape group and back across the bounds, take the last shape out, undo, and save the result. - **Selection:** Selection, Direct/Group Selection, Magic Wand, Lasso. A Shift-drag marquee toggles what it reaches: objects with the Selection tool, anchors with Direct and Group Selection (#483); the Lasso adds with Shift and subtracts with Alt. Dragging a path segment with Direct Selection bends it when it's curved (its anchors stay) and moves its two anchors when it's straight, one undo step; the fill, Shift or Alt still pick the whole path (Alt-drag copies it). + A Direct Selection marquee over part of a segment, with neither of its anchors inside, selects that segment as a click on it does (Shift toggles it), as [Selecting objects](http://web.archive.org/web/20211230015528/https://helpx.adobe.com/illustrator/using/selecting-objects.html) describes (#4654). With the Selection or Group Selection tool, pressing E while dragging a marquee makes the marquee select only the objects that lie entirely inside it. Pressing E again switches the marquee back to its default selection. The Lasso picks anchor points only on art a click can pick, and the Add Anchor Point, Delete Anchor Point, Anchor Point and Scissors tools pick anchor points and segments only on the selected paths and on art a click can pick: not on a Shaper Group's original shapes outside Construction mode, and in isolation mode only inside the isolated group or object. Smart Guides and Snap to Point do not snap to a Shaper Group's original shapes, and the reference point of the transform tools snaps to one only when it is selected, or under the pointer in Construction mode. A marquee selects a clip group, or an object on a layer with a clipping mask, only when it reaches the area inside the clipping path, and it measures the art only within that path's bounds. Within the bounds of a mask that is not a rectangle, it can still select art that the mask hides. Direct Selection's marquee still selects the hidden anchor points inside it (#2345). @@ -1206,6 +1207,7 @@ applies to fills). Tests: `color::gradient::tests` (perceptual midpoint, expansi | Date | Change | Summary | |---|---|---| +| 2026-10-30 | minor | Direct Selection: a marquee over part of a path segment, with neither of its anchors inside, selects the segment (#4654); scores unchanged | | 2026-10-30 | minor | Tools: Object › Path › Average & Join… (`path.averageJoin`, Cmd+Alt+Shift+J) moves two open path ends to their midpoint and joins them there, the joined anchor a corner or a smooth point as its dialog's Points choice asks, in one undo step; evidence added; scores and hours unchanged (estimated). | | 2026-10-30 | minor | UI chrome: G12: Preferences audit (#394): 5 options are stored but not acted on (Open Documents As Tabs, Units › East Asian Type, Hyphenation › Default Language, Scratch Disks, Legacy vector clipboard), each waiting on a subsystem; Highlight Alternate Glyphs, Real-time Drawing and the Devices options act; evidence added; score and hours unchanged (estimated). | | 2026-10-30 | minor | Print, colour management, separations: Separations Preview's plates apply to placed and embedded raster images, a CMYK image's own inks included (#4153); evidence added; score and hours unchanged (estimated). | From bef094a12187c0e5b35eca9ea1405206b2b7278d Mon Sep 17 00:00:00 2001 From: bflatastic Date: Fri, 30 Oct 2026 07:13:13 +0700 Subject: [PATCH 015/163] Direct Selection: copy the segment's anchors (clippy) --- crates/tools/src/direct.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/tools/src/direct.rs b/crates/tools/src/direct.rs index 6fe4819c94..623d2b5c5c 100644 --- a/crates/tools/src/direct.rs +++ b/crates/tools/src/direct.rs @@ -543,7 +543,7 @@ fn crossed_segments(path: &PathData, r: Rect) -> Vec { if r.contains(a.p) || r.contains(b.p) { continue; } - let piece = PathData::single(vectorcraft_geom::SubPath::new(vec![a.clone(), b.clone()], false)); + let piece = PathData::single(vectorcraft_geom::SubPath::new(vec![*a, *b], false)); if vectorcraft_geom::hit::intersects_rect(&piece, r) { out.push((si, seg)); } From 494de9dfa2254e7df7a9bb8b3abd1fb924f2863b Mon Sep 17 00:00:00 2001 From: bflatastic Date: Fri, 30 Oct 2026 07:55:16 +0700 Subject: [PATCH 016/163] Guides: a ruler guide shows while dragged with Real-time Drawing off (#4646) With Preferences > Performance > Real-time Drawing and Editing off, tool previews are deferred to the release, so a guide dragged out of a ruler (guide.add) or moved with a selection tool (guide.move) showed only its position label until the button was released. Guide previews now always apply as the guide is dragged: the guide is all such a drag shows. #4646's units and guides lost on reopen don't reproduce for a native file: a new millimetre document's ruler guides and units survive Save, Close and Open in .vectorcraft, PDF, .ai and EPS (new regression test, and live in the app with Background Save). An SVG saved without Preserve Editing reopens in pixels with no guides, as the reporter saw. --- crates/engine/src/tests/prefs.rs | 17 +++++++++++++++ crates/engine/src/tests/save.rs | 22 ++++++++++++++++++++ crates/engine/src/tooling.rs | 5 +++-- crates/ui-egui/src/canvas/tests.rs | 33 ++++++++++++++++++++++++++++++ docs/target-app-parity.md | 4 +++- 5 files changed, 78 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/tests/prefs.rs b/crates/engine/src/tests/prefs.rs index 8ae55a084a..d2123ef87e 100644 --- a/crates/engine/src/tests/prefs.rs +++ b/crates/engine/src/tests/prefs.rs @@ -1616,6 +1616,23 @@ fn real_time_drawing_off_skips_tool_previews_until_commit() { assert!(s.doc().unwrap().revision > rev, "on again: previews run while dragging"); } +/// #4646: with Real-time Drawing off, a ruler guide moved with the Selection tool still moves +/// while it is dragged (the guide is all the drag shows). +#[test] +fn real_time_drawing_off_still_shows_a_dragged_guide() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap(); + s.execute("guide.add", &json!({"vertical": true, "pos": 100})).unwrap(); + let v = ViewInfo::default(); + s.select_tool("selection", v).unwrap(); + set_pref(&mut s, "realTimeDrawing", json!(false)); + s.pointer(&PointerEvent::new(PointerKind::Down, 100.0, 200.0), v).unwrap(); + s.pointer(&PointerEvent::new(PointerKind::Drag, 150.0, 200.0), v).unwrap(); + assert_eq!(s.doc().unwrap().doc.guides[0].pos, 150.0, "the guide moves while dragged"); + s.pointer(&PointerEvent::new(PointerKind::Up, 150.0, 200.0), v).unwrap(); + assert_eq!((s.doc().unwrap().doc.guides[0].pos, s.doc().unwrap().history.undo.last().map(|e| e.label.as_str())), (150.0, Some("Move Guide"))); +} + /// Real-time Drawing turned on mid-drag still applies the deferred preview on commit. #[test] fn real_time_drawing_turned_on_mid_drag_still_commits_deferred_preview() { diff --git a/crates/engine/src/tests/save.rs b/crates/engine/src/tests/save.rs index 842aec4aae..e562482d0c 100644 --- a/crates/engine/src/tests/save.rs +++ b/crates/engine/src/tests/save.rs @@ -562,3 +562,25 @@ fn eps_save_bounds_large_page_preview_without_cropping_vector_or_editing_data() assert_eq!(native.artboards, s.doc().unwrap().doc.artboards); assert_eq!(native.layers, s.doc().unwrap().doc.layers); } + +/// #4646: a new document's units and ruler guides survive Save, Close and Open in every format +/// that carries the whole document (an SVG keeps them only with Preserve Editing). +#[test] +fn units_and_ruler_guides_survive_save_and_reopen() { + let d = dir("units-guides"); + for ext in ["vectorcraft", "pdf", "ai", "eps"] { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 200, "height": 100, "units": "Millimeters"})).unwrap(); + s.execute("guide.add", &json!({"vertical": true, "pos": 50})).unwrap(); + s.execute("guide.add", &json!({"vertical": false, "pos": 30})).unwrap(); + rect(&mut s); + let p = path(&d, &format!("a.{ext}")); + s.execute("document.save", &json!({"path": p})).unwrap(); + s.execute("file.close", &json!({})).unwrap(); + s.execute("document.open", &json!({"path": p})).unwrap(); + let doc = &s.doc().unwrap().doc; + let guides: Vec<_> = doc.guides.iter().map(|g| (g.vertical, g.pos)).collect(); + assert_eq!((doc.units, guides), (vectorcraft_doc::Unit::Millimeters, vec![(true, 50.0), (false, 30.0)]), "{ext}"); + } + let _ = std::fs::remove_dir_all(d); +} diff --git a/crates/engine/src/tooling.rs b/crates/engine/src/tooling.rs index b991ad2193..13a7c28623 100644 --- a/crates/engine/src/tooling.rs +++ b/crates/engine/src/tooling.rs @@ -743,8 +743,9 @@ impl Session { Action::Begin(label) => self.begin_interaction(&label)?, Action::Preview(cmd, p) => { // Performance › Real-time Drawing and Editing (#394): off, remember the latest - // params and apply them once on Commit instead of every move. - if !self.prefs.real_time_drawing { + // params and apply them once on Commit instead of every move. A ruler guide + // being dragged still shows: the guide is all there is to see (#4646). + if !self.prefs.real_time_drawing && !matches!(cmd.as_str(), "guide.add" | "guide.move") { self.clear_deferred_overlay_cache(); let st = self.doc_mut()?; if let Some(it) = &mut st.interaction { diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 110e3bd5c4..c82c528cdd 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -1032,6 +1032,39 @@ fn a_drag_from_a_ruler_onto_the_canvas_makes_a_guide() { assert_eq!(app.session.active().unwrap().doc.art_bounds(), None, "the tool drew nothing"); } +/// #4646: a guide dragged out of a ruler shows as a line across the canvas while it is dragged, +/// also with Preferences › Performance › Real-time Drawing and Editing off (only its position +/// label showed then). +#[test] +fn a_guide_dragged_out_of_a_ruler_shows_while_dragged() { + for real_time in [true, false] { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.session.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + app.session.execute("prefs.set", &json!({"key": "realTimeDrawing", "value": real_time})).unwrap(); + app.ui.view.rulers = true; + app.ui.view.smart_guides = false; + app.ui.view.snap_to_point = false; + let ctx = egui::Context::default(); + frame(&mut app, &ctx, vec![]); + let rect = app.canvas_rect.unwrap(); + let zoom = app.view().unwrap().zoom as f32; + let from = pos2(rect.center().x, rect.top() - RULER / 2.0); + let at = pos2(rect.center().x, rect.top() + 120.0); + let button = |pos, pressed| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(from)]); + frame(&mut app, &ctx, vec![button(from, true)]); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(at)]); + // A horizontal line across the canvas at the pointer (snapped to a whole point at most). + let across = |s: &Shape| { + matches!(s, Shape::LineSegment { points, .. } + if (points[0].y - at.y).abs() <= zoom && points[0].y == points[1].y && (points[1].x - points[0].x).abs() >= rect.width() - 0.5) + }; + assert!(shapes(&mut app, &ctx).iter().any(across), "real-time drawing {real_time}: the guide shows while dragged"); + frame(&mut app, &ctx, vec![button(at, false)]); + assert_eq!(app.session.active().unwrap().doc.guides.len(), 1, "real-time drawing {real_time}: released, it is made"); + } +} + #[test] fn new_ruler_guides_follow_alt_through_preview_release_and_undo() { use egui::{Event, Modifiers}; diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 3f16df15ad..f8493a0de1 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1,6 +1,6 @@ # Parity with Adobe Illustrator -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (Direct Selection: a marquee over part of a path segment, with neither of its anchors inside, selects the segment (#4654); scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (UI chrome: with Real-time Drawing and Editing off, a ruler guide shows while it is dragged (#4646); scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026) ## Feature submission evidence @@ -601,6 +601,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Preferences that act (#394, in part): Show Tool Tips, Double Click To Isolate, Zoom with Mouse Wheel (the wheel zooms about the pointer, Shift-wheel scrolls up and down, Cmd/Ctrl-wheel sideways; Alt/Option-wheel and a trackpad pinch zoom about the pointer either way), Use Precise Cursors; Selection & Anchor Display › Tolerance (objects, anchors and handles), Object Selection by Path Only, Command Click to Select Objects Behind (cycling down the stack), Zoom to Selection, anchor Size, Highlight anchors on mouse over; Type › Number of Recent Fonts (up to 15); Guides & Grid › guide and grid Color and Style (lines or dots) and Grids In Back. Then Snap to Point (its distance, for moves, drawn points and reference points), Move Locked and Hidden Artwork with Artboard, Enable Rubber Band for the Pen and Curvature tools, Handles style, Show handles when multiple anchors are selected, Hide Corner Widget for angles greater than; General › Transform Pattern Tiles (the transforms' and dialogs' Transform Patterns, Align and Distribute, art moved or duplicated with an artboard, and objects moved whole with direct-selected anchors) and Select Same Tint %; Type › Size/Leading, Tracking and Baseline Shift increments (`type.step`, Cmd+Shift+. and Cmd+Shift+, for the size, the Type tool's Alt+arrows), Enable Missing Glyph Protection and Fill New Type Objects With Placeholder Text. Then Smart Guides › Color, Alignment Guides, Anchor/Path Labels, Measurement Labels, Transform Tools, Object Highlighting (with Smart Guides on) and Snapping Tolerance (4 px by default, for every smart guide snap), then Construction Guides and their Angles (#506: a drawn point near a line at one of those angles through the point it leaves from lands on it). Then Type › Type Object Selection by Path Only (type is picked on the baseline of any of its lines, area type's frame or the path of type on a path, no longer anywhere in its bounds; the Type tools and the Eyedropper still take a click among the characters). Then General › Anti-aliased Artwork (off, the canvas draws the art with hard edges). Then Guides & Grid › Show Pixel Grid (Above 600% Zoom), a line at every document pixel over the art in Pixel Preview, turning with a rotated view as the document grid now does too. Then General › Show The Home Screen When No Documents Are Open (off, closing the last document leaves an empty window; the Home button still opens the screen). Then Units › Numbers Without Units Are Points (on by default: a number typed with no unit into a field in picas is read in points, a typed unit still wins; dimmed unless a unit is Picas). Then User Interface › Auto-Collapse Iconic Panels (off by default: on, a click away from a panel popped out of the icon column puts it away). Then Performance › Animated Zoom (on, with GPU Performance, which it needs and which dims it when off: the Zoom tool dragged sideways zooms about the press, right in and left out, and held still zooms on, Alt out; off, a drag zooms to the area dragged across, now drawn as a marquee), User Interface › Large Tabs (taller document tabs) and Scale Cursor Proportional to UI (off, the tool cursors keep their size whatever the UI Scaling), and File Handling › Display Bitmaps as Anti-aliased Images in Pixel Preview (off by default: Pixel Preview draws images with each pixel taking its nearest image pixel). Type › Auto Size New Area Type works too (new area type gets Auto Size). They reach agents too (`prefs.set`, then `pointer_gesture` or `press_key`; `ui.wheel` on the control channel). Then Smart Guides › Spacing Guides (moves space the selection evenly with its row or column, see Drawing aids). Then Hyphenation › Exceptions (comma-separated words that never break, or break only at their hyphens; `prefs.set` and restore push them into the hyphenator, #394). Then Type › Show Font Names in English (off, font menus label a family by its native-language name when the font has one; documents still use the English family, #394). Then General › Display Print Size at 100% Zoom (off by default: View › Actual Size is one document point per screen point; on, one document inch fills 96 screen points, an inch at the reference density display scaling is set against; `view.actualSize` / `prefs.set`, #394). Then Guides & Grid › Gridline every and Subdivisions (changing either sets the grid of every open document; new and opened documents take that grid too, except a native file and the native document an SVG, PDF, `.ai` or EPS file carries, which open with the grid they were saved with; `file.new`, `document.open`, `file.newFromTemplate`, `file.revert`, #394). Then Appearance of Black › On Screen (Display All Blacks Accurately by default: pure CMYK black shows through the CMYK profile, a dark grey; Display All Blacks as Rich Black shows it on the canvas as RGB black, also in CMYK documents drawn by ink planes, while rich blacks, black tints and images show as before; `RenderOptions::rich_black`, #394). Then Appearance of Black › Printing / Exporting (Output All Blacks Accurately by default; Output All Blacks as Rich Black draws pure CMYK black as RGB black in RGB raster exports and Print as Bitmap; CMYK ink exports and the document stay unchanged; `prefs.blackOutput` / `richBlack`, #394). Then Units › Identify Objects By (Object Name by default: Layers, Variables and Layer Options show and edit free names; XML ID shows and edits AI-style XML ids, `_` for a space and `_xHH_` escapes, and `layer.setProps` / rename refuse invalid ids; the document still stores the object name, #394). Five stored options still do nothing yet (the audit below). - Preferences › Type › Highlight Substituted Fonts (on by default) paints pink behind text drawn in a substitute for a missing font in every document, and turning it off removes that highlight everywhere (`prefs.set highlightSubstitutedFonts`); Document Setup keeps Highlight Substituted Glyphs ([help](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/edit-text-without-replacing-missing-fonts.html)). - Preferences audit (2026-10-30, #394): every Preferences dialog option is read by shipped code, by its field or its key, except User Interface › Open Documents As Tabs, Units › East Asian Type, Hyphenation › Default Language, Plug-ins & Scratch Disks › Primary and Secondary, and Clipboard Handling › Legacy vector clipboard and its mode, which are stored only; [gaps.md G12](gaps.md#g12-preferences-and-panels-that-dont-act-yet) says what each waits on. + - Performance › Real-time Drawing and Editing off defers a drag's edits to its release, but a ruler guide dragged out of a ruler or moved still shows as it is dragged, where only its position label showed (#4646; `a_guide_dragged_out_of_a_ruler_shows_while_dragged`, `real_time_drawing_off_still_shows_a_dragged_guide`). - Dialogs move by dragging their heading (the band down from the top edge, as a title bar), stay on screen and keep where they were moved for the session; the form dialogs' choices are dropdowns (Offset Path's Joins, Average's and Shear's and Reflect's axis), and Offset Path lists Offset, Joins, Miter Limit and previews (#423). - Dialogs open with their first field focused and its value selected: type a value and press Enter (Move, Rotate, Scale…). A dialog opened from a menu takes the keyboard focus every time it opens, not only the first (#1367), and one whose first field starts greyed out (Blend Options on Smooth Color, Layers Panel Options) gives the focus to that field once it is enabled (#1395). Number fields in panels, the Control bar and dialogs (preferences too) step with Up/Down, or with the mouse wheel over the focused field (#485: a notch a step; the panel under it then stays put, and an unfocused field leaves the wheel to scrolling) (Shift: ten, Ctrl/Cmd: a tenth of their unit), applied at once. - While Alt (Option on macOS) is held, the Flare Tool Options' Cancel button reads Reset, which puts every option back to the Flare tool's default and leaves the dialog open (`ui.dialogReset`). @@ -1207,6 +1208,7 @@ applies to fills). Tests: `color::gradient::tests` (perceptual midpoint, expansi | Date | Change | Summary | |---|---|---| +| 2026-10-30 | minor | UI chrome: with Preferences › Performance › Real-time Drawing and Editing off, a ruler guide dragged out of a ruler or moved shows while it is dragged (#4646); evidence added; score and hours unchanged (estimated). | | 2026-10-30 | minor | Direct Selection: a marquee over part of a path segment, with neither of its anchors inside, selects the segment (#4654); scores unchanged | | 2026-10-30 | minor | Tools: Object › Path › Average & Join… (`path.averageJoin`, Cmd+Alt+Shift+J) moves two open path ends to their midpoint and joins them there, the joined anchor a corner or a smooth point as its dialog's Points choice asks, in one undo step; evidence added; scores and hours unchanged (estimated). | | 2026-10-30 | minor | UI chrome: G12: Preferences audit (#394): 5 options are stored but not acted on (Open Documents As Tabs, Units › East Asian Type, Hyphenation › Default Language, Scratch Disks, Legacy vector clipboard), each waiting on a subsystem; Highlight Alternate Glyphs, Real-time Drawing and the Devices options act; evidence added; score and hours unchanged (estimated). | From 0f1b70f8b176d53efcb91d9ac4dd50009e57f29c Mon Sep 17 00:00:00 2001 From: Don Omondi <282319807+mockydevs@users.noreply.github.com> Date: Fri, 30 Oct 2026 03:22:31 +0300 Subject: [PATCH 017/163] .ai import: a PDF part cropped to the art no longer hides the layers A PDF-compatible .ai whose PDF part's pages are cropped to its art (each page the box of all the art, the editing data's bounding box) rather than to its artboards came in as that PDF part: the editing data's artboard wasn't the page's size, so its layers were refused. With several artboards every page held all the art, so the document had a copy of everything per page. When the artboard isn't the page's size but the editing data's bounding box is, the layers are compared with the page on that box and keep their artboards. The comparison of their art with the page still decides whether they are used. --- .../engine/src/cmd/fileio/tests_aiimport.rs | 21 +++++++++++++++++++ crates/eps/src/import/native/build.rs | 14 +++++++++++-- crates/eps/src/import/tests_native.rs | 11 ++++++++-- crates/testkit/src/ai.rs | 12 +++++++++-- docs/file-format-parity.md | 5 +++-- 5 files changed, 55 insertions(+), 8 deletions(-) diff --git a/crates/engine/src/cmd/fileio/tests_aiimport.rs b/crates/engine/src/cmd/fileio/tests_aiimport.rs index 3f0dce5c15..a51c1f5904 100644 --- a/crates/engine/src/cmd/fileio/tests_aiimport.rs +++ b/crates/engine/src/cmd/fileio/tests_aiimport.rs @@ -535,6 +535,27 @@ fn an_ai_file_whose_pdf_part_is_only_text_still_opens_from_editing_data_that_rea check_sample(&s); } +#[test] +fn an_ai_file_whose_pdf_part_is_cropped_to_its_art_opens_from_its_layers() { + // A 400 × 200 pt artboard with two red bars across (100, 50)–(300, 150). The PDF part's page + // is that art's box, 200 × 100 pt (the editing data's bounding box), not the artboard. + let red = "0 1 1 0 1 0 0 Xa\n"; + let art = ai::layer("Art", &format!("{red}{}f\n{red}{}f\n", ai::rect(100.0, 50.0, 180.0, 150.0), ai::rect(220.0, 50.0, 300.0, 150.0))); + let data = ai::editing_data_in([100.0, 50.0, 300.0, 150.0], [0.0, 0.0, 400.0, 200.0], &art); + let page = "1 0 0 rg 0 0 80 100 re f 120 0 80 100 re f"; + let mut s = Session::new(); + let r = open(&mut s, "cropped.ai", &ai::ai(&compressed(data.as_bytes()), page), json!({})).unwrap(); + assert!(!r["warnings"].to_string().contains("weren't read"), "{r}"); + let doc = &s.doc().unwrap().doc; + assert_eq!(names(&doc.layers), ["Art"]); + assert_eq!(doc.artboards.len(), 1); + assert_eq!(doc.artboards[0].rect, vectorcraft_geom::Rect::new(0.0, 0.0, 400.0, 200.0), "the file's artboard, not its page"); + let bars = doc.layers[0].children().unwrap(); + assert_eq!(bars.len(), 2); + let b = bars[0].geometric_bounds().unwrap(); + assert!((b.x0 - 100.0).abs() < 0.01 && (b.y0 - 50.0).abs() < 0.01, "where the artboard has it: {b:?}"); +} + #[test] fn editing_data_false_opens_only_what_the_page_prints() { let mut s = Session::new(); diff --git a/crates/eps/src/import/native/build.rs b/crates/eps/src/import/native/build.rs index 24001e8f0b..a9c0c9bf8c 100644 --- a/crates/eps/src/import/native/build.rs +++ b/crates/eps/src/import/native/build.rs @@ -79,8 +79,18 @@ pub(super) fn build_from( let page_rect = visible.artboards.first().map(|a| a.rect).ok_or("it has no page")?; // The layers' art in the document's terms: a Large Canvas editing copy is written at 1/N // scale, which `to_doc` carries, so its art and the page reach the same size (#2031). - let rect = to_doc.transform_rect_bbox(art_box); - if (rect.width() - page_rect.width()).abs() > 0.5 || (rect.height() - page_rect.height()).abs() > 0.5 { + let fits = |r: &Rect| (r.width() - page_rect.width()).abs() <= 0.5 && (r.height() - page_rect.height()).abs() <= 0.5; + let mut rect = to_doc.transform_rect_bbox(art_box); + // A `.ai` whose PDF part's pages are cropped to its art (each page the box of all of it, + // the editing data's bounding box) rather than to its artboards: the layers are compared + // with the page on that box, and keep their artboards. + if matches!(page, Page::Artboard) + && !fits(&rect) + && let Some(art) = bbox.map(|[a, b, c, d]| to_doc.transform_rect_bbox(Rect::new(a, b, c, d))).filter(fits) + { + rect = art; + } + if !fits(&rect) { // Both sizes in points as the fields show them, and the editing data's page to the // file's as a scale (1:10 is a tenth of its size) when its sides are in proportion and // the scale doesn't round to 1:1. diff --git a/crates/eps/src/import/tests_native.rs b/crates/eps/src/import/tests_native.rs index 4e1848f4fe..56bcf3fbcc 100644 --- a/crates/eps/src/import/tests_native.rs +++ b/crates/eps/src/import/tests_native.rs @@ -381,11 +381,18 @@ fn an_ai_file_that_cant_be_read_through_its_editing_data_keeps_its_pdf_part() { let (d, w, read) = crate::layered_ai(b"nothing", pdf.clone(), vec![], false, false, 1.0); assert_eq!(d.layers.len(), pdf.layers.len()); assert!(w.is_empty() && !read); - // Editing data that isn't for this page. - let other = native(&layer("Jig", true, &square(10, 10))).replace("%AI3_Cropmarks: 0 0 100 100", "%AI3_Cropmarks: 0 0 50 50"); + // Editing data that isn't for this page: neither its artboard nor its art's box is the page. + let other = native(&layer("Jig", true, &square(10, 10))).replace(" 0 0 100 100", " 0 0 50 50"); let (d, w, _) = crate::layered_ai(&private(&other), pdf.clone(), vec![], false, false, 1.0); assert_eq!(names(&d), names(&pdf)); assert!(w.iter().any(|w| w.contains("for a 50 × 50 pt page, the file's 100 × 100 pt page at 1:2")), "{w:?}"); + // A page cropped to the art's box, not the artboard, is that art's page: the layers are read, + // with their artboard. + let cropped = native(&layer("Jig", true, &square(10, 10))).replace("%AI3_Cropmarks: 0 0 100 100", "%AI3_Cropmarks: 0 0 50 50"); + let (d, w, read) = crate::layered_ai(&private(&cropped), pdf.clone(), vec![], false, false, 1.0); + assert!(read, "{w:?}"); + assert_eq!(names(&d), ["Jig"]); + assert_eq!(d.artboards[0].rect.size(), vectorcraft_geom::Size::new(50.0, 50.0)); } /// #2034: editing data for a page of another size gives both sizes in points, in an EPS's note and diff --git a/crates/testkit/src/ai.rs b/crates/testkit/src/ai.rs index b7af4b5a57..c7bbcbff1a 100644 --- a/crates/testkit/src/ai.rs +++ b/crates/testkit/src/ai.rs @@ -5,9 +5,17 @@ /// Editing data of a `width` × `height` page: header comments (the art's bounding box and the crop /// marks are the page), `body` (setup and layers), the trailer. pub fn editing_data(width: f64, height: f64, body: &str) -> String { + editing_data_in([0.0, 0.0, width, height], [0.0, 0.0, width, height], body) +} + +/// [`editing_data`] whose art's bounding box (`x0 y0 x1 y1`, art space) is `art` and whose +/// artboard (the crop marks) is `board`. +pub fn editing_data_in(art: [f64; 4], board: [f64; 4], body: &str) -> String { + let [a0, a1, a2, a3] = art; + let [b0, b1, b2, b3] = board; format!( - "{PS_HEADER}\n%%Creator: VectorCraft tests\n%%BoundingBox: 0 0 {width} {height}\n%%HiResBoundingBox: 0 0 {width} {height}\n\ - %AI5_FileFormat 14.0\n%AI3_Cropmarks: 0 0 {width} {height}\n%%EndComments\n\ + "{PS_HEADER}\n%%Creator: VectorCraft tests\n%%BoundingBox: {a0} {a1} {a2} {a3}\n%%HiResBoundingBox: {a0} {a1} {a2} {a3}\n\ + %AI5_FileFormat 14.0\n%AI3_Cropmarks: {b0} {b1} {b2} {b3}\n%%EndComments\n\ %%BeginProlog\n%%EndProlog\n%%BeginSetup\n%%EndSetup\n{body}\n%%PageTrailer\ngsave annotatepage grestore showpage\n%%Trailer\n%%EOF\n" ) } diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 945b64db4a..6f1b968721 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File format parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-29 · **Change:** minor (`.ai` and Illustrator EPS import: the editing data is read up to an eighth of installed memory, 512 MiB to 2 GiB, #3510, #4628) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (`.ai` import: a PDF part cropped to the art no longer hides the layers) · **Target:** Adobe Illustrator 2026 (30.x) Every format Illustrator opens, places, saves or exports, against VectorCraft's format table (`FORMATS`, `OPEN_EXTS`, `PLACE_EXTS` in `crates/engine/src/cmd/fileio/formats.rs`). Illustrator's list comes from its public @@ -84,7 +84,7 @@ private editing data. VectorCraft: ### Illustrator's private editing data -the app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPrivateData` streams, a PDF's `AIPDFPrivateData` streams when it was saved with the editing data (#868), Zstandard or zlib, the EPS's in ASCII85) is not documented as a whole. VectorCraft reads its structure: layers and sublayers (names, order, visibility, lock, printing, preview, dimming, colour), groups as they were nested, compound paths (painted by their last path, or the last painted one, with the paths of groups inside them kept as their paths: #1410), clipping groups and layer clipping, object names, hidden and locked objects, fills and strokes (grey, CMYK, RGB, named and spot colours, spot colours defined in Lab with their Lab values (#1032), global process colours as global swatches at their tint), linear and radial gradients, pattern fills with their patterns as pattern swatches (#1025), opacity, blend modes, isolation and knockout, embedded images where their matrix puts them, rotated ones too (#2269), with their alpha channel (CMYK images keep their ink amounts, as they do when a `.ai` opens from its PDF part, and an alpha channel that hides part of a CMYK image becomes a grayscale opacity mask), placed (linked) files as linked images in their place, each showing the low-resolution preview the file keeps of it until its file is found or relinked in the Links panel (#1264), guides, and every artboard where it is. A gradient with stops in the middle runs its whole ramp across its shape, and a gradient object does not pass its fill to the next path (#1390). An object whose art style is one fill and one stroke at most (solid colours, its own gradient, a variable-width profile) with an Outer Glow or Drop Shadow comes in as itself with them; one with more, other effects, a brush or dashes aligned to corners comes in as its drawn look (a group named after it). Type keeps its art style as a live appearance whatever its stack, so it can be retyped: each fill and stroke of the style's stack (solid colours, gradients and pattern fills, placed as the drawn look places them) with its own opacity, blend mode and effects, the effects on the whole object, and where the characters paint among them; the effects read are Warp, Offset Path, Transform (with copies), Drop Shadow, Outer Glow, Feather, Gaussian Blur and Bas Relief (its settings at their defaults), and a style with others keeps the type's drawn look. The page's drawing of such a style isn't held to look like VectorCraft's where its drawn look lay. Gradients take their matrix (`Xm`, radials and skewed ones too), focal point and the order of stops sharing a ramp point; gradient meshes, a clipping path's own fill and the artboards' names are read too. `editingData: "always"` (`convert --editing-data`) opens a `.ai` or an Illustrator EPS from its editing data even where it draws differently from its page, which can be older, with a note. Type is made from the file's text document, whole and editable, shown or not: point type (its frame's matrix, which newer files leave out when it is neither turned nor scaled, read as none), area type (a story in several frames as threaded type) and type on a path, with its characters, fonts, size, leading, tracking, scaling, baseline shift, fill and stroke (grey, RGB or CMYK), alignment, indents and paragraph spacing; the page's drawing of it (often in pieces) is left out. Where the text document can't say (a frame of another kind, or a document that doesn't agree with the page), type that shows comes from the page into its text object's place (no group around it), and hidden type is left out with a note. Kerning, underline and the other character and paragraph options aren't read yet. A `.ai` saved without PDF compatibility (a placeholder page) opens from its editing data alone, its point type, area type and type on a path made from the text document. A `.ai` whose PDF part shows only text isn't taken for that placeholder when its page states an art, trim or bleed box: it opens from its editing data alone where that reads, else from its PDF part (#1387). Text objects with an appearance keep their own text and frame, type of hidden layers stays hidden, and type on later artboards lands on its text objects (#1391); area type whose frame is too short for a line of the fallback font shows its first line (the frame is made taller, with a warning in the open result) (#1392). Symbols, pattern fills whose pattern it can't read, placed files the data keeps no preview of and anything else it doesn't read make the file come in as its page (on a layer that doesn't show, they are left out of that layer), with a warning saying what. The layers' art is also compared with the page (by lightness, so colours written as their CMYK equivalents compare alike, and by whether a pixel is inked at all); the page is used when they differ by more than 5%, where one draws an object the other doesn't (away from type, whose lines may be laid out afresh), and when an EPS whose page is its art's box has art printed outside it (#735). An EPS whose page is its art's box keeps that page when it comes in through its layers, not the editing data's artboard, and a text object counts as drawn by the page by its colours, not only its lightness, so a red stroke stacked over a dark red one stays (#1102). `textAs: "outlines"` opens a `.ai` whose type shows from its PDF part, which has the outlines; `editingData: false` opens any of them as its page or PDF part only, for print pipelines (#735). A file whose import left something out (hidden text, art or layers) is never written over by an export or Save As to its own path unless `acknowledgeLoss: true` (`convert --replace-lossy`), so the original keeps what the document lacks. Where a `.ai` can't be read that way (or its layers are turned off in the import options), we read its PDF-compatible part, so Illustrator-only live objects arrive as appearance, and plain groups arrive ungrouped: that part draws each object on its own and marks only layers, clipping groups and groups with opacity, blending or a mask (those come back). Art outside the artboards isn't in that part at all (Illustrator's PDF part leaves it out), so it doesn't open; the import says so in a note (#472). Its pages still go where the editing data puts the artboards (a grid stays a grid), with the art on each, when it has as many artboards as pages, of the same sizes (#1068). Its pages are laid out so that art one of them draws past its artboard (notes beside a design, which the part doesn't clip) doesn't lie over the page before it in the row, where it was taken for that page's art: the check against the editing data then found art its layers don't have there and opened the file as its PDF part, without the art outside the artboards. That part also has no paragraphs: area type is written line by line, and comes back as area type only where its font is installed and lays the lines out with the same breaks, else as a point type object per line (#508). Art off the page that a PDF does draw opens on the pasteboard. +the app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPrivateData` streams, a PDF's `AIPDFPrivateData` streams when it was saved with the editing data (#868), Zstandard or zlib, the EPS's in ASCII85) is not documented as a whole. VectorCraft reads its structure: layers and sublayers (names, order, visibility, lock, printing, preview, dimming, colour), groups as they were nested, compound paths (painted by their last path, or the last painted one, with the paths of groups inside them kept as their paths: #1410), clipping groups and layer clipping, object names, hidden and locked objects, fills and strokes (grey, CMYK, RGB, named and spot colours, spot colours defined in Lab with their Lab values (#1032), global process colours as global swatches at their tint), linear and radial gradients, pattern fills with their patterns as pattern swatches (#1025), opacity, blend modes, isolation and knockout, embedded images where their matrix puts them, rotated ones too (#2269), with their alpha channel (CMYK images keep their ink amounts, as they do when a `.ai` opens from its PDF part, and an alpha channel that hides part of a CMYK image becomes a grayscale opacity mask), placed (linked) files as linked images in their place, each showing the low-resolution preview the file keeps of it until its file is found or relinked in the Links panel (#1264), guides, and every artboard where it is. A gradient with stops in the middle runs its whole ramp across its shape, and a gradient object does not pass its fill to the next path (#1390). An object whose art style is one fill and one stroke at most (solid colours, its own gradient, a variable-width profile) with an Outer Glow or Drop Shadow comes in as itself with them; one with more, other effects, a brush or dashes aligned to corners comes in as its drawn look (a group named after it). Type keeps its art style as a live appearance whatever its stack, so it can be retyped: each fill and stroke of the style's stack (solid colours, gradients and pattern fills, placed as the drawn look places them) with its own opacity, blend mode and effects, the effects on the whole object, and where the characters paint among them; the effects read are Warp, Offset Path, Transform (with copies), Drop Shadow, Outer Glow, Feather, Gaussian Blur and Bas Relief (its settings at their defaults), and a style with others keeps the type's drawn look. The page's drawing of such a style isn't held to look like VectorCraft's where its drawn look lay. Gradients take their matrix (`Xm`, radials and skewed ones too), focal point and the order of stops sharing a ramp point; gradient meshes, a clipping path's own fill and the artboards' names are read too. `editingData: "always"` (`convert --editing-data`) opens a `.ai` or an Illustrator EPS from its editing data even where it draws differently from its page, which can be older, with a note. Type is made from the file's text document, whole and editable, shown or not: point type (its frame's matrix, which newer files leave out when it is neither turned nor scaled, read as none), area type (a story in several frames as threaded type) and type on a path, with its characters, fonts, size, leading, tracking, scaling, baseline shift, fill and stroke (grey, RGB or CMYK), alignment, indents and paragraph spacing; the page's drawing of it (often in pieces) is left out. Where the text document can't say (a frame of another kind, or a document that doesn't agree with the page), type that shows comes from the page into its text object's place (no group around it), and hidden type is left out with a note. Kerning, underline and the other character and paragraph options aren't read yet. A `.ai` saved without PDF compatibility (a placeholder page) opens from its editing data alone, its point type, area type and type on a path made from the text document. A `.ai` whose PDF part shows only text isn't taken for that placeholder when its page states an art, trim or bleed box: it opens from its editing data alone where that reads, else from its PDF part (#1387). Text objects with an appearance keep their own text and frame, type of hidden layers stays hidden, and type on later artboards lands on its text objects (#1391); area type whose frame is too short for a line of the fallback font shows its first line (the frame is made taller, with a warning in the open result) (#1392). Symbols, pattern fills whose pattern it can't read, placed files the data keeps no preview of and anything else it doesn't read make the file come in as its page (on a layer that doesn't show, they are left out of that layer), with a warning saying what. The layers' art is also compared with the page (by lightness, so colours written as their CMYK equivalents compare alike, and by whether a pixel is inked at all); the page is used when they differ by more than 5%, where one draws an object the other doesn't (away from type, whose lines may be laid out afresh), and when an EPS whose page is its art's box has art printed outside it (#735). An EPS whose page is its art's box keeps that page when it comes in through its layers, not the editing data's artboard, and a text object counts as drawn by the page by its colours, not only its lightness, so a red stroke stacked over a dark red one stays (#1102). `textAs: "outlines"` opens a `.ai` whose type shows from its PDF part, which has the outlines; `editingData: false` opens any of them as its page or PDF part only, for print pipelines (#735). A file whose import left something out (hidden text, art or layers) is never written over by an export or Save As to its own path unless `acknowledgeLoss: true` (`convert --replace-lossy`), so the original keeps what the document lacks. Where a `.ai` can't be read that way (or its layers are turned off in the import options), we read its PDF-compatible part, so Illustrator-only live objects arrive as appearance, and plain groups arrive ungrouped: that part draws each object on its own and marks only layers, clipping groups and groups with opacity, blending or a mask (those come back). Art outside the artboards isn't in that part at all (Illustrator's PDF part leaves it out), so it doesn't open; the import says so in a note (#472). Its pages still go where the editing data puts the artboards (a grid stays a grid), with the art on each, when it has as many artboards as pages, of the same sizes (#1068). A `.ai` whose PDF part's pages are cropped to its art (each page the box of all the art, which is the editing data's bounding box) instead of its artboards opens from its layers, with its own artboards, where they draw as that page does. Its pages are laid out so that art one of them draws past its artboard (notes beside a design, which the part doesn't clip) doesn't lie over the page before it in the row, where it was taken for that page's art: the check against the editing data then found art its layers don't have there and opened the file as its PDF part, without the art outside the artboards. That part also has no paragraphs: area type is written line by line, and comes back as area type only where its font is installed and lays the lines out with the same breaks, else as a point type object per line (#508). Art off the page that a PDF does draw opens on the pasteboard. ## Format by format @@ -131,6 +131,7 @@ the app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPri | Date | Change | Summary | |---|---|---| +| 2026-10-30 | minor | `.ai` import: a file whose PDF part's pages are cropped to its art rather than its artboards no longer comes in as that PDF part (each page a copy of all the art) but from its layers, with its artboards, where they draw as the page does; own-fixture test in `tests_aiimport`; scores unchanged | | 2026-10-29 | minor | `.ai` and Illustrator EPS import: the editing data is read up to an eighth of installed memory, from 512 MiB to 2 GiB on 64-bit builds (it was 512 MiB on every machine), so a layered file whose embedded rasters unpack past 512 MiB keeps its layers, groups and text on a machine with 8 GiB or more instead of opening as its page or PDF part (#3510, #4628). Measured: 1.1 GB of editing data peaked 1.1 GB above the start; data past the limit is still refused (a 2 MB file unpacking to 2.2 GB stops in under a second). 32-bit and web builds keep 256 MiB. Own-fixture tests `import::ai::tests::editing_data_past_512_mib_is_read_where_memory_allows`, `the_editing_data_limit_follows_installed_memory`; scores and hours unchanged | | 2026-10-29 | minor | Affinity import: attached Recolor Adjustment (RcRA) layers import as color overlays with HSL lightness (#4420); scores unchanged. | | 2026-10-30 | minor | EMF export: a pattern fill whose tiles stay apart (grid and brick tilings, art inside its tile) is written as one shape for each part of the tile, clipped once to what it fills, instead of every tile in a clip of its own; the picture is the same. A rotated two-colour stripe fill goes from 473 shapes and 246 clips to 2 shapes and 1 clip (122 KB to 61 KB; unrotated 99 KB to 33 KB). Tiles that overlap, hex tilings and tiles with strokes, images or nested clips are written as before (#3911). Tests in `crates/metafile/src/tests.rs` and `scene::merge_tests`; scores and hours unchanged | From 87cb19c5893d4913e69ba8f9e4d400f941c58ad7 Mon Sep 17 00:00:00 2001 From: Don Omondi <282319807+mockydevs@users.noreply.github.com> Date: Fri, 30 Oct 2026 08:15:16 +0700 Subject: [PATCH 018/163] .ai import: a file whose PDF part is an empty page opens from its editing data Squashed from #4651 onto main. --- crates/engine/src/cmd/fileio/load.rs | 16 +++++++++++++-- .../engine/src/cmd/fileio/tests_aiimport.rs | 20 +++++++++++++++++++ docs/file-format-parity.md | 4 +++- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/fileio/load.rs b/crates/engine/src/cmd/fileio/load.rs index cf1ecc6a8a..c1ebdf7233 100644 --- a/crates/engine/src/cmd/fileio/load.rs +++ b/crates/engine/src/cmd/fileio/load.rs @@ -197,6 +197,13 @@ fn from_editing_data_alone(bytes: &[u8], opts: &LoadOptions) -> Option bool { + let mut art = false; + doc.walk(|n| art |= !n.is_layer()); + !art +} + /// Is `e` the error of a file whose pages are only a placeholder /// ([`vectorcraft_pdf::PdfError::PlaceholderOnly`])? pub(crate) fn is_placeholder(e: &EngineError) -> bool { @@ -272,8 +279,13 @@ pub fn load_with(name: &str, bytes: &[u8], opts: &LoadOptions) -> Result restore_or_import(editing, || match super::pdfimport::import(bytes, opts, format.id != "pdf") { Ok(r) => { // Pages of text alone: the editing copy alone where it reads, as for a file - // saved without its PDF part (#1387: else the page, which is the art). - let alone = r.only_text.then(|| from_editing_data_alone(bytes, opts)).flatten().and_then(|read| read.ok()); + // saved without its PDF part (#1387: else the page, which is the art). So too + // pages that draw nothing at all: there is no page art to check the layers + // against, and the empty page would lose all of it. + let alone = (r.only_text || draws_nothing(&r.document)) + .then(|| from_editing_data_alone(bytes, opts)) + .flatten() + .and_then(|read| read.ok()); let (doc, warnings, read) = match alone { Some((doc, warnings)) => (doc, warnings, true), None => through_editing_data(bytes, opts, r.document, r.warnings, r.user_unit), diff --git a/crates/engine/src/cmd/fileio/tests_aiimport.rs b/crates/engine/src/cmd/fileio/tests_aiimport.rs index a51c1f5904..acf7d43b17 100644 --- a/crates/engine/src/cmd/fileio/tests_aiimport.rs +++ b/crates/engine/src/cmd/fileio/tests_aiimport.rs @@ -556,6 +556,26 @@ fn an_ai_file_whose_pdf_part_is_cropped_to_its_art_opens_from_its_layers() { assert!((b.x0 - 100.0).abs() < 0.01 && (b.y0 - 50.0).abs() < 0.01, "where the artboard has it: {b:?}"); } +#[test] +fn an_ai_file_whose_pdf_part_draws_nothing_opens_from_its_editing_data() { + // A PDF-compatible `.ai` whose PDF part is a page with nothing on it (no notice text either), + // with or without the boxes that say where its art is: its editing data is the art. + for boxed in ["", "/ArtBox [0 0 200 100] /TrimBox [0 0 200 100]"] { + let mut s = Session::new(); + let r = open(&mut s, "blank.ai", &ai::ai_with(&compressed(&ai::sample_data()), "", boxed), json!({})).unwrap(); + assert_eq!(r["warnings"], json!([]), "{boxed:?}: {r}"); + check_sample(&s); + // The PDF part alone, as asked: its empty page. + open(&mut s, "blank.ai", &ai::ai_with(&compressed(&ai::sample_data()), "", boxed), json!({"editingData": false})).unwrap(); + let layers = &s.doc().unwrap().doc.layers; + assert!(layers.iter().all(|l| l.children().is_none_or(|c| c.is_empty())), "{boxed:?}"); + } + // Editing data that can't be read leaves the empty page, as before. + let mut s = Session::new(); + open(&mut s, "blank.ai", &ai::ai(b"%AI24_ZStandard_Data\0\0\0\0\0\0\0\0", ""), json!({})).unwrap(); + assert_ne!(names(&s.doc().unwrap().doc.layers), ["Art", "Hidden"]); +} + #[test] fn editing_data_false_opens_only_what_the_page_prints() { let mut s = Session::new(); diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 6f1b968721..01064160bd 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File format parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (`.ai` import: a PDF part cropped to the art no longer hides the layers) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (`.ai` import: a file whose PDF part is an empty page opens from its editing data) · **Target:** Adobe Illustrator 2026 (30.x) Every format Illustrator opens, places, saves or exports, against VectorCraft's format table (`FORMATS`, `OPEN_EXTS`, `PLACE_EXTS` in `crates/engine/src/cmd/fileio/formats.rs`). Illustrator's list comes from its public @@ -84,6 +84,7 @@ private editing data. VectorCraft: ### Illustrator's private editing data +the app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPrivateData` streams, a PDF's `AIPDFPrivateData` streams when it was saved with the editing data (#868), Zstandard or zlib, the EPS's in ASCII85) is not documented as a whole. VectorCraft reads its structure: layers and sublayers (names, order, visibility, lock, printing, preview, dimming, colour), groups as they were nested, compound paths (painted by their last path, or the last painted one, with the paths of groups inside them kept as their paths: #1410), clipping groups and layer clipping, object names, hidden and locked objects, fills and strokes (grey, CMYK, RGB, named and spot colours, spot colours defined in Lab with their Lab values (#1032), global process colours as global swatches at their tint), linear and radial gradients, pattern fills with their patterns as pattern swatches (#1025), opacity, blend modes, isolation and knockout, embedded images where their matrix puts them, rotated ones too (#2269), with their alpha channel (CMYK images keep their ink amounts, as they do when a `.ai` opens from its PDF part, and an alpha channel that hides part of a CMYK image becomes a grayscale opacity mask), placed (linked) files as linked images in their place, each showing the low-resolution preview the file keeps of it until its file is found or relinked in the Links panel (#1264), guides, and every artboard where it is. A gradient with stops in the middle runs its whole ramp across its shape, and a gradient object does not pass its fill to the next path (#1390). An object whose art style is one fill and one stroke at most (solid colours, its own gradient, a variable-width profile) with an Outer Glow or Drop Shadow comes in as itself with them; one with more, other effects, a brush or dashes aligned to corners comes in as its drawn look (a group named after it). Type keeps its art style as a live appearance whatever its stack, so it can be retyped: each fill and stroke of the style's stack (solid colours, gradients and pattern fills, placed as the drawn look places them) with its own opacity, blend mode and effects, the effects on the whole object, and where the characters paint among them; the effects read are Warp, Offset Path, Transform (with copies), Drop Shadow, Outer Glow, Feather, Gaussian Blur and Bas Relief (its settings at their defaults), and a style with others keeps the type's drawn look. The page's drawing of such a style isn't held to look like VectorCraft's where its drawn look lay. Gradients take their matrix (`Xm`, radials and skewed ones too), focal point and the order of stops sharing a ramp point; gradient meshes, a clipping path's own fill and the artboards' names are read too. `editingData: "always"` (`convert --editing-data`) opens a `.ai` or an Illustrator EPS from its editing data even where it draws differently from its page, which can be older, with a note. Type is made from the file's text document, whole and editable, shown or not: point type (its frame's matrix, which newer files leave out when it is neither turned nor scaled, read as none), area type (a story in several frames as threaded type) and type on a path, with its characters, fonts, size, leading, tracking, scaling, baseline shift, fill and stroke (grey, RGB or CMYK), alignment, indents and paragraph spacing; the page's drawing of it (often in pieces) is left out. Where the text document can't say (a frame of another kind, or a document that doesn't agree with the page), type that shows comes from the page into its text object's place (no group around it), and hidden type is left out with a note. Kerning, underline and the other character and paragraph options aren't read yet. A `.ai` saved without PDF compatibility (a placeholder page) opens from its editing data alone, its point type, area type and type on a path made from the text document. A `.ai` whose PDF part shows only text isn't taken for that placeholder when its page states an art, trim or bleed box: it opens from its editing data alone where that reads, else from its PDF part (#1387). A `.ai` whose PDF part draws nothing at all (an empty page, with or without those boxes) opens from its editing data alone where that reads too: there is no page art to check its layers against, and the empty page would lose all of it. Text objects with an appearance keep their own text and frame, type of hidden layers stays hidden, and type on later artboards lands on its text objects (#1391); area type whose frame is too short for a line of the fallback font shows its first line (the frame is made taller, with a warning in the open result) (#1392). Symbols, pattern fills whose pattern it can't read, placed files the data keeps no preview of and anything else it doesn't read make the file come in as its page (on a layer that doesn't show, they are left out of that layer), with a warning saying what. The layers' art is also compared with the page (by lightness, so colours written as their CMYK equivalents compare alike, and by whether a pixel is inked at all); the page is used when they differ by more than 5%, where one draws an object the other doesn't (away from type, whose lines may be laid out afresh), and when an EPS whose page is its art's box has art printed outside it (#735). An EPS whose page is its art's box keeps that page when it comes in through its layers, not the editing data's artboard, and a text object counts as drawn by the page by its colours, not only its lightness, so a red stroke stacked over a dark red one stays (#1102). `textAs: "outlines"` opens a `.ai` whose type shows from its PDF part, which has the outlines; `editingData: false` opens any of them as its page or PDF part only, for print pipelines (#735). A file whose import left something out (hidden text, art or layers) is never written over by an export or Save As to its own path unless `acknowledgeLoss: true` (`convert --replace-lossy`), so the original keeps what the document lacks. Where a `.ai` can't be read that way (or its layers are turned off in the import options), we read its PDF-compatible part, so Illustrator-only live objects arrive as appearance, and plain groups arrive ungrouped: that part draws each object on its own and marks only layers, clipping groups and groups with opacity, blending or a mask (those come back). Art outside the artboards isn't in that part at all (Illustrator's PDF part leaves it out), so it doesn't open; the import says so in a note (#472). Its pages still go where the editing data puts the artboards (a grid stays a grid), with the art on each, when it has as many artboards as pages, of the same sizes (#1068). Its pages are laid out so that art one of them draws past its artboard (notes beside a design, which the part doesn't clip) doesn't lie over the page before it in the row, where it was taken for that page's art: the check against the editing data then found art its layers don't have there and opened the file as its PDF part, without the art outside the artboards. That part also has no paragraphs: area type is written line by line, and comes back as area type only where its font is installed and lays the lines out with the same breaks, else as a point type object per line (#508). Art off the page that a PDF does draw opens on the pasteboard. the app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPrivateData` streams, a PDF's `AIPDFPrivateData` streams when it was saved with the editing data (#868), Zstandard or zlib, the EPS's in ASCII85) is not documented as a whole. VectorCraft reads its structure: layers and sublayers (names, order, visibility, lock, printing, preview, dimming, colour), groups as they were nested, compound paths (painted by their last path, or the last painted one, with the paths of groups inside them kept as their paths: #1410), clipping groups and layer clipping, object names, hidden and locked objects, fills and strokes (grey, CMYK, RGB, named and spot colours, spot colours defined in Lab with their Lab values (#1032), global process colours as global swatches at their tint), linear and radial gradients, pattern fills with their patterns as pattern swatches (#1025), opacity, blend modes, isolation and knockout, embedded images where their matrix puts them, rotated ones too (#2269), with their alpha channel (CMYK images keep their ink amounts, as they do when a `.ai` opens from its PDF part, and an alpha channel that hides part of a CMYK image becomes a grayscale opacity mask), placed (linked) files as linked images in their place, each showing the low-resolution preview the file keeps of it until its file is found or relinked in the Links panel (#1264), guides, and every artboard where it is. A gradient with stops in the middle runs its whole ramp across its shape, and a gradient object does not pass its fill to the next path (#1390). An object whose art style is one fill and one stroke at most (solid colours, its own gradient, a variable-width profile) with an Outer Glow or Drop Shadow comes in as itself with them; one with more, other effects, a brush or dashes aligned to corners comes in as its drawn look (a group named after it). Type keeps its art style as a live appearance whatever its stack, so it can be retyped: each fill and stroke of the style's stack (solid colours, gradients and pattern fills, placed as the drawn look places them) with its own opacity, blend mode and effects, the effects on the whole object, and where the characters paint among them; the effects read are Warp, Offset Path, Transform (with copies), Drop Shadow, Outer Glow, Feather, Gaussian Blur and Bas Relief (its settings at their defaults), and a style with others keeps the type's drawn look. The page's drawing of such a style isn't held to look like VectorCraft's where its drawn look lay. Gradients take their matrix (`Xm`, radials and skewed ones too), focal point and the order of stops sharing a ramp point; gradient meshes, a clipping path's own fill and the artboards' names are read too. `editingData: "always"` (`convert --editing-data`) opens a `.ai` or an Illustrator EPS from its editing data even where it draws differently from its page, which can be older, with a note. Type is made from the file's text document, whole and editable, shown or not: point type (its frame's matrix, which newer files leave out when it is neither turned nor scaled, read as none), area type (a story in several frames as threaded type) and type on a path, with its characters, fonts, size, leading, tracking, scaling, baseline shift, fill and stroke (grey, RGB or CMYK), alignment, indents and paragraph spacing; the page's drawing of it (often in pieces) is left out. Where the text document can't say (a frame of another kind, or a document that doesn't agree with the page), type that shows comes from the page into its text object's place (no group around it), and hidden type is left out with a note. Kerning, underline and the other character and paragraph options aren't read yet. A `.ai` saved without PDF compatibility (a placeholder page) opens from its editing data alone, its point type, area type and type on a path made from the text document. A `.ai` whose PDF part shows only text isn't taken for that placeholder when its page states an art, trim or bleed box: it opens from its editing data alone where that reads, else from its PDF part (#1387). Text objects with an appearance keep their own text and frame, type of hidden layers stays hidden, and type on later artboards lands on its text objects (#1391); area type whose frame is too short for a line of the fallback font shows its first line (the frame is made taller, with a warning in the open result) (#1392). Symbols, pattern fills whose pattern it can't read, placed files the data keeps no preview of and anything else it doesn't read make the file come in as its page (on a layer that doesn't show, they are left out of that layer), with a warning saying what. The layers' art is also compared with the page (by lightness, so colours written as their CMYK equivalents compare alike, and by whether a pixel is inked at all); the page is used when they differ by more than 5%, where one draws an object the other doesn't (away from type, whose lines may be laid out afresh), and when an EPS whose page is its art's box has art printed outside it (#735). An EPS whose page is its art's box keeps that page when it comes in through its layers, not the editing data's artboard, and a text object counts as drawn by the page by its colours, not only its lightness, so a red stroke stacked over a dark red one stays (#1102). `textAs: "outlines"` opens a `.ai` whose type shows from its PDF part, which has the outlines; `editingData: false` opens any of them as its page or PDF part only, for print pipelines (#735). A file whose import left something out (hidden text, art or layers) is never written over by an export or Save As to its own path unless `acknowledgeLoss: true` (`convert --replace-lossy`), so the original keeps what the document lacks. Where a `.ai` can't be read that way (or its layers are turned off in the import options), we read its PDF-compatible part, so Illustrator-only live objects arrive as appearance, and plain groups arrive ungrouped: that part draws each object on its own and marks only layers, clipping groups and groups with opacity, blending or a mask (those come back). Art outside the artboards isn't in that part at all (Illustrator's PDF part leaves it out), so it doesn't open; the import says so in a note (#472). Its pages still go where the editing data puts the artboards (a grid stays a grid), with the art on each, when it has as many artboards as pages, of the same sizes (#1068). A `.ai` whose PDF part's pages are cropped to its art (each page the box of all the art, which is the editing data's bounding box) instead of its artboards opens from its layers, with its own artboards, where they draw as that page does. Its pages are laid out so that art one of them draws past its artboard (notes beside a design, which the part doesn't clip) doesn't lie over the page before it in the row, where it was taken for that page's art: the check against the editing data then found art its layers don't have there and opened the file as its PDF part, without the art outside the artboards. That part also has no paragraphs: area type is written line by line, and comes back as area type only where its font is installed and lays the lines out with the same breaks, else as a point type object per line (#508). Art off the page that a PDF does draw opens on the pasteboard. ## Format by format @@ -131,6 +132,7 @@ the app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPri | Date | Change | Summary | |---|---|---| +| 2026-10-30 | minor | `.ai` import: a file whose PDF part is an empty page opens from its editing data where that reads, instead of opening blank; scores unchanged | | 2026-10-30 | minor | `.ai` import: a file whose PDF part's pages are cropped to its art rather than its artboards no longer comes in as that PDF part (each page a copy of all the art) but from its layers, with its artboards, where they draw as the page does; own-fixture test in `tests_aiimport`; scores unchanged | | 2026-10-29 | minor | `.ai` and Illustrator EPS import: the editing data is read up to an eighth of installed memory, from 512 MiB to 2 GiB on 64-bit builds (it was 512 MiB on every machine), so a layered file whose embedded rasters unpack past 512 MiB keeps its layers, groups and text on a machine with 8 GiB or more instead of opening as its page or PDF part (#3510, #4628). Measured: 1.1 GB of editing data peaked 1.1 GB above the start; data past the limit is still refused (a 2 MB file unpacking to 2.2 GB stops in under a second). 32-bit and web builds keep 256 MiB. Own-fixture tests `import::ai::tests::editing_data_past_512_mib_is_read_where_memory_allows`, `the_editing_data_limit_follows_installed_memory`; scores and hours unchanged | | 2026-10-29 | minor | Affinity import: attached Recolor Adjustment (RcRA) layers import as color overlays with HSL lightness (#4420); scores unchanged. | From 43db0c00bca9931affe911540b78ad854b74e106 Mon Sep 17 00:00:00 2001 From: Don Omondi <282319807+mockydevs@users.noreply.github.com> Date: Fri, 30 Oct 2026 02:32:59 +0300 Subject: [PATCH 019/163] PDF export: gradient meshes as smooth Type 6 patch shadings PDF export (and the PDF-compatible .ai it writes) cut each gradient mesh patch into 8 x 8 flat-coloured quads. Viewers showed colour bands and hairline seams between them, and files with many meshes became very large and slow to write. An opaque mesh is now written as one Type 6 (Coons patch) shading (ISO 32000-1, 8.7.4.5.7) filling its outline, through the PDF writer's MeshGradient: each patch blends its corner colours bilinearly, as the canvas draws it. Colours go through page_color as other fills do, and a mesh mixing RGB with other models goes through RGB. A mesh with see-through points, an invalid one, or one past the coordinate range keeps the quads. --- crates/engine/src/tests/live.rs | 17 ++++- crates/pdf/src/export/nodes.rs | 54 +++++++++++++- crates/pdf/src/tests.rs | 1 + crates/pdf/src/tests/mesh_export.rs | 106 ++++++++++++++++++++++++++++ docs/file-format-parity.md | 3 +- 5 files changed, 177 insertions(+), 4 deletions(-) create mode 100644 crates/pdf/src/tests/mesh_export.rs diff --git a/crates/engine/src/tests/live.rs b/crates/engine/src/tests/live.rs index d663db702c..712845186a 100644 --- a/crates/engine/src/tests/live.rs +++ b/crates/engine/src/tests/live.rs @@ -1224,7 +1224,9 @@ fn cmyk_mesh(create: Value) -> (Session, NodeId) { (s, a) } -/// The fill colours `document.exportPdf {standard: pdfX4}` writes (`… scn` operands), and its warnings. +/// The fill colours `document.exportPdf {standard: pdfX4}` writes (`… scn` operands, and the +/// corner colours of its gradient meshes, which are patch shadings, as PDF import reads them +/// back), and its warnings. fn pdf_fill_colours(s: &mut Session) -> (Vec>, Vec) { let v = s.execute("document.exportPdf", &json!({"standard": "pdfX4", "compression": {"compressText": false}})).unwrap(); let bytes = vectorcraft_format::base64_decode(v["dataBase64"].as_str().unwrap()).unwrap(); @@ -1235,10 +1237,21 @@ fn pdf_fill_colours(s: &mut Session) -> (Vec>, Vec) { for (i, w) in words.iter().enumerate() { if *w == "scn" { let nums: Vec = words[..i].iter().rev().map_while(|x| x.parse().ok()).collect(); - out.push(nums.into_iter().rev().collect()); + // A pattern (`/P0 scn`) has no colour of its own. + if !nums.is_empty() { + out.push(nums.into_iter().rev().collect()); + } } } } + vectorcraft_pdf::import(&bytes).unwrap().walk(|n| { + if let NodeKind::Mesh(m) = &n.kind { + out.extend(m.points.iter().map(|p| match p.color { + Color::Cmyk { c, m, y, k } => vec![c, m, y, k], + c => c.to_rgb().to_vec(), + })); + } + }); (out, serde_json::from_value(v["warnings"].clone()).unwrap()) } diff --git a/crates/pdf/src/export/nodes.rs b/crates/pdf/src/export/nodes.rs index cd65936bd2..3302766df6 100644 --- a/crates/pdf/src/export/nodes.rs +++ b/crates/pdf/src/export/nodes.rs @@ -1,4 +1,4 @@ -use super::exporter::{address, blend, constant_mask, cover, in_range, norm, rects_overlap, rule, to_path, writable}; +use super::exporter::{address, blend, color, constant_mask, cover, in_range, norm, rects_overlap, rule, to_path, writable, xf}; use super::{ Affine, AppearanceItem, BezPath, BlendMode, Exporter, Fill, FillRule, LineCap, LineJoin, Mark, Node, NodeKind, NormalizedF32, Paint, Path, Rect, Shape, Stroke, StrokeAlign, StrokeDash, StrokeLayer, Surface, WrittenShape, krilla, stroke, @@ -198,6 +198,8 @@ impl Exporter<'_> { self.node(s, &art, page, true); } } + // A gradient mesh is a smooth patch shading where it can be written as one. + NodeKind::Mesh(m) if self.mesh(s, m) => {} // Live blends/envelopes/meshes export their evaluated (expanded) form. NodeKind::Blend { .. } | NodeKind::Envelope { .. } @@ -217,6 +219,56 @@ impl Exporter<'_> { } } + /// Gradient mesh `m` as one PDF Type 6 (Coons patch) shading filling its outline (ISO 32000-1, + /// 8.7.4.5.7): each patch blends its corner colours bilinearly, as the canvas draws it, and + /// the viewer or RIP does so smoothly at its own resolution. Cutting the mesh into flat quads + /// instead banded, left seams between them, and made files with many meshes very large. + /// Corner colours are written as [`Self::page_color`] writes any colour; RGB among other + /// models goes through RGB, as the writer needs one colour space a shading (ink-based ones: + /// CMYK and grey, merge). `false` when it isn't written so: the caller draws it expanded. + /// That is a mesh with see-through points (their opacities would be a soft mask of another + /// patch shading, which a common viewer, Poppler, draws with gaps and too opaque; the quads + /// carry their own opacity), an invalid mesh, or one beyond the coordinates a file holds. + fn mesh(&mut self, s: &mut Surface, m: &vectorcraft_doc::live::GradientMesh) -> bool { + if !m.is_valid() || !m.points.iter().all(|p| p.opacity >= 1.0) { + return false; + } + let Some(bounds) = m.bounds() else { return false }; + if !writable(s, Affine::IDENTITY, bounds) { + return false; + } + let Some(path) = to_path(s, &m.outline().to_bezpath()) else { return false }; + let page: Vec = m.points.iter().map(|p| self.page_color(&p.color)).collect(); + let mixed = page.windows(2).any(|w| w[0].model() != w[1].model()); + let rgb = page.iter().any(|c| matches!(c, vectorcraft_color::Color::Rgb { .. } | vectorcraft_color::Color::Lab { .. })); + let colors: Vec = + page.iter().map(|c| if mixed && rgb { color(&c.in_model(vectorcraft_color::cms::Model::Rgb)) } else { color(c) }).collect(); + let pt = |p: vectorcraft_geom::Point| (p.x as f32, p.y as f32); + let mut patches = Vec::with_capacity(m.rows as usize * m.cols as usize); + for r in 0..m.rows as usize { + for c in 0..m.cols as usize { + // The corners in the order a Type 6 shading lists them: down the left edge (v), + // along the bottom (u), back up the right edge and back along the top. + let corners = [m.idx(r, c), m.idx(r + 1, c), m.idx(r + 1, c + 1), m.idx(r, c + 1)]; + let (left, bottom, right, top) = (m.edge_v(r, c), m.edge_u(r + 1, c), m.edge_v(r, c + 1), m.edge_u(r, c)); + let points = + [left.p0, left.p1, left.p2, left.p3, bottom.p1, bottom.p2, bottom.p3, right.p2, right.p1, right.p0, top.p2, top.p1].map(pt); + let Some(colors) = + corners.iter().map(|&i| colors.get(i).cloned()).collect::>>().and_then(|v| <[_; 4]>::try_from(v).ok()) + else { + return false; + }; + patches.push(krilla::paint::MeshPatch { points, colors, opacities: [NormalizedF32::ONE; 4] }); + } + } + let mesh = krilla::paint::MeshGradient { patches, transform: xf(Affine::IDENTITY), anti_alias: false }; + s.set_stroke(None); + s.set_fill(Some(Fill { paint: mesh.into(), opacity: NormalizedF32::ONE, rule: krilla::paint::FillRule::NonZero })); + s.draw_path(&path); + s.set_fill(None); + true + } + fn shape(&mut self, s: &mut Surface, n: &Node, bp: &BezPath, r: FillRule, page: Rect) { let Some(path) = to_path(s, bp) else { return }; let bounds = bp.bounding_box(); diff --git a/crates/pdf/src/tests.rs b/crates/pdf/src/tests.rs index b3ad2eea64..e442c02d54 100644 --- a/crates/pdf/src/tests.rs +++ b/crates/pdf/src/tests.rs @@ -29,6 +29,7 @@ mod import_overprint; mod layers; pub(super) mod live_text; mod marks; +mod mesh_export; mod output; mod pdf13; mod pdfx; diff --git a/crates/pdf/src/tests/mesh_export.rs b/crates/pdf/src/tests/mesh_export.rs new file mode 100644 index 0000000000..cf8ad25e3b --- /dev/null +++ b/crates/pdf/src/tests/mesh_export.rs @@ -0,0 +1,106 @@ +//! Gradient meshes written as PDF Type 6 (Coons patch) shadings (ISO 32000-1, 8.7.4.5.7): the +//! viewer blends each patch's corner colours smoothly, instead of the mesh being cut into small +//! flat-coloured paths that band, show seams and make the file large. + +use vectorcraft_color::Color; +use vectorcraft_doc::live::{GradientMesh, MeshAppearance}; +use vectorcraft_doc::{ColorMode, Document, Node, NodeKind}; +use vectorcraft_geom::{Rect, shapes}; +use vectorcraft_testkit::raster::{assert_similar, render_artboard}; + +use crate::*; + +/// A 200 × 200 pt document with a 2 × 2 mesh over (20, 20)–(180, 180), its nine points coloured +/// by `color(row, col)` and made `opacity` opaque. +fn doc(color: impl Fn(usize, usize) -> Color, opacity: f32) -> Document { + let mut m = GradientMesh::for_path(&shapes::rectangle(Rect::new(20.0, 20.0, 180.0, 180.0)), 2, 2, Color::BLACK, MeshAppearance::Flat, 0.0) + .expect("a mesh"); + for r in 0..=2 { + for c in 0..=2 { + let i = m.idx(r, c); + m.points[i].color = color(r, c); + m.points[i].opacity = opacity; + } + } + let mut d = Document::new(200.0, 200.0); + let l = d.layers[0].id; + let id = d.alloc_id(); + d.insert(Some(l), 0, Node::new(id, NodeKind::Mesh(m))).unwrap(); + d +} + +fn rgb(r: usize, c: usize) -> Color { + Color::rgb(r as f32 / 2.0, c as f32 / 2.0, 1.0 - (r + c) as f32 / 4.0) +} + +/// How many meshes and paths `d` holds. +fn kinds(d: &Document) -> (usize, usize) { + let (mut meshes, mut paths) = (0, 0); + d.walk(|n| match n.kind { + NodeKind::Mesh(_) => meshes += 1, + NodeKind::Path { .. } => paths += 1, + _ => {} + }); + (meshes, paths) +} + +#[test] +fn a_gradient_mesh_is_written_as_a_smooth_patch_shading() { + let d = doc(rgb, 1.0); + let bytes = export(&d, &PdfOptions::default()).unwrap(); + let back = import(&bytes).unwrap(); + // The shading comes back as a mesh, not as the 256 flat quads 8 × 8 a patch made. + let (meshes, paths) = kinds(&back); + assert!(meshes >= 1 && paths <= 4, "meshes {meshes}, paths {paths}"); + let mut corners = vec![]; + back.walk(|n| { + if let NodeKind::Mesh(m) = &n.kind { + corners.extend(m.points.iter().map(|p| p.color.to_rgb())); + } + }); + for want in [rgb(0, 0), rgb(2, 2), rgb(1, 1)] { + let want = want.to_rgb(); + assert!(corners.iter().any(|c| c.iter().zip(want).all(|(a, b)| (a - b).abs() < 0.02)), "{want:?} in {corners:?}"); + } + assert_similar(&render_artboard(&d), &render_artboard(&back), 6.0, 0.01); +} + +#[test] +fn a_cmyk_mesh_is_written_smooth_in_its_inks() { + let cmyk = |r: usize, c: usize| Color::Cmyk { c: r as f32 / 2.0, m: c as f32 / 2.0, y: 0.2, k: 0.0 }; + let mut d = doc(cmyk, 1.0); + d.color_mode = ColorMode::Cmyk; + let back = import(&export(&d, &PdfOptions::default()).unwrap()).unwrap(); + let (meshes, paths) = kinds(&back); + assert!(meshes >= 1 && paths <= 4, "meshes {meshes}, paths {paths}"); + back.walk(|n| { + if let NodeKind::Mesh(m) = &n.kind { + assert!(m.points.iter().all(|p| matches!(p.color, Color::Cmyk { .. })), "{:?}", m.points); + } + }); + assert_similar(&render_artboard(&d), &render_artboard(&back), 6.0, 0.02); +} + +#[test] +fn a_see_through_mesh_is_still_written_as_quads() { + // Its opacities would need a soft mask of a second patch shading; the quads carry their own. + let d = doc(rgb, 0.5); + let back = import(&export(&d, &PdfOptions::default()).unwrap()).unwrap(); + assert_eq!(kinds(&back).0, 0); + // The seams between quads, as before. + assert_similar(&render_artboard(&d), &render_artboard(&back), 6.0, 0.05); +} + +#[test] +fn a_mesh_of_mixed_colour_models_still_exports() { + // RGB, grey and CMYK points: the PDF writer needs one colour space a shading. + let mixed = |r: usize, c: usize| match (r + c) % 3 { + 0 => Color::rgb(1.0, 0.2, 0.2), + 1 => Color::gray(0.4), + _ => Color::Cmyk { c: 0.8, m: 0.0, y: 0.3, k: 0.0 }, + }; + let d = doc(mixed, 1.0); + let back = import(&export(&d, &PdfOptions::default()).unwrap()).unwrap(); + assert!(kinds(&back).0 >= 1); + assert_similar(&render_artboard(&d), &render_artboard(&back), 8.0, 0.02); +} diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 01064160bd..cf2fbe39e1 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File format parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (`.ai` import: a file whose PDF part is an empty page opens from its editing data) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (PDF export: opaque gradient meshes as smooth Type 6 patch shadings) · **Target:** Adobe Illustrator 2026 (30.x) Every format Illustrator opens, places, saves or exports, against VectorCraft's format table (`FORMATS`, `OPEN_EXTS`, `PLACE_EXTS` in `crates/engine/src/cmd/fileio/formats.rs`). Illustrator's list comes from its public @@ -132,6 +132,7 @@ the app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPri | Date | Change | Summary | |---|---|---| +| 2026-10-30 | minor | PDF export: an opaque gradient mesh is written as one PDF Type 6 (Coons patch) shading (ISO 32000-1, 8.7.4.5.7) filling its outline, so viewers blend its colours smoothly instead of showing the bands and seams of the 8 × 8 flat quads a patch it was cut into; a file of 65,558 small meshes exports in 14 s instead of 56 s, at half the size. A mesh with see-through points is still written as quads. Own-fixture tests in `tests::mesh_export`; scores unchanged | | 2026-10-30 | minor | `.ai` import: a file whose PDF part is an empty page opens from its editing data where that reads, instead of opening blank; scores unchanged | | 2026-10-30 | minor | `.ai` import: a file whose PDF part's pages are cropped to its art rather than its artboards no longer comes in as that PDF part (each page a copy of all the art) but from its layers, with its artboards, where they draw as the page does; own-fixture test in `tests_aiimport`; scores unchanged | | 2026-10-29 | minor | `.ai` and Illustrator EPS import: the editing data is read up to an eighth of installed memory, from 512 MiB to 2 GiB on 64-bit builds (it was 512 MiB on every machine), so a layered file whose embedded rasters unpack past 512 MiB keeps its layers, groups and text on a machine with 8 GiB or more instead of opening as its page or PDF part (#3510, #4628). Measured: 1.1 GB of editing data peaked 1.1 GB above the start; data past the limit is still refused (a 2 MB file unpacking to 2.2 GB stops in under a second). 32-bit and web builds keep 256 MiB. Own-fixture tests `import::ai::tests::editing_data_past_512_mib_is_read_where_memory_allows`, `the_editing_data_limit_follows_installed_memory`; scores and hours unchanged | From 6a80e43b68a1a303dc7fdd80f93ae33669ac7242 Mon Sep 17 00:00:00 2001 From: datatimp <12644819+datatimp@users.noreply.github.com> Date: Thu, 29 Oct 2026 21:51:40 -0400 Subject: [PATCH 020/163] Effect dialogs keep a typed distance within the effect's range (#4637) --- crates/effects/src/catalog.rs | 14 ++++++++++++++ crates/effects/src/lib.rs | 2 +- crates/effects/src/tests.rs | 14 ++++++++++++++ crates/ui-egui/src/dialogs/form.rs | 18 +++++++++++++++++- crates/ui-egui/src/dialogs/tests.rs | 27 +++++++++++++++++++++++++++ 5 files changed, 73 insertions(+), 2 deletions(-) diff --git a/crates/effects/src/catalog.rs b/crates/effects/src/catalog.rs index e000b930f4..d10d931d65 100644 --- a/crates/effects/src/catalog.rs +++ b/crates/effects/src/catalog.rs @@ -42,6 +42,20 @@ pub fn is_length(id: &str, key: &str, relative: bool) -> bool { catalog_index().get(id).is_some_and(|info| info.lengths.keys(relative).any(|k| k == key)) } +/// The range in points that distance parameter `key` of effect `id` is kept within, as its +/// parameter documentation gives it (`{maxRadius: pt 4..127 (8), …}`); `None` when it gives none. +pub fn length_range(id: &str, key: &str) -> Option> { + let doc = catalog_index().get(id)?.params; + let starts = |at: usize| doc.get(..at).and_then(|s| s.chars().last()).is_some_and(|c| c == '{' || c == ' '); + let rest = doc.match_indices(key).map(|(at, _)| at).filter(|at| starts(*at)).find_map(|at| { + let rest = doc.get(at + key.len()..)?; + rest.strip_prefix(": pt ").or_else(|| rest.strip_prefix("?: pt ")) + })?; + let (lo, hi) = rest.split_whitespace().next()?.split_once("..")?; + let (lo, hi) = (lo.parse::().ok()?, hi.trim_end_matches(',').parse::().ok()?); + (lo.is_finite() && hi.is_finite() && lo <= hi).then_some(lo..=hi) +} + /// The distance parameters of effect `id` (none for unknown effects). fn lengths_of(id: &str) -> Lengths { let always = |always| Lengths { always, absolute: &[] }; diff --git a/crates/effects/src/lib.rs b/crates/effects/src/lib.rs index b6db2f4d9c..a732e2dfff 100644 --- a/crates/effects/src/lib.rs +++ b/crates/effects/src/lib.rs @@ -94,7 +94,7 @@ mod catalog; mod geometry; mod params; -pub use catalog::{EffectInfo, Lengths, WARP_STYLES, effect_catalog, effect_info, is_length, plugin_effects}; +pub use catalog::{EffectInfo, Lengths, WARP_STYLES, effect_catalog, effect_info, is_length, length_range, plugin_effects}; pub(crate) use geometry::{Budget, apply_one}; pub use geometry::{GeomContext, apply_geometry, apply_geometry_bez, apply_geometry_with}; #[cfg(test)] diff --git a/crates/effects/src/tests.rs b/crates/effects/src/tests.rs index 0241fa8b9f..198da329e8 100644 --- a/crates/effects/src/tests.rs +++ b/crates/effects/src/tests.rs @@ -1207,3 +1207,17 @@ fn a_repeat_of_a_symbol_whose_art_is_a_repeat_shares_the_instance_budget() { let small = Node::new(NodeId(0), NodeKind::Repeat(RepeatSpec::mirror(vec![instance("Small")], 90.0, 5.0))); assert_eq!(expand_live(Some(&d), &small).len(), 2); } + +#[test] +fn a_distance_parameters_range_comes_from_its_documentation() { + assert_eq!(length_range("pixelate.colorHalftone", "maxRadius"), Some(4.0..=127.0)); + // The effect applies the range's floor to a radius below it. + assert_eq!( + crate::pixel::parse("pixelate.colorHalftone", &json!({"maxRadius": 1})), + crate::pixel::parse("pixelate.colorHalftone", &json!({"maxRadius": 4})) + ); + // A distance documented without a range, and unknown effects and parameters, have none. + assert_eq!(length_range("path.offsetPath", "offset"), None); + assert_eq!(length_range("pixelate.colorHalftone", "channel1"), None); + assert_eq!(length_range("no.such", "maxRadius"), None); +} diff --git a/crates/ui-egui/src/dialogs/form.rs b/crates/ui-egui/src/dialogs/form.rs index b82fe54f89..941687ae48 100644 --- a/crates/ui-egui/src/dialogs/form.rs +++ b/crates/ui-egui/src/dialogs/form.rs @@ -44,8 +44,22 @@ pub(super) fn length_field(ui: &mut egui::Ui, d: &mut Dialog, key: &str, label: /// "5 mm", wins), kept in points (a string with a unit, "12 pt", also reads). Returns true when it /// changed. pub(super) fn length(ui: &mut egui::Ui, d: &mut Dialog, key: &str, unit: Unit, width: f32) -> bool { + length_within(ui, d, key, unit, width, None) +} + +/// [`length`] whose value is kept within `range` (points): a value typed outside it becomes the +/// nearer end, so the field shows the distance the command applies (#4637). +pub(super) fn length_within( + ui: &mut egui::Ui, + d: &mut Dialog, + key: &str, + unit: Unit, + width: f32, + range: Option>, +) -> bool { let value = d.fields.contains_key(key).then(|| d.f64(key, 0.0)); let Some(v) = crate::widgets::num_field(ui, ("dlg-len", key), value, unit, width) else { return false }; + let v = range.map_or(v, |r| v.max(*r.start()).min(*r.end())); d.fields.insert(key.into(), json!(v)); true } @@ -365,7 +379,9 @@ pub(super) fn param_fields( return; } if is_length(&k) { - changed |= length(ui, d, &k, unit, 140.0); + // An effect's documented range keeps the field to the distance it applies. + let range = vectorcraft_effects::length_range(&d.str("__effect"), &k); + changed |= length_within(ui, d, &k, unit, 140.0, range); return; } if let Some(options) = choices(&k) { diff --git a/crates/ui-egui/src/dialogs/tests.rs b/crates/ui-egui/src/dialogs/tests.rs index 66f37e10f3..ae9fb664f0 100644 --- a/crates/ui-egui/src/dialogs/tests.rs +++ b/crates/ui-egui/src/dialogs/tests.rs @@ -2486,3 +2486,30 @@ fn artboard_options_selected_fit_spans_other_boards_and_off_board_art() { app.run("edit.redo", json!({})).unwrap(); assert_eq!(app.session.doc().unwrap().doc, after); } + +/// An effect dialog keeps a distance typed outside the effect's range to the range, so the field +/// shows what the effect applies: Color Halftone's Max Radius below 4 pt is 4 pt (#4637). +#[test] +fn an_effect_dialog_keeps_a_typed_distance_within_the_effects_range() { + let enter = || egui::Event::Key { key: egui::Key::Enter, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() }; + for (typed, applied) in [("1 pt", 4.0), ("0.5 px", 4.0), ("200 pt", 127.0), ("10 pt", 10.0)] { + let mut app = app(); + let id = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 50})).unwrap()["id"].as_u64().unwrap(); + let ctx = egui::Context::default(); + theme::install_fonts(&ctx); + theme::apply(&ctx, Default::default()); + let frame = |app: &mut VectorcraftApp, events: Vec| { + let mut out = ctx.run_ui(egui::RawInput { events, ..Default::default() }, |ui| show(app, ui.ctx())); + out.textures_delta.clear(); + }; + app.run("select.all", json!({})).unwrap(); + app.run("effect.dialog", json!({"effect": "pixelate.colorHalftone"})).unwrap(); + // Max Radius, the first field, is focused: type over it and press Enter. + frame(&mut app, vec![]); + frame(&mut app, vec![egui::Event::Text(typed.into())]); + frame(&mut app, vec![enter()]); + assert!(app.ui.dialog.is_none(), "{typed}"); + let node = app.session.doc().unwrap().doc.node(vectorcraft_doc::NodeId(id)).unwrap().clone(); + assert_eq!(node.appearance.effects.last().map(|e| e.params["maxRadius"].clone()), Some(json!(applied)), "{typed}"); + } +} From f398f319da8bf26f9333c56dba58d0694b2d49cd Mon Sep 17 00:00:00 2001 From: C0uki <251395721+C0uki@users.noreply.github.com> Date: Fri, 30 Oct 2026 00:35:44 +0000 Subject: [PATCH 021/163] i18n(ja): translate the update check and the trace progress labels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Help > Check for Updates… item, the update window and the Image Trace progress labels had no ja row and drew English. Wording follows the PhotoCraft ja catalog for the update strings. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01K5NRZNWfaSLBWVzV8hivyS --- crates/ui-egui/src/i18n/ja.tsv | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index a1ff8c8805..2cf6eafe87 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -15,6 +15,11 @@ # Left in English on purpose (`MENU_KEEP_AS_IS` in the tests): the product name, language # names, OpenType, the built-in workspace names and the bracketed perspective grid preset names. About VectorCraft VectorCraft について + Check for Updates… アップデートを確認… + Checking for updates… アップデートを確認中… + Could not check for updates:\n{error} アップデートを確認できませんでした:\n{error} + VectorCraft Updates VectorCraft のアップデート + VectorCraft {version} is currently the newest version available. VectorCraft {version} は最新バージョンです。 All Scripts すべての文字 Anchors: アンカー: Any Kind すべての種類 @@ -586,6 +591,8 @@ font-technology Variable バリアブル Snap to Pixel ピクセルにスナップ Precise Cursors 精密カーソル Image Trace Preview 画像トレースのプレビュー + Preparing the image… 画像を準備中… + Tracing the colors… 色をトレース中… Snap to Point ポイントにスナップ Snap to Glyph グリフにスナップ New View… 新規表示… From 380a3cfcff0a9b9532b75363ec8ceb4f6542c868 Mon Sep 17 00:00:00 2001 From: Don Omondi <282319807+mockydevs@users.noreply.github.com> Date: Fri, 30 Oct 2026 04:21:42 +0300 Subject: [PATCH 022/163] .ai import: a placed file on %_ lines no longer drops the layers A placed (linked) file written as an object's editable copy, on %_ lines after its drawn look, has its %AI5_BeginPlace and %AI5_EndPlace markers on those lines too. The lexer dropped comments after %_ that don't start a section, so the placed file never began, the ~ that ends it was an operator the reader didn't know, and the whole file came in as its PDF part. The lexer now returns those two markers from %_ lines, and the preview reader skips the %_ its header line starts with. --- crates/eps/src/import/ai/lex.rs | 6 +++++ crates/eps/src/import/ai/read/art.rs | 4 +++- crates/eps/src/import/ai/tests.rs | 36 ++++++++++++++++++++++++++++ docs/file-format-parity.md | 3 ++- 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/crates/eps/src/import/ai/lex.rs b/crates/eps/src/import/ai/lex.rs index c7904948be..9b81e29a8d 100644 --- a/crates/eps/src/import/ai/lex.rs +++ b/crates/eps/src/import/ai/lex.rs @@ -40,6 +40,8 @@ pub(super) struct Token<'a> { /// A placed file's preview (binary): (begin, end) markers. const PREVIEW: (&[u8], &[u8]) = (b"%AI26_BeginPlacedObjectPreview", b"%AI26_EndPlacedObjectPreview"); +/// A placed file's markers, which a hidden one has on `%_` lines. +const PLACE: [&[u8]; 2] = [b"%AI5_BeginPlace", b"%AI5_EndPlace"]; /// A binary section skipped whole: (begin, end) markers. const DOCUMENT: (&[u8], &[u8]) = (b"%%BeginDocument", b"%%EndDocument"); @@ -142,6 +144,10 @@ impl<'a> Lexer<'a> { if start { return Some(Token { tok: Tok::Comment(line.get(1..).unwrap_or_default()), hidden: false }); } + // So does a hidden placed file: its `~` ends what `%_%AI5_BeginPlace` begins. + if prefixed && PLACE.iter().any(|m| line.starts_with(m)) { + return Some(Token { tok: Tok::Comment(line.get(1..).unwrap_or_default()), hidden: true }); + } // A comment later in a line. continue; } diff --git a/crates/eps/src/import/ai/read/art.rs b/crates/eps/src/import/ai/read/art.rs index 52bd7e6857..70cbcf17be 100644 --- a/crates/eps/src/import/ai/read/art.rs +++ b/crates/eps/src/import/ai/read/art.rs @@ -504,7 +504,9 @@ pub(super) fn elements<'o>(o: &'o Obj, name: &'o str) -> impl Iterator Option<(Vec, u32, u32)> { - let mut rest = data.trim_ascii_start(); + // A placed file's copy on `%_` lines has its header on one too: `%_512 256 2048 32 17 `. + let data = data.trim_ascii_start(); + let mut rest = data.strip_prefix(b"%_").unwrap_or(data); let mut head = [0usize; 5]; for v in &mut head { let n = rest.iter().position(|b| *b == b' ')?; diff --git a/crates/eps/src/import/ai/tests.rs b/crates/eps/src/import/ai/tests.rs index f6ae839577..9b453de24c 100644 --- a/crates/eps/src/import/ai/tests.rs +++ b/crates/eps/src/import/ai/tests.rs @@ -833,6 +833,42 @@ fn placed(visible: bool, matrix: &str, path: &str, preview: Option<&[u8]>, after s } +/// [`placed`]'s file with its placed file written as the copy of an object on `%_` lines (the +/// editable object whose drawn look comes before it): the lines from `%AI5_BeginPlace` to +/// `%AI5_EndPlace` start with `%_`, the versioned content's markers aside. The preview's header +/// line does too; its samples follow it raw. +fn hide_placed(data: &[u8]) -> Vec { + let find = |w: &[u8]| data.windows(w.len()).position(|x| x == w).unwrap(); + let (from, to) = (find(b"%AI5_BeginPlace"), find(b"%AI5_EndPlace\r") + 14); + let mut out = data[..from].to_vec(); + for line in data[from..to].split(|b| *b == b'\r') { + if !line.is_empty() && !line.starts_with(b"%AI17_") { + out.extend_from_slice(b"%_"); + } + out.extend_from_slice(line); + out.push(b'\r'); + } + out.pop(); + out.extend_from_slice(&data[to..]); + out +} + +#[test] +fn a_placed_file_on_commented_lines_is_read() { + // Its `%_%AI5_BeginPlace` was dropped as a comment after `%_`, so the `~` that ends it was an + // operator the reader didn't know, and the whole file came in as its PDF part; and its + // preview, whose header starts with `%_`, wasn't read. + let preview = [&b"2 1 12 32 17 "[..], &[255, 255, 0, 0, 128, 0, 64, 0, 9, 9, 9, 9]].concat(); + let data = hide_placed(&placed(true, "[5 0 0 -5 0 200]", "/pics/photo.png", Some(&preview), "")); + assert!(data.windows(18).any(|w| w == b"%_%AI5_BeginPlace\r"), "{}", String::from_utf8_lossy(&data)); + let r = read(&data).unwrap(); + let a = art(&r.doc); + let NodeKind::Image(im) = &a[0].kind else { panic!("{:?}", a[0].kind) }; + assert_eq!((im.link.as_ref().map(|l| l.path.as_str()), im.width, im.height), (Some("/pics/photo.png"), 2, 1)); + let (img, _) = pixels(&r.doc); + assert_eq!((img.get_pixel(0, 0).0, img.get_pixel(1, 0).0), ([255, 0, 0, 255], [0, 127, 0, 128]), "its preview"); +} + #[test] fn placed_files_are_linked_images_showing_their_preview() { // A 2×1 preview (premultiplied ARGB, a padded row) of a file of 4×2 pixels. diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index cf2fbe39e1..77a5bd789c 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File format parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (PDF export: opaque gradient meshes as smooth Type 6 patch shadings) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (`.ai` import: placed files on `%_` lines no longer send the file to its PDF part) · **Target:** Adobe Illustrator 2026 (30.x) Every format Illustrator opens, places, saves or exports, against VectorCraft's format table (`FORMATS`, `OPEN_EXTS`, `PLACE_EXTS` in `crates/engine/src/cmd/fileio/formats.rs`). Illustrator's list comes from its public @@ -132,6 +132,7 @@ the app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPri | Date | Change | Summary | |---|---|---| +| 2026-10-30 | minor | `.ai` import: a placed (linked) file written as an object's copy on `%_` lines is read: its `%AI5_BeginPlace` and `%AI5_EndPlace` markers there were dropped, so the `~` that ends it was an unknown operator and the whole file came in as its PDF part; its preview's header, on a `%_` line too, is read. Own-fixture test in `import::ai::tests`; scores unchanged | | 2026-10-30 | minor | PDF export: an opaque gradient mesh is written as one PDF Type 6 (Coons patch) shading (ISO 32000-1, 8.7.4.5.7) filling its outline, so viewers blend its colours smoothly instead of showing the bands and seams of the 8 × 8 flat quads a patch it was cut into; a file of 65,558 small meshes exports in 14 s instead of 56 s, at half the size. A mesh with see-through points is still written as quads. Own-fixture tests in `tests::mesh_export`; scores unchanged | | 2026-10-30 | minor | `.ai` import: a file whose PDF part is an empty page opens from its editing data where that reads, instead of opening blank; scores unchanged | | 2026-10-30 | minor | `.ai` import: a file whose PDF part's pages are cropped to its art rather than its artboards no longer comes in as that PDF part (each page a copy of all the art) but from its layers, with its artboards, where they draw as the page does; own-fixture test in `tests_aiimport`; scores unchanged | From 39bb862420cfe8e06fe6a8e061d0a7e5f49295bb Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Thu, 29 Oct 2026 22:32:34 -0400 Subject: [PATCH 023/163] deps: bump tar, zip, roxmltree, rustls-webpki and symphonia to their latest versions (#4662) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `roxmltree`: 0.20.0, 0.21.1 → 0.20.0, 0.21.2 - `zip`: 9.1.0 → 9.1.3 Lockfile only. --- Cargo.lock | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 78306baae3..9627beff96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -217,7 +217,7 @@ dependencies = [ "objc2-foundation 0.3.2", "parking_lot", "percent-encoding", - "windows-sys 0.61.2", + "windows-sys 0.59.0", "wl-clipboard-rs", "x11rb", ] @@ -1017,7 +1017,7 @@ source = "git+https://github.com/storytold/craft-libs?rev=92d392cff132eaf53e13af dependencies = [ "craft-winprint-gdi", "miniz_oxide 0.9.1", - "roxmltree 0.21.1", + "roxmltree 0.21.2", "tempfile", "winprint", "winsafe", @@ -1562,7 +1562,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -3617,7 +3617,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -4139,7 +4139,7 @@ dependencies = [ "once_cell", "socket2", "tracing", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -4445,9 +4445,9 @@ checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" [[package]] name = "roxmltree" -version = "0.21.1" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1964b10c76125c36f8afe190065a4bf9a87bf324842c05701330bba9f1cacbb" +checksum = "9da7f59328b09405b181fee1018925fad50f157afb43c0c0f5c522c256dd5907" dependencies = [ "memchr", ] @@ -4496,7 +4496,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.12.1", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -4555,7 +4555,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -5414,10 +5414,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.4.3", + "getrandom 0.3.4", "once_cell", "rustix 1.1.5", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -5992,7 +5992,7 @@ dependencies = [ "kurbo 0.13.1", "log", "pico-args", - "roxmltree 0.21.1", + "roxmltree 0.21.2", "simplecss", "siphasher", "skrifa 0.44.0", @@ -6196,7 +6196,7 @@ dependencies = [ "kurbo 0.13.1", "log", "proptest", - "roxmltree 0.21.1", + "roxmltree 0.21.2", "rustix 1.1.5", "ruzstd", "serde", @@ -6335,7 +6335,7 @@ dependencies = [ "kurbo 0.13.1", "log", "md-5", - "roxmltree 0.21.1", + "roxmltree 0.21.2", "serde", "serde_json", "sha2", @@ -7181,7 +7181,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -7907,9 +7907,9 @@ dependencies = [ [[package]] name = "zip" -version = "9.1.0" +version = "9.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2886b00003a72c4ccee3f42cfc34908d33b2508a74d827dc2a4244706475c704" +checksum = "1156b39d142a34b999c2310a50455e0cb3760bf7efad0122f796d813bee26ccb" dependencies = [ "crc32fast", "flate2", From c733ae97f01f6c16edc5213fac7998d2e7f0c0ce Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Thu, 29 Oct 2026 22:36:34 -0400 Subject: [PATCH 024/163] CI: workflows only call craft-common-actions at @main (#4656) AGENTS.md (and CLAUDE.md where present) gets a CI workflows section: workflows only call craft-common-actions at @main, with no other jobs; feature and fix PRs don't touch CI and link or open a craft-common-actions issue (a PR only for a small fix that is safe for every app and does not increase CI time); legacy jobs aren't added to and move only as their own task, staying until a shared workflow runs them. windows-arm64.yml moves from its SHA pin to @main. The pinned revision is on craft-common-actions main and the workflow (and the actions it calls) is identical there, so nothing changes in behaviour. --- .github/workflows/windows-arm64.yml | 4 ++-- AGENTS.md | 5 +++++ CLAUDE.md | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-arm64.yml b/.github/workflows/windows-arm64.yml index 7fc9b59251..b121ce45f1 100644 --- a/.github/workflows/windows-arm64.yml +++ b/.github/workflows/windows-arm64.yml @@ -27,8 +27,8 @@ permissions: jobs: windows-arm64: - # Immutable supporting workflow revision until the new install contract lands upstream. - uses: storytold/craft-common-actions/.github/workflows/windows-arm64.yml@8bb4e5ab95443171104ad88113fe1ef9b0e5ce3f + # Intentionally tracked at @main (not SHA-pinned) so org-wide CI improvements, security fixes, and build optimizations propagate without PR churn across all craftapp repos. + uses: storytold/craft-common-actions/.github/workflows/windows-arm64.yml@main with: app-name: vectorcraft app-dir: VectorCraft diff --git a/AGENTS.md b/AGENTS.md index 61f141079e..1677f01c52 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -86,3 +86,8 @@ When a task lands, update in the same PR: the area row in `docs/target-app-parit GitHub profiles). Never hand-edit `contributors.json`. - Maintainers refresh the stats with `python3 ../../craftrules/scripts/contributors.py .` (it also re-verifies who wrote each `people.toml` entry; `--check` only verifies). + +## CI workflows +- Workflows in `.github/workflows/` call the shared workflows in [`storytold/craft-common-actions`](https://github.com/storytold/craft-common-actions) at `@main`, with their inputs and secrets. No other jobs: if no shared workflow does what's needed, it doesn't go here. +- Don't add or change CI in a feature or fix PR. If the existing workflows can't build or test a change, link an existing craft-common-actions issue or PR, or open a new issue, or a PR only for a small fix that is safe for every app and does not increase CI time. +- Some workflow files here still run their own jobs. Don't add to them. Moving a job into craft-common-actions is its own task, never part of another PR, and the job stays here until a shared workflow runs it. diff --git a/CLAUDE.md b/CLAUDE.md index 0460b61925..2b6ffcc436 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -69,3 +69,8 @@ The progress docs follow craftrules' [`standards/progress-docs.md`](https://gith When a task lands, update in the same PR: the area row in `docs/target-app-parity.md` (score, missing items, hours) and its evidence list, the gap entry in `docs/gaps.md` if it closed or shrank, the checklist it belongs to, the milestone row in `docs/roadmap.md`, and the ROADMAP's tables and progress log when a headline number moves. Update each touched doc's status line and revision history. - Grade by behaviour against the public documentation (`plan/illustrator/` notes), not by whether a menu item exists. Scores are self-assessed, so err low; mark each number measured or estimated. - Keep the README's Status section in step with the ROADMAP headline. + +## CI workflows +- Workflows in `.github/workflows/` call the shared workflows in [`storytold/craft-common-actions`](https://github.com/storytold/craft-common-actions) at `@main`, with their inputs and secrets. No other jobs: if no shared workflow does what's needed, it doesn't go here. +- Don't add or change CI in a feature or fix PR. If the existing workflows can't build or test a change, link an existing craft-common-actions issue or PR, or open a new issue, or a PR only for a small fix that is safe for every app and does not increase CI time. +- Some workflow files here still run their own jobs. Don't add to them. Moving a job into craft-common-actions is its own task, never part of another PR, and the job stays here until a shared workflow runs it. From beb0ae651583729e93092366cd7ebce9dc82a610 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Fri, 30 Oct 2026 08:53:10 +0700 Subject: [PATCH 025/163] SVG export: rectangles, circles, ellipses, lines and straight paths as SVG shape elements (#4652) --- crates/engine/src/cmd/effectcmd/tests.rs | 2 +- crates/engine/src/cmd/fileio/tests_dxf.rs | 2 +- crates/engine/src/cmd/fileio/tests_svg.rs | 4 +- crates/engine/src/cmd/fileio/tests_svgenc.rs | 8 +- crates/engine/src/tests/clippaint.rs | 2 +- crates/engine/src/tests/containers.rs | 4 +- crates/engine/src/tests/file.rs | 2 +- crates/engine/src/tests/live.rs | 2 +- crates/engine/src/tests/pattern.rs | 2 +- crates/engine/src/tests/registration.rs | 4 +- crates/engine/tests/it/three_d_light_color.rs | 2 +- crates/svg/src/export.rs | 3 +- crates/svg/src/export/nodes.rs | 19 ++- crates/svg/src/export/output.rs | 93 ++++++++++++ crates/svg/src/export/text.rs | 6 +- crates/svg/tests/it/basic_shapes.rs | 136 ++++++++++++++++++ crates/svg/tests/it/effects_export.rs | 10 +- crates/svg/tests/it/main.rs | 1 + crates/svg/tests/it/options.rs | 2 +- crates/svg/tests/it/roundtrip.rs | 10 +- crates/svg/tests/it/symbols_layers.rs | 6 +- crates/testkit/src/lib.rs | 6 + crates/ui-egui/src/dialogs/svg_options.rs | 2 +- crates/ui-egui/src/dialogs/tests_export.rs | 2 +- docs/file-format-parity.md | 5 +- docs/target-app-parity.md | 4 +- 26 files changed, 294 insertions(+), 45 deletions(-) create mode 100644 crates/svg/tests/it/basic_shapes.rs diff --git a/crates/engine/src/cmd/effectcmd/tests.rs b/crates/engine/src/cmd/effectcmd/tests.rs index c23c578d06..e5279391ac 100644 --- a/crates/engine/src/cmd/effectcmd/tests.rs +++ b/crates/engine/src/cmd/effectcmd/tests.rs @@ -68,7 +68,7 @@ fn solid_effects_apply_save_edit_export_expand_and_undo() { assert!(s.execute("effect.setParams", &json!({"index": 0, "params": {"bevel": "nope"}, "ids": [id.0], "item": null})).is_err()); let svg = s.execute("document.serialize", &json!({"format": "svg"})).unwrap(); let svg = svg["data"].as_str().or_else(|| svg["text"].as_str()).map(str::to_string).unwrap_or_else(|| svg.to_string()); - assert!(svg.matches("= 2, "{effect}: exported as vector faces"); + assert!(vectorcraft_testkit::svg_shapes(&svg) >= 2, "{effect}: exported as vector faces"); s.execute("effect.expandAppearance", &json!({"ids": [id.0]})).unwrap(); assert!(matches!(node(&s, id).kind, NodeKind::Group { .. }), "{effect}"); assert!(!effects::has_solid(&node(&s, id))); diff --git a/crates/engine/src/cmd/fileio/tests_dxf.rs b/crates/engine/src/cmd/fileio/tests_dxf.rs index 6bea6dad72..eec800d74a 100644 --- a/crates/engine/src/cmd/fileio/tests_dxf.rs +++ b/crates/engine/src/cmd/fileio/tests_dxf.rs @@ -101,7 +101,7 @@ fn selected_only_exports_the_selection_in_its_layers() { // Other formats take it too. s.execute("select.set", &json!({"ids": [line]})).unwrap(); let svg = s.execute("document.serialize", &json!({"format": "svg", "selectedOnly": true})).unwrap()["text"].as_str().unwrap().to_string(); - assert_eq!((svg.matches("") && o.contains("class=\"cls-1\"")); changed(&mut s, json!({"objectIds": "minimal"}), &|o| !o.contains(" id=\"")); changed(&mut s, json!({"objectIds": "unique"}), &|o| o.contains(" id=\"u") && o.contains("-Layer_1\"")); - changed(&mut s, json!({"decimals": 1}), &|o| o.contains("M10.1 ") && !o.contains("10.123")); + changed(&mut s, json!({"decimals": 1}), &|o| o.contains("x=\"10.1\"") && !o.contains("10.123")); changed(&mut s, json!({"decimals": 6}), &|o| o.contains("10.123456")); changed(&mut s, json!({"minify": true}), &|o| !o.trim_end().contains('\n') && !o.contains("") && text.matches("") && vectorcraft_testkit::svg_shapes(&text) == 2, "Save reuses the options: {text}"); assert!(s.execute("document.save", &json!({"path": dir.join("x.png").to_string_lossy()})).is_err(), "PNG is an export"); // A native save switches back. let native = dir.join("doc.vectorcraft").to_string_lossy().to_string(); diff --git a/crates/engine/src/cmd/fileio/tests_svgenc.rs b/crates/engine/src/cmd/fileio/tests_svgenc.rs index f901115d1e..d1d9123139 100644 --- a/crates/engine/src/cmd/fileio/tests_svgenc.rs +++ b/crates/engine/src/cmd/fileio/tests_svgenc.rs @@ -61,7 +61,7 @@ fn a_chosen_artboard_s_svg_holds_only_its_own_art() { s.execute("shape.rectangle", &json!({"x": first + 10.0, "y": 10, "width": 30, "height": 30})).unwrap(); s.execute("shape.ellipse", &json!({"x": third + 10.0, "y": 10, "width": 30, "height": 30})).unwrap(); // A rectangle has straight sides only; the ellipse is curves. - let shapes = |svg: &str| (svg.matches("