mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 15:48:23 +00:00
Fill Area: in isolation mode only the isolated group's paths bound areas
With a group or layer isolated, the tool's hover and click and shapeBuilder.copyRegion take only the paths inside it, and the new path goes inside it, directly above the object in it that holds the front-most path along the area. Before, a click on art outside the isolated group added a path there. No area is found while the isolated object is a path or compound path, a group that makes, moves or combines its own art (Live Paint, compound shapes, Shaper groups, graphs, Image Trace results, dimensions, flares, Objects on Path), a layer or group with a live effect, a clipping mask, or an object inside one of these or inside an envelope. An isolated object that no longer exists counts as no isolation, for the tool as for the command.
This commit is contained in:
@@ -73,7 +73,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Fill Area",
|
||||
[],
|
||||
None,
|
||||
"{point: [x,y], ids?|id?: [id…] (the objects or layers whose paths bound areas; default: every layer, nothing needs to be selected), gap?: pt (0–72; 0: Gap Detection off; out of range is an error), openFilledAsClosed?: true (as shapeBuilder.merge), fill?, stroke?: \"#rrggbb\" | {color|swatch|gradient|none} (default: the current fill and stroke, with the current stroke weight)} add a new closed path of the area under point that the visible, unlocked paths enclose (the region of shapeBuilder.regions holding it: areas a shape already fills and areas open paths bound count too), directly above the front-most object along the area (its outline touches the area's outline, or it covers the area; when a group, Live Paint group, Shaper group or clipping group holds that path, above the outermost group in its layer, never inside it), and select it; the paths around the area are not changed; a point in no enclosed area is an error and changes nothing (no undo step); when the paths together have more than 65,536 segments, only an area the paths near the point enclose is found → {id, above (the object the new path went above)}",
|
||||
"{point: [x,y], ids?|id?: [id…] (the objects or layers whose paths bound areas; default: every layer, nothing needs to be selected), gap?: pt (0–72; 0: Gap Detection off; out of range is an error), openFilledAsClosed?: true (as shapeBuilder.merge), fill?, stroke?: \"#rrggbb\" | {color|swatch|gradient|none} (default: the current fill and stroke, with the current stroke weight)} add a new closed path of the area under point that the visible, unlocked paths enclose (the region of shapeBuilder.regions holding it: areas a shape already fills and areas open paths bound count too), directly above the front-most object along the area (its outline touches the area's outline, or it covers the area; when a group, Live Paint group, Shaper group or clipping group holds that path, above the outermost group in its layer, never inside it), and select it; in isolation mode only the paths of the isolated layer or group bound areas (with ids, only the paths of the listed objects that are in it), and the new path goes inside it, directly above the object in it that holds that path; no area is found while the isolated object is not a layer or group (a path or compound path), is a Live Paint group, compound shape, Shaper group, graph, Image Trace result, dimension, flare or Objects on Path group, is a layer or group with a live effect or a clipping mask, or lies inside one of these or inside an envelope; the paths around the area are not changed; a point in no enclosed area is an error and changes nothing (no undo step); when the paths together have more than 65,536 segments, only an area the paths near the point enclose is found → {id, above (the object the new path went above)}",
|
||||
has_doc,
|
||||
sb_copy_region
|
||||
),
|
||||
|
||||
@@ -195,18 +195,22 @@ pub(super) fn sb_copy_region(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let stroke = paint_param(s, p, "stroke", C)?.unwrap_or_else(|| s.paint.stroke.clone());
|
||||
let look = s.new_art_look(fill, stroke, s.paint.stroke_width);
|
||||
let area = {
|
||||
let d = &s.doc()?.doc;
|
||||
let roots = match named_ids(p)? {
|
||||
let st = s.doc()?;
|
||||
let d = &st.doc;
|
||||
let named = match named_ids(p)? {
|
||||
Some(ids) => {
|
||||
if let Some(bad_id) = ids.iter().find(|i| d.node(**i).is_none()) {
|
||||
return Err(EngineError::NoNode(*bad_id));
|
||||
}
|
||||
// An object listed with a layer or group that holds it counts once.
|
||||
outermost(d, ids)
|
||||
Some(outermost(d, ids))
|
||||
}
|
||||
None => b::every_layer(d),
|
||||
None => None,
|
||||
};
|
||||
b::AreaFinder::new(d, &roots, gap, open_filled_as_closed).find(pt)
|
||||
// In isolation mode only the isolated layer or group's paths bound areas, and the new path
|
||||
// goes inside it.
|
||||
b::fill_area_roots(d, st.isolation, named.as_deref())
|
||||
.and_then(|(roots, scope)| b::AreaFinder::new(d, &roots, scope, gap, open_filled_as_closed).find(pt))
|
||||
};
|
||||
let Some(area) = area else { return Err(EngineError::Other("Fill Area: no enclosed area under the pointer".into())) };
|
||||
let id = s.edit("Fill Area", |d, sel| {
|
||||
|
||||
Reference in New Issue
Block a user