Live Paint: a Bucket drag from an edge strokes every edge it crosses

A press on an edge (Shift with Paint Fills alone, or a plain press with
Paint Strokes on) now starts a drag, as a press on a face does. The drag
paints the edge and every visible edge of the same group that it crosses
or comes within 0.0001 pt of, between pointer events and on the release,
as one undo step; Escape cancels it. Edges of other groups and hidden
edges keep their strokes, a drag over edges that already have the stroke
records no undo step, and a drag that starts on a face still fills only
faces. A double-click after such a drag joins through the edges the drag
stroked as the paint they had before it.

livePaint.strokeEdge takes the drag's points and continuation as
livePaint.fill does, and both refuse them with scope connected or
samePaint.

Help page: https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/paint-with-the-live-paint-bucket-tool.html
This commit is contained in:
dotCooCoo
2026-11-16 05:32:00 -08:00
parent 7452b6f383
commit ebeffa15ab
9 changed files with 475 additions and 76 deletions
+1 -1
View File
@@ -126,7 +126,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Live Paint Bucket (Stroke)",
[],
None,
"{group: id, point: [x,y], color?|swatch?|none? (default: current stroke), width?: pt (default: current weight), tolerance?: pt (4), scope?: \"one\" (default: the edge alone) | \"connected\" (a double-click: also each edge joined to it, end to end, through edges that draw with stroke paint match) | \"samePaint\" (a triple-click: also every edge of the group that draws with stroke paint match), match?: paint (as the document stores it; scope connected or samePaint only; default: the stroke paint the edge draws with; an edge draws with the paint of its topmost stroke that is shown, with paint, above 0 pt and not fully transparent, and with none when the edge is fully transparent or has no such stroke), through?: [id…] (scope connected only; at most 4096 of the group's edges, each given once, counted as drawing with stroke paint match whatever they draw with, such as another edge a double-click's clicks painted; any other id is an error), tint?: 0..100, keepModel?: bool (both as paint.setFill)} paint the edge nearest point, skipping hidden edges: each edge reached has its strokes replaced by one stroke with the paint and width, shown, fully opaque and blending normally, in the place of its topmost stroke and with the dashes, caps and arrowheads of its topmost shown stroke (a new stroke above the fills when it has none; none leaves one stroke of none), and its fills stay as they are; when every edge it reaches already has only that one stroke (at any width for none), nothing changes (no undo step, and the recent colors stay as they are) → {group, edge, count (edges reached)}",
"{group: id, point: [x,y], color?|swatch?|none? (default: current stroke), width?: pt (default: current weight), tolerance?: pt (4), points?: [[x,y]…] (a drag polyline starting at point; 1 to 4096 finite canvas points; also paints every edge of the group, hidden edges skipped, that the polyline crosses or comes within 0.0001 pt of), continuation?: [[[x,y]…]…] (further path chunks of 1 to 4096 finite canvas points each; each starts at the preceding chunk's last point; requires points), scope?: \"one\" (default: the edge alone) | \"connected\" (a double-click: also each edge joined to it, end to end, through edges that draw with stroke paint match) | \"samePaint\" (a triple-click: also every edge of the group that draws with stroke paint match; \"connected\" and \"samePaint\" are refused with points), match?: paint (as the document stores it; scope connected or samePaint only; default: the stroke paint the edge draws with; an edge draws with the paint of its topmost stroke that is shown, with paint, above 0 pt and not fully transparent, and with none when the edge is fully transparent or has no such stroke), through?: [id…] (scope connected only; at most 4096 of the group's edges, each given once, counted as drawing with stroke paint match whatever they draw with, such as another edge a double-click's clicks painted; any other id is an error), tint?: 0..100, keepModel?: bool (both as paint.setFill)} paint the edge nearest point, skipping hidden edges: each edge reached has its strokes replaced by one stroke with the paint and width, shown, fully opaque and blending normally, in the place of its topmost stroke and with the dashes, caps and arrowheads of its topmost shown stroke (a new stroke above the fills when it has none; none leaves one stroke of none), and its fills stay as they are; when every edge it reaches already has only that one stroke (at any width for none), nothing changes (no undo step, and the recent colors stay as they are) → {group, edge, count (edges reached)}",
has_doc,
lp_stroke_edge
),
+49 -22
View File
@@ -409,43 +409,61 @@ fn match_param(p: &Value, c: &str, allowed: bool, scopes: &str) -> Result<Option
serde_json::from_value::<super::Paint>(v.clone()).map(Some).map_err(|_| bad(c, "match must be a paint as the document stores it"))
}
pub(super) fn lp_fill(s: &mut Session, p: &Value) -> Result<Value> {
const C: &str = "livePaint.fill";
let pt = point_param(p, "point").filter(|q| finite(*q)).ok_or_else(|| bad(C, "missing point [x,y]"))?;
let scope = scope_param(p, C)?;
let like = match_param(p, C, scope == LpScope::SamePaint, "\"samePaint\"")?;
/// The drag path of `livePaint.fill` or `livePaint.strokeEdge` (command `c`) pressed at `start`:
/// `points` followed by each chunk of `continuation`, where every chunk holds 1 to
/// [`b::LP_FILL_CHUNK_POINTS`] finite canvas points and starts at the last point of the chunk
/// before it (`points` at `start`). None when `points` is left out. With a `scope` other than
/// `one`, `points` is an error.
fn path_param(p: &Value, c: &str, start: Point, scope: LpScope) -> Result<Option<Vec<Vec<Point>>>> {
if scope != LpScope::One && p.get("points").is_some() {
return Err(bad(C, "scope applies to a click: leave out points"));
return Err(bad(c, "scope applies to a click: leave out points"));
}
let parse_chunk = |input: &Value, start: Point| -> Result<Vec<Point>> {
let values = input
.as_array()
.filter(|points| !points.is_empty() && points.len() <= b::LP_FILL_CHUNK_POINTS)
.ok_or_else(|| bad(C, "each path chunk must contain 1 to 4096 points"))?;
.ok_or_else(|| bad(c, "each path chunk must contain 1 to 4096 points"))?;
let points: Vec<_> = values
.iter()
.map(|point| {
let pair = point.as_array().filter(|pair| pair.len() == 2).ok_or_else(|| bad(C, "points must be [x,y] pairs"))?;
let x = pair.first().and_then(Value::as_f64).ok_or_else(|| bad(C, "point x must be a number"))?;
let y = pair.get(1).and_then(Value::as_f64).ok_or_else(|| bad(C, "point y must be a number"))?;
let pair = point.as_array().filter(|pair| pair.len() == 2).ok_or_else(|| bad(c, "points must be [x,y] pairs"))?;
let x = pair.first().and_then(Value::as_f64).ok_or_else(|| bad(c, "point x must be a number"))?;
let y = pair.get(1).and_then(Value::as_f64).ok_or_else(|| bad(c, "point y must be a number"))?;
let point = Point::new(x, y);
if !finite(point) {
return Err(bad(C, "points must be finite canvas points"));
return Err(bad(c, "points must be finite canvas points"));
}
Ok(point)
})
.collect::<Result<_>>()?;
if points.first() != Some(&start) {
return Err(bad(C, "path chunks must share their boundary point"));
return Err(bad(c, "path chunks must share their boundary point"));
}
Ok(points)
};
let points = p.get("points");
let Some(points) = p.get("points") else {
return if p.get("continuation").is_some() { Err(bad(c, "continuation requires points")) } else { Ok(None) };
};
let continuation = match p.get("continuation") {
None => &[][..],
Some(input) if points.is_some() => input.as_array().ok_or_else(|| bad(C, "continuation must be an array of path chunks"))?.as_slice(),
Some(_) => return Err(bad(C, "continuation requires points")),
Some(input) => input.as_array().ok_or_else(|| bad(c, "continuation must be an array of path chunks"))?.as_slice(),
};
let mut chunks: Vec<Vec<Point>> = Vec::with_capacity(continuation.len() + 1);
let mut last = start;
for input in std::iter::once(points).chain(continuation) {
let chunk = parse_chunk(input, last)?;
last = chunk.last().copied().unwrap_or(last);
chunks.push(chunk);
}
Ok(Some(chunks))
}
pub(super) fn lp_fill(s: &mut Session, p: &Value) -> Result<Value> {
const C: &str = "livePaint.fill";
let pt = point_param(p, "point").filter(|q| finite(*q)).ok_or_else(|| bad(C, "missing point [x,y]"))?;
let scope = scope_param(p, C)?;
let like = match_param(p, C, scope == LpScope::SamePaint, "\"samePaint\"")?;
let path = path_param(p, C, pt, scope)?;
crate::cmd::paint::check_keep_model(p, C)?;
let paint = paint_from(s, p)?.unwrap_or_else(|| s.paint.fill.clone());
let group = object_param(p, "group", C)?;
@@ -472,7 +490,7 @@ pub(super) fn lp_fill(s: &mut Session, p: &Value) -> Result<Value> {
targets.extend(b::faces(n).into_iter().filter(|f| f.visible && f.appearance.fill_paint() == like).map(|f| f.id));
}
}
if let Some(points) = points {
if let Some(chunks) = &path {
let n = d.node(gid).ok_or(EngineError::NoNode(gid))?;
// Use the existing region-crossing probes, so even a face narrower than the distance
// between pointer events is filled. Reversing matches visible_face_at's front first.
@@ -488,11 +506,8 @@ pub(super) fn lp_fill(s: &mut Session, p: &Value) -> Result<Value> {
}
}
let map = b::BuilderMap { regions, ..Default::default() };
let mut last = pt;
for input in std::iter::once(points).chain(continuation) {
let chunk = parse_chunk(input, last)?;
last = chunk.last().copied().unwrap_or(last);
targets.extend(map.hits_along(&chunk, None).regions.iter().filter_map(|i| face_ids.get(*i).copied()));
for chunk in chunks {
targets.extend(map.hits_along(chunk, None).regions.iter().filter_map(|i| face_ids.get(*i).copied()));
}
}
Ok((fid, targets))
@@ -567,6 +582,7 @@ pub(super) fn lp_stroke_edge(s: &mut Session, p: &Value) -> Result<Value> {
let tol = number_or(p, "tolerance", 4.0, C)?.clamp(0.0, 1000.0);
let scope = scope_param(p, C)?;
let like = match_param(p, C, scope != LpScope::One, "\"connected\" or \"samePaint\"")?;
let path = path_param(p, C, pt, scope)?;
let through: Vec<NodeId> = match p.get("through") {
None => vec![],
Some(_) if scope != LpScope::Connected => return Err(bad(C, "through applies to scope \"connected\"")),
@@ -590,7 +606,18 @@ pub(super) fn lp_stroke_edge(s: &mut Session, p: &Value) -> Result<Value> {
let eid = start.id;
let like = like.unwrap_or_else(|| b::lp_stroke_paint(start));
let targets = match scope {
LpScope::One => vec![eid],
// A drag also reaches every edge of the group that is not hidden and that its path
// crosses or touches.
LpScope::One => std::iter::once(eid)
.chain(
path.as_deref()
.map(|chunks| b::visible_edges_along(n, chunks))
.unwrap_or_default()
.into_iter()
.map(|e| e.id)
.filter(|id| *id != eid),
)
.collect(),
LpScope::Connected => b::connected_edges_through(n, eid, &like, &through),
LpScope::SamePaint => std::iter::once(eid)
.chain(b::edges(n).into_iter().filter(|e| e.visible && e.id != eid && b::lp_stroke_paint(e) == like).map(|e| e.id))
+131
View File
@@ -5198,6 +5198,137 @@ fn live_paint_bucket_drag_rejects_invalid_points_atomically() {
}
}
/// The edge of `g` through (`x`, 25), halfway up the squares of [`live_squares`].
fn vertical_edge(s: &Session, g: NodeId, x: f64) -> NodeId {
vectorcraft_tools::builder::edge_near(&node(s, g), Point::new(x, 25.0), 0.5).map(|e| e.id).unwrap_or_else(|| panic!("an edge at x {x}"))
}
/// A Shift-drag from an edge strokes every visible edge of that group the drag crosses, between
/// pointer events and on the release too, as one undo step that Escape cancels; hidden edges and
/// another group's edges keep their strokes.
#[test]
fn live_paint_bucket_drag_strokes_crossed_edges_as_one_undo() {
for cancel in [false, true] {
let mut s = session();
let g = live_squares(&mut s, &[0.0, 50.0, 100.0, 150.0, 200.0]);
let other = live_squares(&mut s, &[300.0]);
let black = Paint::solid(Color::rgb(0.0, 0.0, 0.0));
let green = Paint::solid(Color::from_hex("#00ff00").unwrap());
let all: Vec<NodeId> = [g, other].iter().flat_map(|g| edges_in(&s, *g, Rect::new(-1.0, -1.0, 351.0, 51.0))).collect();
paint_parts(&mut s, &all, &black, &[]);
let hidden = vertical_edge(&s, g, 100.0);
s.edit("t", |d, _| {
d.node_mut(hidden).unwrap().visible = false;
Ok(())
})
.unwrap();
let before = s.doc().unwrap().doc.clone();
let depth = s.doc().unwrap().history.undo.len();
let v = ViewInfo::default();
s.select_tool("livePaintBucket", v).unwrap();
s.paint.stroke = green.clone();
s.paint.stroke_width = 3.0;
let shift = Mods { shift: true, ..Default::default() };
s.pointer(&PointerEvent::new(PointerKind::Down, 50.0, 25.0).with_mods(shift), v).unwrap();
// Past the hidden edge and the edge at 150, then back across it, between pointer events.
s.pointer(&PointerEvent::new(PointerKind::Drag, 160.0, 25.0).with_mods(shift), v).unwrap();
s.pointer(&PointerEvent::new(PointerKind::Drag, 140.0, 30.0).with_mods(shift), v).unwrap();
if cancel {
assert!(s.tool_busy());
s.tool_key(ToolKey::Escape, Mods::default(), v).unwrap();
assert!(!s.tool_busy());
}
// The release crosses the edges at 200 and 250 and goes on into the other group.
s.pointer(&PointerEvent::new(PointerKind::Up, 325.0, 25.0).with_mods(shift), v).unwrap();
if cancel {
assert!(s.doc().unwrap().doc == before, "Escape cancels the whole drag");
assert_eq!(s.doc().unwrap().history.undo.len(), depth);
continue;
}
let stroke = |s: &Session, id: NodeId| {
let n = node(s, id);
(n.appearance.stroke_paint(), n.appearance.stroke().map(|st| st.width))
};
for x in [50.0, 150.0, 200.0, 250.0] {
assert_eq!(stroke(&s, vertical_edge(&s, g, x)), (green.clone(), Some(3.0)), "edge at {x}");
}
for (group, x) in [(g, 0.0), (g, 100.0), (other, 300.0), (other, 350.0)] {
assert_eq!(stroke(&s, vertical_edge(&s, group, x)), (black.clone(), Some(1.0)), "edge at {x}");
}
for e in edges_in(&s, g, Rect::new(-1.0, -1.0, 201.0, 1.0)) {
assert_eq!(stroke(&s, e).0, black, "a top edge is not crossed");
}
assert_eq!(s.doc().unwrap().history.undo.len(), depth + 1, "one undo step");
s.execute("edit.undo", &json!({})).unwrap();
assert!(s.doc().unwrap().doc == before, "one Undo restores every edge");
}
}
/// A stroke drag over edges that already have the stroke records no undo step and keeps the redo
/// steps.
#[test]
fn live_paint_bucket_stroke_drag_no_op_keeps_history() {
let mut s = session();
let g = live_squares(&mut s, &[0.0, 50.0]);
let green = Paint::solid(Color::from_hex("#00ff00").unwrap());
let all = edges_in(&s, g, Rect::new(-1.0, -1.0, 101.0, 51.0));
paint_parts(&mut s, &all, &green, &[]);
paint_parts(&mut s, &all, &green, &[]);
s.execute("edit.undo", &json!({})).unwrap();
let before = s.doc().unwrap().doc.clone();
let (undo, redo) = (s.doc().unwrap().history.undo.len(), s.doc().unwrap().history.redo.len());
assert_eq!(redo, 1);
let v = ViewInfo::default();
s.select_tool("livePaintBucket", v).unwrap();
s.paint.stroke = green;
s.paint.stroke_width = 1.0;
let shift = Mods { shift: true, ..Default::default() };
s.pointer(&PointerEvent::new(PointerKind::Down, 0.0, 25.0).with_mods(shift), v).unwrap();
s.pointer(&PointerEvent::new(PointerKind::Drag, 60.0, 25.0).with_mods(shift), v).unwrap();
s.pointer(&PointerEvent::new(PointerKind::Up, 110.0, 25.0).with_mods(shift), v).unwrap();
assert!(s.doc().unwrap().doc == before);
assert_eq!((s.doc().unwrap().history.undo.len(), s.doc().unwrap().history.redo.len()), (undo, redo));
}
/// `livePaint.strokeEdge` with `points` paints the crossed edges, counting the edge at the point;
/// a malformed path or a scope other than "one" with `points` is an error that changes nothing.
#[test]
fn live_paint_stroke_drag_rejects_invalid_points_atomically() {
let mut s = session();
let g = live_squares(&mut s, &[0.0, 50.0, 100.0]);
let before = s.doc().unwrap().doc.clone();
let stroke = |s: &mut Session, extra: Value| {
let mut p = json!({"group": g.0, "point": [50.0, 25.0], "color": "#00ff00"});
for (k, v) in extra.as_object().unwrap() {
p[k] = v.clone();
}
s.execute("livePaint.strokeEdge", &p)
};
for points in
[json!([]), json!([[51.0, 25.0]]), json!([[50.0, 25.0], [null, 0]]), json!([[50.0, 25.0], [1e30, 0]]), json!(vec![[50.0, 25.0]; 4097])]
{
assert!(stroke(&mut s, json!({ "points": points })).is_err(), "{points}");
assert_eq!(s.doc().unwrap().doc, before);
}
for continuation in [json!(null), json!([[[51.0, 25.0], [125.0, 25.0]]]), json!([vec![[50.0, 25.0]; 4097]])] {
assert!(stroke(&mut s, json!({ "points": [[50.0, 25.0]], "continuation": continuation })).is_err(), "{continuation}");
assert_eq!(s.doc().unwrap().doc, before);
}
assert!(stroke(&mut s, json!({ "continuation": [[[50.0, 25.0]]] })).is_err());
for scope in ["connected", "samePaint"] {
assert!(stroke(&mut s, json!({ "points": [[50.0, 25.0], [125.0, 25.0]], "scope": scope })).is_err(), "{scope}");
}
assert_eq!(s.doc().unwrap().doc, before);
// A path in two chunks reaches the edges at 50, 100 and 150, not the one at 0.
let r = stroke(&mut s, json!({ "points": [[50.0, 25.0], [90.0, 25.0]], "continuation": [[[90.0, 25.0], [160.0, 25.0]]] })).unwrap();
assert_eq!(r["count"], 3);
let green = Paint::solid(Color::from_hex("#00ff00").unwrap());
for x in [50.0, 100.0, 150.0] {
assert_eq!(node(&s, vertical_edge(&s, g, x)).appearance.stroke_paint(), green, "edge at {x}");
}
assert_ne!(node(&s, vertical_edge(&s, g, 0.0)).appearance.stroke_paint(), green);
}
#[test]
fn live_paint_bucket_tool_fills_face() {
let mut s = session();
+1 -1
View File
@@ -44,7 +44,7 @@ pub use lookup::{
EDGE_NAME, FACE_NAME, Face, LIVE_PAINT_NAME, LIVE_PAINT_PREFIX, LP_JOIN_TOL, SOURCES_NAME, builder_members, connected_edges,
connected_edges_through, drawn_outlines, edge_near, edges, face_at, faces, flood_faces, is_live_paint, leaf_shapes, live_paint_at,
live_paint_takes, lp_stroke_paint, node_outline, outline_snap, path_contains, shape_builder_shapes, shapes_for, sources, visible_edge_near,
visible_face_at,
visible_edges_along, visible_face_at,
};
pub use map::{
BuilderMap, HATCH, HIGHLIGHT_RED, Hit, MergeGeometry, MergeInput, PreparedMerge, Rest, Touched, hatch, maps_built, merge_geometry, merge_inputs,
+48 -40
View File
@@ -1,7 +1,7 @@
use super::cache::RegionCache;
use super::lookup::{
connected_edges, connected_edges_through, edges, face_at, faces, flood_faces, is_live_paint, leaf_shapes, live_paint_at, live_paint_at_where,
lp_stroke_paint, node_outline, visible_edge_near, visible_face_at,
lp_stroke_paint, node_outline, visible_edge_near, visible_edges_along, visible_face_at,
};
use super::map::{BuilderMap, HIGHLIGHT_RED, sorted_roots};
use super::{
@@ -173,9 +173,12 @@ enum LpPaint {
/// With Paint Strokes alone on, a click paints the edge nearest the pointer and
/// Shift-click fills the face. With both on, a click paints the edge nearest the pointer when one
/// is within 4 pixels, else it fills the face, and Shift-click fills the face. With both off, a
/// click paints nothing. With Highlight off, the face or edge under the pointer is not
/// highlighted. The cursor is a filled bucket where a click fills a face, a brush where it paints
/// an edge and an empty bucket where it paints nothing; with Alt it is the Eyedropper.
/// click paints nothing. A drag from where a click paints an edge paints that edge and every edge
/// of the same group that the drag crosses or touches with the current stroke, as one undo step
/// (Escape cancels); a drag from where a click fills a face fills only faces. With Highlight off,
/// the face or edge under the pointer is not highlighted. The cursor is a filled bucket where a
/// click fills a face, a brush where it paints an edge and an empty bucket where it paints nothing;
/// with Alt it is the Eyedropper.
///
/// A double-click on a face fills it and the faces reached from it across edges that draw no
/// stroke (`scope: "connected"`); on an edge it paints the edges joined to it that have its stroke.
@@ -195,16 +198,17 @@ enum LpPaint {
/// Swatches panel, wrapping around; from a color that is no swatch, Right picks the first swatch
/// and Left the last. The selected art keeps its paint. With `cursorSwatchPreview` (on), the
/// active paint shows as a chip above the pointer between the swatches before and after it,
/// except during a fill drag or with Alt held; a solid color that is no swatch shows alone, and a
/// except during a fill or stroke drag or with Alt held; a solid color that is no swatch shows alone, and a
/// paint that is not a solid color shows no chip.
pub struct LivePaintBucketTool {
pub(super) cache: RegionCache,
pub(super) hover: LpHover,
/// Where the pointer last moved, and the modifiers held there.
at: Option<(Point, Mods)>,
/// The fill command and polyline previewed from the press's snapshot.
fill_drag: Option<(Value, Vec<Vec<Point>>)>,
/// What a fill drag paints, as it was at its press.
/// The command (`livePaint.fill` or `livePaint.strokeEdge`), its params and the polyline of a
/// drag, previewed from the press's snapshot.
fill_drag: Option<(&'static str, Value, Vec<Vec<Point>>)>,
/// What a drag paints, as it was at its press.
drag_from: LpDragFrom,
/// The last [`LP_PRESSES`] presses, oldest first: the face or edge each one painted, with its
/// paint before that press, or None for a press that painted no face or edge.
@@ -234,15 +238,15 @@ struct LpPress {
/// The other faces or edges the double-click that followed the press reached, each with its
/// fill or drawn stroke paint before the double-click.
also: Vec<(NodeId, Paint)>,
/// The other faces the press's drag crossed, its release included, each with its fill before
/// the press.
/// The other faces or edges the press's drag crossed, its release included, each with its fill
/// or drawn stroke paint before the press.
dragged: Vec<(NodeId, Paint)>,
/// For a press that makes the Live Paint group: what the group is made from, with the path
/// chunks of the press's drag, its release included.
dragged_made: Option<Arc<(LpMade, Vec<Vec<Point>>)>>,
}
/// What a Live Paint Bucket fill drag paints, as it was at the press.
/// What a Live Paint Bucket fill or stroke drag paints, as it was at the press.
#[derive(Default)]
enum LpDragFrom {
#[default]
@@ -251,6 +255,8 @@ enum LpDragFrom {
Faces(Vec<Arc<Node>>),
/// What the group is made from, for a drag that makes the group.
Made(LpMade),
/// The Live Paint group whose edges a stroke drag paints.
Edges(Arc<Node>),
}
/// The faces among `faces` (a Live Paint group's faces, back to front) that a drag along the path
@@ -404,13 +410,15 @@ impl LivePaintBucketTool {
usize::from(!cx.fill_active)
}
fn begin_fill(&mut self, params: Value, p: Point) -> Vec<Action> {
self.fill_drag = Some((params.clone(), vec![vec![p]]));
vec![Action::Begin("Live Paint Bucket".into()), Action::Preview("livePaint.fill".into(), params)]
/// Start a drag pressed at `p` that previews `cmd` with `params` and the drag's path.
fn begin_fill(&mut self, cmd: &'static str, params: Value, p: Point) -> Vec<Action> {
self.fill_drag = Some((cmd, params.clone(), vec![vec![p]]));
vec![Action::Begin("Live Paint Bucket".into()), Action::Preview(cmd.into(), params)]
}
fn drag_fill(&mut self, p: Point) -> Vec<Action> {
let Some((params, chunks)) = &mut self.fill_drag else { return vec![] };
let Some((cmd, params, chunks)) = &mut self.fill_drag else { return vec![] };
let cmd = *cmd;
let Some(points) = chunks.last_mut() else { return vec![] };
let Some(&last) = points.last() else { return vec![] };
if last == p {
@@ -431,7 +439,7 @@ impl LivePaintBucketTool {
if !continuation.is_empty() {
params["continuation"] = Value::Array(continuation);
}
vec![Action::Preview("livePaint.fill".into(), params)]
vec![Action::Preview(cmd.into(), params)]
}
/// What a click paints, Shift held or not. Shift switches Paint Fills alone to Paint Strokes
@@ -459,13 +467,13 @@ impl LivePaintBucketTool {
self.note_press(Some(LpPress { part: Some(n.id), at, before, also: vec![], dragged: vec![], dragged_made: None }));
}
/// End the fill drag, noting on the last press the other faces its drag crossed, with their
/// fills before the press (for a press that makes the group, what the group is made from and
/// the drag, for [`Self::before`] to look the faces up in the group made). → whether a fill
/// drag was on.
/// End the drag, noting on the last press the other faces or edges its drag crossed, with their
/// fills or drawn stroke paints before the press (for a press that makes the group, what the
/// group is made from and the drag, for [`Self::before`] to look the faces up in the group
/// made). → whether a drag was on.
fn end_fill(&mut self) -> bool {
let from = std::mem::take(&mut self.drag_from);
let Some((_, chunks)) = self.fill_drag.take() else { return false };
let Some((_, _, chunks)) = self.fill_drag.take() else { return false };
let Some(Some(last)) = self.presses.last_mut() else { return true };
match from {
LpDragFrom::None => {}
@@ -474,6 +482,11 @@ impl LivePaintBucketTool {
last.dragged = crossed_faces(&faces, &chunks).into_iter().filter(|(id, _)| part != Some(*id)).collect();
}
LpDragFrom::Made(made) => last.dragged_made = Some(Arc::new((made, chunks))),
LpDragFrom::Edges(group) => {
let part = last.part;
last.dragged =
visible_edges_along(&group, &chunks).into_iter().filter(|e| part != Some(e.id)).map(|e| (e.id, lp_stroke_paint(e))).collect();
}
}
true
}
@@ -549,22 +562,16 @@ impl LivePaintBucketTool {
if clicks == 2
&& let Some(group) = cx.doc.node(g)
{
// The other edge of this group either click painted joins as the stroke paint it
// had before. A face either click filled is not an edge and does not join.
// The other edges of this group either click painted, by its press or its drag, join
// as the stroke paint they had before. A face either click filled is not an edge and
// does not join. `livePaint.strokeEdge` takes at most 4096 of them.
let group_edges: std::collections::HashSet<NodeId> = edges(group).iter().map(|x| x.id).collect();
let mut seen = std::collections::HashSet::from([e.id]);
let mut through: Vec<NodeId> = vec![];
for id in self
.presses
.len()
.checked_sub(2)
.and_then(|i| self.presses.get(i..))
.into_iter()
.flatten()
.flatten()
.filter(|q| q.before == like)
.filter_map(|q| q.part)
{
if id != e.id && group_edges.contains(&id) && !through.contains(&id) {
for id in self.presses.len().checked_sub(2).and_then(|i| self.presses.get(i..)).into_iter().flatten().flatten().flat_map(|q| {
q.part.filter(|_| q.before == like).into_iter().chain(q.dragged.iter().filter(|(_, before)| *before == like).map(|(id, _)| *id))
}) {
if through.len() < 4096 && group_edges.contains(&id) && seen.insert(id) {
through.push(id);
}
}
@@ -718,7 +725,8 @@ impl Tool for LivePaintBucketTool {
&& let Some((g, Some(e))) = lp_part_at(cx.doc, p, cx.tol(4.0), true, &|id| lp_visible(cx, id))
{
self.note_part(e, true, p);
return vec![Action::Exec("livePaint.strokeEdge".into(), json!({ "group": g.0, "point": point, "tolerance": cx.tol(4.0) }))];
self.drag_from = cx.doc.node(g).map_or(LpDragFrom::None, |n| LpDragFrom::Edges(Arc::new(n.clone())));
return self.begin_fill("livePaint.strokeEdge", json!({ "group": g.0, "point": point, "tolerance": cx.tol(4.0) }), p);
}
if !matches!(paint, LpPaint::Fills | LpPaint::Both) {
self.note_press(None);
@@ -730,7 +738,7 @@ impl Tool for LivePaintBucketTool {
None => self.note_press(None),
}
self.drag_from = LpDragFrom::Faces(cx.doc.node(g).map(|n| faces(n).into_iter().cloned().collect()).unwrap_or_default());
return self.begin_fill(json!({ "group": g.0, "point": point }), p);
return self.begin_fill("livePaint.fill", json!({ "group": g.0, "point": point }), p);
}
if self.cache.at(cx, p).is_some() {
let roots = sorted_roots(cx.doc, &cx.selection.objects);
@@ -738,7 +746,7 @@ impl Tool for LivePaintBucketTool {
let before = made_face_fill(&made, p);
self.note_press(Some(LpPress { part: None, at: p, before, also: vec![], dragged: vec![], dragged_made: None }));
self.drag_from = LpDragFrom::Made(made);
return self.begin_fill(json!({ "ids": json_ids(&roots), "point": point }), p);
return self.begin_fill("livePaint.fill", json!({ "ids": json_ids(&roots), "point": point }), p);
}
self.note_press(None);
vec![]
@@ -762,7 +770,7 @@ impl Tool for LivePaintBucketTool {
self.presses.clear();
}
/// Escape during a fill drag cancels it. Left and Right pick the color swatch before or after
/// Escape during a fill or stroke drag cancels it. Left and Right pick the color swatch before or after
/// the active paint, while no drag is on.
fn key(&mut self, cx: &ToolContext, key: ToolKey, mods: Mods) -> Vec<Action> {
if key == ToolKey::Escape {
@@ -819,7 +827,7 @@ impl Tool for LivePaintBucketTool {
fn overlays(&self, cx: &ToolContext) -> Vec<Overlay> {
let mut out = lp_overlays(&self.hover, &self.cache, self.color, self.width as f32, (self.width * LP_BUCKET_EDGE_FRACTION) as f32);
// No chips during a fill drag, or while Alt makes the tool sample with the eyedropper.
// No chips during a fill or stroke drag, or while Alt makes the tool sample with the eyedropper.
if self.preview
&& !self.busy()
&& let Some((at, mods)) = self.at
+58
View File
@@ -90,6 +90,64 @@ pub fn visible_edge_near(group: &Node, p: Point, tol: f64) -> Option<&Arc<Node>>
nearest_edge(edges(group).into_iter().filter(|e| e.visible), p, tol)
}
/// The edges of `group` that are not hidden and that the polyline through the points of each chunk
/// of `chunks` crosses or comes within [`LP_JOIN_TOL`] of, each once, in the group's order. Each
/// stretch of the polyline tests only the edge segments whose bounds lie near it.
pub fn visible_edges_along<'a>(group: &'a Node, chunks: &[Vec<Point>]) -> Vec<&'a Arc<Node>> {
use kurbo::ParamCurveNearest as _;
let shown: Vec<&Arc<Node>> = edges(group).into_iter().filter(|e| e.visible).collect();
// Each edge segment, with the index in `shown` of its edge.
let mut owner: Vec<usize> = vec![];
let mut segs: Vec<(kurbo::CubicBez, bool)> = vec![];
for (i, e) in shown.iter().enumerate() {
for s in e.path_data().map(lp_segments).unwrap_or_default() {
owner.push(i);
segs.push((s, true));
}
}
if segs.is_empty() {
return vec![];
}
let grid = LpEdgeGrid::new(&segs);
let close = LP_JOIN_TOL * LP_JOIN_TOL;
let mut hit = vec![false; shown.len()];
for chunk in chunks {
for pair in chunk.windows(2) {
let &[a, b] = pair else { continue };
let line = kurbo::Line::new(a, b);
let on_line = |p: Point| line.nearest(p, 1e-9).distance_sq <= close;
for k in grid.near_box(Rect::from_points(a, b).inflate(LP_JOIN_TOL, LP_JOIN_TOL)) {
let (Some((c, _)), Some(&i)) = (segs.get(k), owner.get(k)) else { continue };
let Some(h) = hit.get_mut(i) else { continue };
if *h {
continue;
}
let on_seg = |p: Point| c.nearest(p, 1e-9).distance_sq <= close;
// An end of either one on the other covers a touch and a stretch that runs along
// the edge, where no single crossing point exists. Where neither crosses the other,
// their closest points are ends or a point of the edge where it runs parallel to
// the drag.
*h = on_seg(a)
|| on_seg(b)
|| on_line(c.p0)
|| on_line(c.p3)
|| (a != b
&& (!kurbo::PathSeg::Cubic(*c).intersect_line(line).is_empty()
|| lp_parallel_at(c, b - a).into_iter().any(|t| on_line(kurbo::ParamCurve::eval(c, t)))));
}
}
}
shown.into_iter().zip(hit).filter_map(|(e, h)| h.then_some(e)).collect()
}
/// The parameters strictly between 0 and 1 where cubic `c` runs parallel to direction `d`: the
/// roots of the cross product of its derivative with `d`.
fn lp_parallel_at(c: &kurbo::CubicBez, d: kurbo::Vec2) -> Vec<f64> {
let [a, b, e] = [c.p1 - c.p0, c.p2 - c.p1, c.p3 - c.p2].map(|v| v.cross(d));
// a(1-t)² + 2b·t(1-t) + e·t², expanded in powers of t.
kurbo::common::solve_quadratic(a, 2.0 * (b - a), a - 2.0 * b + e).into_iter().filter(|t| t.is_finite() && *t > 0.0 && *t < 1.0).collect()
}
/// The edge of `edges` nearest to `p` within `tol`.
fn nearest_edge<'a>(edges: impl IntoIterator<Item = &'a Arc<Node>>, p: Point, tol: f64) -> Option<&'a Arc<Node>> {
let mut best: Option<(f64, &Arc<Node>)> = None;
+160 -6
View File
@@ -1120,8 +1120,147 @@ fn bucket_click_fills_face_and_shift_click_strokes_edge() {
assert_eq!(t.pointer(&cx, &ev(PointerKind::Up, 75.0, 25.0)), vec![Action::Commit]);
let shift = Mods { shift: true, ..Default::default() };
let acts = t.pointer(&cx, &ev(PointerKind::Down, 51.0, 25.0).with_mods(shift));
let Action::Exec(id, _) = &acts[0] else { panic!() };
let [Action::Begin(_), Action::Preview(id, _)] = acts.as_slice() else { panic!("{acts:?}") };
assert_eq!(id, "livePaint.strokeEdge");
assert_eq!(t.pointer(&cx, &ev(PointerKind::Up, 51.0, 25.0).with_mods(shift)), vec![Action::Commit]);
}
/// A drag reaches the visible edges its path crosses or passes within 0.0001 pt of, including the
/// middle of a curved edge it runs past without crossing; a hidden edge and an edge farther away are
/// not reached.
#[test]
fn visible_edges_along_finds_crossed_and_near_edges() {
let mut d = Document::new(500.0, 500.0);
let l = d.layers[0].id;
let mut arc = BezPath::new();
arc.move_to((100.0, 0.0));
// Farthest right at (130, 50), where it runs straight down.
arc.curve_to((140.0, 0.0), (140.0, 100.0), (100.0, 100.0));
let mut kids = vec![empty_sources(&mut d)];
let mut ids = vec![];
for (path, visible) in [
(shapes::line(Point::new(0.0, 0.0), Point::new(0.0, 100.0)), true),
(shapes::line(Point::new(50.0, 0.0), Point::new(50.0, 100.0)), false),
(vectorcraft_geom::PathData::from_bezpath(&arc), true),
(shapes::line(Point::new(0.0, 200.0), Point::new(100.0, 200.0)), true),
] {
let id = d.alloc_id();
let mut edge = Node::path(id, path, Appearance::default());
edge.name = Some(EDGE_NAME.into());
edge.visible = visible;
kids.push(Arc::new(edge));
ids.push(id);
}
let gid = d.alloc_id();
let mut g = Node::group(gid, kids);
g.name = Some(LIVE_PAINT_NAME.into());
d.insert(Some(l), 0, g).unwrap();
let group = d.node(gid).unwrap();
let reached = |x: f64| {
let chunks = vec![
vec![Point::new(-10.0, 50.0), Point::new(60.0, 50.0), Point::new(60.0, -20.0)],
vec![Point::new(60.0, -20.0), Point::new(x, -20.0), Point::new(x, 60.0)],
];
visible_edges_along(group, &chunks).iter().map(|e| e.id).collect::<Vec<_>>()
};
assert_eq!(reached(130.00005), vec![ids[0], ids[2]]);
assert_eq!(reached(130.001), vec![ids[0]]);
}
/// A double-click on an edge after a press whose drag stroked another edge of the line joins
/// through that edge as the stroke paint it had before the drag.
#[test]
fn bucket_edge_double_click_joins_through_an_edge_the_first_drag_stroked() {
let black = vectorcraft_color::Paint::solid(vectorcraft_color::Color::rgb(0.0, 0.0, 0.0));
let green = vectorcraft_color::Paint::solid(vectorcraft_color::Color::rgb(0.0, 1.0, 0.0));
let mut d = Document::new(500.0, 500.0);
let l = d.layers[0].id;
let mut kids = vec![empty_sources(&mut d)];
let mut ids = vec![];
for (x0, x1) in [(0.0, 30.0), (30.0, 70.0), (70.0, 100.0)] {
let id = d.alloc_id();
let mut a = Appearance::default();
a.set_stroke(black.clone());
let mut edge = Node::path(id, shapes::line(Point::new(x0, 100.0), Point::new(x1, 100.0)), a);
edge.name = Some(EDGE_NAME.into());
kids.push(Arc::new(edge));
ids.push(id);
}
let gid = d.alloc_id();
let mut g = Node::group(gid, kids);
g.name = Some(LIVE_PAINT_NAME.into());
d.insert(Some(l), 0, g).unwrap();
let mut later = d.clone();
for id in &ids[1..] {
later.node_mut(*id).unwrap().appearance.set_stroke(green.clone());
}
let s = Selection::default();
let p = paint();
let (cx, later) = (cx(&d, &s, &p), cx(&later, &s, &p));
let shift = Mods { shift: true, ..Default::default() };
let mut t = LivePaintBucketTool::default();
// The first press strokes the right edge and its drag crosses the middle one.
for (k, x, y) in
[(PointerKind::Down, 85.0, 100.0), (PointerKind::Drag, 85.0, 110.0), (PointerKind::Drag, 50.0, 110.0), (PointerKind::Up, 50.0, 90.0)]
{
t.pointer(&cx, &ev(k, x, y).with_mods(shift));
}
t.pointer(&later, &ev(PointerKind::Down, 85.0, 100.0).with_mods(shift));
t.pointer(&later, &ev(PointerKind::Up, 85.0, 100.0).with_mods(shift));
let like = serde_json::to_value(&black).unwrap();
assert_eq!(
t.pointer(&later, &ev(PointerKind::DoubleClick, 85.0, 100.0).with_mods(shift)),
vec![Action::Exec(
"livePaint.strokeEdge".into(),
json!({ "group": gid.0, "point": [85.0, 100.0], "tolerance": 4.0, "scope": "connected", "through": [ids[1].0], "match": like })
)]
);
}
/// A drag from an edge previews `livePaint.strokeEdge` with the drag's path as it goes and commits
/// once on the release; Escape cancels it, and what the drag paints is fixed at the press.
#[test]
fn bucket_edge_drag_previews_points_and_commits_once() {
let (d, gid, ..) = live_group_doc();
let s = Selection::default();
let p = paint();
let cx = cx(&d, &s, &p);
let shift = Mods { shift: true, ..Default::default() };
let stroke = |points: Value| {
let mut v = json!({ "group": gid.0, "point": [51.0, 25.0], "tolerance": 4.0 });
if !points.is_null() {
v["points"] = points;
}
Action::Preview("livePaint.strokeEdge".into(), v)
};
let mut t = LivePaintBucketTool::default();
assert_eq!(
t.pointer(&cx, &ev(PointerKind::Down, 51.0, 25.0).with_mods(shift)),
vec![Action::Begin("Live Paint Bucket".into()), stroke(Value::Null)]
);
assert!(t.busy());
// Shift let go during the drag: the drag still paints edges.
assert_eq!(t.pointer(&cx, &ev(PointerKind::Drag, 75.0, 25.0)), vec![stroke(json!([[51.0, 25.0], [75.0, 25.0]]))]);
assert_eq!(t.pointer(&cx, &ev(PointerKind::Up, 120.0, 25.0)), vec![stroke(json!([[51.0, 25.0], [75.0, 25.0], [120.0, 25.0]])), Action::Commit]);
assert!(!t.busy());
// Escape before the release cancels the drag, and the release then commits nothing.
assert_eq!(
t.pointer(&cx, &ev(PointerKind::Down, 51.0, 25.0).with_mods(shift)),
vec![Action::Begin("Live Paint Bucket".into()), stroke(Value::Null)]
);
t.pointer(&cx, &ev(PointerKind::Drag, 75.0, 25.0).with_mods(shift));
assert!(t.claims_key(&cx, ToolKey::Escape));
assert_eq!(t.key(&cx, ToolKey::Escape, Mods::default()), vec![Action::Cancel]);
assert!(t.pointer(&cx, &ev(PointerKind::Up, 120.0, 25.0).with_mods(shift)).is_empty());
// With both options on, a drag from a face fills faces, even across an edge.
t.set_option("paintStrokes", &json!(true));
let acts = t.pointer(&cx, &ev(PointerKind::Down, 75.0, 25.0));
let [Action::Begin(_), Action::Preview(id, _)] = acts.as_slice() else { panic!("{acts:?}") };
assert_eq!(id, "livePaint.fill");
let acts = t.pointer(&cx, &ev(PointerKind::Drag, 51.0, 25.0));
let [Action::Preview(id, _)] = acts.as_slice() else { panic!("{acts:?}") };
assert_eq!(id, "livePaint.fill");
t.pointer(&cx, &ev(PointerKind::Up, 51.0, 25.0));
}
/// A double-click runs a click's command with `scope: "connected"` and a triple-click with
@@ -1484,7 +1623,12 @@ fn bucket_options_choose_what_a_click_paints() {
let fill = |x: f64| {
vec![Action::Begin("Live Paint Bucket".into()), Action::Preview("livePaint.fill".into(), json!({ "group": gid.0, "point": [x, 25.0] }))]
};
let stroke = |x: f64| vec![Action::Exec("livePaint.strokeEdge".into(), json!({ "group": gid.0, "point": [x, 25.0], "tolerance": 4.0 }))];
let stroke = |x: f64| {
vec![
Action::Begin("Live Paint Bucket".into()),
Action::Preview("livePaint.strokeEdge".into(), json!({ "group": gid.0, "point": [x, 25.0], "tolerance": 4.0 })),
]
};
let click = |t: &mut LivePaintBucketTool, x: f64, m: Mods| {
let acts = t.pointer(&cx, &ev(PointerKind::Down, x, 25.0).with_mods(m));
t.pointer(&cx, &ev(PointerKind::Up, x, 25.0).with_mods(m));
@@ -3095,8 +3239,13 @@ fn live_paint_edges_outside_the_faces_come_from_the_nearest_visible_group() {
bucket.set_option("cursorSwatchPreview", &json!(false));
bucket.pointer(&cx, &ev(PointerKind::Move, x, y).with_mods(shift));
assert_eq!(edge_x(&bucket.overlays(&cx)), want.map(|w| w.2));
let stroked = want.map(|(g, ..)| Action::Exec("livePaint.strokeEdge".into(), json!({ "group": g.0, "point": [x, y], "tolerance": 4.0 })));
assert_eq!(bucket.pointer(&cx, &ev(PointerKind::Down, x, y).with_mods(shift)), stroked.into_iter().collect::<Vec<_>>());
let stroked = want.map(|(g, ..)| {
vec![
Action::Begin("Live Paint Bucket".into()),
Action::Preview("livePaint.strokeEdge".into(), json!({ "group": g.0, "point": [x, y], "tolerance": 4.0 })),
]
});
assert_eq!(bucket.pointer(&cx, &ev(PointerKind::Down, x, y).with_mods(shift)), stroked.unwrap_or_default());
};
check(&d, Some((back, back_right, 100.0)));
// A hidden group's edges are not highlighted or picked.
@@ -3139,8 +3288,13 @@ fn live_paint_tools_skip_hidden_edges() {
bucket.set_option("cursorSwatchPreview", &json!(false));
bucket.pointer(&cx, &ev(PointerKind::Move, x, 50.0).with_mods(shift));
assert_eq!(edge_x(&bucket.overlays(&cx)), want.map(|w| w.2), "x {x}");
let stroked = want.map(|(g, ..)| Action::Exec("livePaint.strokeEdge".into(), json!({ "group": g.0, "point": [x, 50.0], "tolerance": 4.0 })));
assert_eq!(bucket.pointer(&cx, &ev(PointerKind::Down, x, 50.0).with_mods(shift)), stroked.into_iter().collect::<Vec<_>>(), "x {x}");
let stroked = want.map(|(g, ..)| {
vec![
Action::Begin("Live Paint Bucket".into()),
Action::Preview("livePaint.strokeEdge".into(), json!({ "group": g.0, "point": [x, 50.0], "tolerance": 4.0 })),
]
});
assert_eq!(bucket.pointer(&cx, &ev(PointerKind::Down, x, 50.0).with_mods(shift)), stroked.unwrap_or_default(), "x {x}");
}
}
+12 -6
View File
@@ -4092,8 +4092,12 @@ already walks Image Trace. Short agent entry points:
With `paintStrokes` alone on, a click runs `livePaint.strokeEdge` on the edge within 4 screen pixels of the pointer,
or nothing when none is in reach, and Shift-click runs `livePaint.fill`. With both on, a click runs
`livePaint.strokeEdge` when an edge is within 4 screen pixels of the pointer and `livePaint.fill` otherwise, and
Shift-click runs `livePaint.fill`. With both off, a click runs nothing. With `highlight` off, the face or edge under
the pointer is not outlined.
Shift-click runs `livePaint.fill`. With both off, a click runs nothing. A drag from a press that runs
`livePaint.strokeEdge` previews it with the drag's path in `points` (and `continuation` past 4096 points), so the edge
and every edge of the same group that the drag crosses or comes within 0.0001 pt of take the stroke, hidden edges and
other groups' edges skipped; the release keeps it as one undo step and Escape before the release cancels it. A drag
from a press that fills a face fills only faces. With `highlight` off, the face or edge under the pointer is not
outlined.
A double-click runs the command a click there runs with `scope: "connected"`, and a triple-click with
`scope: "samePaint"`; Alt held runs nothing, and so does Cmd/Ctrl (`mods.cmd`), whose presses go to the selection
tool Cmd lends. With Space held (`mods.space`, the view tools), a press, a
@@ -4125,9 +4129,10 @@ already walks Image Trace. Short agent entry points:
defaults to the face's fill or the stroke paint the edge draws with. `livePaint.strokeEdge {scope: "connected", through}`
takes `through`, at most 4096 ids of the group's edges, each given once, that the join counts as drawing with `match`
whatever they draw with now; a hidden edge among them is still skipped. The tool passes each other edge of the group
that either of the double-click's two clicks painted and that drew with `match` before that click. `through` with
that either of the double-click's two clicks painted, by its press or its drag, and that drew with `match` before
that click. `through` with
another scope, or one that is not an array of the group's edge ids or names an edge twice, is an error and changes
nothing. `livePaint.fill` refuses a `scope` other than `"one"` with `points`. Both replies add `count`, the number of
nothing. `livePaint.fill` and `livePaint.strokeEdge` refuse a `scope` other than `"one"` with `points`. Both replies add `count`, the number of
faces or edges the click reaches, including those that already had the paint.
With the Live Paint Bucket selected and no drag in progress, Left and Right without Shift, Alt or Cmd/Ctrl (which
keep their shortcuts) run `paint.setFill {swatch, ids: []}` (or
@@ -4135,7 +4140,7 @@ already walks Image Trace. Short agent entry points:
Swatches panel, wrapping around at the ends; from a color that is no swatch, Right picks the first swatch and Left
the last, and with no color swatch the tool does not take the keys. The selected art keeps its paint. With
`cursorSwatchPreview` on, the active paint shows as a ringed chip above the pointer between the swatches before and
after it, except during a fill drag or with Alt held; a solid color that is no swatch shows alone, and a paint that is not a solid color shows no chip. Left and
after it, except during a fill or stroke drag or with Alt held; a solid color that is no swatch shows alone, and a paint that is not a solid color shows no chip. Left and
Right step the swatches with `cursorSwatchPreview` off too.
`livePaint.merge` keeps the bottom Live Paint group's id, name, lock, visibility, transparency, appearance, opacity
mask and graphic style link. With a Live Paint group among the objects, `livePaint.make` adds the others to it as
@@ -4145,7 +4150,8 @@ already walks Image Trace. Short agent entry points:
objects; otherwise it returns an error and does not merge the objects.
A Live Paint command that changes nothing records no undo step, keeps the redo steps, leaves a saved document saved
and replies as usual: `livePaint.fill` (a click, or a Bucket drag) when every face it reaches already has one fill, shown,
fully opaque, blending normally and with the paint (or no fill, for none), `livePaint.strokeEdge` when every edge it
fully opaque, blending normally and with the paint (or no fill, for none), `livePaint.strokeEdge` (a click, or a
Bucket drag from an edge) when every edge it
reaches already has one such stroke with the paint and the width (at any width for none, or no stroke),
`livePaint.gapOptions` (and the Gap Options
dialog's OK) when every group already has the options and `closeGaps` finds no gap, and `livePaint.make` or
+15
View File
@@ -2624,6 +2624,21 @@ Edit › Copy and Cut put the selected ruler guides on the clipboard, with the s
`live_paint_bucket_drag_rejects_invalid_points_atomically` covers invalid command input.
Behaviour source: [Paint with the Live Paint Bucket tool](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/paint-with-the-live-paint-bucket-tool.html).
Scores and estimates unchanged.
- **Live Paint Bucket stroke drag:** starting on an edge (Shift with Paint Fills alone, or a
plain press with Paint Strokes on), a drag paints with the current stroke that edge and every
visible edge of the same group it crosses or touches, including edges between pointer events;
edges of other groups and hidden edges keep their strokes. The gesture is one Undo step, Escape
cancels it, and a drag over edges that already have the stroke records no undo step. A drag
that starts on a face still fills only faces. `livePaint.strokeEdge` takes the drag's `points`
and `continuation` as `livePaint.fill` does. Regression evidence:
`live_paint_bucket_drag_strokes_crossed_edges_as_one_undo`,
`live_paint_bucket_stroke_drag_no_op_keeps_history`,
`live_paint_stroke_drag_rejects_invalid_points_atomically` and the tool's
`bucket_edge_drag_previews_points_and_commits_once`,
`visible_edges_along_finds_crossed_and_near_edges` and
`bucket_edge_double_click_joins_through_an_edge_the_first_drag_stroked`. The help page describes dragging across
edges to stroke several at once: [Paint with the Live Paint Bucket tool](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/paint-with-the-live-paint-bucket-tool.html);
how a drag finds the edges it crosses is VectorCraft's own rule. Scores and estimates unchanged.
- **Live Paint Bucket cursors:** over a face a click fills (of a Live Paint group, or a region of
the selected paths) the cursor is a filled paint bucket, over an edge it paints it is a brush,
and where a click paints nothing it is an empty bucket. It follows Paint Fills, Paint Strokes