mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-20 17:37:10 +01:00
Merge pull request #8765 from dotCooCoo/fix/live-paint-group-review-gaps
Live Paint: the Eyedropper, overprint, proxies and contents edits follow the whole-group rule
This commit is contained in:
10 files changed
+610
-59
No files matched your search
@@ -29,6 +29,7 @@ use vectorcraft_color::{BlendMode, Paint};
|
||||
use vectorcraft_doc::appearance::SharedStack;
|
||||
use vectorcraft_doc::{Appearance, AppearanceItem, CharStyle, Document, FillLayer, Node, NodeKind, ParaStyle, StrokeLayer};
|
||||
use vectorcraft_geom::Rect;
|
||||
use vectorcraft_tools::builder::{edges, faces, is_live_paint};
|
||||
|
||||
use super::edit::{outermost, roots_of, selected_roots};
|
||||
use super::opacitymask::percent;
|
||||
@@ -48,7 +49,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Add New Fill",
|
||||
["Window", "Appearance"],
|
||||
Some("Cmd+/"),
|
||||
"{ids?|id?, target?: \"object\"|\"contents\"} add a fill on top of each selected object's own stack, on an image right below its Contents row, with its top fill's paint (type without one: its characters' fill; else the default fill). With a fill row active (appearance.setActiveItem), no `ids`, no `id` and no `target: \"contents\"`, the new fill takes that row's paint, goes right above it, and becomes the active row; appearance.duplicateItem copies a whole row. On a path directly in a graph series (a series group's id stands for those paths), the graph also stores the paint, weight, opacity and blend mode of the topmost visible fill and stroke (exceptions, and the art of a graph design in a series, which is left out: docs/mcp.md); on a graph label, or a graph's axis line, tick mark or radar ring (a graph's Axes group stands for the lines and labels directly in it, its Legend group for the labels), the graph stores that object's topmost visible fill and stroke rows and object opacity and blend mode for every label or line of its kind (of a line, what the edit changes, and the row it adds when that row becomes the line's topmost visible row of its kind)",
|
||||
"{ids?|id?, target?: \"object\"|\"contents\"} add a fill on top of each selected object's own stack, on an image right below its Contents row, with its top fill's paint (type without one: its characters' fill; else the default fill). In the contents of a Live Paint group the fill goes on its faces only, and its hidden source paths, like every contents edit, are left as they are. With a fill row active (appearance.setActiveItem), no `ids`, no `id` and no `target: \"contents\"`, the new fill takes that row's paint, goes right above it, and becomes the active row; appearance.duplicateItem copies a whole row. On a path directly in a graph series (a series group's id stands for those paths), the graph also stores the paint, weight, opacity and blend mode of the topmost visible fill and stroke (exceptions, and the art of a graph design in a series, which is left out: docs/mcp.md); on a graph label, or a graph's axis line, tick mark or radar ring (a graph's Axes group stands for the lines and labels directly in it, its Legend group for the labels), the graph stores that object's topmost visible fill and stroke rows and object opacity and blend mode for every label or line of its kind (of a line, what the edit changes, and the row it adds when that row becomes the line's topmost visible row of its kind)",
|
||||
has_doc,
|
||||
|s, p| add_item(s, p, true)
|
||||
),
|
||||
@@ -57,7 +58,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Add New Stroke",
|
||||
["Window", "Appearance"],
|
||||
Some("Cmd+Alt+/"),
|
||||
"{ids?|id?, target?} add a stroke on top of each selected object's own stack, on an image right below its Contents row, with its top stroke's paint (else the default stroke) and that stroke's weight when it has paint, at least 1 pt. On a path directly in a graph series (a series group's id stands for those paths), the graph also stores the paint, weight, opacity and blend mode of the topmost visible fill and stroke (exceptions, and the art of a graph design in a series, which is left out: docs/mcp.md); on a graph label, or a graph's axis line, tick mark or radar ring (a graph's Axes group stands for the lines and labels directly in it, its Legend group for the labels), the graph stores that object's topmost visible fill and stroke rows and object opacity and blend mode for every label or line of its kind (of a line, what the edit changes, and the row it adds when that row becomes the line's topmost visible row of its kind)",
|
||||
"{ids?|id?, target?} add a stroke on top of each selected object's own stack, on an image right below its Contents row, with its top stroke's paint (else the default stroke) and that stroke's weight when it has paint, at least 1 pt. In the contents of a Live Paint group the stroke goes on its edges only, and its hidden source paths are left as they are. On a path directly in a graph series (a series group's id stands for those paths), the graph also stores the paint, weight, opacity and blend mode of the topmost visible fill and stroke (exceptions, and the art of a graph design in a series, which is left out: docs/mcp.md); on a graph label, or a graph's axis line, tick mark or radar ring (a graph's Axes group stands for the lines and labels directly in it, its Legend group for the labels), the graph stores that object's topmost visible fill and stroke rows and object opacity and blend mode for every label or line of its kind (of a line, what the edit changes, and the row it adds when that row becomes the line's topmost visible row of its kind)",
|
||||
has_doc,
|
||||
|s, p| add_item(s, p, false)
|
||||
),
|
||||
@@ -129,7 +130,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Eyedropper",
|
||||
[],
|
||||
None,
|
||||
"{source: id, ids?, pickUp?, apply? (trees as eyedropper.setOptions, merged over the Eyedropper Options for this call), reverse?: bool, append?: bool, defaultsOnly?: bool} copy the attributes both picked up and applied (by default the whole appearance stack, opacity and blend mode, and from type to type the character and paragraph attributes using effective character dimensions while preserving target transforms) from `source` to ids (default: highlighted characters while editing type, after Select All in a frame of threaded text the text of the story's frames, leaving out `source`, otherwise the object selection; highlighted characters reject enabled non-neutral object transparency), the fill, stroke and weight also to the paint defaults; `defaultsOnly` updates only paint defaults and cannot be combined with ids, reverse or append; `reverse` (Alt-click) copies from the first selected object (or ids) onto `source` instead, or with nothing selected what the Eyedropper picked up last (a click without Alt); `append` (Shift+Alt-click) adds the source's fills, strokes and effects on top of each target's stack; placed gradients land at the same place relative to each target's bounds (defaults: fitted to new art); with an object of a dynamic symbol instance selected by Direct Selection and no ids, reverse, append or defaultsOnly, that object takes the source's fill and stroke (solid, none, gradient or pattern) for this instance only, as the Eyedropper Options allow, and a source that is not a path, compound path or type, or options that pick up neither color, are refused. On a path directly in a graph series, the graph also stores the paint, weight, opacity and blend mode of the topmost visible fill and stroke and the object's opacity and blend mode (exceptions, and the art of a graph design in a series, which is left out: docs/mcp.md); on a graph label, the graph stores, for every label of its kind, the character attributes the pick gives all of its text, its object opacity and blend mode when transparency is applied, and with `append` its topmost visible fill and stroke rows of the kinds it adds; on a graph's axis line, tick mark or radar ring, its topmost visible fill and stroke rows, and when transparency is applied its object opacity and blend mode, for every line of its kind (a pick of some attributes without `append`: what it changes, and the paint, stroke weight and row transparency it applies to the topmost visible rows; with `append`: only the kinds of row it adds) → {ids}",
|
||||
"{source: id, ids?, pickUp?, apply? (trees as eyedropper.setOptions, merged over the Eyedropper Options for this call), reverse?: bool, append?: bool, defaultsOnly?: bool} copy the attributes both picked up and applied (by default the whole appearance stack, opacity and blend mode, and from type to type the character and paragraph attributes using effective character dimensions while preserving target transforms) from `source` to ids (default: highlighted characters while editing type, after Select All in a frame of threaded text the text of the story's frames, leaving out `source`, otherwise the object selection; highlighted characters reject enabled non-neutral object transparency), the fill, stroke and weight also to the paint defaults; `defaultsOnly` updates only paint defaults and cannot be combined with ids, reverse or append; `reverse` (Alt-click) copies from the first selected object (or ids) onto `source` instead, or with nothing selected what the Eyedropper picked up last (a click without Alt); `append` (Shift+Alt-click) adds the source's fills, strokes and effects on top of each target's stack; a whole Live Paint group (selected, in ids, or `source` with `reverse`) takes the fill attributes on its faces and the stroke attributes on its edges (a whole-appearance pick: every fill row on each face and every stroke row on each edge, which keep their rows of the other kind and their effects; `append` adds the source's rows but not its object effects to them), and its hidden source paths keep their paint; a whole Live Paint group picked up (`source`, or selected first with `reverse`) gives its first face's fills with its first edge's strokes above them and the group's own opacity, blend mode and effects; placed gradients land at the same place relative to each target's bounds (defaults: fitted to new art); with an object of a dynamic symbol instance selected by Direct Selection and no ids, reverse, append or defaultsOnly, that object takes the source's fill and stroke (solid, none, gradient or pattern) for this instance only, as the Eyedropper Options allow, and a source that is not a path, compound path or type, or options that pick up neither color, are refused. On a path directly in a graph series, the graph also stores the paint, weight, opacity and blend mode of the topmost visible fill and stroke and the object's opacity and blend mode (exceptions, and the art of a graph design in a series, which is left out: docs/mcp.md); on a graph label, the graph stores, for every label of its kind, the character attributes the pick gives all of its text, its object opacity and blend mode when transparency is applied, and with `append` its topmost visible fill and stroke rows of the kinds it adds; on a graph's axis line, tick mark or radar ring, its topmost visible fill and stroke rows, and when transparency is applied its object opacity and blend mode, for every line of its kind (a pick of some attributes without `append`: what it changes, and the paint, stroke weight and row transparency it applies to the topmost visible rows; with `append`: only the kinds of row it adds) → {ids}",
|
||||
has_doc,
|
||||
copy_from
|
||||
),
|
||||
@@ -280,7 +281,8 @@ impl ItemTarget {
|
||||
|
||||
/// [`ItemTarget::targets`] of a fill (`fill`) or a stroke edit: on the topmost fill or stroke, a
|
||||
/// Live Paint group stands for its faces in a fill edit and for its edges in a stroke edit
|
||||
/// ([`super::paint::live_paint_parts_skipped`]).
|
||||
/// ([`super::paint::live_paint_parts_skipped`]); an item edit with `target: "contents"` leaves out
|
||||
/// the parts of the other kind the same way ([`contents_skipped`]).
|
||||
pub(crate) fn targets_for(self, s: &Session, p: &Value, fill: bool) -> Result<Vec<NodeId>> {
|
||||
Ok(self.targets_and_skipped(s, p, fill)?.0)
|
||||
}
|
||||
@@ -290,13 +292,16 @@ impl ItemTarget {
|
||||
/// to new art.
|
||||
pub(crate) fn targets_and_skipped(self, s: &Session, p: &Value, fill: bool) -> Result<(Vec<NodeId>, bool)> {
|
||||
let mut ids = self.targets(s, p)?;
|
||||
let mut skipped_any = false;
|
||||
if self == ItemTarget::Top {
|
||||
let skipped = super::paint::live_paint_parts_skipped(&s.doc()?.doc, &super::targets(s, p)?, fill);
|
||||
let before = ids.len();
|
||||
ids.retain(|id| !skipped.contains(id));
|
||||
skipped_any = ids.len() != before;
|
||||
}
|
||||
// An item edit of the contents of a Live Paint group goes to its parts of the edited kind too.
|
||||
let skipped = if self == ItemTarget::Top {
|
||||
super::paint::live_paint_parts_skipped(&s.doc()?.doc, &super::targets(s, p)?, fill)
|
||||
} else {
|
||||
contents_skipped(s, p, fill)?
|
||||
};
|
||||
let before = ids.len();
|
||||
ids.retain(|id| !skipped.contains(id));
|
||||
// A contents edit already leaves hidden source paths out of `ids`, so `skipped` is checked on its own too.
|
||||
let skipped_any = ids.len() != before || !skipped.is_empty();
|
||||
Ok((ids, skipped_any))
|
||||
}
|
||||
|
||||
@@ -491,15 +496,37 @@ pub(crate) fn subject_roots(s: &Session) -> Result<Vec<NodeId>> {
|
||||
|
||||
/// Objects whose own appearance stack a command edits: `ids`/`id` (layers too; an id inside
|
||||
/// another given one is dropped), else the [`subject_roots`]; with `target: "contents"` the painted
|
||||
/// objects inside the groups and layers among them ([`leaf_targets`]).
|
||||
/// objects inside the groups and layers among them ([`leaf_targets`]), without the hidden source paths
|
||||
/// of Live Paint groups.
|
||||
pub(crate) fn appearance_targets(s: &Session, p: &Value) -> Result<Vec<NodeId>> {
|
||||
let roots = if p.get("ids").is_none() && p.get("id").is_none() {
|
||||
subject_roots(s)?
|
||||
let roots = appearance_roots(s, p)?;
|
||||
if !targets_contents(p)? {
|
||||
return Ok(roots);
|
||||
}
|
||||
let (_, _, hidden) = super::paint::live_paint_split(&s.doc()?.doc, &roots);
|
||||
let mut ids = leaf_targets(s, &roots)?;
|
||||
ids.retain(|id| !hidden.contains(id));
|
||||
Ok(ids)
|
||||
}
|
||||
|
||||
/// The objects [`appearance_targets`] starts from: `ids`/`id`, else the [`subject_roots`].
|
||||
fn appearance_roots(s: &Session, p: &Value) -> Result<Vec<NodeId>> {
|
||||
if p.get("ids").is_none() && p.get("id").is_none() {
|
||||
subject_roots(s)
|
||||
} else {
|
||||
let d = &s.doc()?.doc;
|
||||
outermost(d, targets(s, p)?.into_iter().filter(|id| d.node(*id).is_some()).collect())
|
||||
};
|
||||
if targets_contents(p)? { leaf_targets(s, &roots) } else { Ok(roots) }
|
||||
Ok(outermost(d, targets(s, p)?.into_iter().filter(|id| d.node(*id).is_some()).collect()))
|
||||
}
|
||||
}
|
||||
|
||||
/// The parts of the Live Paint groups whose contents `p` targets (`target: "contents"`) that a fill
|
||||
/// (`fill`) or stroke edit of those contents leaves as they are: their edges or faces. Empty without
|
||||
/// `target: "contents"`.
|
||||
pub(crate) fn contents_skipped(s: &Session, p: &Value, fill: bool) -> Result<HashSet<NodeId>> {
|
||||
if !targets_contents(p)? {
|
||||
return Ok(HashSet::new());
|
||||
}
|
||||
Ok(super::paint::live_paint_parts_skipped(&s.doc()?.doc, &appearance_roots(s, p)?, fill))
|
||||
}
|
||||
|
||||
/// The refusal of an appearance edit whose targets are all the art of graph designs drawn in graph series.
|
||||
@@ -897,7 +924,26 @@ fn set_active_item(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
|
||||
fn add_item(s: &mut Session, p: &Value, fill: bool) -> Result<Value> {
|
||||
let ids = require_targets(s, p, if fill { "appearance.addFill" } else { "appearance.addStroke" })?;
|
||||
let cmd = if fill { "appearance.addFill" } else { "appearance.addStroke" };
|
||||
let mut ids = row_targets(s, p, cmd)?;
|
||||
if ids.is_empty() {
|
||||
// A selected Live Paint group left with only its hidden source paths has nothing to edit: it is
|
||||
// still a selection, so the edit changes nothing.
|
||||
let roots = appearance_roots(s, p)?;
|
||||
if targets_contents(p)? && !roots.is_empty() && !super::paint::live_paint_split(&s.doc()?.doc, &roots).2.is_empty() {
|
||||
return ok();
|
||||
}
|
||||
return Err(bad(cmd, "select objects or give ids"));
|
||||
}
|
||||
// In the contents of a Live Paint group, a new fill goes on its faces and a new stroke on its edges;
|
||||
// with no part of that kind, nothing changes.
|
||||
let skipped = contents_skipped(s, p, fill)?;
|
||||
if !skipped.is_empty() {
|
||||
ids.retain(|id| !skipped.contains(id));
|
||||
if ids.is_empty() {
|
||||
return ok();
|
||||
}
|
||||
}
|
||||
let defaults = s.paint.clone();
|
||||
// The panel's active Fill row, when the new fill goes on the selection: the new fill takes that
|
||||
// row's paint, right above it in each target that has it (others take their top fill's paint).
|
||||
@@ -1779,7 +1825,23 @@ fn copy_from(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
// Reversed, the first selected object's attributes go onto the clicked object; with nothing
|
||||
// selected, what the Eyedropper picked up last does (#4382).
|
||||
let (source, mut targets) = if reverse {
|
||||
let source = match leaf_targets(s, &selected)?.into_iter().next() {
|
||||
// The selected objects are tried in order: a Live Paint group with a look is picked up as a whole
|
||||
// ([`live_paint_look`]), any other object gives its first painted leaf, and a group with nothing to pick
|
||||
// up (its hidden source paths are not what it draws) passes to the next object.
|
||||
let d = &s.doc()?.doc;
|
||||
let mut first = None;
|
||||
for root in &selected {
|
||||
if d.node(*root).and_then(live_paint_look).is_some() {
|
||||
first = Some(*root);
|
||||
break;
|
||||
}
|
||||
let (_, _, hidden) = super::paint::live_paint_split(d, &[*root]);
|
||||
if let Some(leaf) = leaf_targets(s, &[*root])?.into_iter().find(|id| !hidden.contains(id)) {
|
||||
first = Some(leaf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
let source = match first {
|
||||
Some(first) => Some(first),
|
||||
None if s.eyedropper_sample.is_some() => None,
|
||||
None => return Err(bad(C, "select the object to copy from")),
|
||||
@@ -1788,10 +1850,45 @@ fn copy_from(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
} else {
|
||||
(Some(clicked), leaf_targets(s, &selected)?)
|
||||
};
|
||||
targets.retain(|id| Some(*id) != source);
|
||||
// A whole Live Paint group takes the fill attributes on its faces and the stroke attributes on its edges, and its
|
||||
// hidden source paths keep their paint.
|
||||
let roots = if reverse { vec![clicked] } else { selected };
|
||||
let (faces, edges, hidden) = super::paint::live_paint_split(&s.doc()?.doc, &roots);
|
||||
// Some(true) for a face, Some(false) for an edge.
|
||||
let part_of = |id: &NodeId| {
|
||||
if faces.contains(id) {
|
||||
Some(true)
|
||||
} else if edges.contains(id) {
|
||||
Some(false)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
let attrs_for = |id: &NodeId| {
|
||||
let mut a = attrs;
|
||||
match part_of(id) {
|
||||
Some(true) => a.appearance.stroke = StrokeAttrs::NONE,
|
||||
Some(false) => a.appearance.fill = FillAttrs::NONE,
|
||||
None => {}
|
||||
}
|
||||
a
|
||||
};
|
||||
// A pick of the whole appearance gives a face every fill row and an edge every stroke row.
|
||||
let whole = attrs.appearance.fill == FillAttrs::ALL && attrs.appearance.stroke == StrokeAttrs::ALL;
|
||||
// A source that is a Live Paint group is not one of its own targets: neither are its faces and edges.
|
||||
let mut inside_source = HashSet::new();
|
||||
if let Some(n) = source.and_then(|id| s.doc().ok()?.doc.node(id)).filter(|n| is_live_paint(n)) {
|
||||
n.walk(&mut |c| {
|
||||
inside_source.insert(c.id);
|
||||
});
|
||||
}
|
||||
targets.retain(|id| Some(*id) != source && !hidden.contains(id) && !inside_source.contains(id));
|
||||
let mut targets = without_design_art(&s.doc()?.doc, targets, C)?;
|
||||
let node = match source {
|
||||
Some(id) => Arc::new(s.doc()?.doc.node(id).ok_or(EngineError::NoNode(id))?.clone()),
|
||||
Some(id) => {
|
||||
let n = s.doc()?.doc.node(id).ok_or(EngineError::NoNode(id))?;
|
||||
Arc::new(live_paint_look(n).unwrap_or_else(|| n.clone()))
|
||||
}
|
||||
None => s.eyedropper_sample.clone().ok_or_else(|| bad(C, "select the object to copy from"))?,
|
||||
};
|
||||
let picked = Picked::of(&node);
|
||||
@@ -1919,7 +2016,17 @@ fn copy_from(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
super::overprint::edit_counted(s, "Eyedropper", |d| {
|
||||
for id in &targets {
|
||||
if let Some(n) = d.node_mut(*id) {
|
||||
picked.apply(n, &attrs, append, characters.get(id));
|
||||
match part_of(id) {
|
||||
Some(fill) if whole && !append => picked.apply_rows(n, &attrs, fill),
|
||||
// `append` does not add the picked object effects to a face or edge, as a whole pick keeps the part's
|
||||
// own; a row's effects go with the row.
|
||||
Some(_) => {
|
||||
let effects = n.appearance.effects.len();
|
||||
picked.apply(n, &attrs_for(id), append, characters.get(id));
|
||||
n.appearance.effects.truncate(effects);
|
||||
}
|
||||
None => picked.apply(n, &attrs_for(id), append, characters.get(id)),
|
||||
}
|
||||
}
|
||||
}
|
||||
check_text_bounds(d)?;
|
||||
@@ -2170,6 +2277,52 @@ impl Picked {
|
||||
}
|
||||
super::object::snap_if_aligned(n);
|
||||
}
|
||||
|
||||
/// A whole pick ([`Self::apply`] with every fill and stroke attribute) onto a Live Paint face
|
||||
/// (`fill`) or edge: the face's fills (the edge's strokes) become the picked ones, and its rows of
|
||||
/// the other kind and its effects stay as they are.
|
||||
fn apply_rows(&self, n: &mut Node, a: &EyedropperAttrs, fill: bool) {
|
||||
if a.appearance.transparency {
|
||||
n.opacity = self.opacity;
|
||||
n.blend = self.blend;
|
||||
}
|
||||
let taken: Vec<AppearanceItem> = self.placed(n.geometric_bounds()).items.into_iter().filter(|it| it.is_fill() == fill).collect();
|
||||
// The picked rows go where the part's first row of that kind was, the other rows keep their order; without
|
||||
// such a row, fills go to the bottom and strokes to the top.
|
||||
let items = &n.appearance.items;
|
||||
let at = items.iter().position(|it| it.is_fill() == fill);
|
||||
let at = at.map_or(if fill { 0 } else { items.iter().filter(|it| it.is_fill() != fill).count() }, |i| {
|
||||
items.iter().take(i).filter(|it| it.is_fill() != fill).count()
|
||||
});
|
||||
let mut kept: Vec<AppearanceItem> = items.iter().filter(|it| it.is_fill() != fill).cloned().collect();
|
||||
kept.splice(at..at, taken);
|
||||
n.appearance.items = kept;
|
||||
super::object::snap_if_aligned(n);
|
||||
}
|
||||
}
|
||||
|
||||
/// What the Eyedropper picks up from a whole Live Paint group `n`: its first face (else its first edge) with that
|
||||
/// face's fills and the first edge's strokes above them, their gradients placed as on those parts, and the group's
|
||||
/// own opacity, blend mode and effects. None for any other object, and for a group with no face and no edge.
|
||||
fn live_paint_look(n: &Node) -> Option<Node> {
|
||||
if !is_live_paint(n) {
|
||||
return None;
|
||||
}
|
||||
let (face, edge) = (faces(n).first().copied(), edges(n).first().copied());
|
||||
let mut look = (**face.or(edge)?).clone();
|
||||
let rows = |part: Option<&Arc<Node>>, fill: bool| -> Vec<AppearanceItem> {
|
||||
part.map(|p| p.appearance.items.iter().filter(|it| it.is_fill() == fill).cloned().collect()).unwrap_or_default()
|
||||
};
|
||||
// The edge's stroke gradients, placed relative to the look's bounds as they are to the edge's.
|
||||
let mut strokes = Appearance { items: rows(edge, false), ..Default::default() };
|
||||
if let (Some(from), Some(to)) = (edge.and_then(|e| e.geometric_bounds()), look.geometric_bounds()) {
|
||||
strokes.rebase_gradients(from, to);
|
||||
}
|
||||
look.appearance.items = rows(face, true).into_iter().chain(strokes.items).collect();
|
||||
look.appearance.effects = n.appearance.effects.clone();
|
||||
look.opacity = n.opacity;
|
||||
look.blend = n.blend;
|
||||
Some(look)
|
||||
}
|
||||
|
||||
/// The focal (topmost) fill and stroke attributes `a` of `from` onto `to`. Taking a colour creates
|
||||
|
||||
@@ -804,7 +804,7 @@ fn set_gradient_geom(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let skipped = super::paint::live_paint_parts_skipped(&s.doc()?.doc, &roots, !stroke);
|
||||
leaf_targets(s, &roots)?.into_iter().filter(|id| !skipped.contains(id)).collect()
|
||||
}
|
||||
_ => item.targets(s, p)?,
|
||||
_ => item.targets_for(s, p, !stroke)?,
|
||||
};
|
||||
if targets.is_empty() {
|
||||
return Err(EngineError::Other("nothing selected".into()));
|
||||
|
||||
@@ -21,7 +21,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Overprint",
|
||||
[],
|
||||
None,
|
||||
"{fill?: bool, stroke?: bool, item?: appearance item index|null, ids?|id?, target?: \"object\"|\"contents\"} make fills and/or strokes overprint (Overprint Preview, Separations Preview) or knock out: item's, else every fill or stroke of the painted objects (groups: their contents; type: its characters too). Without item and ids, the Appearance panel's active item stands in when it is of that kind → {changed: objects}",
|
||||
"{fill?: bool, stroke?: bool, item?: appearance item index|null, ids?|id?, target?: \"object\"|\"contents\"} make fills and/or strokes overprint (Overprint Preview, Separations Preview) or knock out: item's, else every fill or stroke of the painted objects (groups: their contents; type: its characters too). Without item and ids, the Appearance panel's active item stands in when it is of that kind. A whole Live Paint group (also its contents with `item`) takes the fill flags on its faces and the stroke flags on its edges, and its hidden source paths keep theirs → {changed: objects}",
|
||||
has_doc,
|
||||
set_overprint
|
||||
),
|
||||
@@ -135,7 +135,7 @@ fn aims(s: &Session, p: &Value, cmd: &str, kinds: impl IntoIterator<Item = bool>
|
||||
.into_iter()
|
||||
.map(|fill| {
|
||||
let it = item.of_kind(s, fill);
|
||||
let ids = it.targets(s, p)?;
|
||||
let ids = it.targets_for(s, p, fill)?;
|
||||
let ids = if edit { super::appearance::drop_design_art_rows(s, ids, it, fill, cmd)? } else { ids };
|
||||
Ok((fill, it, ids))
|
||||
})
|
||||
|
||||
@@ -216,12 +216,15 @@ impl Session {
|
||||
}
|
||||
let first = st.doc.node(*st.selection.subjects().first()?)?;
|
||||
let item = self.appearance_item();
|
||||
// Only an active Appearance row is shown here: it is a row of the first selected object.
|
||||
if first.appearance.item_of_kind(item, !stroke).is_some() {
|
||||
return Some((Cow::Borrowed(first), item));
|
||||
}
|
||||
// A Live Paint group without faces (or edges) shows the next selected object's paint; any other
|
||||
// object without a painted object shows the defaults for new art.
|
||||
for id in st.selection.subjects() {
|
||||
// object without a painted object shows the defaults for new art. A face or edge selected with
|
||||
// its Live Paint group counts with the group, wherever it is in the selection.
|
||||
let covered = live_paint_covered(&st.doc, st.selection.subjects());
|
||||
for id in st.selection.subjects().iter().filter(|id| !covered.contains(*id)) {
|
||||
let Some(n) = st.doc.node(*id) else { continue };
|
||||
let mut nodes = vec![];
|
||||
painted(n, true, stroke, &mut nodes);
|
||||
@@ -273,14 +276,6 @@ fn same_in_proxy(a: &Paint, b: &Paint) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of the faces and edges of `n` when it is a Live Paint group, else none.
|
||||
pub(crate) fn live_paint_parts(n: &Node) -> Vec<NodeId> {
|
||||
if !is_live_paint(n) {
|
||||
return vec![];
|
||||
}
|
||||
faces(n).into_iter().chain(edges(n)).map(|part| part.id).collect()
|
||||
}
|
||||
|
||||
/// The objects whose paints the proxies show for a selected `n`, the ones the paint commands
|
||||
/// change ([`leaf_targets`]): groups and layers stand for their contents (and so do blends and
|
||||
/// other containers inside them), a compound path for its parts. A Live Paint group stands for its
|
||||
@@ -331,8 +326,9 @@ impl DocState {
|
||||
// Looking the first object up builds the id cache when there is none.
|
||||
let first = self.selection.objects.first().and_then(|id| self.doc.node(*id));
|
||||
let (mut selected, mut fills, mut strokes) = (vec![], vec![], vec![]);
|
||||
// The faces and edges of the selected Live Paint groups: selected as well, they count with their group's.
|
||||
let mut covered = std::collections::HashSet::new();
|
||||
// The faces and edges of the selected Live Paint groups (or of those inside selected groups): selected as well,
|
||||
// they count with their group's.
|
||||
let covered = live_paint_covered(&self.doc, &self.selection.objects);
|
||||
// Every node with a selected id, in tree order: a repeated id (a damaged file) counts at each
|
||||
// place it appears.
|
||||
for n in self.doc.nodes_in_order(self.selection.objects.iter().copied()) {
|
||||
@@ -342,7 +338,6 @@ impl DocState {
|
||||
if covered.contains(&n.id) {
|
||||
continue;
|
||||
}
|
||||
covered.extend(live_paint_parts(n));
|
||||
painted(n, true, false, &mut fills);
|
||||
painted(n, true, true, &mut strokes);
|
||||
}
|
||||
@@ -839,6 +834,36 @@ pub(crate) fn live_paint_parts_skipped(d: &Document, roots: &[NodeId], fill: boo
|
||||
out
|
||||
}
|
||||
|
||||
/// Faces, edges and the other objects (the hidden source paths) of Live Paint groups.
|
||||
pub(crate) type LivePaintParts = (std::collections::HashSet<NodeId>, std::collections::HashSet<NodeId>, std::collections::HashSet<NodeId>);
|
||||
|
||||
/// The faces, the edges and the hidden source paths of the Live Paint groups in `roots` (or inside them),
|
||||
/// found as [`live_paint_parts_skipped`] finds them.
|
||||
pub(crate) fn live_paint_split(d: &Document, roots: &[NodeId]) -> LivePaintParts {
|
||||
let groups = live_paint_groups(d, roots);
|
||||
let mut hidden = inside_live_paint(d, &groups);
|
||||
let (mut faces, mut edges) = (std::collections::HashSet::new(), std::collections::HashSet::new());
|
||||
for (_, f, e) in &groups {
|
||||
faces.extend(f.iter().copied());
|
||||
edges.extend(e.iter().copied());
|
||||
}
|
||||
hidden.retain(|id| !faces.contains(id) && !edges.contains(id));
|
||||
(faces, edges, hidden)
|
||||
}
|
||||
|
||||
/// The faces and edges in `selected` whose Live Paint group is selected too, itself or inside another selected
|
||||
/// object: they count with their group, wherever they are in `selected`. The groups are looked for only when an
|
||||
/// object in `selected` is inside a Live Paint group.
|
||||
pub(crate) fn live_paint_covered(d: &Document, selected: &[NodeId]) -> std::collections::HashSet<NodeId> {
|
||||
let inside = |id: &NodeId| d.ancestry(*id).is_some_and(|up| up.iter().rev().skip(1).filter_map(|a| d.node(*a)).any(is_live_paint));
|
||||
if !selected.iter().any(inside) {
|
||||
return std::collections::HashSet::new();
|
||||
}
|
||||
let (mut parts, edges, _) = live_paint_split(d, selected);
|
||||
parts.extend(edges);
|
||||
parts
|
||||
}
|
||||
|
||||
/// The instance whose object is selected with Direct Selection, and that object's path
|
||||
/// ([`super::brushsym::selected_part`]), when `p` names no `ids`, `id` or `item`: the paint commands
|
||||
/// then change that object. A bad `target` or `aligned` is refused as it is for any other selection.
|
||||
@@ -1356,7 +1381,7 @@ fn proxy_recolor(s: &mut Session, p: &Value, cmd: &str, label: &str, f: &dyn Fn(
|
||||
let item = item_target(s, p, cmd)?.of_kind(s, !stroke);
|
||||
// Read before the check below, so that a bad param (such as `target` or `aligned`, or an explicit `item` the art has
|
||||
// no row for) is still an error.
|
||||
let targets = super::appearance::drop_design_art_rows(s, item.targets(s, p)?, item, !stroke, cmd)?;
|
||||
let targets = super::appearance::drop_design_art_rows(s, item.targets_for(s, p, !stroke)?, item, !stroke, cmd)?;
|
||||
let of = match item {
|
||||
ItemTarget::Item { .. } => super::appearance::reference_of(s, p, item, cmd)?,
|
||||
ItemTarget::Top => None,
|
||||
|
||||
@@ -11,7 +11,7 @@ use vectorcraft_color::{Color, Paint};
|
||||
use vectorcraft_doc::{Appearance, Document, LayerColor, Node, NodeId, NodeKind};
|
||||
use vectorcraft_geom::{Rect, shapes};
|
||||
|
||||
use super::{live_paint_parts, painted, picked_colors, proxy_paint, same_in_proxy};
|
||||
use super::{live_paint_covered, painted, picked_colors, proxy_paint, same_in_proxy};
|
||||
use crate::{DocState, Session};
|
||||
|
||||
thread_local! {
|
||||
@@ -39,12 +39,11 @@ fn walked(st: &DocState, item: Option<usize>, points: &[(NodeId, Vec<usize>)]) -
|
||||
}
|
||||
let ids: HashSet<NodeId> = st.selection.objects.iter().copied().collect();
|
||||
let (mut selected, mut fills, mut strokes) = (vec![], vec![], vec![]);
|
||||
let mut covered = HashSet::new();
|
||||
let covered = live_paint_covered(&st.doc, &st.selection.objects);
|
||||
st.doc.walk(|n| {
|
||||
if ids.contains(&n.id) {
|
||||
selected.push(n);
|
||||
if !covered.contains(&n.id) {
|
||||
covered.extend(live_paint_parts(n));
|
||||
painted(n, true, false, &mut fills);
|
||||
painted(n, true, true, &mut strokes);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use vectorcraft_geom::PathData;
|
||||
use vectorcraft_tools::builder::is_live_paint;
|
||||
|
||||
use super::appearance::{ItemTarget, edit_items, item_target};
|
||||
use super::paint::{live_paint_parts, live_paint_parts_skipped, painted};
|
||||
use super::paint::{live_paint_covered, live_paint_parts_skipped, painted};
|
||||
use super::{CommandSpec, Result, Session, always, bad, bool_or, cmd, has_doc, ok, str_param};
|
||||
use crate::DocState;
|
||||
use crate::inspect::{ALIGNS, CAPS, JOINS, StrokeMixed, node_stroke, scale_layer};
|
||||
@@ -250,10 +250,15 @@ fn stroke_set(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
} else if item == ItemTarget::Top {
|
||||
own_stroke_or_leaves(s, p)?
|
||||
} else {
|
||||
item.targets(s, p)?
|
||||
item.targets_for(s, p, false)?
|
||||
};
|
||||
// A Live Paint group without edges was still selected or given: the options do not go to new art.
|
||||
let live_paint = !bucket && item == ItemTarget::Top && !live_paint_parts_skipped(&s.doc()?.doc, &super::targets(s, p)?, false).is_empty();
|
||||
let live_paint = !bucket
|
||||
&& if item == ItemTarget::Top {
|
||||
!live_paint_parts_skipped(&s.doc()?.doc, &super::targets(s, p)?, false).is_empty()
|
||||
} else {
|
||||
!super::appearance::contents_skipped(s, p, false)?.is_empty()
|
||||
};
|
||||
let new_art = bucket || (no_targets(&ids, p) && !live_paint);
|
||||
let given = !ids.is_empty() || live_paint;
|
||||
// The art of a graph design in a series keeps the design's stroke.
|
||||
@@ -453,12 +458,15 @@ impl Session {
|
||||
}
|
||||
let Some(first) = st.selection.objects.first() else { return Some(self.new_art_stroke()) };
|
||||
let first = st.doc.node(*first)?;
|
||||
// Only an active Appearance row is shown here: it is a row of the first selected object.
|
||||
if let Some(i) = first.appearance.item_of_kind(self.appearance_item(), false) {
|
||||
return first.appearance.stroke_at(Some(i)).cloned();
|
||||
}
|
||||
// A Live Paint group without edges shows the next selected object's stroke; any other object
|
||||
// without a painted object shows none.
|
||||
for id in &st.selection.objects {
|
||||
// without a painted object shows none. A face or edge selected with its Live Paint group counts
|
||||
// with the group, wherever it is in the selection.
|
||||
let covered = live_paint_covered(&st.doc, &st.selection.objects);
|
||||
for id in st.selection.objects.iter().filter(|id| !covered.contains(*id)) {
|
||||
let Some(n) = st.doc.node(*id) else { continue };
|
||||
let mut nodes = vec![];
|
||||
painted(n, true, true, &mut nodes);
|
||||
@@ -532,7 +540,7 @@ impl DocState {
|
||||
} else {
|
||||
let selected: Vec<&Node> = self.selection.objects.iter().filter_map(|id| self.doc.node(*id)).collect();
|
||||
// The faces and edges of the selected Live Paint groups: selected as well, they count with their group's.
|
||||
let covered: std::collections::HashSet<vectorcraft_doc::NodeId> = selected.iter().flat_map(|n| live_paint_parts(n)).collect();
|
||||
let covered = live_paint_covered(&self.doc, &self.selection.objects);
|
||||
for n in selected.into_iter().filter(|n| !covered.contains(&n.id)) {
|
||||
painted(n, true, true, &mut nodes);
|
||||
}
|
||||
|
||||
@@ -356,6 +356,7 @@ pub struct FillAttrs {
|
||||
|
||||
impl FillAttrs {
|
||||
pub const ALL: Self = Self { color: true, transparency: true, overprint: true };
|
||||
pub const NONE: Self = Self { color: false, transparency: false, overprint: false };
|
||||
}
|
||||
|
||||
impl Default for FillAttrs {
|
||||
@@ -383,6 +384,8 @@ pub struct StrokeAttrs {
|
||||
|
||||
impl StrokeAttrs {
|
||||
pub const ALL: Self = Self { color: true, transparency: true, overprint: true, weight: true, cap: true, join: true, miter: true, dash: true };
|
||||
pub const NONE: Self =
|
||||
Self { color: false, transparency: false, overprint: false, weight: false, cap: false, join: false, miter: false, dash: false };
|
||||
}
|
||||
|
||||
impl Default for StrokeAttrs {
|
||||
|
||||
@@ -4283,6 +4283,353 @@ fn live_paint_group_stroke_panel_edits_change_its_edges() {
|
||||
assert_eq!(node(&s, g).appearance.stroke().map(|st| st.width), Some(1.0));
|
||||
}
|
||||
|
||||
/// A face or edge selected before its Live Paint group counts with the group: the Fill proxy shows
|
||||
/// the faces' fill and the Stroke panel the edges' stroke, whatever the order of the selection.
|
||||
#[test]
|
||||
fn live_paint_group_proxies_do_not_depend_on_the_selection_order() {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#ff00ff"})).unwrap();
|
||||
s.execute("stroke.set", &json!({"weight": 6})).unwrap();
|
||||
let magenta = serde_json::to_value(Paint::solid(Color::from_hex("#ff00ff").unwrap())).unwrap();
|
||||
let edge = vectorcraft_tools::builder::edges(&node(&s, g))[0].id;
|
||||
s.execute("select.set", &json!({"ids": [edge.0, g.0]})).unwrap();
|
||||
assert_eq!(s.execute("paint.proxies", &json!({})).unwrap()["fill"], magenta, "an edge first shows the faces' fill");
|
||||
// A face with a stroke of its own (from a file, say), selected first, shows the edges' stroke.
|
||||
let face = vectorcraft_tools::builder::faces(&node(&s, g))[0].id;
|
||||
s.edit("t", |d, _| {
|
||||
let n = d.node_mut(face).unwrap();
|
||||
n.appearance.set_stroke(Paint::solid(Color::BLACK));
|
||||
n.appearance.stroke_at_mut(None).unwrap().width = 2.0;
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
s.execute("select.set", &json!({"ids": [face.0, g.0]})).unwrap();
|
||||
assert_eq!(s.shown_stroke().map(|st| st.width), Some(6.0), "a face first shows the edges' stroke");
|
||||
}
|
||||
|
||||
/// The Eyedropper onto a whole selected Live Paint group, or reversed onto a clicked one, gives the
|
||||
/// picked fill attributes to its faces and the picked stroke attributes to its edges; its hidden
|
||||
/// source paths keep their paint.
|
||||
#[test]
|
||||
fn live_paint_group_eyedropper_gives_the_fill_to_faces_and_the_stroke_to_edges() {
|
||||
for reverse in [false, true] {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
let src = rect(&mut s, 400.0, 0.0, 50.0, 50.0);
|
||||
s.execute("paint.setFill", &json!({"ids": [src.0], "color": "#ff00ff"})).unwrap();
|
||||
s.execute("paint.setStroke", &json!({"ids": [src.0], "color": "#0000ff"})).unwrap();
|
||||
s.execute("stroke.set", &json!({"ids": [src.0], "weight": 3})).unwrap();
|
||||
let (faces0, edges0) = part_looks(&s, g);
|
||||
let sources0 = sources_looks(&s, g);
|
||||
if reverse {
|
||||
s.execute("select.set", &json!({"ids": [src.0]})).unwrap();
|
||||
s.execute("appearance.copyFrom", &json!({"source": g.0, "reverse": true})).unwrap();
|
||||
} else {
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("appearance.copyFrom", &json!({"source": src.0})).unwrap();
|
||||
}
|
||||
let (faces1, edges1) = part_looks(&s, g);
|
||||
let magenta = Paint::solid(Color::from_hex("#ff00ff").unwrap());
|
||||
let blue = Paint::solid(Color::from_hex("#0000ff").unwrap());
|
||||
for (f, f0) in faces1.iter().zip(&faces0) {
|
||||
assert_eq!(f.fill_paint(), magenta, "reverse {reverse}: a face takes the fill");
|
||||
assert_eq!((f.stroke_paint(), f.stroke_width()), (f0.stroke_paint(), f0.stroke_width()), "reverse {reverse}: a face takes no stroke");
|
||||
}
|
||||
for (e, e0) in edges1.iter().zip(&edges0) {
|
||||
assert_eq!((e.stroke_paint(), e.stroke_width()), (blue.clone(), 3.0), "reverse {reverse}: an edge takes the stroke");
|
||||
assert_eq!(e.fill_paint(), e0.fill_paint(), "reverse {reverse}: an edge takes no fill");
|
||||
}
|
||||
assert_eq!(sources_looks(&s, g), sources0, "reverse {reverse}: the hidden source paths keep their paint");
|
||||
}
|
||||
}
|
||||
|
||||
/// A whole-appearance Eyedropper pick of a source with several fills and strokes gives each face
|
||||
/// of a selected Live Paint group every fill row and each edge every stroke row.
|
||||
#[test]
|
||||
fn live_paint_group_eyedropper_gives_every_fill_and_stroke_row() {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
let src = rect(&mut s, 400.0, 0.0, 50.0, 50.0);
|
||||
s.execute("paint.setFill", &json!({"ids": [src.0], "color": "#ff00ff"})).unwrap();
|
||||
s.execute("paint.setStroke", &json!({"ids": [src.0], "color": "#0000ff"})).unwrap();
|
||||
s.execute("appearance.addFill", &json!({"ids": [src.0]})).unwrap();
|
||||
s.execute("appearance.addStroke", &json!({"ids": [src.0]})).unwrap();
|
||||
let kinds = |a: &vectorcraft_doc::Appearance, fill: bool| a.items.iter().filter(|it| it.is_fill() == fill).count();
|
||||
let source = (*node(&s, src).appearance).clone();
|
||||
assert_eq!((kinds(&source, true), kinds(&source, false)), (2, 2));
|
||||
// A face with a stroke row below its fill keeps that row below the picked fills.
|
||||
let face = vectorcraft_tools::builder::faces(&node(&s, g))[0].id;
|
||||
s.edit("t", |d, _| {
|
||||
let n = d.node_mut(face).unwrap();
|
||||
n.appearance.items.insert(0, vectorcraft_doc::AppearanceItem::Stroke(vectorcraft_doc::StrokeLayer::new(Paint::solid(Color::BLACK), 9.0)));
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let (faces0, edges0) = part_looks(&s, g);
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("appearance.copyFrom", &json!({"source": src.0})).unwrap();
|
||||
let (faces1, edges1) = part_looks(&s, g);
|
||||
let order: Vec<bool> = faces1[0].items.iter().map(|it| it.is_fill()).collect();
|
||||
assert_eq!(order.first(), Some(&false), "the face's lower stroke row stays below its fills: {order:?}");
|
||||
for (f, f0) in faces1.iter().zip(&faces0) {
|
||||
assert_eq!(kinds(f, true), 2, "a face takes every fill row");
|
||||
assert_eq!(kinds(f, false), kinds(f0, false), "a face keeps its strokes");
|
||||
}
|
||||
for (e, e0) in edges1.iter().zip(&edges0) {
|
||||
assert_eq!(kinds(e, false), 2, "an edge takes every stroke row");
|
||||
assert_eq!(kinds(e, true), kinds(e0, true), "an edge keeps its fills");
|
||||
}
|
||||
}
|
||||
|
||||
/// The Appearance panel's edits of a Live Paint group's contents (`target: "contents"`) follow the
|
||||
/// group's rule: a new fill goes on its faces, a new stroke on its edges, and its hidden source paths
|
||||
/// keep their appearance under every contents edit.
|
||||
#[test]
|
||||
fn live_paint_group_contents_edits_follow_the_group_rule() {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
let (faces0, edges0) = part_looks(&s, g);
|
||||
let sources0 = sources_looks(&s, g);
|
||||
s.execute("appearance.addFill", &json!({"target": "contents"})).unwrap();
|
||||
let (faces1, edges1) = part_looks(&s, g);
|
||||
assert!(faces1.iter().zip(&faces0).all(|(f, f0)| f.items.len() == f0.items.len() + 1), "every face takes a new fill");
|
||||
assert_eq!(edges1, edges0, "edges take no new fill");
|
||||
s.execute("appearance.addStroke", &json!({"target": "contents"})).unwrap();
|
||||
let (faces2, edges2) = part_looks(&s, g);
|
||||
assert_eq!(faces2, faces1, "faces take no new stroke");
|
||||
assert!(edges2.iter().zip(&edges1).all(|(e, e0)| e.items.len() == e0.items.len() + 1), "every edge takes a new stroke");
|
||||
// A stroke row edit of the contents reaches the edges, not the faces.
|
||||
s.execute("stroke.set", &json!({"target": "contents", "item": 0, "weight": 7})).unwrap();
|
||||
let (faces3, edges3) = part_looks(&s, g);
|
||||
assert_eq!(faces3, faces2, "faces keep their rows");
|
||||
assert!(edges3.iter().all(|e| e.stroke_at(Some(0)).map(|st| st.width) == Some(7.0)), "every edge's stroke row takes the weight");
|
||||
s.execute("appearance.clear", &json!({"target": "contents"})).unwrap();
|
||||
assert_eq!(sources_looks(&s, g), sources0, "the hidden source paths keep their appearance");
|
||||
}
|
||||
|
||||
/// Fill edits of a Live Paint group's contents with an `item` (a gradient vector, Invert, Overprint
|
||||
/// Fill) change its faces and leave an edge's fill row as it is, and Overprint on the whole group goes
|
||||
/// to the faces' fills and the edges' strokes, leaving the hidden source paths as they are.
|
||||
#[test]
|
||||
fn live_paint_group_item_edits_and_overprint_follow_the_group_rule() {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"gradient": {}})).unwrap();
|
||||
// Each edge gets a copy of a face's gradient fill row, below its stroke.
|
||||
let n = node(&s, g);
|
||||
let face_row = vectorcraft_tools::builder::faces(&n)[0].appearance.items[0].clone();
|
||||
let edge_ids: Vec<NodeId> = vectorcraft_tools::builder::edges(&n).iter().map(|e| e.id).collect();
|
||||
let mut face_ids: Vec<u64> = vectorcraft_tools::builder::faces(&n).iter().map(|f| f.id.0).collect();
|
||||
face_ids.sort_unstable();
|
||||
s.edit("t", |d, _| {
|
||||
for e in &edge_ids {
|
||||
d.node_mut(*e).unwrap().appearance.items.insert(0, face_row.clone());
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let (faces0, edges0) = part_looks(&s, g);
|
||||
let sources0 = sources_looks(&s, g);
|
||||
let r = s.execute("paint.setGradientGeom", &json!({"stroke": false, "item": 0, "target": "contents", "start": [0, 0], "end": [100, 0]})).unwrap();
|
||||
let mut changed: Vec<u64> = r["ids"].as_array().unwrap().iter().map(|v| v.as_u64().unwrap()).collect();
|
||||
changed.sort_unstable();
|
||||
assert_eq!(changed, face_ids, "only the faces take the vector");
|
||||
assert_eq!(part_looks(&s, g).1, edges0, "an edge's fill row keeps its vector");
|
||||
let stops = |a: &vectorcraft_doc::Appearance| match a.fill_paint() {
|
||||
Paint::Gradient(gr) => gr.gradient.stops.iter().map(|st| st.color).collect::<Vec<_>>(),
|
||||
_ => vec![],
|
||||
};
|
||||
let before: Vec<_> = part_looks(&s, g).0.iter().map(stops).collect();
|
||||
s.execute("paint.invert", &json!({"stroke": false, "item": 0, "target": "contents"})).unwrap();
|
||||
for (f, b) in part_looks(&s, g).0.iter().zip(&before) {
|
||||
assert_eq!(stops(f), b.iter().rev().copied().collect::<Vec<_>>(), "the black-to-white stops of a face's fill are inverted");
|
||||
}
|
||||
assert_ne!(part_looks(&s, g).0, faces0);
|
||||
assert_eq!(part_looks(&s, g).1, edges0, "an edge's fill row is not inverted");
|
||||
s.execute("object.setOverprint", &json!({"fill": true, "item": 0, "target": "contents"})).unwrap();
|
||||
let (faces1, edges1) = part_looks(&s, g);
|
||||
assert!(faces1.iter().all(|f| f.items[0].overprint()), "the faces' fill overprints");
|
||||
assert_eq!(edges1, edges0, "an edge's fill row does not overprint");
|
||||
s.execute("object.setOverprint", &json!({"fill": true, "stroke": true})).unwrap();
|
||||
let (_, edges2) = part_looks(&s, g);
|
||||
assert!(edges2.iter().all(|e| e.items.iter().all(|it| it.overprint() != it.is_fill())), "only the edges' strokes overprint");
|
||||
assert_eq!(sources_looks(&s, g), sources0, "the hidden source paths keep their flags");
|
||||
}
|
||||
|
||||
/// A face selected before an ordinary group that holds its Live Paint group counts with that group:
|
||||
/// the Stroke panel shows the edges' stroke.
|
||||
#[test]
|
||||
fn live_paint_group_inside_a_selected_group_keeps_the_proxies_independent_of_order() {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("stroke.set", &json!({"weight": 6})).unwrap();
|
||||
let outer = NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap());
|
||||
let face = vectorcraft_tools::builder::faces(&node(&s, g))[0].id;
|
||||
s.edit("t", |d, _| {
|
||||
let n = d.node_mut(face).unwrap();
|
||||
n.appearance.set_stroke(Paint::solid(Color::BLACK));
|
||||
n.appearance.stroke_at_mut(None).unwrap().width = 2.0;
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
s.execute("select.set", &json!({"ids": [face.0, outer.0]})).unwrap();
|
||||
assert_eq!(s.shown_stroke().map(|st| st.width), Some(6.0), "a face first shows the edges' stroke");
|
||||
assert!(!s.active().unwrap().stroke_mixed().weight, "the face's own stroke does not make the weight mixed");
|
||||
// An unfilled edge selected with the outer group does not make the faces' fill mixed.
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#ff0000"})).unwrap();
|
||||
let edge = vectorcraft_tools::builder::edges(&node(&s, g))[0].id;
|
||||
s.execute("select.set", &json!({"ids": [edge.0, outer.0]})).unwrap();
|
||||
let r = s.execute("paint.proxies", &json!({})).unwrap();
|
||||
assert_eq!(r["fill"], serde_json::to_value(Paint::solid(Color::from_hex("#ff0000").unwrap())).unwrap());
|
||||
assert_eq!(r["fillMixed"], false, "the edge counts with its group");
|
||||
}
|
||||
|
||||
/// The Eyedropper picks up a whole Live Paint group as its faces' fill under its edges' stroke, and
|
||||
/// `append` onto a whole group adds the picked fills and strokes without the picked effects.
|
||||
#[test]
|
||||
fn live_paint_group_eyedropper_picks_up_the_group_and_appends_without_effects() {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#ff00ff"})).unwrap();
|
||||
s.execute("paint.setStroke", &json!({"color": "#0000ff"})).unwrap();
|
||||
s.execute("stroke.set", &json!({"weight": 5})).unwrap();
|
||||
s.edit("t", |d, _| {
|
||||
d.node_mut(g).unwrap().opacity = 0.5;
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let target = rect(&mut s, 400.0, 0.0, 50.0, 50.0);
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("appearance.copyFrom", &json!({"source": target.0, "reverse": true})).unwrap();
|
||||
let a = (*node(&s, target).appearance).clone();
|
||||
assert_eq!(a.fill_paint(), Paint::solid(Color::from_hex("#ff00ff").unwrap()), "the faces' fill");
|
||||
assert_eq!((a.stroke_paint(), a.stroke_width()), (Paint::solid(Color::from_hex("#0000ff").unwrap()), 5.0), "the edges' stroke");
|
||||
assert_eq!(node(&s, target).opacity, 0.5, "the group's own opacity");
|
||||
// A Live Paint group with no face and no edge is not picked up: the next selected object is.
|
||||
let empty = rect(&mut s, 600.0, 0.0, 50.0, 50.0);
|
||||
s.execute("select.set", &json!({"ids": [empty.0]})).unwrap();
|
||||
let e = NodeId(s.execute("livePaint.make", &json!({})).unwrap()["id"].as_u64().unwrap());
|
||||
let en = node(&s, e);
|
||||
let parts: Vec<NodeId> =
|
||||
vectorcraft_tools::builder::faces(&en).iter().chain(vectorcraft_tools::builder::edges(&en).iter()).map(|p| p.id).collect();
|
||||
assert!(!parts.is_empty());
|
||||
s.edit("t", |d, _| {
|
||||
d.node_mut(e).unwrap().children_mut().unwrap().retain(|c| !parts.contains(&c.id));
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
assert!(vectorcraft_tools::builder::is_live_paint(&node(&s, e)));
|
||||
let other = rect(&mut s, 700.0, 0.0, 50.0, 50.0);
|
||||
s.execute("paint.setFill", &json!({"ids": [other.0], "color": "#00ff00"})).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [e.0, other.0]})).unwrap();
|
||||
s.execute("appearance.copyFrom", &json!({"source": target.0, "reverse": true})).unwrap();
|
||||
assert_eq!(node(&s, target).appearance.fill_paint(), Paint::solid(Color::from_hex("#00ff00").unwrap()), "the next selected object's fill");
|
||||
// Append a source with a drop shadow onto the whole group.
|
||||
let src = rect(&mut s, 500.0, 0.0, 50.0, 50.0);
|
||||
s.execute("select.set", &json!({"ids": [src.0]})).unwrap();
|
||||
s.execute("effect.apply", &json!({"effect": "stylize.dropShadow", "item": null})).unwrap();
|
||||
assert!(!node(&s, src).appearance.effects.is_empty());
|
||||
let (faces0, edges0) = part_looks(&s, g);
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("appearance.copyFrom", &json!({"source": src.0, "append": true})).unwrap();
|
||||
let (faces1, edges1) = part_looks(&s, g);
|
||||
for (p, p0) in faces1.iter().chain(&edges1).zip(faces0.iter().chain(&edges0)) {
|
||||
assert_eq!(p.effects, p0.effects, "a face or edge takes no effect");
|
||||
}
|
||||
assert!(faces1.iter().zip(&faces0).all(|(f, f0)| f.items.len() > f0.items.len()), "every face takes the fill");
|
||||
}
|
||||
|
||||
/// Reversed onto a clicked object, an empty Live Paint group first in the selection passes to the next
|
||||
/// selected Live Paint group, whose faces' fill and edges' stroke are both picked up.
|
||||
#[test]
|
||||
fn live_paint_group_eyedropper_reversed_skips_an_empty_group_for_the_next_whole_group() {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#ff00ff"})).unwrap();
|
||||
s.execute("paint.setStroke", &json!({"color": "#0000ff"})).unwrap();
|
||||
s.execute("stroke.set", &json!({"weight": 5})).unwrap();
|
||||
let empty = rect(&mut s, 600.0, 0.0, 50.0, 50.0);
|
||||
s.execute("select.set", &json!({"ids": [empty.0]})).unwrap();
|
||||
let e = NodeId(s.execute("livePaint.make", &json!({})).unwrap()["id"].as_u64().unwrap());
|
||||
let en = node(&s, e);
|
||||
let parts: Vec<NodeId> =
|
||||
vectorcraft_tools::builder::faces(&en).iter().chain(vectorcraft_tools::builder::edges(&en).iter()).map(|p| p.id).collect();
|
||||
s.edit("t", |d, _| {
|
||||
d.node_mut(e).unwrap().children_mut().unwrap().retain(|c| !parts.contains(&c.id));
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let target = rect(&mut s, 400.0, 0.0, 50.0, 50.0);
|
||||
s.execute("appearance.copyFrom", &json!({"source": target.0, "reverse": true, "ids": [e.0, g.0]})).unwrap();
|
||||
let a = (*node(&s, target).appearance).clone();
|
||||
assert_eq!(a.fill_paint(), Paint::solid(Color::from_hex("#ff00ff").unwrap()), "the faces' fill");
|
||||
assert_eq!((a.stroke_paint(), a.stroke_width()), (Paint::solid(Color::from_hex("#0000ff").unwrap()), 5.0), "the edges' stroke");
|
||||
}
|
||||
|
||||
/// An Eyedropper pick whose source is the selected Live Paint group leaves the group's own faces and
|
||||
/// edges as they are.
|
||||
#[test]
|
||||
fn live_paint_group_eyedropper_does_not_target_its_own_source_group() {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
s.execute("livePaint.fill", &json!({"group": g.0, "point": [25, 50], "color": "#ff0000"})).unwrap();
|
||||
s.execute("livePaint.fill", &json!({"group": g.0, "point": [75, 50], "color": "#00ff00"})).unwrap();
|
||||
let before = part_looks(&s, g);
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("appearance.copyFrom", &json!({"source": g.0})).unwrap();
|
||||
assert_eq!(part_looks(&s, g), before);
|
||||
}
|
||||
|
||||
/// A Live Paint group left with only its hidden source paths is still a selection: a stroke edit of its
|
||||
/// contents changes nothing and leaves the settings for new art as they are.
|
||||
#[test]
|
||||
fn live_paint_group_with_only_source_paths_leaves_new_art_alone_for_a_contents_edit() {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
let n = node(&s, g);
|
||||
let parts: Vec<NodeId> = vectorcraft_tools::builder::faces(&n).iter().chain(vectorcraft_tools::builder::edges(&n).iter()).map(|p| p.id).collect();
|
||||
s.edit("t", |d, _| {
|
||||
d.children_mut(Some(g)).unwrap().retain(|c| !parts.contains(&c.id));
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
let (paint0, stroke0) = (s.paint.clone(), s.new_art_stroke());
|
||||
s.execute("stroke.setAdvanced", &json!({"target": "contents", "item": 0, "arrowScale": [200, 150]})).unwrap();
|
||||
assert_eq!((s.paint.clone(), s.new_art_stroke()), (paint0, stroke0), "new art keeps its stroke");
|
||||
}
|
||||
|
||||
/// Adding a fill or a stroke to the contents of a Live Paint group left with only its hidden source paths
|
||||
/// succeeds and changes nothing, while an empty selection is still refused.
|
||||
#[test]
|
||||
fn live_paint_group_with_only_source_paths_ignores_add_fill_and_add_stroke_of_its_contents() {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
let n = node(&s, g);
|
||||
let parts: Vec<NodeId> = vectorcraft_tools::builder::faces(&n).iter().chain(vectorcraft_tools::builder::edges(&n).iter()).map(|p| p.id).collect();
|
||||
s.edit("t", |d, _| {
|
||||
d.children_mut(Some(g)).unwrap().retain(|c| !parts.contains(&c.id));
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
let before = node(&s, g);
|
||||
for cmd in ["appearance.addFill", "appearance.addStroke"] {
|
||||
s.execute(cmd, &json!({"target": "contents"})).unwrap();
|
||||
assert_eq!(node(&s, g), before, "{cmd} changes nothing");
|
||||
}
|
||||
s.execute("select.none", &json!({})).unwrap();
|
||||
assert!(s.execute("appearance.addFill", &json!({"target": "contents"})).is_err(), "no selection is still refused");
|
||||
}
|
||||
|
||||
/// A selected Live Paint group with no part of the edited kind is still a selection: a stroke edit
|
||||
/// of a group without edges, or a fill gradient edit of a group without faces, changes nothing and
|
||||
/// leaves the settings for new art as they are.
|
||||
@@ -4304,6 +4651,8 @@ fn live_paint_group_without_parts_of_the_edited_kind_leaves_new_art_alone() {
|
||||
s.execute("stroke.set", &json!({"weight": 4})).unwrap();
|
||||
s.execute("stroke.weightUp", &json!({})).unwrap();
|
||||
s.execute("stroke.setAdvanced", &json!({"arrowScale": [200, 150]})).unwrap();
|
||||
// A stroke row edit of the group's contents finds no edge either.
|
||||
s.execute("stroke.set", &json!({"target": "contents", "item": 0, "weight": 9})).unwrap();
|
||||
assert_eq!((s.paint.clone(), s.new_art_stroke()), (paint0, stroke0), "new art keeps its stroke");
|
||||
assert_eq!(part_looks(&s, g), looks);
|
||||
|
||||
|
||||
+24
-10
@@ -4883,15 +4883,23 @@ already walks Image Trace. Short agent entry points:
|
||||
`paint.none` paint the faces or the edges. `paint.editGradient`, `paint.setGradientGeom` and the `paint.freeform`
|
||||
point and line edits change the faces' or the edges' gradients, `paint.invert` and `paint.complement` recolor the
|
||||
faces' fills or the edges' strokes, and `stroke.set`, `stroke.weightUp`, `stroke.weightDown` and
|
||||
`stroke.setAdvanced` change the edges. The Fill proxy shows the faces' fill, and the Stroke proxy, the Stroke panel
|
||||
and the Control bar show the edges' stroke. A face or edge selected or given together with its whole group follows
|
||||
the group's rule: a fill does not reach an edge, and a stroke does not reach a face. `paint.swap` gives the faces
|
||||
the stroke the edges share and gives the edges the fill the faces share, with a gradient fitted to each face or
|
||||
edge. It leaves a group as it is when its faces' fills or its edges' strokes differ, when any of them is a freeform
|
||||
gradient, or when it has no face or no edge. `paint.default` replaces each face's appearance with no fill and each
|
||||
edge's appearance with a 0.5 pt black stroke, also when the document's Default Graphic Style is redefined. With
|
||||
only Live Paint groups selected or given, the fill and stroke for new art become no fill and a 0.5 pt black stroke;
|
||||
with New Art Has Basic Appearance off, new art then takes the selection's appearance, as after any command.
|
||||
`stroke.setAdvanced` change the edges. `object.setOverprint` sets the faces' fill overprint and the edges' stroke
|
||||
overprint. `appearance.copyFrom` (the Eyedropper) gives the picked fill attributes to the faces and the picked
|
||||
stroke attributes to the edges, also onto a group given as `source` with `reverse`. A whole-appearance pick gives
|
||||
each face every picked fill row and each edge every picked stroke row, and the faces and edges keep their rows of
|
||||
the other kind and their effects; `append` adds the source's rows to them but not its object effects. A whole group
|
||||
picked up as the source (given as `source`, or selected first with `reverse`) gives its first face's fills with its
|
||||
first edge's strokes above them, and the group's own opacity, blend mode and effects. The Fill proxy shows the
|
||||
faces' fill, and the Stroke proxy, the Stroke panel and the Control bar show the edges' stroke, whatever the order of
|
||||
a selection that holds the group, directly or inside a selected group, and some of its parts. A face or edge
|
||||
selected or given together with its whole group follows the group's rule: a fill does not reach an edge, and a
|
||||
stroke does not reach a face. `paint.swap` gives the faces the stroke the edges share and gives the edges the fill
|
||||
the faces share, with a gradient fitted to each face or edge. It leaves a group as it is when its faces' fills or its
|
||||
edges' strokes differ, when any of them is a freeform gradient, or when it has no face or no edge. `paint.default`
|
||||
replaces each face's appearance with no fill and each edge's appearance with a 0.5 pt black stroke, also when the
|
||||
document's Default Graphic Style is redefined. With only Live Paint groups selected or given, the fill and stroke
|
||||
for new art become no fill and a 0.5 pt black stroke; with New Art Has Basic Appearance off, new art then takes the
|
||||
selection's appearance, as after any command.
|
||||
|
||||
`brush.selectionArt {ids?|id?}` (a query) replies `{art}`: the object that `brush.new` given the same `ids` or `id`,
|
||||
or the same selection, takes as a new scatter or art brush's art and as a new pattern brush's side tile. Several
|
||||
@@ -5689,7 +5697,13 @@ fills and strokes above it paint over the members (characters), those below unde
|
||||
`contents` to say where the row ends up in the same undo step; `document.node` shows the slot as
|
||||
`appearance.contents_index`. The `appearance.*`, `effect.*` and `graphicStyle.apply` commands edit the selected
|
||||
objects themselves (a group's own stack; layers through `ids`) or, with `target: "contents"`, the objects inside the
|
||||
groups and layers. `appearance.targetContents` selects a group's members (double-clicking the Contents row).
|
||||
groups and layers. In a Live Paint group those are its faces and edges, not its hidden source paths.
|
||||
`appearance.addFill` adds a fill to the faces only, and `appearance.addStroke` adds a stroke to the edges only; a selected group left with only its hidden source paths is returned without a change. A
|
||||
fill or stroke command with an `item` and `target: "contents"` (such as `paint.setFill`, `stroke.set`,
|
||||
`paint.invert`, `paint.setGradientGeom` and `object.setOverprint`) changes the faces for a fill row and the edges for
|
||||
a stroke row. The row commands (`appearance.setItem`, `appearance.removeItem` and the others) find their rows on each
|
||||
face and edge as on any other object in the contents.
|
||||
`appearance.targetContents` selects a group's members (double-clicking the Contents row).
|
||||
SVG and PDF export bake a group's own fills, strokes and geometry effects into paths; its raster effects stay a
|
||||
filter on the whole group in SVG and become an image of the whole group in PDF.
|
||||
A geometry effect on one of type's own fills or strokes (`effect.apply` with `item`) reshapes the whole outline that
|
||||
|
||||
@@ -1930,7 +1930,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
As VectorCraft's own rule, OK in Live Paint Selection Tool Options, Live Paint Bucket Options, Gap Options and Tile Edge Color gives an error for a color with an alpha part (`#rrggbbaa` or `#rgba`) and changes nothing.
|
||||
As VectorCraft's own rule, a Live Paint edit that changes nothing records no undo step, keeps the redo steps and leaves a saved document saved: a Live Paint Bucket click or drag over faces that already have the fill, a stroke on an edge that already has the paint and weight, Gap Options OK with the options the groups have and no gap to close, and Make or Merge with one Live Paint group alone. Such a fill or stroke also leaves the recent colors as they are. Regression tests: `live_paint_fill_same_paint_is_no_op`, `live_paint_bucket_click_with_the_face_paint_is_no_op`, `live_paint_stroke_edge_same_paint_and_width_is_no_op`, `live_paint_gap_options_same_values_are_no_op`, `live_paint_gap_options_close_without_gaps_is_no_op`, `live_paint_make_existing_group_is_no_op` and `live_paint_merge_single_group_is_no_op` in `crates/engine/src/tests/build.rs`, and `ok_on_unchanged_options_records_no_undo_step` in `crates/ui-egui/src/dialogs/live_paint_gaps.rs`.
|
||||
As VectorCraft's own rule, the Live Paint Bucket replaces all of a face's fills, or all of an edge's strokes, with one fill or stroke of the paint, shown, fully opaque and blending normally, so a lower fill or stroke no longer draws under the new paint and a fill or stroke of none leaves nothing of that kind drawing; the face's strokes, the edge's fills, the part's own opacity and the topmost shown stroke's dashes, caps and arrowheads stay as they are, and a part that already has only that one fill or stroke records no undo step. [The help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/paint-with-the-live-paint-bucket-tool.html) says the tool paints faces with the current fill and edges with the current stroke. Regression tests: `live_paint_bucket_replaces_every_fill_row`, `live_paint_stroke_edge_replaces_every_stroke_row` and `live_paint_stroke_edge_paints_the_shown_stroke` in `crates/engine/src/tests/build.rs`.
|
||||
As VectorCraft's own rule, with a tool other than the Live Paint Bucket, a fill given to a whole selected Live Paint group paints its faces only and a stroke paints its edges only, and the hidden source paths keep their paint. Swap Fill and Stroke trades the fill the faces share with the stroke the edges share, and Default Fill and Stroke leaves the faces with no fill and gives the edges a 0.5 pt black stroke (`docs/mcp.md`). Evidence: `tests::build::{live_paint_group_fill_goes_to_faces_and_stroke_to_edges, live_paint_group_swap_trades_the_faces_fill_and_the_edges_stroke, live_paint_group_default_clears_the_faces_and_gives_the_edges_a_thin_black_stroke, live_paint_group_invert_recolors_the_faces_fill, live_paint_group_gradient_vector_and_freeform_edits_change_its_faces, live_paint_group_stroke_panel_edits_change_its_edges, live_paint_group_rules_stop_where_paint_commands_stop, live_paint_group_without_parts_of_the_edited_kind_leaves_new_art_alone}`.
|
||||
As VectorCraft's own rule, with a tool other than the Live Paint Bucket, a fill given to a whole selected Live Paint group paints its faces only and a stroke paints its edges only, and the hidden source paths keep their paint. Swap Fill and Stroke trades the fill the faces share with the stroke the edges share, and Default Fill and Stroke leaves the faces with no fill and gives the edges a 0.5 pt black stroke (`docs/mcp.md`). The Eyedropper gives the picked fill attributes to the faces and the picked stroke attributes to the edges, and picks up a whole group as its first face's fills with its first edge's strokes. Overprint Fill goes to the faces and Overprint Stroke goes to the edges. The proxies show the same paint whatever the order of a selection that holds the group and one of its parts. Appearance panel edits of the group's contents leave the hidden source paths as they are, a new fill goes on the faces, and a new stroke goes on the edges. Evidence: `tests::build::{live_paint_group_fill_goes_to_faces_and_stroke_to_edges, live_paint_group_swap_trades_the_faces_fill_and_the_edges_stroke, live_paint_group_default_clears_the_faces_and_gives_the_edges_a_thin_black_stroke, live_paint_group_invert_recolors_the_faces_fill, live_paint_group_gradient_vector_and_freeform_edits_change_its_faces, live_paint_group_stroke_panel_edits_change_its_edges, live_paint_group_rules_stop_where_paint_commands_stop, live_paint_group_without_parts_of_the_edited_kind_leaves_new_art_alone, live_paint_group_proxies_do_not_depend_on_the_selection_order, live_paint_group_eyedropper_gives_the_fill_to_faces_and_the_stroke_to_edges, live_paint_group_eyedropper_gives_every_fill_and_stroke_row, live_paint_group_contents_edits_follow_the_group_rule, live_paint_group_item_edits_and_overprint_follow_the_group_rule, live_paint_group_inside_a_selected_group_keeps_the_proxies_independent_of_order, live_paint_group_eyedropper_picks_up_the_group_and_appends_without_effects}`.
|
||||
As VectorCraft's own rule, `tool.setOption` for the Live Paint Bucket and the Live Paint Selection tool, chosen or not, checks every value before it sets any: a switch that is not `true` or `false`, a `color` that is not an RGB color or a layer color's name, or that has an alpha part, a `width` that is not a number and an option the tool does not have give an error naming the option, and nothing is set or saved. A `width` outside 1 to 20 px is still set to the nearest end of that range. Saved settings that hold an invalid value still load, and the tool keeps its default for that option. Evidence: `tests::build::{live_paint_tool_options_refuse_invalid_values_and_change_nothing, live_paint_tool_options_take_rgb_colors_and_clamp_the_width, live_paint_tools_load_saved_settings_with_invalid_values}`.
|
||||
As VectorCraft's own rule, `tool.setOption` for the Shape Builder, chosen or not, checks every value the same way: a switch that is not `true` or `false`, a `pickColorFrom` or `selection` that is not one of its names, a `gapLength` that is not a number, a `highlightColor` that is not an RGB color or a layer color's name, or that has an alpha part, and an option the tool does not have give an error naming the option, and nothing is set or saved. A `gapLength` outside 0 to 72 pt is still set to the nearest end of that range. Evidence: `tests::build::{shape_builder_tool_options_refuse_invalid_values_and_change_nothing, shape_builder_tool_options_take_valid_values_and_clamp_the_gap}`.
|
||||
A drag of 3 screen pixels or more with the Live Paint Selection tool draws a marquee and selects the faces and edges it touches, partly enclosed ones included, and a Shift-drag adds them to the selection or removes them from it ([Modify Live Paint groups](https://web.archive.org/web/20261006115247/https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/modify-live-paint-groups.html)). A click and a marquee change the selection on release, and Escape before the release leaves the selection as it was. Locked Live Paint groups, those on a locked layer or artboard, and in isolation mode those outside the isolated art are not highlighted or selected.
|
||||
|
||||
Reference in new issue
Block a user