Merge main into fix/script-remove-trace-source

This commit is contained in:
dotCooCoo committed 2026-12-03 11:24:30 -08:00
commit d5637c8d06
28 files changed
+648 -21

No files matched your search

+2
View File
@@ -124,6 +124,8 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap
## Progress log
- 2026-12-03: View › Show Curvature Comb (`view.curvatureComb`) draws the curvature comb of the selected paths and compound paths: teeth along the normal as long as the curvature, and a line through their tips (#10659). Headline numbers unchanged.
- 2026-12-02: The desktop Print dialog looks up installed printers in the background. Named printers become selectable after the lookup returns and the dialog applies the list. PDF File is available at once. Physical printing waits for the list to be applied, and Done can save settings while the lookup runs. The dialog shows and announces discovery and disables physical Print until the list is applied.
- 2026-11-20: Color conversion indexes global swatch bases and linked-paint lookups (#8804); scores, estimates and measured budgets unchanged.
+2
View File
@@ -980,6 +980,8 @@ pub const DESKTOP_MENU_ITEMS: &[(&[&str], &str)] = &[
(&["View"], "Show Corner Widget"),
(&["View"], "Show Live Paint Gaps"),
(&["View"], "Hide Live Paint Gaps"),
(&["View"], "Show Curvature Comb"),
(&["View"], "Hide Curvature Comb"),
(&["View"], "Guides"),
(&["View"], "Smart Guides"),
(&["View"], "Perspective Grid"),
+24 -8
View File
@@ -1410,7 +1410,8 @@ fn see_points(h: &super::Host, key: (u64, u64), own: impl FnOnce() -> bool) {
/// [`see_points`] for each path whose points the run has read, after each command, so that a
/// change that a later command reverses still makes the points stale. Paths under the object that
/// the object model is changing ([`super::State`]), or that object itself, take the change as the
/// object model's own, and their points stay valid. A document that is the one the run last looked
/// object model's own, and their points stay valid; the other Global Edit members, which take the
/// object model's edit too, are looked at as well. A document that is the one the run last looked
/// at is skipped, as are its paths. The look is charged by the objects it looks at.
pub(super) fn see_all_points(h: &super::Host) -> std::result::Result<(), HostError> {
let (keys, looked_at): (Vec<(u64, u64)>, u64) = {
@@ -1420,7 +1421,8 @@ pub(super) fn see_all_points(h: &super::Host) -> std::result::Result<(), HostErr
let mut keys = Vec::new();
let mut looked_at = 0u64;
docs.retain(|uid, before| {
let after = s.documents().iter().find(|d| d.uid == *uid).map(|st| &st.doc);
let state = s.documents().iter().find(|d| d.uid == *uid);
let after = state.map(|st| &st.doc);
if after.is_some_and(|after| Arc::ptr_eq(before, after)) {
return true;
}
@@ -1430,16 +1432,28 @@ pub(super) fn see_all_points(h: &super::Host) -> std::result::Result<(), HostErr
return false;
}
// Editing a path in an Objects on Path group can move the other paths in the group, so
// the outermost such group is looked at in place of the path.
// the outermost such group is looked at in place of the path. While Global Edit is on,
// an edit of the selected member (also one made by moving a group that holds it) is
// given to the other members, so each of them, or the outermost Objects on Path group
// holding it, is looked at too. Subtrees the command left as they were are skipped.
// Each node is paired with the node of the same id under the same parent now, so that no
// node is searched for through the whole document.
let mut todo: Vec<_> = match h.dom.editing.get().filter(|item| item.doc.uid == *uid) {
Some(item) => {
let group = before
.ancestry(item.id)
.and_then(|a| a.into_iter().find(|g| before.node(*g).is_some_and(vectorcraft_doc::objects_on_path::is_objects_on_path)));
let id = group.unwrap_or(item.id);
node_arc(before, id).map(|n| (n, after.and_then(|d| node_arc(d, id)))).into_iter().collect()
let root = |id: NodeId| {
before
.ancestry(id)
.and_then(|a| a.into_iter().find(|g| before.node(*g).is_some_and(vectorcraft_doc::objects_on_path::is_objects_on_path)))
.unwrap_or(id)
};
let members = state.and_then(|st| st.global_edit.as_ref()).map(|ge| ge.members.iter().map(|(id, _)| *id)).into_iter().flatten();
let mut roots = std::collections::HashSet::new();
std::iter::once(item.id)
.chain(members)
.map(root)
.filter(|id| roots.insert(*id))
.filter_map(|id| node_arc(before, id).map(|n| (n, after.and_then(|d| node_arc(d, id)))))
.collect()
}
None => paired(&before.layers, after.map(|d| &d.layers), &mut looked_at),
};
@@ -1481,6 +1495,8 @@ pub(super) fn see_all_points(h: &super::Host) -> std::result::Result<(), HostErr
false
}
});
keys.sort_unstable();
keys.dedup();
(keys, looked_at)
};
if looked_at > 0 {
@@ -1624,6 +1624,71 @@ fn a_point_outside_an_inner_objects_on_path_group_is_stale_after_its_path_change
assert_eq!(art(&s), before);
}
/// Global Edit gives an edit of one member to the others, so a point read of another member before
/// the edit is stale afterwards, even when an undo puts the member back.
#[test]
fn a_point_of_another_global_edit_member_is_stale_after_an_edit_and_undo() {
let (mut s, a, _) = doc();
let c = rect(&mut s, 200.0, 100.0, 30.0, 40.0);
s.execute("object.setProps", &json!({"ids": [a.0], "name": "edit"})).unwrap();
s.execute("object.setProps", &json!({"ids": [c.0], "name": "m"})).unwrap();
s.execute("select.set", &json!({"ids": [a.0]})).unwrap();
let r = s.execute("select.globalEdit", &json!({})).unwrap();
assert_eq!(r["count"], json!(2), "{r}");
let before = art(&s);
let out = log(
&mut s,
"var P = app.activeDocument.pathItems, p = P.getByName('edit'), m = P.getByName('m');\
vc.log(m.pathPoints[0].anchor);\
var q = p.pathPoints[0]; q.anchor = [q.anchor[0] - 10, q.anchor[1]];\
vc.log(P.getByName('m').pathPoints[0].anchor); app.undo();",
);
assert_ne!(out[0], out[1], "the other member took the edit");
assert_eq!(art(&s), before);
let e = failure(
&mut s,
"var P = app.activeDocument.pathItems, p = P.getByName('edit'), m = P.getByName('m');\
var mp = m.pathPoints[0]; mp.anchor;\
var q = p.pathPoints[0]; q.anchor = [q.anchor[0] - 10, q.anchor[1]]; app.undo();\
mp.anchor;",
);
assert!(e.contains("Stale path point"), "{e}");
assert_eq!(art(&s), before);
}
/// Moving a group that holds the selected Global Edit member moves the other members too, so a
/// point read of another member before the move is stale afterwards.
#[test]
fn a_point_of_another_global_edit_member_is_stale_after_its_group_moves_and_undoes() {
let (mut s, a, b) = doc();
let c = rect(&mut s, 200.0, 100.0, 30.0, 40.0);
s.execute("object.setProps", &json!({"ids": [c.0], "name": "m"})).unwrap();
s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap();
s.execute("object.group", &json!({})).unwrap();
s.execute("select.set", &json!({"ids": [a.0]})).unwrap();
let r = s.execute("select.globalEdit", &json!({})).unwrap();
assert_eq!(r["count"], json!(2), "{r}");
let before = art(&s);
let out = log(
&mut s,
"var P = app.activeDocument.pathItems, m = P.getByName('m');\
vc.log(m.pathPoints[0].anchor);\
app.activeDocument.groupItems[0].translate(10, 0);\
vc.log(P.getByName('m').pathPoints[0].anchor); app.undo();",
);
assert_ne!(out[0], out[1], "the other member took the move");
assert_eq!(art(&s), before);
let e = failure(
&mut s,
"var P = app.activeDocument.pathItems, m = P.getByName('m');\
var mp = m.pathPoints[0]; mp.anchor;\
app.activeDocument.groupItems[0].translate(10, 0); app.undo();\
mp.anchor;",
);
assert!(e.contains("Stale path point"), "{e}");
assert_eq!(art(&s), before);
}
/// [`doc`] with pattern `Dots` and spot swatch `Ink`, and path `a` with no fill or stroke.
fn doc_with_paints() -> (Session, NodeId) {
let (mut s, a, _) = doc();
+321
View File
@@ -219,12 +219,333 @@ pub fn circular_arc(c: CubicBez) -> Option<(Point, f64)> {
((l0 - handle).abs() <= HANDLE_TOL * handle && (l3 - handle).abs() <= HANDLE_TOL * handle).then_some((center, radius))
}
/// One tooth of a curvature comb: it starts on the curve at `at` and ends at `tip`, along the
/// curve's normal on the side away from its center of curvature, `scale` times the curvature long.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct CombTooth {
pub at: Point,
pub tip: Point,
/// The first tooth of the comb, the first after a point or segment that has no tooth, or the
/// first after the curve turns back on itself (a cusp between two teeth): a line through the
/// tips starts again here.
pub start: bool,
/// The index of the segment the tooth sits on.
pub segment: usize,
}
/// The most teeth a curvature comb draws in all.
pub const MAX_COMB_TEETH: usize = 20_000;
/// The curvature comb of `sp`: `samples` teeth on each segment (at least 2), evenly spaced in `t`
/// from 0 to 1, each `scale` times the signed curvature long ([`CombTooth`]). A straight segment
/// gives teeth of no length, its ends included. A point of a curved segment where it has no
/// direction (a handle drawn back onto its anchor) gives no tooth, and neither does a segment
/// with no length, a segment whose points are not finite, or a `scale` that is not finite. When
/// `samples` teeth on every segment would pass `max_teeth`, every segment gets 2 teeth, and when
/// that would still pass it, only every k-th segment gets teeth, spread along the whole subpath.
pub fn curvature_comb(sp: &SubPath, samples: usize, scale: f64, max_teeth: usize) -> Vec<CombTooth> {
let n = sp.segment_count();
if n == 0 || !scale.is_finite() || max_teeth < 2 {
return vec![];
}
let per = if samples.max(2).saturating_mul(n) <= max_teeth { samples.max(2) } else { 2 };
let stride = (per * n).div_ceil(max_teeth).max(1);
let mut teeth = Vec::with_capacity((per * n / stride).min(max_teeth));
let mut start = true;
// The direction of the last curved tooth, carried across segments so that a cusp at an
// anchor also starts a new line through the tips.
let mut previous_direction: Option<Vec2> = None;
for seg in (0..n).step_by(stride) {
if stride > 1 {
start = true;
previous_direction = None;
}
let c = sp.segment(seg);
if ![c.p0, c.p1, c.p2, c.p3].iter().all(|p| p.is_finite()) {
start = true;
previous_direction = None;
continue;
}
let (d1, d2) = (c.deriv(), c.deriv().deriv());
// The control polygon's length sets what counts as no speed.
let size = (c.p1 - c.p0).hypot() + (c.p2 - c.p1).hypot() + (c.p3 - c.p2).hypot();
let chord = c.p3 - c.p0;
let line = sp.segment_is_line(seg) && chord.hypot() > 0.0;
for i in 0..per {
if teeth.len() >= max_teeth {
return teeth;
}
let t = i as f64 / (per - 1) as f64;
if line {
// A line stored with its handles on its anchors has no speed at its ends, but a
// direction and no curvature all along.
let at = c.eval(t);
previous_direction = None;
if !at.is_finite() {
start = true;
continue;
}
teeth.push(CombTooth { at, tip: at, start, segment: seg });
start = false;
continue;
}
let (v, a) = (d1.eval(t).to_vec2(), d2.eval(t).to_vec2());
let speed = v.hypot();
if speed <= CUSP_SHARE * size || !speed.is_finite() {
start = true;
previous_direction = None;
continue;
}
let k = v.cross(a) / (speed * speed * speed);
let direction = v / speed;
start |= previous_direction.is_some_and(|previous| previous.dot(direction) < 0.0);
previous_direction = Some(direction);
let normal = Vec2::new(-direction.y, direction.x);
let at = c.eval(t);
let tip = at - normal * (k * scale);
if !at.is_finite() || !tip.is_finite() {
start = true;
previous_direction = None;
continue;
}
teeth.push(CombTooth { at, tip, start, segment: seg });
start = false;
}
}
teeth
}
/// Does the line through the tips of `teeth`, the comb of `sp` ([`curvature_comb`]), close where
/// it starts: `sp` is closed, only segments with no length lie between its last tooth and its
/// first across the seam, the two sit on the same point, and the curve does not turn back on itself at its
/// first anchor. A comb that skips segments to keep to its budget does not close across the ones
/// it skipped at the end.
pub fn comb_closes(sp: &SubPath, teeth: &[CombTooth]) -> bool {
let (Some(first), Some(last)) = (teeth.first(), teeth.last()) else {
return false;
};
let n = sp.segment_count();
if !sp.closed || teeth.len() < 2 || first.at.distance(last.at) >= 1e-9 {
return false;
}
// Only segments with no length may lie between the last tooth and the first across the seam.
let no_length = |i: usize| start_direction(sp.segment(i)) == Vec2::ZERO;
if !(last.segment + 1..n).chain(0..first.segment).all(no_length) {
return false;
}
match (neighbor(sp, 0, false), neighbor(sp, n.saturating_sub(1), true)) {
(Some((into, _)), Some((out, _))) => end_direction(into).dot(start_direction(out)) >= 0.0,
_ => false,
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::{Anchor, shapes};
use kurbo::Rect;
fn tooth_len(t: &CombTooth) -> f64 {
t.at.distance(t.tip)
}
/// A circle's comb points away from the center, each tooth `scale` times the cubic's own
/// curvature at its point ([`curvature_circle_with`] without arcs), all within 3% of
/// `scale / r` (the usual cubic of a quarter turn strays that little from its circle).
#[test]
fn the_comb_of_a_circle_has_teeth_of_one_length() {
let pd = shapes::ellipse(Rect::new(50.0, 50.0, 250.0, 250.0));
let sp = &pd.subpaths[0];
let teeth = curvature_comb(sp, 9, 1000.0, MAX_COMB_TEETH);
assert_eq!(teeth.len(), 9 * sp.segment_count());
assert_eq!(teeth.iter().filter(|t| t.start).count(), 1, "one unbroken comb");
let center = Point::new(150.0, 150.0);
for (i, t) in teeth.iter().enumerate() {
let (seg, at) = (i / 9, (i % 9) as f64 / 8.0);
let r = curvature_circle_with(sp.segment(seg), at, false, false).unwrap().radius;
assert!((tooth_len(t) * r - 1000.0).abs() < 1e-6, "{t:?} {r}");
assert!((tooth_len(t) - 10.0).abs() < 0.3, "{t:?}");
assert!(t.tip.distance(center) > t.at.distance(center), "outward: {t:?}");
}
}
/// A straight line has teeth of no length, its two ends included.
#[test]
fn the_comb_of_a_line_is_flat() {
let sp = SubPath::polyline(&[Point::new(0.0, 0.0), Point::new(100.0, 40.0), Point::new(200.0, 0.0)], false);
let teeth = curvature_comb(&sp, 5, 1000.0, MAX_COMB_TEETH);
assert_eq!(teeth.len(), 10);
assert!(teeth.iter().all(|t| tooth_len(t) < 1e-9), "{teeth:?}");
assert_eq!(teeth[4].at, Point::new(100.0, 40.0), "the corner has a tooth on each side");
}
/// Two quarter circles of radius 100 and 50 that meet in one direction: the teeth double in
/// length at the anchor they share.
#[test]
fn the_comb_jumps_where_the_curvature_does() {
let k = 4.0 / 3.0 * (std::f64::consts::FRAC_PI_8).tan();
let a0 = Anchor { h_out: Point::new(100.0 * k, 0.0), ..Anchor::corner(Point::new(0.0, 0.0)) };
let a1 = Anchor {
h_in: Point::new(100.0, 100.0 - 100.0 * k),
h_out: Point::new(100.0, 100.0 + 50.0 * k),
..Anchor::corner(Point::new(100.0, 100.0))
};
let a2 = Anchor { h_in: Point::new(50.0 + 50.0 * k, 150.0), ..Anchor::corner(Point::new(50.0, 150.0)) };
let sp = SubPath::new(vec![a0, a1, a2], false);
let teeth = curvature_comb(&sp, 3, 1000.0, MAX_COMB_TEETH);
assert_eq!(teeth.len(), 6);
let (before, after) = (tooth_len(&teeth[2]), tooth_len(&teeth[3]));
assert!((after / before - 2.0).abs() < 1e-9, "{before} {after}");
assert!((before - 10.0).abs() < 0.3, "{before}");
assert!(teeth[2].at.distance(teeth[3].at) < 1e-9, "both teeth start on the shared anchor");
assert_eq!(teeth.iter().filter(|t| t.start).count(), 1, "a smooth anchor keeps one unbroken comb");
}
/// Two segments that meet at a cusp on their shared anchor: the first segment ends heading
/// down and the second starts heading up, so the line through the tips starts again there.
#[test]
fn the_comb_breaks_at_a_cusp_on_an_anchor() {
let a0 = Anchor { h_out: Point::new(0.0, -50.0), ..Anchor::corner(Point::new(0.0, 0.0)) };
let a1 = Anchor { h_in: Point::new(100.0, -50.0), h_out: Point::new(100.0, -25.0), ..Anchor::corner(Point::new(100.0, 0.0)) };
let a2 = Anchor { h_in: Point::new(200.0, -25.0), ..Anchor::corner(Point::new(200.0, 0.0)) };
let sp = SubPath::new(vec![a0, a1, a2], false);
let teeth = curvature_comb(&sp, 3, 1000.0, MAX_COMB_TEETH);
assert_eq!(teeth.len(), 6);
assert_eq!(teeth.iter().map(|t| t.start).collect::<Vec<_>>(), [true, false, false, true, false, false]);
assert!(!comb_closes(&sp, &teeth), "an open subpath does not close");
}
/// A closed comb closes at its first anchor when the curve goes on smoothly there, even with a
/// cusp elsewhere, and stays open when the first anchor is the cusp.
#[test]
fn the_comb_closes_unless_its_first_anchor_is_a_cusp() {
let closed = |h_in: Point| {
let a0 = Anchor { h_in, h_out: Point::new(0.0, -50.0), ..Anchor::corner(Point::new(0.0, 0.0)) };
let a1 = Anchor { h_in: Point::new(100.0, -50.0), h_out: Point::new(100.0, -25.0), ..Anchor::corner(Point::new(100.0, 0.0)) };
let a2 = Anchor { h_in: Point::new(200.0, -25.0), h_out: Point::new(200.0, 50.0), ..Anchor::corner(Point::new(200.0, 0.0)) };
SubPath::new(vec![a0, a1, a2], true)
};
let smooth = closed(Point::new(0.0, 50.0));
let teeth = curvature_comb(&smooth, 3, 1000.0, MAX_COMB_TEETH);
assert_eq!(teeth.iter().filter(|t| t.start).count(), 2, "the cusp at the second anchor breaks the comb");
assert!(comb_closes(&smooth, &teeth));
let cusp = closed(Point::new(0.0, -50.0));
assert!(!comb_closes(&cusp, &curvature_comb(&cusp, 3, 1000.0, MAX_COMB_TEETH)));
let circle = shapes::ellipse(Rect::new(0.0, 0.0, 100.0, 100.0));
let sp = &circle.subpaths[0];
assert!(comb_closes(sp, &curvature_comb(sp, 5, 1000.0, MAX_COMB_TEETH)));
}
/// A segment with no length and a handle drawn back onto its anchor do not panic and give no
/// tooth where the curve has no direction; a scale that is not finite gives no comb.
#[test]
fn the_comb_skips_points_with_no_direction() {
let p = Point::new(10.0, 10.0);
assert!(curvature_comb(&SubPath::polyline(&[p, p], false), 4, 1000.0, MAX_COMB_TEETH).is_empty());
let curve = SubPath::new(
vec![Anchor { h_out: Point::new(50.0, 0.0), ..Anchor::corner(Point::new(0.0, 0.0)) }, Anchor::corner(Point::new(100.0, 100.0))],
false,
);
let teeth = curvature_comb(&curve, 5, 1000.0, MAX_COMB_TEETH);
assert_eq!(teeth.len(), 4, "the end whose handle sits on its anchor has no tooth: {teeth:?}");
assert_eq!(teeth.iter().map(|t| t.start).collect::<Vec<_>>(), [true, false, false, false]);
let back = SubPath::new(
vec![Anchor::corner(Point::new(0.0, 0.0)), Anchor { h_in: Point::new(50.0, 0.0), ..Anchor::corner(Point::new(100.0, 100.0)) }],
false,
);
let teeth = curvature_comb(&back, 5, 1000.0, MAX_COMB_TEETH);
assert_eq!(teeth.len(), 4, "the start, whose handle sits on its anchor, has no tooth: {teeth:?}");
assert!(teeth[0].start, "the comb starts after the point with no tooth");
assert!(teeth.iter().all(|t| t.at.is_finite() && t.tip.is_finite()), "{teeth:?}");
assert!(curvature_comb(&curve, 5, f64::NAN, MAX_COMB_TEETH).is_empty());
}
/// A cusp between samples starts a new line through the comb's tips after the cusp.
#[test]
fn the_comb_breaks_at_a_cusp_between_samples() {
let bp = kurbo::BezPath::from_svg("M0 0 C100 100 0 100 100 0").unwrap();
let sp = &crate::PathData::from_bezpath(&bp).subpaths[0];
let teeth = curvature_comb(sp, 6, 1000.0, MAX_COMB_TEETH);
assert_eq!(teeth.len(), 6, "the cusp falls between teeth");
assert_eq!(teeth.iter().map(|t| t.start).collect::<Vec<_>>(), [true, false, false, true, false, false]);
assert!(teeth.iter().all(|t| t.at.is_finite() && t.tip.is_finite()), "{teeth:?}");
}
/// A tooth whose tip overflows is skipped, and the next finite tooth starts a new envelope.
#[test]
fn the_comb_breaks_after_a_nonfinite_tip() {
let sp = SubPath::new(
vec![
Anchor::with_handles(Point::new(-1.0, 1.0), Point::new(-1.0, 1.0), Point::new(-1.0 / 3.0, -1.0 / 3.0)),
Anchor::with_handles(Point::new(1.0, 1.0), Point::new(1.0 / 3.0, -1.0 / 3.0), Point::new(1.0, 1.0)),
],
false,
);
let teeth = curvature_comb(&sp, 5, f64::MAX, MAX_COMB_TEETH);
assert_eq!(teeth.len(), 4, "the middle tooth overflows");
assert!(teeth.iter().all(|t| t.at.is_finite() && t.tip.is_finite()), "{teeth:?}");
assert_eq!(teeth.iter().map(|t| t.start).collect::<Vec<_>>(), [true, false, true, false]);
assert!(teeth[1].at.x < 0.0 && teeth[2].at.x > 0.0, "the gap is inside the segment");
}
/// A speed whose cube underflows gives no tooth, and the first finite tooth starts the comb.
#[test]
fn the_comb_skips_a_tip_when_speed_cubed_underflows() {
let sp = SubPath::new(
vec![
Anchor::with_handles(Point::ORIGIN, Point::ORIGIN, Point::new(1e-109, 0.0)),
Anchor::with_handles(Point::ORIGIN, Point::new(1e-101, 1e-101), Point::ORIGIN),
],
false,
);
let teeth = curvature_comb(&sp, 5, 1.0, MAX_COMB_TEETH);
assert_eq!(teeth.len(), 4, "the first tooth has a nonfinite tip");
assert!(teeth.iter().all(|t| t.at.is_finite() && t.tip.is_finite()), "{teeth:?}");
assert!(teeth[0].start && teeth[0].at.x > 0.0, "the comb starts after the skipped tooth");
}
/// A subpath with more segments than the budget allows keeps to it, with teeth spread to its
/// far end rather than stopping part way.
#[test]
fn the_comb_is_capped_and_spread() {
let points: Vec<Point> = (0..30_001).map(|i| Point::new(i as f64, (i % 2) as f64)).collect();
let sp = SubPath::polyline(&points, false);
let teeth = curvature_comb(&sp, 16, 1.0, 1000);
assert!(teeth.len() <= 1000 && teeth.len() >= 900, "{}", teeth.len());
assert!(teeth.last().is_some_and(|t| t.at.x > 29_000.0), "{:?}", teeth.last());
assert_eq!(teeth.iter().filter(|t| t.start).count() * 2, teeth.len(), "each sampled segment starts a new line through the tips");
let few = curvature_comb(&sp, 16, 1.0, 100_000);
assert_eq!(few.len(), 60_000, "too many for 16 on each, so 2 on each");
}
/// A capped comb that skips the last segment does not close, even when the last segment it
/// samples ends on the first anchor: the line through the tips would cross the skipped loop.
#[test]
fn a_capped_comb_does_not_close_across_a_skipped_segment() {
let sp = SubPath::new(
vec![
Anchor::with_handles(Point::new(0.0, 0.0), Point::new(-50.0, -50.0), Point::new(50.0, 50.0)),
Anchor::with_handles(Point::new(100.0, 0.0), Point::new(80.0, 40.0), Point::new(120.0, 20.0)),
Anchor::with_handles(Point::new(100.0, 100.0), Point::new(140.0, 80.0), Point::new(60.0, 140.0)),
Anchor::with_handles(Point::new(0.0, 0.0), Point::new(30.0, 120.0), Point::new(-60.0, 60.0)),
],
true,
);
let teeth = curvature_comb(&sp, 16, 1000.0, 4);
let (first, last) = (&teeth[0], &teeth[teeth.len() - 1]);
assert!(last.segment < 3, "the closing segment is skipped: {teeth:?}");
assert!(first.at.distance(last.at) < 1e-9, "the last sampled tooth sits on the first anchor");
assert!(!comb_closes(&sp, &teeth), "the comb does not close across the skipped last segment");
assert!(comb_closes(&sp, &curvature_comb(&sp, 16, 1000.0, MAX_COMB_TEETH)), "the full comb closes");
let mut anchors: Vec<Anchor> = sp.anchors.iter().copied().collect();
anchors[0].h_in = anchors[0].p;
anchors.insert(0, Anchor { h_in: Point::new(-50.0, -50.0), ..Anchor::corner(Point::new(0.0, 0.0)) });
let seam = SubPath::new(anchors, true);
let full = curvature_comb(&seam, 16, 1000.0, MAX_COMB_TEETH);
assert_eq!(full.first().map(|t| t.segment), Some(1), "the segment of no length at the seam has no teeth");
assert!(comb_closes(&seam, &full), "the comb closes across a segment of no length");
}
/// Every segment of a circle drawn by [`shapes::ellipse`] is the usual cubic of a quarter
/// turn, and the circle at any point of it is the circle itself: radius 100, center (150, 150).
#[test]
+6
View File
@@ -261,6 +261,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"",
"{} toggle drawing the gaps of the selected Live Paint groups (those livePaint.info lists) in each group's Gap Preview Color while edges show → true when on",
),
(
"view.curvatureComb",
"Show Curvature Comb",
"",
"{} toggle drawing the curvature comb of the selected paths and compound paths while edges show: 16 teeth per segment along the normal, on the outer side of the bend, each as long as the curvature there (a radius of 100 screen points gives a 20-point tooth at any zoom), with a line through their tips in the layer color; about 20,000 teeth at most, fewer per segment on a large selection; a view setting, not saved in the document and not an undo step → true when on",
),
(
"type.hiddenCharacters",
"Show Hidden Characters",
+62
View File
@@ -835,3 +835,65 @@ pub(in crate::canvas) fn live_paint_gap_overlays(app: &mut VectorcraftApp) -> Ve
};
gaps.to_vec()
}
/// Teeth View → Show Curvature Comb draws on each segment.
const COMB_SAMPLES: usize = 16;
/// The comb's length at zoom 1, in screen points squared: a curve that bends with a radius of
/// 100 screen points has teeth 20 screen points long at any zoom. VectorCraft's own value.
const COMB_SCALE: f64 = 2000.0;
/// View → Show Curvature Comb: on each selected path, and each path of a selected compound path, a
/// tooth along the normal at evenly spaced points of every segment, as long as the curvature there,
/// and a line through the teeth's tips, in the path's layer color. At most
/// [`vectorcraft_geom::curvature::MAX_COMB_TEETH`] teeth in all, shared among the subpaths by their
/// number of segments, so a large selection gets fewer teeth everywhere.
pub(in crate::canvas) fn curvature_comb_overlays(app: &VectorcraftApp, zoom: f64) -> Vec<Overlay> {
use vectorcraft_geom::curvature::{MAX_COMB_TEETH, comb_closes, curvature_comb};
let Some(st) = app.session.active() else { return vec![] };
if !(zoom.is_finite() && zoom > 0.0) {
return vec![];
}
let scale = COMB_SCALE / (zoom * zoom);
let mut paths = vec![];
for &id in &st.selection.objects {
let Some(n) = st.doc.node(id).filter(|n| !n.is_guide()) else { continue };
let color = st.doc.layer_color(id);
match &n.kind {
NodeKind::Compound { children, .. } => paths.extend(children.iter().filter_map(|c| c.path_data()).map(|pd| (pd, color))),
_ => paths.extend(n.path_data().map(|pd| (pd, color))),
}
}
let all: Vec<_> =
paths.iter().flat_map(|(pd, color)| pd.subpaths.iter().map(move |sp| (sp, *color))).filter(|(sp, _)| sp.segment_count() > 0).collect();
// With more subpaths than the teeth allow 2 each, every k-th subpath gets a comb.
let stride = (all.len() * 2).div_ceil(MAX_COMB_TEETH).max(1);
let chosen: Vec<_> = all.into_iter().step_by(stride).collect();
// Each chosen subpath has 2 teeth set aside; the rest are shared by number of segments.
let total: usize = chosen.iter().map(|(sp, _)| sp.segment_count()).sum();
let spare = MAX_COMB_TEETH.saturating_sub(2 * chosen.len());
let mut o = vec![];
for (sp, color) in chosen {
let extra = (spare as u128) * (sp.segment_count() as u128) / (total.max(1) as u128);
let share = 2usize.saturating_add(usize::try_from(extra).unwrap_or(usize::MAX));
let teeth = curvature_comb(sp, COMB_SAMPLES, scale, share);
let mut envelope = BezPath::new();
for t in &teeth {
o.push(Overlay::Line { a: t.at, b: t.tip, color, dashed: false });
if t.start {
envelope.move_to(t.tip);
} else {
envelope.line_to(t.tip);
}
}
// A closed subpath combed all the way round ends where it starts: the line closes there.
if let Some(first) = teeth.first()
&& comb_closes(sp, &teeth)
{
envelope.line_to(first.tip);
}
if teeth.len() > 1 {
o.push(Overlay::Path { path: envelope, color, width: 1.0, dashed: false });
}
}
o
}
+40
View File
@@ -359,6 +359,46 @@ fn live_paint_gaps_follow_the_selected_groups() {
assert!(live_paint_gap_overlays(&mut app).is_empty());
}
/// View → Show Curvature Comb: a selected circle of radius 100 gets teeth 20 screen points long at
/// zoom 1 and 10 at zoom 2, where it shows twice as large (within 3%: the circle is made of cubics),
/// and a line through their tips; a compound path gets a comb on each of its paths; nothing
/// selected draws nothing.
#[test]
fn the_curvature_comb_follows_the_selection_and_the_zoom() {
let mut app = app();
let id = app.session.execute("shape.ellipse", &json!({"x": 100, "y": 50, "width": 200, "height": 200})).unwrap()["id"].as_u64().unwrap();
app.session.execute("select.set", &json!({"ids": [id]})).unwrap();
let teeth = |o: &[Overlay], zoom: f64| -> Vec<f64> {
o.iter().filter_map(|o| if let Overlay::Line { a, b, .. } = o { Some(a.distance(*b) * zoom) } else { None }).collect()
};
let at_one = teeth(&curvature_comb_overlays(&app, 1.0), 1.0);
for zoom in [1.0, 2.0] {
let o = curvature_comb_overlays(&app, zoom);
let got = teeth(&o, zoom);
assert_eq!(got.len(), 64, "16 teeth on each of the circle's four segments");
let want = 2000.0 / (100.0 * zoom);
assert!(got.iter().all(|t| (t - want).abs() < 0.03 * want), "{zoom}: {got:?}");
assert!(got.iter().zip(&at_one).all(|(t, one)| (t * zoom - one).abs() < 1e-9), "zoom divides each tooth's screen length");
assert_eq!(o.iter().filter(|o| matches!(o, Overlay::Path { .. })).count(), 1, "one line through the tips");
let Some(Overlay::Path { path, .. }) = o.iter().find(|o| matches!(o, Overlay::Path { .. })) else { panic!("no line through the tips") };
let ends: Vec<_> = path.elements().iter().filter_map(|e| e.end_point()).collect();
assert_eq!(ends.first(), ends.last(), "the closed circle's line through the tips closes");
}
let other = app.session.execute("shape.ellipse", &json!({"x": 150, "y": 100, "width": 100, "height": 100})).unwrap()["id"].as_u64().unwrap();
app.session.execute("select.set", &json!({"ids": [id, other]})).unwrap();
app.session.execute("object.compoundPath.make", &json!({})).unwrap();
let o = curvature_comb_overlays(&app, 1.0);
assert_eq!(o.iter().filter(|o| matches!(o, Overlay::Path { .. })).count(), 2, "the compound path's two paths");
assert_eq!(teeth(&o, 1.0).len(), 128);
app.session.execute("select.set", &json!({"ids": []})).unwrap();
assert!(curvature_comb_overlays(&app, 1.0).is_empty());
assert!(app.run("view.curvatureComb", json!({"on": true})).is_err(), "it takes no parameters");
assert!(!app.ui.view.curvature_comb, "a refused call leaves it off");
assert!(app.run("view.curvatureComb", json!({})).unwrap() == json!(true));
assert!(app.ui.view.curvature_comb);
assert!(app.run("view.curvatureComb", json!({})).unwrap() == json!(false));
}
/// Draw Inside's arms: an open rectangle round the object, each arm a third of its side or 16
/// points at most, kept with the object deselected and gone with the mode.
#[test]
@@ -782,6 +782,9 @@ fn show_overlays(app: &mut VectorcraftApp, ui: &mut Ui, pass: &ToolPass, view_in
if app.ui.view.live_paint_gaps {
extra.extend(super::marks::live_paint_gap_overlays(app));
}
if app.ui.view.curvature_comb {
extra.extend(super::marks::curvature_comb_overlays(app, space.view.zoom));
}
}
super::overlays::show(app, ui, &space, &list, &extra);
}
+6 -1
View File
@@ -93,8 +93,13 @@ impl Adjust {
{
old.preview.cancel(app);
}
let canvas = crate::doc_windows::current(app).map(crate::canvas::canvas_id);
let dialog = HostedParamDialog::new(&ctx, self.kind, (self.initial)(), move |fields| {
ParamDialog::new(self.kind, self.label, (self.rows)()).values(Bind::bound(fields)).previews(true)
let dialog = ParamDialog::new(self.kind, self.label, (self.rows)()).values(Bind::bound(fields)).previews(true);
match canvas {
Some(canvas) => dialog.canvas(canvas),
None => dialog,
}
});
let id = host::open_held(app, dialog, move |app, answer| self.commit(app, answer)).ok_or(NO_WINDOW)?;
*(self.slot)(&mut app.color_dialogs) = Some(Open { id, document, preview: LivePreview::default() });
@@ -287,6 +287,12 @@ pub fn open(app: &mut VectorcraftApp, p: &Value) -> Result<Value, String> {
if let Some((document, _, index, _)) = artboard {
dialog = dialog.instance((document, index));
}
// The picker adds no dimming of its own over the canvas, so its live preview shows the true color; another open
// dialog's scrim can still dim the canvas. Presses on it stay blocked:
// the app does not take the picker's canvas eyedropper request.
if let Some(canvas) = crate::doc_windows::current(app).map(crate::canvas::canvas_id) {
dialog = dialog.canvas(canvas).canvas_samples(false);
}
let id = dialogs.with(|h| h.open(dialog));
// A picker the open replaced leaves its preview behind: end it.
if let Some(at) = app.color_dialogs.pickers.iter().position(|open| open.id == id) {
@@ -451,3 +451,46 @@ fn the_artboard_picker_leaves_restored_artboards_unchanged() {
assert_eq!(artboard_color(&app).map(|c| c.to_hex()).as_deref(), Some("#abcdef"));
}
}
/// The picker keeps the document's canvas open under its modal layer (#10639): the canvas is not dimmed, so the live
/// preview shows the true color, and the wheel over the canvas still scrolls the view.
#[test]
fn the_canvas_stays_open_under_the_picker() {
let step = |app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<egui::Event>| {
let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 850.0));
crate::testing::app_frame(app, ctx, egui::RawInput { screen_rect: Some(screen), events, ..Default::default() });
};
let (mut app, ctx) = app();
for _ in 0..3 {
step(&mut app, &ctx, vec![]);
}
app.run("ui.colorPicker", json!({})).unwrap();
for _ in 0..3 {
step(&mut app, &ctx, vec![]);
}
assert!(!app.color_dialogs.pickers.is_empty(), "the picker is open");
let at = app.canvas_view().unwrap().rect.left_top() + egui::vec2(20.0, 20.0);
for _ in 0..3 {
step(&mut app, &ctx, vec![egui::Event::PointerMoved(at)]);
}
let before = app.canvas_view().unwrap().center;
let wheel = egui::Event::MouseWheel {
unit: egui::MouseWheelUnit::Line,
delta: egui::vec2(0.0, -3.0),
phase: egui::TouchPhase::Move,
modifiers: egui::Modifiers::default(),
source: egui::MouseWheelSource::Unknown,
};
for _ in 0..5 {
step(&mut app, &ctx, vec![egui::Event::PointerMoved(at), wheel.clone()]);
}
assert_ne!(app.canvas_view().unwrap().center, before, "the wheel over the canvas scrolls the view under the picker");
// A click on the canvas stays blocked: it does not reach the tool and clear the selection.
let selected = app.session.doc().unwrap().selection.clone();
let press =
|pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::default() };
step(&mut app, &ctx, vec![egui::Event::PointerMoved(at), press(true)]);
step(&mut app, &ctx, vec![press(false)]);
step(&mut app, &ctx, vec![]);
assert_eq!(app.session.doc().unwrap().selection, selected, "the click under the picker leaves the selection");
}
+7 -2
View File
@@ -249,8 +249,13 @@ pub(crate) fn apply_custom(job: &mut SavePdfJob, parent: &HostedPdfExport, field
/// Open Flatten Transparency for the selection with the default preset.
pub(crate) fn open(app: &mut VectorcraftApp) -> Result<Value, String> {
let ctx = app.ui_ctx.clone().ok_or("no window")?;
let dialog = HostedParamDialog::new(&ctx, KEY, option_fields(&FlattenOptions::default()), |fields| {
ParamDialog::new(KEY, tl!("Flatten Transparency"), option_params(&[], "")).values(Bind::bound(fields)).previews(true)
let canvas = crate::doc_windows::current(app).map(crate::canvas::canvas_id);
let dialog = HostedParamDialog::new(&ctx, KEY, option_fields(&FlattenOptions::default()), move |fields| {
let dialog = ParamDialog::new(KEY, tl!("Flatten Transparency"), option_params(&[], "")).values(Bind::bound(fields)).previews(true);
match canvas {
Some(canvas) => dialog.canvas(canvas),
None => dialog,
}
})
// Flattening complex art is slow: the preview waits until it is turned on.
.preview_off();
+7 -2
View File
@@ -102,9 +102,14 @@ pub(crate) fn open(app: &mut VectorcraftApp) -> Result<Value, String> {
let defaults = fields();
let rows = screen_params(false, &DialogFields::new());
let initial = fields_of(&rows, defaults.as_object().unwrap_or(&Default::default()));
let dialog = HostedParamDialog::command(&ctx, CMD, initial, |fields| {
let canvas = crate::doc_windows::current(app).map(crate::canvas::canvas_id);
let dialog = HostedParamDialog::command(&ctx, CMD, initial, move |fields| {
let rows = screen_params(false, fields);
ParamDialog::command(CMD, tl!("Vector Halftone"), rows).previews(true).values(Bind::bound(fields))
let dialog = ParamDialog::command(CMD, tl!("Vector Halftone"), rows).previews(true).values(Bind::bound(fields));
match canvas {
Some(canvas) => dialog.canvas(canvas),
None => dialog,
}
});
let ok = |app: &mut VectorcraftApp, result: &ParamResult| {
let open = app.effect_dialogs.halftone.as_ref().ok_or("the dialog is closed")?;
+5 -1
View File
@@ -103,7 +103,11 @@ pub fn open(app: &mut VectorcraftApp) {
if let Some(old) = app.object_dialogs.indexed.take() {
old.cancel_preview(app);
}
let dialog = HostedParamDialog::new(&ctx, KIND, DialogFields::new(), build);
let canvas = crate::doc_windows::current(app).map(crate::canvas::canvas_id);
let dialog = HostedParamDialog::new(&ctx, KIND, DialogFields::new(), move |fields| match canvas {
Some(canvas) => build(fields).canvas(canvas),
None => build(fields),
});
let opening = Arc::new(());
let cancelled = Arc::clone(&opening);
let ok = |app: &mut VectorcraftApp, r: &ParamResult| {
+6 -1
View File
@@ -144,8 +144,13 @@ fn try_open(app: &mut VectorcraftApp) -> Result<Value, String> {
let lengths = LengthUnits::new(UnitKind::Points, super::rearrange_artboards::length_kind(app.session.general_unit()), 72.0);
let lengths = crate::fields::bare_points(lengths, app.session.prefs.numbers_without_units_are_points);
let cuts = cut_options(app);
let canvas = crate::doc_windows::current(app).map(crate::canvas::canvas_id);
let dialog = HostedParamDialog::command(&ctx, CMD, fields(), move |fields| {
ParamDialog::command(CMD, tl!("Step and Repeat"), rows(lengths, cuts.clone())).previews(true).values(Bind::bound(fields))
let dialog = ParamDialog::command(CMD, tl!("Step and Repeat"), rows(lengths, cuts.clone())).previews(true).values(Bind::bound(fields));
match canvas {
Some(canvas) => dialog.canvas(canvas),
None => dialog,
}
});
let ok = |app: &mut VectorcraftApp, result: &ParamResult| {
let mut open = app.object_dialogs.step.take().ok_or("the dialog is closed")?;
+5 -1
View File
@@ -515,7 +515,11 @@ pub(crate) fn open(app: &mut VectorcraftApp) {
}
}
apply_links(&mut f, shared);
let dialog = HostedParamDialog::new(&ctx, KEY, f, move |fields| form(fields, shared, lengths));
let canvas = crate::doc_windows::current(app).map(crate::canvas::canvas_id);
let dialog = HostedParamDialog::new(&ctx, KEY, f, move |fields| match canvas {
Some(canvas) => form(fields, shared, lengths).canvas(canvas),
None => form(fields, shared, lengths),
});
let options = HeldOptions { cancel: Some(Box::new(cancel)), ..Default::default() };
if let Some(id) = open_held_with(app, dialog, move |app, result| ok(app, &ctx, result), options) {
app.object_dialogs.each =
+1
View File
@@ -1035,6 +1035,7 @@ fn toggled_labels() -> Vec<String> {
"type.hiddenCharacters",
"view.gradientAnnotator",
"view.livePaintGaps",
"view.curvatureComb",
"view.artboards",
"view.template",
"view.rulers",
+2 -1
View File
@@ -76,7 +76,7 @@ const MENU_ONLY_COMMANDS: [&str; 5] = ["imageTrace.make", "imageTrace.makeAndExp
/// action ([`plays_in_app`]): Outline, Pixel Preview, Trim View, Presentation Mode and Screen Mode,
/// the zoom, fit and rotate view items, and the items that show or hide or turn snapping on or off.
/// The saved-view slots are not among them.
const UI_STEP_COMMANDS: [&str; 30] = [
const UI_STEP_COMMANDS: [&str; 31] = [
"view.outline",
"view.pixelPreview",
"view.trimView",
@@ -100,6 +100,7 @@ const UI_STEP_COMMANDS: [&str; 30] = [
"view.gradientAnnotator",
"view.cornerWidget",
"view.livePaintGaps",
"view.curvatureComb",
"view.guides",
"view.smartGuides",
"view.grid",
+3
View File
@@ -29,6 +29,7 @@ fn view_toggle_label(app: &VectorcraftApp, id: &str) -> Option<String> {
"type.hiddenCharacters" => if v.hidden_chars { "Hide Hidden Characters" } else { "Show Hidden Characters" }.into(),
"view.gradientAnnotator" => if v.gradient_annotator { "Hide Gradient Annotator" } else { "Show Gradient Annotator" }.into(),
"view.livePaintGaps" => if v.live_paint_gaps { "Hide Live Paint Gaps" } else { "Show Live Paint Gaps" }.into(),
"view.curvatureComb" => if v.curvature_comb { "Hide Curvature Comb" } else { "Show Curvature Comb" }.into(),
_ => return None,
};
Some(text)
@@ -356,6 +357,8 @@ pub const DYNAMIC_LABELS: &[&str] = &[
"Show Gradient Annotator",
"Hide Live Paint Gaps",
"Show Live Paint Gaps",
"Hide Curvature Comb",
"Show Curvature Comb",
"Hide Artboards",
"Show Artboards",
"Hide Rulers",
+1 -1
View File
@@ -144,7 +144,7 @@ fn rows_key(app: &VectorcraftApp, input: Option<u64>) -> u64 {
let (prefs, v) = (&s.prefs, &app.ui.view);
(prefs.font_preview, prefs.font_samples_on_white, prefs.font_names_in_english, crate::workspaces::current_name(&app.ui)).hash(&mut h);
(v.edges, v.templates, v.corner_widgets, v.shape_widgets, v.text_threads, v.hidden_chars, v.gradient_annotator).hash(&mut h);
(v.live_paint_gaps, v.artboards, v.rulers, v.video_rulers, v.bounding_box, v.guides, v.grid).hash(&mut h);
(v.live_paint_gaps, v.curvature_comb, v.artboards, v.rulers, v.video_rulers, v.bounding_box, v.guides, v.grid).hash(&mut h);
(app.outline_view(), s.guides_locked(), s.slices_hidden()).hash(&mut h);
// The Align To choice: Object › Align's checks and the Distribute buttons with the Artboard tool.
app.ui.align_to.hash(&mut h);
+3 -1
View File
@@ -408,7 +408,7 @@ fn run_ui_part3(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option<Result<
}
/// UI commands, part 4.
fn run_ui_part4(app: &mut VectorcraftApp, id: &str, _p: &Value) -> Option<Result<Value, String>> {
fn run_ui_part4(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option<Result<Value, String>> {
let flag = |b: &mut bool| {
*b = !*b;
Ok(json!(*b))
@@ -419,6 +419,8 @@ fn run_ui_part4(app: &mut VectorcraftApp, id: &str, _p: &Value) -> Option<Result
id if let Some(v) = crate::panels::align::align_to_command(id) => crate::panels::align::run_align_to(app, v),
"view.gradientAnnotator" => flag(&mut app.ui.view.gradient_annotator),
"view.livePaintGaps" => flag(&mut app.ui.view.live_paint_gaps),
"view.curvatureComb" if !(p.is_null() || p.as_object().is_some_and(|m| m.is_empty())) => Err("view.curvatureComb takes no parameters".into()),
"view.curvatureComb" => flag(&mut app.ui.view.curvature_comb),
"effect.last" => match app.last_effect.clone() {
Some((e, params)) => crate::dialogs::effect::open_last(app, &e, params),
None => Err("no effect applied yet".into()),
+1
View File
@@ -773,6 +773,7 @@ fn last_effect_dialog_and_view_toggles() {
("view.textThreads", "Hide Text Threads", "Show Text Threads"),
("view.gradientAnnotator", "Hide Gradient Annotator", "Show Gradient Annotator"),
("view.livePaintGaps", "Show Live Paint Gaps", "Hide Live Paint Gaps"),
("view.curvatureComb", "Show Curvature Comb", "Hide Curvature Comb"),
("type.hiddenCharacters", "Show Hidden Characters", "Hide Hidden Characters"),
("view.template", "Hide Template", "Show Template"),
] {
+1
View File
@@ -678,6 +678,7 @@ fn built_in_tree(english_names: bool, listed: &Listed) -> Vec<(&'static str, Vec
c("Hide Gradient Annotator", "view.gradientAnnotator"),
c("Hide Corner Widget", "view.cornerWidget"),
c("Show Live Paint Gaps", "view.livePaintGaps"),
c("Show Curvature Comb", "view.curvatureComb"),
Sep,
sub(
"Guides",
+6
View File
@@ -262,6 +262,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"",
"{} toggle drawing the gaps of the selected Live Paint groups (those livePaint.info lists) in each group's Gap Preview Color while edges show → true when on",
),
(
"view.curvatureComb",
"Show Curvature Comb",
"",
"{} toggle drawing the curvature comb of the selected paths and compound paths while edges show: 16 teeth per segment along the normal, on the outer side of the bend, each as long as the curvature there (a radius of 100 screen points gives a 20-point tooth at any zoom), with a line through their tips in the layer color; about 20,000 teeth at most, fewer per segment on a large selection; a view setting, not saved in the document and not an undo step → true when on",
),
(
"type.hiddenCharacters",
"Show Hidden Characters",
+4
View File
@@ -410,6 +410,9 @@ pub struct ViewFlags {
/// Preview Color.
#[serde(default)]
pub live_paint_gaps: bool,
/// View → Show/Hide Curvature Comb: draw the curvature comb of the selected paths.
#[serde(default)]
pub curvature_comb: bool,
/// Type → Show Hidden Characters.
pub hidden_chars: bool,
/// Edit › Spelling › Auto Spell Check: a red underline under the words of the type its
@@ -443,6 +446,7 @@ impl Default for ViewFlags {
text_threads: true,
gradient_annotator: true,
live_paint_gaps: false,
curvature_comb: false,
hidden_chars: false,
auto_spell_check: false,
templates: true,
+15 -1
View File
@@ -684,6 +684,9 @@ space. RGB edits preserve the other native channels; HSB uses those same working
display sRGB retain their native numeric values. `ui.colorPanel` selects the panel mode and `ui.colorPicker`
opens the picker through `run_command` with the remote backend. Edit › Keyboard Shortcuts lists `ui.colorPicker` as
Color Picker… with no default key; a key assigned there opens the picker for the proxy in front, as `{}` does.
While the picker is open, it adds no dimming of its own over the canvas of the current window, so the live preview shows the picked color. Another open dialog, such as New Swatch, can still dim the canvas with its own scrim.
The wheel scrolls and zooms the view, and a middle-button drag or a drag with Space held pans it; other presses on the
canvas do not reach the tools or sample a color.
`ui.colorPanel {"recentColors": false}` unchecks the panel menu's Show Recent Colors, which hides the Color panel's
Recent Colors row, and `true` shows it again; applied colors still join the list while it is hidden.
`ui.colorPanel {"rgbPercent": true}` shows the Color panel's RGB fields in percent, as a double-click right of an RGB
@@ -3721,7 +3724,9 @@ through `$`:
than the object model changed the path's points (a command run with `vc.run`, such as `path.setAnchors`,
`object.move` or `edit.undo`); points stay valid through the object model's other changes to the path or to an
object that holds it, such as `translate()`. An exception applies when editing another path in an Objects on
Path group moves a path inside that group. Its existing `PathPoint` handles throw `Stale path point`.
Path group moves a path inside that group, and when Global Edit changes another member's path points.
Their existing `PathPoint` handles throw `Stale path point`. An appearance-only change, such as a fill change,
leaves the handles valid.
After each command, the script checks each document that holds a path whose points it still holds: it goes down
through every layer and group the command changed and counts each object directly inside them, changed or not, toward
the script's operation budget.
@@ -9493,6 +9498,15 @@ of more than half a degree and the anchor is not marked smooth with both handles
marked smooth), when the circle would reach past the canvas (4,000,000 pt from the
origin), when `t` is not from 0 to 1, when `id` is a guide, and when the path, subpath or segment does not exist.
`view.curvatureComb` (View › Show Curvature Comb, or Hide Curvature Comb while it is on) turns on the curvature comb
of the selected paths, and of each path in a selected compound path, while edges show. Each segment gets 16 evenly
spaced teeth along the normal, on the outer side of the bend, each as long as the curvature at that point, and a line
joins the teeth's tips, in the path's layer color. A straight segment has teeth of no length, and a point of a curve
where it has no direction (a handle on its anchor) has no tooth. The length is VectorCraft's own value: a bend with a
radius of 100 screen points draws 20-point teeth at any zoom. The comb draws about 20,000 teeth at most, shared among
the selected paths by their number of segments: a larger selection gets 2 teeth per segment, then teeth on every k-th
segment. The setting belongs to the view: it is not saved in the document and makes no undo step.
The Curvature Circle tool, after the Circle tool in the Ellipse tool's toolbar group, draws with this command. The
pointer snaps to the nearest path that is not a guide within the tool's Snap Tolerance (`snapTolerance` below, 5
screen points by default), or within Smart Guides › Snapping Tolerance when that is larger; with Snap with Smart
+1 -1
View File
@@ -1119,7 +1119,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- Scripts: a page item's `translate`, `rotate`, `resize` and `transform` move, turn, scale and transform the object by offsets, an angle, percentages or a `Matrix` record, about its center or a `Transformation` point, with positions, patterns, gradients and line widths following their arguments (https://ai-scripting.docsforadobe.dev/jsobjref/PageItem/). Each call that moves or reshapes the object runs `object.transform` inside the run's transaction, a call that changes only a path's stroke weight runs `stroke.set`, and a call that changes nothing runs no command. `resize` and `transform` on a member of a compound path with `changeLineWidths` at their own scale set the compound's stroke weight; locked art, art on a locked artboard and bad arguments throw an error with nothing changed (`docs/mcp.md`). `crates/engine/src/tests/script_dom_transform.rs`.
- Scripts: `Document.placedItems` and `Document.rasterItems` list a document's linked and embedded images; `placedItems.add()` with a `File` assigned to `file` places an image linked, and `PlacedItem.relink(file)` and `embed()` relink and embed it, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/PlacedItems/, https://ai-scripting.docsforadobe.dev/jsobjref/PlacedItem/, https://ai-scripting.docsforadobe.dev/jsobjref/RasterItems/ and https://ai-scripting.docsforadobe.dev/jsobjref/RasterItem/ describe them. A raster item's bits per channel, channels, color space and transparency come from its encoded pixels' header. Only files the script may read, of at most 256 MiB and holding an image, are placed or relinked. `crates/engine/src/tests/script_dom_images.rs`.
- Scripts: `app.preferences` reads, stores and removes values by key with the type they were set as, keeps them across runs and restarts, and turns the warning before a picked script on with the key `ShowExternalJSXWarning`, and off only after the person answers Yes to a confirm (https://ai-scripting.docsforadobe.dev/jsobjref/Preferences/; the confirm is VectorCraft's own rule); `app` makes, joins, inverts and compares `Matrix` records (https://ai-scripting.docsforadobe.dev/jsobjref/Matrix/), rounding each joined value once from its exact sum of products and deciding whether an inverted value overflows from its exact quotient, and runs Copy, Cut and Paste on the active document inside the run's transaction (https://ai-scripting.docsforadobe.dev/jsobjref/Application/). `crates/engine/src/tests/script_dom_prefs.rs`.
- Scripts: `Document.pathItems` lists the paths and makes rectangles, rounded rectangles, ellipses, polygons, stars and empty paths with the defaults the help page https://ai-scripting.docsforadobe.dev/jsobjref/PathItems/ gives; each path's points, closed state, fill rule, area, length, guide state, selected points, fill and stroke colors, stroke options and transforms read and change as https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/ and https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/ describe them, and `RGBColor`, `CMYKColor`, `GrayColor`, `LabColor` and `NoColor` make colors (`docs/mcp.md`). `pathItems["name"]` reads a path by name as `pageItems` does, and `removeAll()` deletes nothing and throws when any path is hidden or locked or is on a locked artboard. A path takes the page item transforms, and `resize` also sets its stroke weight to a `changeLineWidths` percent from 0 to 100000 (at most 1000 points; a member of a compound sets the compound's stroke); gradients move with positions, so a `changeFillGradients` different from `changePositions` throws an error, as do `changeFillPatterns` and `changeStrokePattern` given as different values (`docs/mcp.md` lists these limits). Gradient stops are not there yet. A `PathPoint` of a path in an Objects on Path group goes stale when an edit of another path in the group moves it. `crates/engine/src/tests/script_dom_paths.rs`.
- Scripts: `Document.pathItems` lists the paths and makes rectangles, rounded rectangles, ellipses, polygons, stars and empty paths with the defaults the help page https://ai-scripting.docsforadobe.dev/jsobjref/PathItems/ gives; each path's points, closed state, fill rule, area, length, guide state, selected points, fill and stroke colors, stroke options and transforms read and change as https://ai-scripting.docsforadobe.dev/jsobjref/PathItem/, https://ai-scripting.docsforadobe.dev/jsobjref/PathPoints/ and https://ai-scripting.docsforadobe.dev/jsobjref/PathPoint/ describe them, and `RGBColor`, `CMYKColor`, `GrayColor`, `LabColor` and `NoColor` make colors (`docs/mcp.md`). `pathItems["name"]` reads a path by name as `pageItems` does, and `removeAll()` deletes nothing and throws when any path is hidden or locked or is on a locked artboard. A path takes the page item transforms, and `resize` also sets its stroke weight to a `changeLineWidths` percent from 0 to 100000 (at most 1000 points; a member of a compound sets the compound's stroke); gradients move with positions, so a `changeFillGradients` different from `changePositions` throws an error, as do `changeFillPatterns` and `changeStrokePattern` given as different values (`docs/mcp.md` lists these limits). Gradient stops are not there yet. A `PathPoint` of a path in an Objects on Path group goes stale when an edit of another path in the group moves it. A `PathPoint` of another Global Edit member goes stale when Global Edit changes its path's points. `crates/engine/src/tests/script_dom_paths.rs`.
- Scripts: `PlacedItem.trace()` and `RasterItem.trace()` make an Image Trace object and return it as a `PluginItem` whose `tracing` gives its path, anchor and color counts, the source image's resolution, `expandTracing()`, `releaseTracing()` and its `TracingOptions`; assigning an option or loading a preset traces it again, except that the view options (`viewRaster` and `viewVector`) only change the view, as the help pages https://ai-scripting.docsforadobe.dev/jsobjref/PluginItem/, https://ai-scripting.docsforadobe.dev/jsobjref/TracingObject/ and https://ai-scripting.docsforadobe.dev/jsobjref/TracingOptions/ describe them. Option values are checked for type and range before any trace, a script cannot save a preset, and the options without a VectorCraft setting throw. The source image of a traced item is left out of `pageItems`, `placedItems` and `rasterItems`; a script reaches it through `PluginItem.tracing.sourceArt`. `remove()` also refuses a shown source image. Renaming an ordinary group that holds an image first to `Image Trace`, or moving or duplicating an image to the bottom of an ordinary group with that name, throws an error. `crates/engine/src/tests/script_dom_tracing.rs`.
- Scripts: a document's `default*` members (https://ai-scripting.docsforadobe.dev/jsobjref/Document/) read and set the fill, stroke and stroke options of the next object drawn through `appearance.setNewArt`, leaving the selection and its art as they were, and `scaleFactor` reads 1 (`docs/mcp.md`). `crates/engine/src/tests/script_dom_defaults.rs`.
- Scripts: `app.undo()` and `app.redo()` undo and redo the edits the run made, and each document open before and after the run that it changed gets one undo step. `crates/engine/src/tests/script_dom.rs`.