From b4580f9fb9a2a3b0de5968c4f938d805dd308864 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 3 Dec 2026 06:42:11 -0800 Subject: [PATCH 01/10] Blend: steps between rounded rectangles keep round corners Steps between two live rectangles were made by matching the keys' anchors and moving each anchor and handle in a straight line. When the keys' corners had different anchor layouts (a sharp rectangle and a rounded one, or radii too large for one key), the steps' corners came out as skewed curves, and every step lost its live rectangle. Steps between two live rectangles with the same corner kinds and the same rotation, reflection and shear are now live rectangles whose width, height, position and corner radii lie between the keys'. Each key's radii are the radii it draws, so a stored radius too large for its rectangle counts as the largest that fits. A start anchor given for either key, and every other pair, keep anchor matching. Fixes #10707 --- crates/doc/src/blend.rs | 154 ++++++++++++++++++++++++- crates/engine/src/cmd/live/commands.rs | 2 +- docs/mcp.md | 7 +- docs/target-app-parity.md | 1 + 4 files changed, 161 insertions(+), 3 deletions(-) diff --git a/crates/doc/src/blend.rs b/crates/doc/src/blend.rs index 7c40d9d133..c7ec77ac7f 100644 --- a/crates/doc/src/blend.rs +++ b/crates/doc/src/blend.rs @@ -21,11 +21,12 @@ use std::sync::Arc; use vectorcraft_color::{Color, Gradient, GradientMethod, GradientPaint, GradientSpread, GradientStop, Paint}; use vectorcraft_geom::kurbo::{ParamCurve, ParamCurveArclen, ParamCurveDeriv}; +use vectorcraft_geom::shapes::CornerKind; use vectorcraft_geom::{Affine, Anchor, BezPath, FillRule, PathData, Point, Rect, SubPath, Vec2}; use crate::appearance::{AngleProfile, Appearance, AppearanceItem, Dash, PressureProfile, StrokeGradientMode, StrokeLayer, WidthProfile}; use crate::live::{BlendOrientation, BlendSpacing, BlendSpec}; -use crate::node::{Node, NodeId, NodeKind}; +use crate::node::{LiveShape, Node, NodeId, NodeKind}; use crate::text::TextObject; // ===================================================================================== @@ -1032,6 +1033,9 @@ enum Shape { /// Paths and compound paths; `members`: the subpath count of each member when both keys are /// compound paths. Path { pair: PathPair, rules: (FillRule, FillRule), members: Option<(Vec, Vec)> }, + /// Two live rectangles: each step is a live rectangle whose size, transform and corner radii + /// lie between the keys'. A shared shear or nonuniform scale makes the corners elliptical. + LiveRect(Box<(LiveRectParts, LiveRectParts)>), /// Text, symbols and images: their transforms interpolate. Placed, /// Anything else: a copy of the nearer key moved and scaled into the interpolated box. @@ -1046,6 +1050,47 @@ pub struct Lerp { shape: Shape, } +/// A live rectangle's size, transform, corner kinds and corner radii in document units. +#[derive(Clone, Debug)] +struct LiveRectParts { + w: f64, + h: f64, + radii: [f64; 4], + kinds: [CornerKind; 4], + xf: Affine, +} + +/// The parts of `s` when it is a live rectangle, with its radii as the lengths it draws. +fn live_rect(s: &LiveShape) -> Option { + let LiveShape::Rectangle { w, h, radii, kinds, radii_relative, xf } = s else { return None }; + let base = vectorcraft_geom::shapes::rectangle(Rect::new(0.0, 0.0, *w, *h)); + let resolved = crate::corners::resolve_stored_radii(&base, radii, *radii_relative); + let corners = vectorcraft_geom::corners::path_corners(&base); + let mut drawn = [0.0; 4]; + for (c, r) in corners.iter().zip(vectorcraft_geom::corners::fitted_radii(&corners, &resolved)) { + if let Some(d) = drawn.get_mut(c.index) { + *d = r; + } + } + Some(LiveRectParts { w: *w, h: *h, radii: drawn, kinds: *kinds, xf: *xf }) +} + +/// The parts of `a` and `b` when steps between them can be live rectangles: both are live +/// rectangles with the same corner kinds and the same rotation, reflection and shear, so each step +/// only moves and resizes. +fn live_rect_pair(a: &LiveShape, b: &LiveShape) -> Option<(LiveRectParts, LiveRectParts)> { + let (x, y) = (live_rect(a)?, live_rect(b)?); + let (p, q) = (x.xf.as_coeffs(), y.xf.as_coeffs()); + let scale = p[..4].iter().chain(&q[..4]).map(|c| c.abs()).fold(0.0, f64::max); + let determinant_sign = |c: [f64; 6]| { + let scale = if scale > 0.0 { scale } else { 1.0 }; + let det = (c[0] / scale) * (c[3] / scale) - (c[1] / scale) * (c[2] / scale); + (det > 0.0, det < 0.0) + }; + (x.kinds == y.kinds && p[..4].iter().zip(&q[..4]).all(|(a, b)| (a - b).abs() <= 1e-9 * scale) && determinant_sign(p) == determinant_sign(q)) + .then_some((x, y)) +} + /// `n` shrunk to a point at `c`: the counterpart of an object only one of two groups has. fn collapsed(n: &Node, c: Point) -> Node { let mut x = n.clone(); @@ -1083,6 +1128,12 @@ impl Lerp { | (NodeKind::SymbolInstance { .. }, NodeKind::SymbolInstance { .. }) | (NodeKind::Image(_), NodeKind::Image(_)) | (NodeKind::PlacedDocument(_), NodeKind::PlacedDocument(_)) => Shape::Placed, + // A clicked start point asks for anchors to be paired; the path route does that. + (NodeKind::Path { live: Some(la), .. }, NodeKind::Path { live: Some(lb), .. }) + if let Some(parts) = live_rect_pair(la, lb).filter(|_| starts == (None, None)) => + { + Shape::LiveRect(Box::new(parts)) + } _ => match (node_path(a), node_path(b)) { (Some((pa, ra, ma)), Some((pb, rb, mb))) => { Shape::Path { pair: PathPair::new(&pa, &pb, starts), rules: (ra, rb), members: ma.zip(mb) } @@ -1145,6 +1196,28 @@ impl Lerp { } } } + Shape::LiveRect(parts) => { + let (x, y) = &**parts; + let (p, q) = (x.xf.as_coeffs(), y.xf.as_coeffs()); + let live = LiveShape::Rectangle { + w: lerp_f64(x.w, y.w, t), + h: lerp_f64(x.h, y.h, t), + radii: std::array::from_fn(|i| lerp_f64(x.radii[i], y.radii[i], t)), + kinds: x.kinds, + radii_relative: false, + xf: Affine::new([p[0], p[1], p[2], p[3], lerp_f64(p[4], q[4], t), lerp_f64(p[5], q[5], t)]), + }; + let rule = match &base.kind { + NodeKind::Path { rule, .. } => *rule, + _ => FillRule::default(), + }; + let mut n = Node::path(NodeId(0), live.to_path(), Appearance::default()); + if let NodeKind::Path { rule: r, live: l, .. } = &mut n.kind { + *r = rule; + *l = Some(Box::new(live)); + } + n + } Shape::Placed => { let mut n = base.clone(); match (&mut n.kind, &a.kind, &b.kind) { @@ -2321,6 +2394,85 @@ mod tests { assert_eq!(m.subpaths[0].anchors[0].p, Point::new(55.0, 0.0)); } + /// A live rectangle `w` by `h` at `(x, 0)` with every corner radius `r`. + fn rounded(x: f64, w: f64, h: f64, r: f64) -> Node { + let live = + LiveShape::Rectangle { w, h, radii: [r; 4], kinds: [CornerKind::Round; 4], radii_relative: false, xf: Affine::translate((x, 0.0)) }; + let mut n = Node::path(NodeId(1), live.to_path(), Appearance::default()); + if let NodeKind::Path { live: l, .. } = &mut n.kind { + *l = Some(Box::new(live)); + } + n + } + + /// The step's live radii, after checking that every curve of its outline is a circular arc of + /// that radius about the matching corner center. + fn round_step_radii(step: &Node) -> [f64; 4] { + let Some(LiveShape::Rectangle { radii, .. }) = step.live_shape() else { panic!("a live rectangle step: {step:?}") }; + let r = radii[0]; + let b = step.path_data().and_then(|p| p.bounds()).unwrap_or_default(); + let centers = [(b.x0 + r, b.y0 + r), (b.x1 - r, b.y0 + r), (b.x1 - r, b.y1 - r), (b.x0 + r, b.y1 - r)].map(|(x, y)| Point::new(x, y)); + let path = step.path_data().map(|p| p.to_bezpath()).unwrap_or_default(); + let curves = path.segments().filter(|s| matches!(s, vectorcraft_geom::kurbo::PathSeg::Cubic(_))).count(); + assert_eq!(curves, if r > 1e-9 { 4 } else { 0 }, "one arc per corner: {path:?}"); + for seg in path.segments() { + if let vectorcraft_geom::kurbo::PathSeg::Cubic(c) = seg { + for u in [0.0, 0.25, 0.5, 0.75, 1.0] { + let p = c.eval(u); + let d = centers.iter().map(|q| (p - *q).hypot()).fold(f64::INFINITY, f64::min); + assert!((d - r).abs() < 0.01 * r.max(1.0), "{p:?} is {d} from its corner center, not {r}"); + } + } + } + *radii + } + + /// Steps between live rectangles are live rectangles whose corner radii lie between the keys'. + #[test] + fn steps_between_rounded_rectangles_keep_round_corners() { + let blend = Lerp::new(&rounded(0.0, 100.0, 100.0, 10.0), &rounded(300.0, 200.0, 60.0, 30.0), (None, None)); + for r in round_step_radii(&blend.at(0.5)) { + assert!((r - 20.0).abs() < 1e-9, "{r}"); + } + let blend = Lerp::new(&rounded(0.0, 100.0, 100.0, 0.0), &rounded(300.0, 200.0, 60.0, 30.0), (None, None)); + for t in [0.25, 0.5, 0.75] { + for r in round_step_radii(&blend.at(t)) { + assert!((r - 30.0 * t).abs() < 1e-9, "{t}: {r}"); + } + } + // A radius too large for its rectangle counts as the radius it draws. + let blend = Lerp::new(&rounded(0.0, 20.0, 20.0, 100.0), &rounded(300.0, 200.0, 200.0, 10.0), (None, None)); + for r in round_step_radii(&blend.at(0.5)) { + assert!((r - 10.0).abs() < 1e-9, "{r}"); + } + // Keys turned differently keep the anchor-by-anchor route. + let mut turned = rounded(300.0, 200.0, 60.0, 30.0); + turned.transform(Affine::rotate(0.5), false); + assert!(matches!(Lerp::new(&rounded(0.0, 100.0, 100.0, 10.0), &turned, (None, None)).shape, Shape::Path { .. })); + let mut a = rounded(0.0, 100.0, 100.0, 10.0); + let mut b = rounded(300.0, 100.0, 100.0, 30.0); + a.transform(Affine::rotate(30.0_f64.to_radians()), false); + b.transform(Affine::rotate(390.0_f64.to_radians()), false); + let blend = Lerp::new(&a, &b, (None, None)); + assert!(matches!(&blend.shape, Shape::LiveRect(_))); + let step = blend.at(0.5); + let Some(LiveShape::Rectangle { xf, .. }) = step.live_shape() else { panic!("a live rectangle step") }; + let Some(LiveShape::Rectangle { xf: first, .. }) = a.live_shape() else { panic!("a live rectangle key") }; + assert_eq!(xf.as_coeffs()[..4], first.as_coeffs()[..4]); + for starts in [(Some(0), None), (None, Some(0))] { + assert!(matches!(Lerp::new(&a, &b, starts).shape, Shape::Path { .. })); + } + b.transform(Affine::scale_non_uniform(-1.0, 1.0), false); + assert!(matches!(Lerp::new(&a, &b, (None, None)).shape, Shape::Path { .. })); + for scale in [1.0, 1e-200] { + let mut a = rounded(0.0, 100.0, 100.0, 10.0); + let mut b = rounded(300.0, 100.0, 100.0, 30.0); + a.transform(Affine::scale_non_uniform(scale, scale * 1e-12), false); + b.transform(Affine::scale_non_uniform(scale, -scale * 1e-12), false); + assert!(matches!(Lerp::new(&a, &b, (None, None)).shape, Shape::Path { .. })); + } + } + /// A step between two distorted images has its corners between the keys' corners. #[test] fn steps_between_distorted_images_have_corners_between_theirs() { diff --git a/crates/engine/src/cmd/live/commands.rs b/crates/engine/src/cmd/live/commands.rs index b44a26e645..5724498e14 100644 --- a/crates/engine/src/cmd/live/commands.rs +++ b/crates/engine/src/cmd/live/commands.rs @@ -18,7 +18,7 @@ pub fn specs() -> Vec { "Make", ["Object", "Blend"], Some("Cmd+Alt+B"), - "{ids?, steps?: n | distance?: pt | smooth?: bool, orientation?: page|path (default: the Blend Options set with nothing selected, else smooth colour and page), starts?: [anchor index | null, …] (per object of `ids`, else of the selection in paint order: the anchor of its first subpath the blend starts from; an open path's last anchor runs it the other way), spacing?: smooth|steps|distance (with value), value?: n, easingType?: easeIn|easeOut|easeInOut|easeOutIn, ramp?: pct (0..100), colorShift?: pct (-100..100; 0: even), createSpine?: auto|always|never (default: the mode object.blend.createSpine sets; never: a blend without a spine, which takes no easing)} blend the selected objects (paint order) into a live blend; a blend among them takes the others in as more key objects (keeping its options, name, transparency and whether it has a spine) instead of nesting → {id}", + "{ids?, steps?: n | distance?: pt | smooth?: bool, orientation?: page|path (default: the Blend Options set with nothing selected, else smooth colour and page), starts?: [anchor index | null, …] (per object of `ids`, else of the selection in paint order: the anchor of its first subpath the blend starts from; an open path's last anchor runs it the other way. A start anchor makes rectangles blend anchor by anchor.), spacing?: smooth|steps|distance (with value), value?: n, easingType?: easeIn|easeOut|easeInOut|easeOutIn, ramp?: pct (0..100), colorShift?: pct (-100..100; 0: even), createSpine?: auto|always|never (default: the mode object.blend.createSpine sets; never: a blend without a spine, which takes no easing)} blend the selected objects (paint order) into a live blend; a blend among them takes the others in as more key objects (keeping its options, name, transparency and whether it has a spine) instead of nesting → {id}", has_doc, blend_make ), diff --git a/docs/mcp.md b/docs/mcp.md index 30ac0bfb82..b4eac5addb 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -16808,7 +16808,12 @@ key holds a gradient or a pattern, the count is the largest distance between the bounding-box edges divided by their mean width (left and right edges) or height (top and bottom), rounded, less one, from 1 to 1000. Keys with no width or no height are measured by their other side, keys with neither in points, and keys without bounds make 1 step. `starts` gives, per object, the anchor of its first subpath the blend starts -from (as the Blend tool's clicks on anchor points do; an open path's last anchor runs it the other way). With the +from (as the Blend tool's clicks on anchor points do; an open path's last anchor runs it the other way). Steps +between two live rectangles with the same corner kinds and the same rotation, reflection and shear are live +rectangles whose width, height, position and corner radii lie between the keys'. Rounded corners stay circular +arcs only when the keys are not sheared and have no nonuniform scale in their transforms; a shared shear draws +elliptical corners on the canvas. Other path and live-shape pairs use anchor matching. A start anchor given in +`starts` for either key also sends live rectangles through anchor matching; an all-null `starts` does not. With the Blend tool, `press_key` Escape drops the object clicked first and stops the next click adding to the blend just made; the document and the selection stay as they are. A blend among the objects takes the others in as more key objects, keeping its options, name, transparency and whether it diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 594d6de35b..bd63035ba5 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2132,6 +2132,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur A double-click with the Live Paint Selection tool on a face selects it and the faces of its group that no stroked edge parts from it ([the help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/modify-live-paint-groups.html)), and on an edge selects it and the edges joined to it end to end that have its stroke paint ([the help page](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)); Shift-double-click adds them to the selection or removes them from it. A triple-click on a face selects every face of its group with that face's fill, and on an edge every edge of its group that has its stroke paint ([the help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/modify-live-paint-groups.html)); hidden faces and edges are left out, and Shift-triple-click adds them to the selection or removes them from it. When the object the Blend tool picked first is deleted or undone away before the second click, the next click on an object picks that object first instead of doing nothing. Regression tests: `blend_tool_picks_again_when_its_first_pick_is_gone` in `meshblend.rs` and `the_blend_tool_picks_again_when_its_first_pick_is_deleted` in `tests/blendopts.rs`. Window › Blend opens the Blend panel: Make, the selected blend's Spacing and Orientation (with no blend selected, the options new blends start with), Reverse Front to Back, Reverse Spine, Replace Spine, Expand and Release, each running its Object › Blend command. Make is dimmed until two or more objects are selected. Spacing and Orientation are dimmed until a blend or two or more objects are selected, and the other buttons are dimmed until a blend is selected. + Steps between live rectangles with matching corner kinds and equivalent linear transforms stay live rectangles with interpolated sizes, positions and corner radii. A start anchor given for either key selects anchor matching instead; all-null `starts` keeps live rectangles. Rounded corners stay circular only without shear or a nonuniform scale in the keys' transforms. Evidence: `blend::tests::steps_between_rounded_rectangles_keep_round_corners` in `crates/doc/src/blend.rs`. The Blend panel's Create Spine menu (Auto, Always, Never; `object.blend.createSpine`) sets whether new blends get a spine, from the Blend tool, Make and `object.blend.make` alike ([Blend panel overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/blend-panel-overview.html)). Auto and Always give every new blend a straight spine, as before; Never makes blends without one, which keep their steps on the straight lines between the keys, have Type and Ramp dimmed, refuse Reverse Spine and spine edits, release without a spine path, and get a spine from Replace Spine. The setting is kept with the preferences and leaves blends already made as they are; Auto as the starting value and keeping the setting across sessions are VectorCraft's own rules. Builds on #5177 by adambelis. Evidence: `tests::blendopts::{create_spine_sets_whether_new_blends_get_a_spine, a_blend_without_a_spine_has_none_to_edit_reverse_ease_or_release, whether_a_blend_has_a_spine_is_saved_and_old_blends_have_one}` and `panels::tests_blend::create_spine_sets_what_new_blends_get_whatever_is_selected`. Blend Options on several selected blends (the Blend Options dialog, the Blend panel's Type, Ramp and Shift, and `object.blend.options`) sets only the values given or set in the dialog, and each blend keeps its own spacing, orientation, type, ramp and shift for the rest instead of taking the first blend's; a spacing mode given without a count keeps the count of a blend already in that mode. `object.blend.options {id}` edits that blend alone; a hidden or locked blend, an object that is not a blend, a value out of range and an unknown orientation are errors that change nothing, and a call that changes nothing records no undo step. A drag of the panel's Ramp or Shift slider previews on the canvas and records one undo step on release, and Type, Ramp and Reverse Spine are dimmed while a selected blend, or the blend of a key selected with Direct Selection, has no spine. Builds on #8022 by ruchirguitar. Evidence: `tests::blendopts::{options_on_several_blends_set_only_the_values_given, options_with_an_id_edit_that_blend_alone, options_that_change_nothing_or_are_refused_record_no_undo_step}`, `dialogs::blend_options::tests::on_several_blends_ok_sets_only_the_fields_changed` and `panels::tests_blend::{a_ramp_or_shift_drag_is_one_undo_step, ramp_and_shift_edit_every_selected_blend_and_keep_their_other_options, ramp_is_dimmed_while_a_selected_blend_has_no_spine, ramp_and_reverse_spine_are_dimmed_while_a_selected_key_belongs_to_a_blend_with_no_spine}`. The Blend panel, the Object › Blend, Envelope Distort and Gradient Mesh menu items and their commands find each selected object's nearest blend, envelope or mesh by reading the object's place in the tree once, instead of looking up every ancestor by id, and the checks of whether one is selected stop at the first one found. The results, their order and the errors are the same. With Select All of 102,200 objects (100,000 rectangles, 2,000 blends and 200 envelopes in 10 layers), a release build took a median of 16.5 ms of thread CPU time for the Blend check before and 0.5 ms after, and 18.4 ms before and 8.2 ms after to list the selected blends. Evidence: `cmd::live::selected_tests` and `tests::lookups::nearest_finder_*`. From 3537d1bb602bb20bfe900d99221a9131f4787888 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 3 Dec 2026 06:47:40 -0800 Subject: [PATCH 02/10] Blend: live rectangle steps need keys with no scale left in their transforms Live rectangle steps keep the first key's rotation and reflection. A key whose transform still held a scale could pass the comparison with a large scale on one axis hiding a difference on the other, and Align to Path then folded that scale into each step, so its corners changed shape along the spine. Only keys whose transforms are a rotation or a reflection, the same for both, now take the live rectangle route; the rest keep anchor matching. --- crates/doc/src/blend.rs | 18 +++++++----------- docs/mcp.md | 7 +++---- docs/target-app-parity.md | 2 +- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/crates/doc/src/blend.rs b/crates/doc/src/blend.rs index c7ec77ac7f..2101baddeb 100644 --- a/crates/doc/src/blend.rs +++ b/crates/doc/src/blend.rs @@ -1034,7 +1034,7 @@ enum Shape { /// compound paths. Path { pair: PathPair, rules: (FillRule, FillRule), members: Option<(Vec, Vec)> }, /// Two live rectangles: each step is a live rectangle whose size, transform and corner radii - /// lie between the keys'. A shared shear or nonuniform scale makes the corners elliptical. + /// lie between the keys', so their rounded corners stay circular arcs. LiveRect(Box<(LiveRectParts, LiveRectParts)>), /// Text, symbols and images: their transforms interpolate. Placed, @@ -1076,19 +1076,15 @@ fn live_rect(s: &LiveShape) -> Option { } /// The parts of `a` and `b` when steps between them can be live rectangles: both are live -/// rectangles with the same corner kinds and the same rotation, reflection and shear, so each step -/// only moves and resizes. +/// rectangles with the same corner kinds, turned and reflected alike, and with no scale or shear +/// left in their transforms, so each step only moves and resizes and its corners stay circular. fn live_rect_pair(a: &LiveShape, b: &LiveShape) -> Option<(LiveRectParts, LiveRectParts)> { let (x, y) = (live_rect(a)?, live_rect(b)?); let (p, q) = (x.xf.as_coeffs(), y.xf.as_coeffs()); - let scale = p[..4].iter().chain(&q[..4]).map(|c| c.abs()).fold(0.0, f64::max); - let determinant_sign = |c: [f64; 6]| { - let scale = if scale > 0.0 { scale } else { 1.0 }; - let det = (c[0] / scale) * (c[3] / scale) - (c[1] / scale) * (c[2] / scale); - (det > 0.0, det < 0.0) - }; - (x.kinds == y.kinds && p[..4].iter().zip(&q[..4]).all(|(a, b)| (a - b).abs() <= 1e-9 * scale) && determinant_sign(p) == determinant_sign(q)) - .then_some((x, y)) + // A rotation or a reflection: unit columns at right angles. + let rigid = + |c: [f64; 6]| (c[0].hypot(c[1]) - 1.0).abs() < 1e-9 && (c[2].hypot(c[3]) - 1.0).abs() < 1e-9 && (c[0] * c[2] + c[1] * c[3]).abs() < 1e-9; + (x.kinds == y.kinds && rigid(p) && rigid(q) && p[..4].iter().zip(&q[..4]).all(|(a, b)| (a - b).abs() < 1e-9)).then_some((x, y)) } /// `n` shrunk to a point at `c`: the counterpart of an object only one of two groups has. diff --git a/docs/mcp.md b/docs/mcp.md index b4eac5addb..c4465ae0c1 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -16809,10 +16809,9 @@ bounding-box edges divided by their mean width (left and right edges) or height from 1 to 1000. Keys with no width or no height are measured by their other side, keys with neither in points, and keys without bounds make 1 step. `starts` gives, per object, the anchor of its first subpath the blend starts from (as the Blend tool's clicks on anchor points do; an open path's last anchor runs it the other way). Steps -between two live rectangles with the same corner kinds and the same rotation, reflection and shear are live -rectangles whose width, height, position and corner radii lie between the keys'. Rounded corners stay circular -arcs only when the keys are not sheared and have no nonuniform scale in their transforms; a shared shear draws -elliptical corners on the canvas. Other path and live-shape pairs use anchor matching. A start anchor given in +between two live rectangles with the same corner kinds and the same rotation and reflection, and with no scale +or shear left in their transforms, are live rectangles whose width, height, position and corner radii lie between +the keys', so their rounded corners stay circular arcs. Other path and live-shape pairs use anchor matching. A start anchor given in `starts` for either key also sends live rectangles through anchor matching; an all-null `starts` does not. With the Blend tool, `press_key` Escape drops the object clicked first and stops the next click adding to the blend just made; the document and the selection stay as they are. A blend diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index bd63035ba5..9e4dc14697 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2132,7 +2132,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur A double-click with the Live Paint Selection tool on a face selects it and the faces of its group that no stroked edge parts from it ([the help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/modify-live-paint-groups.html)), and on an edge selects it and the edges joined to it end to end that have its stroke paint ([the help page](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)); Shift-double-click adds them to the selection or removes them from it. A triple-click on a face selects every face of its group with that face's fill, and on an edge every edge of its group that has its stroke paint ([the help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/modify-live-paint-groups.html)); hidden faces and edges are left out, and Shift-triple-click adds them to the selection or removes them from it. When the object the Blend tool picked first is deleted or undone away before the second click, the next click on an object picks that object first instead of doing nothing. Regression tests: `blend_tool_picks_again_when_its_first_pick_is_gone` in `meshblend.rs` and `the_blend_tool_picks_again_when_its_first_pick_is_deleted` in `tests/blendopts.rs`. Window › Blend opens the Blend panel: Make, the selected blend's Spacing and Orientation (with no blend selected, the options new blends start with), Reverse Front to Back, Reverse Spine, Replace Spine, Expand and Release, each running its Object › Blend command. Make is dimmed until two or more objects are selected. Spacing and Orientation are dimmed until a blend or two or more objects are selected, and the other buttons are dimmed until a blend is selected. - Steps between live rectangles with matching corner kinds and equivalent linear transforms stay live rectangles with interpolated sizes, positions and corner radii. A start anchor given for either key selects anchor matching instead; all-null `starts` keeps live rectangles. Rounded corners stay circular only without shear or a nonuniform scale in the keys' transforms. Evidence: `blend::tests::steps_between_rounded_rectangles_keep_round_corners` in `crates/doc/src/blend.rs`. + Steps between two live rectangles with the same corner kinds, turned and reflected alike, are live rectangles whose sizes, positions and corner radii lie between the keys', so their rounded corners stay circular arcs (#10707). A start point clicked on either key, a scale or shear left in a key's transform, and every other pair of paths keep anchor-by-anchor matching. Evidence: `blend::tests::steps_between_rounded_rectangles_keep_round_corners` in `crates/doc/src/blend.rs`. The Blend panel's Create Spine menu (Auto, Always, Never; `object.blend.createSpine`) sets whether new blends get a spine, from the Blend tool, Make and `object.blend.make` alike ([Blend panel overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/blend-panel-overview.html)). Auto and Always give every new blend a straight spine, as before; Never makes blends without one, which keep their steps on the straight lines between the keys, have Type and Ramp dimmed, refuse Reverse Spine and spine edits, release without a spine path, and get a spine from Replace Spine. The setting is kept with the preferences and leaves blends already made as they are; Auto as the starting value and keeping the setting across sessions are VectorCraft's own rules. Builds on #5177 by adambelis. Evidence: `tests::blendopts::{create_spine_sets_whether_new_blends_get_a_spine, a_blend_without_a_spine_has_none_to_edit_reverse_ease_or_release, whether_a_blend_has_a_spine_is_saved_and_old_blends_have_one}` and `panels::tests_blend::create_spine_sets_what_new_blends_get_whatever_is_selected`. Blend Options on several selected blends (the Blend Options dialog, the Blend panel's Type, Ramp and Shift, and `object.blend.options`) sets only the values given or set in the dialog, and each blend keeps its own spacing, orientation, type, ramp and shift for the rest instead of taking the first blend's; a spacing mode given without a count keeps the count of a blend already in that mode. `object.blend.options {id}` edits that blend alone; a hidden or locked blend, an object that is not a blend, a value out of range and an unknown orientation are errors that change nothing, and a call that changes nothing records no undo step. A drag of the panel's Ramp or Shift slider previews on the canvas and records one undo step on release, and Type, Ramp and Reverse Spine are dimmed while a selected blend, or the blend of a key selected with Direct Selection, has no spine. Builds on #8022 by ruchirguitar. Evidence: `tests::blendopts::{options_on_several_blends_set_only_the_values_given, options_with_an_id_edit_that_blend_alone, options_that_change_nothing_or_are_refused_record_no_undo_step}`, `dialogs::blend_options::tests::on_several_blends_ok_sets_only_the_fields_changed` and `panels::tests_blend::{a_ramp_or_shift_drag_is_one_undo_step, ramp_and_shift_edit_every_selected_blend_and_keep_their_other_options, ramp_is_dimmed_while_a_selected_blend_has_no_spine, ramp_and_reverse_spine_are_dimmed_while_a_selected_key_belongs_to_a_blend_with_no_spine}`. The Blend panel, the Object › Blend, Envelope Distort and Gradient Mesh menu items and their commands find each selected object's nearest blend, envelope or mesh by reading the object's place in the tree once, instead of looking up every ancestor by id, and the checks of whether one is selected stop at the first one found. The results, their order and the errors are the same. With Select All of 102,200 objects (100,000 rectangles, 2,000 blends and 200 envelopes in 10 layers), a release build took a median of 16.5 ms of thread CPU time for the Blend check before and 0.5 ms after, and 18.4 ms before and 8.2 ms after to list the selected blends. Evidence: `cmd::live::selected_tests` and `tests::lookups::nearest_finder_*`. From 988a9b91935e0f7fd8479449dd8da33df62f1811 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 3 Dec 2026 07:02:16 -0800 Subject: [PATCH 03/10] Blend: test that unlike corner kinds keep the path route and steps keep the fill rule Keys whose corner kinds differ blend anchor by anchor, and the last step is the second key's outline. Steps between live rectangles keep the fill rule of the key they are nearer and stay live rectangles. --- crates/doc/src/blend.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crates/doc/src/blend.rs b/crates/doc/src/blend.rs index 2101baddeb..fe7ef7a6be 100644 --- a/crates/doc/src/blend.rs +++ b/crates/doc/src/blend.rs @@ -2467,6 +2467,31 @@ mod tests { b.transform(Affine::scale_non_uniform(scale, -scale * 1e-12), false); assert!(matches!(Lerp::new(&a, &b, (None, None)).shape, Shape::Path { .. })); } + // Keys whose corner kinds differ keep the anchor-by-anchor route. + let mut kinds = [CornerKind::Round; 4]; + kinds[2] = CornerKind::InvertedRound; + let live = LiveShape::Rectangle { w: 200.0, h: 60.0, radii: [30.0; 4], kinds, radii_relative: false, xf: Affine::translate((300.0, 0.0)) }; + let mut inverted = Node::path(NodeId(1), live.to_path(), Appearance::default()); + if let NodeKind::Path { live: l, .. } = &mut inverted.kind { + *l = Some(Box::new(live)); + } + let blend = Lerp::new(&rounded(0.0, 100.0, 100.0, 10.0), &inverted, (None, None)); + assert!(matches!(blend.shape, Shape::Path { .. })); + // The last step is the inverted key's outline. + assert_eq!(blend.at(1.0).path_data().and_then(|p| p.bounds()), inverted.path_data().and_then(|p| p.bounds())); + // Each step keeps the fill rule of the key it is nearer. + let mut a = rounded(0.0, 100.0, 100.0, 10.0); + if let NodeKind::Path { rule, .. } = &mut a.kind { + *rule = FillRule::EvenOdd; + } + let blend = Lerp::new(&a, &rounded(300.0, 200.0, 60.0, 30.0), (None, None)); + assert!(matches!(&blend.shape, Shape::LiveRect(_))); + let rule = |n: &Node| match &n.kind { + NodeKind::Path { rule, .. } => *rule, + _ => panic!("a path step: {n:?}"), + }; + assert_eq!(rule(&blend.at(0.25)), FillRule::EvenOdd); + assert_eq!(rule(&blend.at(0.75)), FillRule::NonZero); } /// A step between two distorted images has its corners between the keys' corners. From b09940b6a6b0b9e76073b80f3679ba09e0db708b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 3 Dec 2026 09:09:20 -0800 Subject: [PATCH 04/10] Docs: blend steps take the keys' drawn radii, positions on a straight spine Steps between live rectangles interpolate each key's radius after it is fitted to its sides, not the stored radius. Their positions lie between the keys' only on a straight spine; on an edited or replaced spine each step sits on the spine. --- docs/mcp.md | 6 ++++-- docs/target-app-parity.md | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/mcp.md b/docs/mcp.md index c4465ae0c1..5eb8f4113b 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -16810,8 +16810,10 @@ from 1 to 1000. Keys with no width or no height are measured by their other side keys without bounds make 1 step. `starts` gives, per object, the anchor of its first subpath the blend starts from (as the Blend tool's clicks on anchor points do; an open path's last anchor runs it the other way). Steps between two live rectangles with the same corner kinds and the same rotation and reflection, and with no scale -or shear left in their transforms, are live rectangles whose width, height, position and corner radii lie between -the keys', so their rounded corners stay circular arcs. Other path and live-shape pairs use anchor matching. A start anchor given in +or shear left in their transforms, are live rectangles whose width, height and drawn corner radii lie between +the keys', so their rounded corners stay circular arcs. The drawn radius is a key's radius fitted to its sides (a +20 by 10 key that stores a radius of 50 blends with a radius of 5). On a straight spine the steps' positions also +lie between the keys'; on an edited or replaced spine each step sits on the spine. Other path and live-shape pairs use anchor matching. A start anchor given in `starts` for either key also sends live rectangles through anchor matching; an all-null `starts` does not. With the Blend tool, `press_key` Escape drops the object clicked first and stops the next click adding to the blend just made; the document and the selection stay as they are. A blend diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 9e4dc14697..304025ecbe 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2132,7 +2132,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur A double-click with the Live Paint Selection tool on a face selects it and the faces of its group that no stroked edge parts from it ([the help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/modify-live-paint-groups.html)), and on an edge selects it and the edges joined to it end to end that have its stroke paint ([the help page](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)); Shift-double-click adds them to the selection or removes them from it. A triple-click on a face selects every face of its group with that face's fill, and on an edge every edge of its group that has its stroke paint ([the help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/modify-live-paint-groups.html)); hidden faces and edges are left out, and Shift-triple-click adds them to the selection or removes them from it. When the object the Blend tool picked first is deleted or undone away before the second click, the next click on an object picks that object first instead of doing nothing. Regression tests: `blend_tool_picks_again_when_its_first_pick_is_gone` in `meshblend.rs` and `the_blend_tool_picks_again_when_its_first_pick_is_deleted` in `tests/blendopts.rs`. Window › Blend opens the Blend panel: Make, the selected blend's Spacing and Orientation (with no blend selected, the options new blends start with), Reverse Front to Back, Reverse Spine, Replace Spine, Expand and Release, each running its Object › Blend command. Make is dimmed until two or more objects are selected. Spacing and Orientation are dimmed until a blend or two or more objects are selected, and the other buttons are dimmed until a blend is selected. - Steps between two live rectangles with the same corner kinds, turned and reflected alike, are live rectangles whose sizes, positions and corner radii lie between the keys', so their rounded corners stay circular arcs (#10707). A start point clicked on either key, a scale or shear left in a key's transform, and every other pair of paths keep anchor-by-anchor matching. Evidence: `blend::tests::steps_between_rounded_rectangles_keep_round_corners` in `crates/doc/src/blend.rs`. + Steps between two live rectangles with the same corner kinds, turned and reflected alike, are live rectangles whose sizes and drawn corner radii lie between the keys', so their rounded corners stay circular arcs (#10707). The drawn radii are the radii after each key's radius is fitted to its sides: a 20 by 10 key that stores a radius of 50 draws and blends with a radius of 5. On a straight spine the steps' positions also lie between the keys'; on an edited or replaced spine each step sits on the spine. A start point clicked on either key, a scale or shear left in a key's transform, and every other pair of paths keep anchor-by-anchor matching. Evidence: `blend::tests::steps_between_rounded_rectangles_keep_round_corners` in `crates/doc/src/blend.rs`. The Blend panel's Create Spine menu (Auto, Always, Never; `object.blend.createSpine`) sets whether new blends get a spine, from the Blend tool, Make and `object.blend.make` alike ([Blend panel overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/blend-panel-overview.html)). Auto and Always give every new blend a straight spine, as before; Never makes blends without one, which keep their steps on the straight lines between the keys, have Type and Ramp dimmed, refuse Reverse Spine and spine edits, release without a spine path, and get a spine from Replace Spine. The setting is kept with the preferences and leaves blends already made as they are; Auto as the starting value and keeping the setting across sessions are VectorCraft's own rules. Builds on #5177 by adambelis. Evidence: `tests::blendopts::{create_spine_sets_whether_new_blends_get_a_spine, a_blend_without_a_spine_has_none_to_edit_reverse_ease_or_release, whether_a_blend_has_a_spine_is_saved_and_old_blends_have_one}` and `panels::tests_blend::create_spine_sets_what_new_blends_get_whatever_is_selected`. Blend Options on several selected blends (the Blend Options dialog, the Blend panel's Type, Ramp and Shift, and `object.blend.options`) sets only the values given or set in the dialog, and each blend keeps its own spacing, orientation, type, ramp and shift for the rest instead of taking the first blend's; a spacing mode given without a count keeps the count of a blend already in that mode. `object.blend.options {id}` edits that blend alone; a hidden or locked blend, an object that is not a blend, a value out of range and an unknown orientation are errors that change nothing, and a call that changes nothing records no undo step. A drag of the panel's Ramp or Shift slider previews on the canvas and records one undo step on release, and Type, Ramp and Reverse Spine are dimmed while a selected blend, or the blend of a key selected with Direct Selection, has no spine. Builds on #8022 by ruchirguitar. Evidence: `tests::blendopts::{options_on_several_blends_set_only_the_values_given, options_with_an_id_edit_that_blend_alone, options_that_change_nothing_or_are_refused_record_no_undo_step}`, `dialogs::blend_options::tests::on_several_blends_ok_sets_only_the_fields_changed` and `panels::tests_blend::{a_ramp_or_shift_drag_is_one_undo_step, ramp_and_shift_edit_every_selected_blend_and_keep_their_other_options, ramp_is_dimmed_while_a_selected_blend_has_no_spine, ramp_and_reverse_spine_are_dimmed_while_a_selected_key_belongs_to_a_blend_with_no_spine}`. The Blend panel, the Object › Blend, Envelope Distort and Gradient Mesh menu items and their commands find each selected object's nearest blend, envelope or mesh by reading the object's place in the tree once, instead of looking up every ancestor by id, and the checks of whether one is selected stop at the first one found. The results, their order and the errors are the same. With Select All of 102,200 objects (100,000 rectangles, 2,000 blends and 200 envelopes in 10 layers), a release build took a median of 16.5 ms of thread CPU time for the Blend check before and 0.5 ms after, and 18.4 ms before and 8.2 ms after to list the selected blends. Evidence: `cmd::live::selected_tests` and `tests::lookups::nearest_finder_*`. From 7cba3b786d1729f99b77ad638619be78e5c22a8f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 3 Dec 2026 09:36:33 -0800 Subject: [PATCH 05/10] Links: clicking a link on desktop opens it in the browser again The desktop app sends every link it opens (Help menu community links, the app bar's Discord button, Home's Community links, About and credits, help links in dialogs, the updater's Open URL, an object's URL attribute) as egui's OpenUrl output. The app built eframe without its `links` feature, so egui-winit only logged "Cannot open url - feature \"links\" not enabled." and nothing opened. Turn on eframe's `links` feature in apps/vectorcraft. Cargo.lock adds webbrowser 1.2.8. The web build does not use egui-winit and is unchanged. The feature can be removed once the craft-libs pin includes storytold/craft-libs#5083, which opens links in the shared app setup. --- Cargo.lock | 17 +++++++++++++++++ apps/vectorcraft/Cargo.toml | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 75c87011b4..be4b734a08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2900,6 +2900,7 @@ dependencies = [ "raw-window-handle", "smithay-clipboard", "web-time", + "webbrowser", "windows-sys 0.61.2", "winit", ] @@ -9642,6 +9643,22 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webbrowser" +version = "1.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13b31216ad837f3f4062538be333d8431d37c11832ef86924a3d0ad50defdc2f" +dependencies = [ + "jni", + "log", + "ndk-context", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "url", + "web-sys", +] + [[package]] name = "webpki-root-certs" version = "1.0.11" diff --git a/apps/vectorcraft/Cargo.toml b/apps/vectorcraft/Cargo.toml index bc000f0bd6..d4d2659b3e 100644 --- a/apps/vectorcraft/Cargo.toml +++ b/apps/vectorcraft/Cargo.toml @@ -23,7 +23,10 @@ vectorcraft-text = { workspace = true } # the update client. craft = { workspace = true, features = ["ui", "ui-app", "settings", "automation", "platform", "window", "dialogs", "print", "update"] } craft-nightly = { workspace = true } -eframe = { workspace = true, features = ["clipboard", "default_fonts", "wayland", "x11"] } +# `links` makes egui's OpenUrl output (every link the app opens) start the system browser; without it egui-winit only +# logs the request. Remove it when the craft-libs pin includes storytold/craft-libs#5083, which opens links in the +# shared app setup. +eframe = { workspace = true, features = ["clipboard", "default_fonts", "links", "wayland", "x11"] } egui = { workspace = true } egui_extras = { workspace = true } serde_json = { workspace = true } From 6ba1e6cc235fc13528bd1b646db991707f0d546f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 3 Dec 2026 09:46:51 -0800 Subject: [PATCH 06/10] EPS import: test the skipping of oversized image data under a 1 MiB limit the_data_of_an_image_too_large_to_hold_is_skipped built 300 MiB of zeros and Flate- and LZW-encoded each of them to get past the reader's 256 MiB data limit, and took about 8.7 s. Tests can now lower the limit on their own thread with `with_data_limit`; shipped builds keep the 256 MiB constant. The test runs under a 1 MiB limit with 2 MiB of data per filter, and checks that the Flate and LZW data is measured in full, so it fails when the lower limit does not take effect. It now takes about 0.14 s. --- crates/eps/src/import/data.rs | 2 +- crates/eps/src/import/data/filters.rs | 14 ++++----- crates/eps/src/import/data/ops.rs | 45 ++++++++++++++++++++++----- crates/eps/src/import/tests_images.rs | 37 +++++++++++++--------- 4 files changed, 69 insertions(+), 29 deletions(-) diff --git a/crates/eps/src/import/data.rs b/crates/eps/src/import/data.rs index 09f7531ff1..911b356793 100644 --- a/crates/eps/src/import/data.rs +++ b/crates/eps/src/import/data.rs @@ -22,4 +22,4 @@ mod pixels; pub(crate) use filters::Stream; #[cfg(test)] -pub(crate) use ops::measured; +pub(crate) use ops::{measured, with_data_limit}; diff --git a/crates/eps/src/import/data/filters.rs b/crates/eps/src/import/data/filters.rs index cada27219a..7f3d37e043 100644 --- a/crates/eps/src/import/data/filters.rs +++ b/crates/eps/src/import/data/filters.rs @@ -1,4 +1,4 @@ -use super::ops::MAX_DATA; +use super::ops::max_data; use super::{DictRef, ImageBlob, Key, Obj, PsError, Rc, RefCell, Res, find, hex_decode, jpeg_components, ps, ps_err}; use craft_stream_codecs::CcittParams; @@ -44,7 +44,7 @@ fn run_length(raw: &[u8]) -> Res<(Vec, usize)> { out.extend(std::iter::repeat_n(b, 257 - usize::from(n))); } } - if out.len() > MAX_DATA { + if out.len() > max_data() { return Err(PsError::Limit("decoded data is too large")); } } @@ -54,7 +54,7 @@ fn run_length(raw: &[u8]) -> Res<(Vec, usize)> { /// zlib data inflated, and how many bytes of `raw` it took. fn flate(raw: &[u8]) -> Res<(Vec, usize)> { let mut z = flate2::Decompress::new(true); - let mut out = Vec::with_capacity(raw.len().saturating_mul(3).min(MAX_DATA)); + let mut out = Vec::with_capacity(raw.len().saturating_mul(3).min(max_data())); loop { let before = (z.total_in(), z.total_out()); if out.capacity() - out.len() < 64 * 1024 { @@ -62,7 +62,7 @@ fn flate(raw: &[u8]) -> Res<(Vec, usize)> { } let input = raw.get(z.total_in() as usize..).unwrap_or_default(); let status = z.decompress_vec(input, &mut out, flate2::FlushDecompress::None).map_err(|_| PsError::Ps("ioerror", "FlateDecode".into()))?; - if out.len() > MAX_DATA { + if out.len() > max_data() { return Err(PsError::Limit("decoded data is too large")); } match status { @@ -79,7 +79,7 @@ fn lzw(raw: &[u8]) -> Res<(Vec, usize)> { let mut out = vec![]; let used = lzw_into(raw, &mut |bytes| { out.extend_from_slice(bytes); - if out.len() > MAX_DATA { + if out.len() > max_data() { return Err(PsError::Limit("decoded data is too large")); } Ok(()) @@ -238,10 +238,10 @@ fn dct(raw: &[u8]) -> Res<(Vec, usize, u8)> { /// `EndOfBlock` the rows end at the end-of-block code (EOFB, or RTC in Group 3) regardless of /// `Rows`; without it they end after `Rows` rows, or at the end of the data when `Rows` is 0. /// Damaged data ends the rows: those decoded before it are kept, and damage in the first row is an -/// `ioerror`. Rows that would take more than `MAX_DATA` bytes are refused. +/// `ioerror`. Rows that would take more than [`max_data`] bytes are refused. fn fax(raw: &[u8], settings: CcittParams) -> Res<(Vec, usize)> { let row = (settings.columns as usize).div_ceil(8).max(1); - let most = u32::try_from(MAX_DATA / row).unwrap_or(u32::MAX); + let most = u32::try_from(max_data() / row).unwrap_or(u32::MAX); if !settings.end_of_block && settings.rows > i64::from(most) { return Err(PsError::Limit("decoded data is too large")); } diff --git a/crates/eps/src/import/data/ops.rs b/crates/eps/src/import/data/ops.rs index c27dc3c3c6..c83b4dca4d 100644 --- a/crates/eps/src/import/data/ops.rs +++ b/crates/eps/src/import/data/ops.rs @@ -6,7 +6,38 @@ use super::{ }; /// Most bytes one filter or image reads. -pub(super) const MAX_DATA: usize = 1 << 28; +const MAX_DATA: usize = 1 << 28; + +#[cfg(test)] +thread_local! { + /// The most bytes one filter or image reads on this thread ([`MAX_DATA`] unless a test lowered it). + static DATA_LIMIT: std::cell::Cell = const { std::cell::Cell::new(MAX_DATA) }; +} + +/// The most bytes one filter or image reads: [`MAX_DATA`]. +#[cfg(not(test))] +pub(super) const fn max_data() -> usize { + MAX_DATA +} + +/// The most bytes one filter or image reads: [`DATA_LIMIT`] of this thread. +#[cfg(test)] +pub(super) fn max_data() -> usize { + DATA_LIMIT.get() +} + +/// Runs `f` with [`max_data`] set to `limit` on this thread, and restores it afterwards. +#[cfg(test)] +pub(crate) fn with_data_limit(limit: usize, f: impl FnOnce() -> R) -> R { + struct Restore(usize); + impl Drop for Restore { + fn drop(&mut self) { + DATA_LIMIT.set(self.0); + } + } + let _restore = Restore(DATA_LIMIT.replace(limit)); + f() +} /// Decoded bytes the measuring of an image's data left out charges one operation for. A program's /// budget grows by 64 operations for each byte of it, so the data of one image compressed up to @@ -410,7 +441,7 @@ impl Interp<'_> { Stream::Buf { data, pos: 0, rgb } } p @ Obj::Array { .. } => { - let raw = self.gather(&p, MAX_DATA)?; + let raw = self.gather(&p, max_data())?; let (data, _, rgb) = decode(&spec, &raw)?; self.charge_decoded(data.len())?; Stream::Buf { data, pos: 0, rgb } @@ -600,7 +631,7 @@ impl Interp<'_> { if last.predictor.is_some() || !matches!(&*last.name, "FlateDecode" | "LZWDecode") { return Ok(None); } - let Some(kept) = row.checked_mul(oh).filter(|k| *k <= MAX_DATA) else { return Ok(None) }; + let Some(kept) = row.checked_mul(oh).filter(|k| *k <= max_data()) else { return Ok(None) }; self.alloc(kept)?; // The compressed data: what the filters before the last one decode, or the file itself. let compressed = if head.is_empty() { @@ -618,7 +649,7 @@ impl Interp<'_> { }; let (mut rows, mut seen) = (Vec::with_capacity(kept), 0usize); // Past the image's data and as much again the data is not an image's: it stops there. - let most = row.saturating_mul(s.h).saturating_add(MAX_DATA); + let most = row.saturating_mul(s.h).saturating_add(max_data()); let mut sink = |mut chunk: &[u8]| -> Res { while !chunk.is_empty() { let (r, off) = (seen / row.max(1), seen % row.max(1)); @@ -829,7 +860,7 @@ impl Interp<'_> { let (mrow, drow) = (stencil.row_bytes(1), image.row_bytes(n)); let total = mrow.saturating_mul(stencil.h).saturating_add(drow.saturating_mul(image.h)); // What is read: an image past the pixel cap is reduced from the samples read. - charged = total.min(MAX_DATA); + charged = total.min(max_data()); self.alloc(charged)?; let raw = self.source_bytes(&src, charged)?; by_rows(&raw, (mrow, stencil.h), (drow, image.h)) @@ -838,7 +869,7 @@ impl Interp<'_> { stencil.bpc = image.bpc; (stencil.w, stencil.h) = (image.w, image.h); let row = (image.w * (n + 1) * usize::from(image.bpc)).div_ceil(8); - charged = row.saturating_mul(image.h).min(MAX_DATA); + charged = row.saturating_mul(image.h).min(max_data()); self.alloc(charged)?; let raw = self.source_bytes(&src, charged)?; by_samples(&raw, image.w, image.h, n, image.bpc) @@ -1020,7 +1051,7 @@ impl Interp<'_> { // skipped), while one within the pixel cap whose samples are still too much data // (16-bit CMYK, say) stops the read with the limit, as before (#3568: such a plane // is refused). - let Some(plane) = row.checked_mul(s.h).filter(|p| *p <= MAX_DATA) else { + let Some(plane) = row.checked_mul(s.h).filter(|p| *p <= max_data()) else { if step > 1 { return Ok(self.leave_out(&s)); } diff --git a/crates/eps/src/import/tests_images.rs b/crates/eps/src/import/tests_images.rs index 2324de4eb4..ffc482f0f7 100644 --- a/crates/eps/src/import/tests_images.rs +++ b/crates/eps/src/import/tests_images.rs @@ -686,11 +686,15 @@ fn an_image_of_more_data_than_the_reader_holds_keeps_only_the_rows_it_reads() { /// reader holds) is left out, and its data is skipped: when a procedure reads it, the procedure /// is called until the data ends; when its first filter decompresses to more than the reader /// holds (and can't be read a row at a time), the compressed data (Flate, LZW or run-length) is -/// measured without keeping it. +/// measured without keeping it. The reader holds 1 MiB here, and each filter's data decompresses +/// to 2 MiB: Flate and LZW data is measured in full (run-length data is measured by its run +/// lengths, without decoding it). #[test] fn the_data_of_an_image_too_large_to_hold_is_skipped() { + const LIMIT: usize = 1 << 20; + const DECODED: usize = 2 * LIMIT; let after = "0 0 1 setrgbcolor 10 10 80 80 rectfill"; - let zeros = crate::ps::deflate(&vec![0u8; 300 << 20]); + let zeros = crate::ps::deflate(&vec![0u8; DECODED]); // Predicted rows aren't decoded a row at a time: such an image is left out. let mut flate = b"10000 10000 8 [1 0 0 1 0 0] currentfile << /Predictor 15 /Colors 3 /Columns 10000 >> /FlateDecode filter false 3 colorimage\n".to_vec(); @@ -699,7 +703,7 @@ fn the_data_of_an_image_too_large_to_hold_is_skipped() { // The same through LZW, which counts the codes up to its end-of-data code. let mut lzw = b"10000 10000 8 [1 0 0 1 0 0] currentfile << /Predictor 15 /Colors 3 /Columns 10000 >> /LZWDecode filter false 3 colorimage\n".to_vec(); - lzw.extend(craft_stream_codecs::lzw::encode(&vec![0u8; 300 << 20], true)); + lzw.extend(craft_stream_codecs::lzw::encode(&vec![0u8; DECODED], true)); lzw.extend(format!("\n{after}").as_bytes()); // Run-length data isn't decoded a row at a time either: a literal run of three bytes, runs of // 128 bytes, and the end-of-data byte (128) after which the art follows. The literal ends in @@ -707,24 +711,29 @@ fn the_data_of_an_image_too_large_to_hold_is_skipped() { // run's length and stays off by one. let mut run_length = b"10000 10000 8 [1 0 0 1 0 0] currentfile /RunLengthDecode filter false 3 colorimage\n".to_vec(); run_length.extend([2, 200, 200, 200]); - run_length.extend([129u8, 200].repeat((300 << 20) / 128)); + run_length.extend([129u8, 200].repeat(DECODED / 128)); run_length.push(128); run_length.extend(format!("\n{after}").as_bytes()); - for program in [ - format!( - "/F currentfile 0 (%%EndData) /SubFileDecode filter def \ - 10000 10000 8 [1 0 0 1 0 0] {{ F 4096 string readstring pop }} false 3 colorimage\n@@@@ not PostScript @@@@\n%%EndData\n{after}" - ) - .into_bytes(), - flate, - lzw, - run_length, + for (program, measured) in [ + ( + format!( + "/F currentfile 0 (%%EndData) /SubFileDecode filter def \ + 10000 10000 8 [1 0 0 1 0 0] {{ F 4096 string readstring pop }} false 3 colorimage\n@@@@ not PostScript @@@@\n%%EndData\n{after}" + ) + .into_bytes(), + 0, + ), + (flate, DECODED as u64), + (lzw, DECODED as u64), + (run_length, 0), ] { let text = String::from_utf8_lossy(program.get(..120).unwrap_or(&program)).into_owned(); let mut file = b"%!PS-Adobe-3.0 EPSF-3.0\n%%BoundingBox: 0 0 100 100\n%%EndComments\n".to_vec(); file.extend(&program); file.extend(b"\nshowpage\n%%EOF\n"); - let r = import(&file).unwrap(); + let before = crate::import::data::measured(); + let r = crate::import::data::with_data_limit(LIMIT, || import(&file)).unwrap(); + assert_eq!(crate::import::data::measured() - before, measured, "{text}"); assert!(r.warnings.iter().any(|w| w.contains("too large to read")), "{text}: {:?}", r.warnings); let o = super::tests::objects(&r.document); assert_eq!(o.len(), 1, "{text}: {:?}", r.warnings); From db1d346bc4dffac3407c9299fd4e6661c72e7223 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 3 Dec 2026 09:56:28 -0800 Subject: [PATCH 07/10] Tests: Divide refuses cutting lines past the segment cap A square and an unfilled zigzag with one segment more than the planar map's cap: Divide returns the "select fewer paths" error and leaves the document and the undo history unchanged. With the check replaced by the unchecked Divide, the test fails because Divide returns the square uncut. --- crates/engine/src/tests/pathops.rs | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/crates/engine/src/tests/pathops.rs b/crates/engine/src/tests/pathops.rs index a5a082058e..d1b5197012 100644 --- a/crates/engine/src/tests/pathops.rs +++ b/crates/engine/src/tests/pathops.rs @@ -171,6 +171,38 @@ fn pathfinder_refuses_a_selection_without_paths_and_invalid_coordinates() { assert_eq!(s.doc().unwrap().history.undo.len(), undo_len); } +/// Divide refuses a cutting line with more segments than its planar map takes, instead of +/// dividing the square without the line, and leaves the document and the undo history as they were. +#[test] +fn divide_refuses_cutting_lines_past_the_segment_cap() { + let mut s = session(); + let base = rect(&mut s, 0.0, 0.0, 100.0, 100.0); + let cutter = NodeId(s.execute("path.create", &json!({"anchors": [{"x": -10, "y": 50}, {"x": 110, "y": 50}]})).unwrap()["id"].as_u64().unwrap()); + // A zigzag across the square with one segment more than the cap, the square's four sides aside. + let segments = vectorcraft_pathops::SHAPE_BUILDER_MAX_SEGMENTS - 3; + s.edit("zigzag", |d, sel| { + let mut bp = vectorcraft_geom::BezPath::new(); + bp.move_to((-10.0, 40.0)); + for i in 1..=segments { + let x = -10.0 + 120.0 * i as f64 / segments as f64; + bp.line_to((x, if i % 2 == 0 { 40.0 } else { 60.0 })); + } + // Unfilled, so the zigzag stays open and cuts. + let n = d.node_mut(cutter).unwrap(); + n.appearance = Appearance::basic(Paint::None, Paint::solid(Color::BLACK), 1.0).into(); + n.kind = NodeKind::Path { path: PathData::from_bezpath(&bp), rule: FillRule::NonZero, live: None, clipping: false, guide: false }; + sel.set([cutter, base]); + Ok(()) + }) + .unwrap(); + let before = s.doc().unwrap().doc.clone(); + let undo_len = s.doc().unwrap().history.undo.len(); + let e = s.execute("object.pathfinder.divide", &json!({})).unwrap_err().to_string(); + assert!(e.contains("select fewer paths"), "{e}"); + assert!(s.doc().unwrap().doc == before); + assert_eq!(s.doc().unwrap().history.undo.len(), undo_len); +} + #[test] fn exclude_makes_compound() { let mut s = session(); From c976e47115c8c908a2c0223612a0aa1b201ea13b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 3 Dec 2026 10:09:29 -0800 Subject: [PATCH 08/10] Panels: hidden or minimized palette windows no longer block canvas drops A floating panel's OS window counted as covering the canvas even while it was minimized, or hidden because a dialog or popup was open. Art dragged onto the canvas and released over the spot where such a window sat was refused, and the tools treated the pointer there as covered. os_window_at now skips windows the OS reports minimized, and reports no cover while a dialog or popup is open. This works around storytold/craft-libs#4739; the checks are removed when the craft-libs pin includes that change. --- crates/ui-egui/src/panel_docking.rs | 15 ++++-- .../ui-egui/src/panel_docking/native_tests.rs | 48 +++++++++++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/panel_docking.rs b/crates/ui-egui/src/panel_docking.rs index 1a47d5a7d2..4e7edbbfa7 100644 --- a/crates/ui-egui/src/panel_docking.rs +++ b/crates/ui-egui/src/panel_docking.rs @@ -1317,15 +1317,24 @@ fn window_viewport(app: &VectorcraftApp, panel: &str) -> Option