mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-29 17:54:36 +01:00
Brushes: Alt-drag art onto a brush to replace its art
Art Alt-dragged (Option-dragged on macOS) from the canvas onto a scatter, art or pattern brush in the Brushes panel becomes its art (brush.replaceArt). When strokes use the brush, the app checks the art first, then a dialog offers Apply to Strokes, which redraws them with the new art, Leave Strokes, which keeps the brush and its strokes as they were and adds "<name> copy" with the new art as the current brush, and Cancel. Each change is one undo step. A pattern brush takes back the tile groups brush.placeArt places, frames included, and takes other art as its side tile. Calligraphic and bristle brushes, an empty selection and art with no width are refused. Art Alt-dragged off the canvas now reaches the panels as the art the drag started with. Before, the panels got the ids of the copy the drag previews, which no longer exist once the release over a panel ends the move. brush.new now also measures a symbol instance in the selected art by its symbol's art when it checks that the art has width. Docs: docs/mcp.md, docs/target-app-parity.md.
This commit is contained in:
1 parent
bcc9901419
commit
d69e9c10d7
40 files changed
+866
-10
No files matched your search
@@ -34,7 +34,7 @@ mod symbols;
|
||||
pub(crate) use brushes::{apply_brush, brush_targets, stroke_paint};
|
||||
use brushes::{
|
||||
brush_apply, brush_delete, brush_duplicate, brush_freehand, brush_get, brush_list, brush_move, brush_new, brush_options, brush_place_art,
|
||||
brush_remove, brush_selection_art, brush_set_current, brush_unused, expand_brush,
|
||||
brush_remove, brush_replace_art, brush_selection_art, brush_set_current, brush_unused, expand_brush,
|
||||
};
|
||||
pub(crate) use dynamic::{edit_part, part_only, selected_part};
|
||||
use dynamic::{symbol_instance_reset, symbol_instance_select_part, symbol_instance_set_appearance};
|
||||
@@ -76,6 +76,15 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
has_doc,
|
||||
brush_place_art
|
||||
),
|
||||
cmd!(
|
||||
"brush.replaceArt",
|
||||
"Replace Brush Art",
|
||||
[],
|
||||
None,
|
||||
"{name, ids?|id?, applyToStrokes?: true} make the selected art (several objects become one group, as in brush.new) the art of a scatter, art or pattern brush, keeping its other options, as Alt-dragging (Option-dragging on macOS) art onto the brush in the Brushes panel does; a pattern brush takes a group named for one of its tiles, or a group of such groups (as brush.placeArt places them), tile by tile (of two named for one tile, the frontmost), each with the repeat frame an unpainted rectangle at its back marks (other tiles stay as they are), and other art as its side tile; when strokes use the brush and applyToStrokes is false, the brush and its strokes stay as they were and a copy of the brush with the new art, named `<name> copy`, goes after it and becomes the current brush; otherwise the strokes redraw with the new art; one undo step; refused for a calligraphic or bristle brush, with nothing selected, and for art (or a tile) with no width → {name: the brush that has the new art}",
|
||||
has_doc,
|
||||
brush_replace_art
|
||||
),
|
||||
cmd!(
|
||||
"brush.apply",
|
||||
"Apply Brush",
|
||||
|
||||
@@ -239,7 +239,7 @@ pub(super) fn brush_new(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
&& v.get(k).is_none()
|
||||
{
|
||||
let art = selection_art(s, p)?.ok_or_else(|| bad(C, format!("{ty} brushes need selected art (or params.{k})")))?;
|
||||
if art.geometric_bounds().is_none_or(|b| b.width() <= 1e-6) {
|
||||
if !has_width(&art, &s.doc()?.doc.symbol_boxes()) {
|
||||
return Err(bad(C, "the selected art has no width"));
|
||||
}
|
||||
v[k] = serde_json::to_value(&art).unwrap_or_default();
|
||||
@@ -249,6 +249,12 @@ pub(super) fn brush_new(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Ok(json!({ "name": name }))
|
||||
}
|
||||
|
||||
/// Whether art `n` has width for a brush to be made of, with symbol instances measured by their
|
||||
/// symbols' art in `symbols`.
|
||||
fn has_width(n: &Node, symbols: &vectorcraft_doc::SymbolBoxes) -> bool {
|
||||
n.geometric_bounds_with(symbols).is_some_and(|b| b.width() > 1e-6)
|
||||
}
|
||||
|
||||
/// Refuses `name` for a bristle brush when it has more than [`Bristle::MAX_NAME_CHARS`] characters.
|
||||
fn bristle_name_fits(cmd: &str, name: &str) -> Result<()> {
|
||||
let (count, max) = (name.chars().count(), Bristle::MAX_NAME_CHARS);
|
||||
@@ -367,6 +373,12 @@ fn art_brushes(n: &Node, out: &mut Vec<String>) {
|
||||
pub(super) fn brush_unused(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
let d = &s.doc()?.doc;
|
||||
let lib = brush::library(d);
|
||||
let names = brush_unused_in(d, &lib);
|
||||
Ok(json!({ "names": names }))
|
||||
}
|
||||
|
||||
/// The brushes of `lib` no stroke in `d` paints with, in library order ([`brush_unused`]).
|
||||
fn brush_unused_in(d: &Document, lib: &[Brush]) -> Vec<String> {
|
||||
let mut todo = vec![];
|
||||
let trees = d.layers.iter().chain(d.symbols.iter().map(|s| &s.art)).chain(d.graph_designs.iter().map(|g| &g.art));
|
||||
let patterns = d.patterns.iter().chain(d.pattern_edit.iter().filter_map(|pe| pe.original.as_ref()));
|
||||
@@ -379,8 +391,7 @@ pub(super) fn brush_unused(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
used.insert(name);
|
||||
}
|
||||
}
|
||||
let names: Vec<&str> = lib.iter().map(|b| b.name.as_str()).filter(|n| !used.contains(*n)).collect();
|
||||
Ok(json!({ "names": names }))
|
||||
lib.iter().map(|b| b.name.clone()).filter(|n| !used.contains(n)).collect()
|
||||
}
|
||||
|
||||
pub(super) fn brush_options(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
@@ -484,7 +495,7 @@ pub(super) fn brush_options(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
|
||||
/// The name `brush.placeArt` gives each pattern brush tile it places, by tile, in the order it
|
||||
/// places them.
|
||||
/// places them; `brush.replaceArt` reads a group of that name as that tile.
|
||||
const TILE_NAMES: [&str; 5] = ["Side Tile", "Outer Corner Tile", "Inner Corner Tile", "Start Tile", "End Tile"];
|
||||
|
||||
/// The space between the pattern brush tiles `brush.placeArt` places, in points.
|
||||
@@ -506,6 +517,18 @@ fn tile(p: &brush::PatternBrush, i: usize) -> Option<(&Node, Option<vectorcraft_
|
||||
}
|
||||
}
|
||||
|
||||
/// Gives tile `i` of `p` ([`TILE_NAMES`] order) the art `art` and the repeat frame `frame`. The tile
|
||||
/// no longer comes from a pattern swatch, and a corner draws its own art.
|
||||
fn set_tile(p: &mut brush::PatternBrush, i: usize, art: Node, frame: Option<vectorcraft_geom::Rect>) {
|
||||
match i {
|
||||
0 => (p.side, p.side_frame, p.side_swatch) = (art, frame, None),
|
||||
1 => (p.outer_corner, p.outer_corner_frame, p.outer_corner_swatch, p.outer_source) = (Some(art), frame, None, None),
|
||||
2 => (p.inner_corner, p.inner_corner_frame, p.inner_corner_swatch, p.inner_source) = (Some(art), frame, None, None),
|
||||
3 => (p.start, p.start_frame, p.start_swatch) = (Some(art), frame, None),
|
||||
_ => (p.end, p.end_frame, p.end_swatch) = (Some(art), frame, None),
|
||||
}
|
||||
}
|
||||
|
||||
/// The art `brush.placeArt` places for brush `b`, in the brush's own coordinates: a scatter or art
|
||||
/// brush's art, or a pattern brush's tiles in a row, each in a group named for its tile
|
||||
/// ([`TILE_NAMES`]), with an unpainted rectangle at the back of a tile that has a repeat frame
|
||||
@@ -570,6 +593,118 @@ pub(super) fn brush_place_art(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Ok(json!({ "id": id.0 }))
|
||||
}
|
||||
|
||||
/// The repeat frame an unpainted rectangle at the back of a tile group marks ([`placed_art`]): the
|
||||
/// rectangle's bounds, when `n` is a path of one closed subpath through the four corners of its
|
||||
/// bounds, without curves, whose fills and strokes paint nothing and that has no other appearance.
|
||||
fn frame_marker(n: &Node) -> Option<vectorcraft_geom::Rect> {
|
||||
let NodeKind::Path { path, guide: false, clipping: false, .. } = &n.kind else { return None };
|
||||
let unpainted = n.appearance.effects.is_empty()
|
||||
&& n.appearance.items.iter().all(|i| match i {
|
||||
AppearanceItem::Fill(f) => f.paint.is_none(),
|
||||
AppearanceItem::Stroke(st) => st.paint.is_none(),
|
||||
});
|
||||
let [sp] = path.subpaths.as_slice() else { return None };
|
||||
let r = n.geometric_bounds()?;
|
||||
let corners = [(r.x0, r.y0), (r.x1, r.y0), (r.x1, r.y1), (r.x0, r.y1)];
|
||||
let at_corners = sp.anchors.len() == 4
|
||||
&& sp.anchors.iter().all(|a| a.h_in == a.p && a.h_out == a.p)
|
||||
&& corners.iter().all(|c| sp.anchors.iter().any(|a| (a.p.x, a.p.y) == *c));
|
||||
(unpainted && sp.closed && at_corners && r.width() > 1e-9 && r.height() > 1e-9).then_some(r)
|
||||
}
|
||||
|
||||
/// The tiles in `art` for a pattern brush, by tile ([`TILE_NAMES`] order), with their repeat frames:
|
||||
/// a group named for a tile, as `brush.placeArt` places them, is the art of its tile (an unpainted
|
||||
/// rectangle at its back marks the tile's frame, [`frame_marker`], and is left out of the art; a
|
||||
/// group left with one member gives that member), and so is each member of a group whose members
|
||||
/// are all such groups; any other art is the side tile.
|
||||
fn tiles_of(art: Node) -> Vec<(usize, Node, Option<vectorcraft_geom::Rect>)> {
|
||||
let named = |c: &Node| matches!(c.kind, NodeKind::Group { clip: false, .. }) && c.name.as_deref().is_some_and(|n| TILE_NAMES.contains(&n));
|
||||
let tiles = match &art.kind {
|
||||
_ if named(&art) => vec![Arc::new(art)],
|
||||
NodeKind::Group { children, clip: false } if !children.is_empty() && children.iter().all(|c| named(c)) => children.clone(),
|
||||
_ => return vec![(0, art, None)],
|
||||
};
|
||||
let mut out: Vec<(usize, Node, Option<vectorcraft_geom::Rect>)> = vec![];
|
||||
for t in tiles {
|
||||
let Some(i) = t.name.as_deref().and_then(|n| TILE_NAMES.iter().position(|x| *x == n)) else { continue };
|
||||
let mut g = (*t).clone();
|
||||
let mut frame = None;
|
||||
if let NodeKind::Group { children, .. } = &mut g.kind
|
||||
&& let Some(f) = children.first().and_then(|c| frame_marker(c))
|
||||
{
|
||||
frame = Some(f);
|
||||
children.remove(0);
|
||||
}
|
||||
g.name = None;
|
||||
// The group `brush.placeArt` put around the tile's art: the art itself goes back, so a
|
||||
// tile does not gain a group each time it goes out and back.
|
||||
if let NodeKind::Group { children, clip: false } = &g.kind
|
||||
&& let [only] = children.as_slice()
|
||||
&& g == Node::group(g.id, children.clone())
|
||||
{
|
||||
g = (**only).clone();
|
||||
}
|
||||
// A tile named twice: the frontmost one counts.
|
||||
out.retain(|(j, ..)| *j != i);
|
||||
out.push((i, g, frame));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// `brush.replaceArt`: the selected art (or `ids`/`id`; several objects become one group, as in
|
||||
/// `brush.new`) becomes the art of scatter, art or pattern brush `name`, keeping its other options,
|
||||
/// as one undo step. A pattern brush takes the tiles `brush.placeArt` places by their names
|
||||
/// ([`tiles_of`]) and other art as its side tile. When strokes use the brush and `applyToStrokes` is
|
||||
/// false, the brush and its strokes stay as they were and a copy of the brush with the new art is
|
||||
/// added after it and becomes the current brush; otherwise the strokes redraw with the new art.
|
||||
pub(super) fn brush_replace_art(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
const C: &str = "brush.replaceArt";
|
||||
let name = name_param(p, C)?.to_string();
|
||||
let apply = super::switch_or(p, "applyToStrokes", true, C)?;
|
||||
let mut lib = brush::library(&s.doc()?.doc);
|
||||
let i = lib.iter().position(|b| b.name == name).ok_or_else(|| bad(C, format!("no brush named `{name}`")))?;
|
||||
if lib[i].art().is_empty() {
|
||||
return Err(bad(C, no_art(&name)));
|
||||
}
|
||||
let art = selection_art(s, p)?.ok_or_else(|| bad(C, "nothing selected"))?;
|
||||
let d = &s.doc()?.doc;
|
||||
let symbols = d.symbol_boxes();
|
||||
let check = |n: &Node| if has_width(n, &symbols) { Ok(()) } else { Err(bad(C, "the selected art has no width")) };
|
||||
let mut b = lib[i].clone();
|
||||
match &mut b.kind {
|
||||
BrushKind::Scatter(sc) => {
|
||||
check(&art)?;
|
||||
sc.art = art;
|
||||
}
|
||||
BrushKind::Art(a) => {
|
||||
check(&art)?;
|
||||
a.art = art;
|
||||
}
|
||||
BrushKind::Pattern(pb) => {
|
||||
for (t, art, frame) in tiles_of(art) {
|
||||
check(&art)?;
|
||||
set_tile(pb, t, art, frame);
|
||||
}
|
||||
}
|
||||
BrushKind::Calligraphic(_) | BrushKind::Bristle(_) => return Err(bad(C, no_art(&name))),
|
||||
}
|
||||
let used = !brush_unused_in(d, &lib).contains(&name);
|
||||
if apply || !used {
|
||||
lib[i] = b;
|
||||
save_library(s, "Replace Brush Art", lib, &[])?;
|
||||
return Ok(json!({ "name": name }));
|
||||
}
|
||||
b.name = brush::unique_name(&lib, &format!("{} copy", name.trim()));
|
||||
let copy = b.name.clone();
|
||||
lib.insert(i + 1, b);
|
||||
s.edit("Replace Brush Art", |d, _| {
|
||||
d.unknown.insert(brush::CURRENT_KEY.into(), json!(copy));
|
||||
brush::store(d, &lib);
|
||||
Ok(())
|
||||
})?;
|
||||
Ok(json!({ "name": copy }))
|
||||
}
|
||||
|
||||
pub(super) fn expand_brush(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let ids = brush_targets(&s.doc()?.doc, &roots(s, p)?);
|
||||
let ids: Vec<NodeId> = ids.into_iter().filter(|id| s.doc().ok().and_then(|st| st.doc.node(*id)).is_some_and(brush::has_brush)).collect();
|
||||
|
||||
@@ -110,6 +110,7 @@ pub(super) const ALLOWED: &[&str] = &[
|
||||
"brush.options",
|
||||
"brush.placeArt",
|
||||
"brush.remove",
|
||||
"brush.replaceArt",
|
||||
"brush.selectionArt",
|
||||
"brush.setCurrent",
|
||||
"brush.unused",
|
||||
|
||||
@@ -365,6 +365,255 @@ fn pattern_brushes_place_their_tiles_in_a_row() {
|
||||
assert_eq!(tiles[1].children().unwrap().len(), 1, "no frame, no rectangle");
|
||||
}
|
||||
|
||||
/// `brush.replaceArt` reads the tiles `brush.placeArt` places back tile by tile, frames included:
|
||||
/// every tile and the frame keep their sizes, and the frame keeps its place around the art.
|
||||
#[test]
|
||||
fn placed_pattern_tiles_go_back_into_the_brush_tile_by_tile() {
|
||||
let mut s = session();
|
||||
let name = framed_pattern_brush(&mut s);
|
||||
let before = s.execute("brush.get", &json!({"name": name})).unwrap();
|
||||
let id = NodeId(s.execute("brush.placeArt", &json!({"name": name, "x": 200, "y": 150})).unwrap()["id"].as_u64().unwrap());
|
||||
let steps = undo_steps(&s);
|
||||
s.execute("brush.replaceArt", &json!({"name": name, "ids": [id.0]})).unwrap();
|
||||
assert_eq!(undo_steps(&s), steps + 1);
|
||||
let after = s.execute("brush.get", &json!({"name": name})).unwrap();
|
||||
let size = |v: &Value| {
|
||||
let n: Node = serde_json::from_value(v.clone()).unwrap();
|
||||
let b = n.geometric_bounds().unwrap();
|
||||
(b.width(), b.height())
|
||||
};
|
||||
for key in ["side", "outer_corner", "start"] {
|
||||
let (a, b) = (size(&before[key]), size(&after[key]));
|
||||
assert!((a.0 - b.0).abs() < 1e-6 && (a.1 - b.1).abs() < 1e-6, "{key}: {a:?} → {b:?}");
|
||||
}
|
||||
assert!(after.get("end").is_none_or(Value::is_null) && after.get("inner_corner").is_none_or(Value::is_null));
|
||||
let frame: Rect = serde_json::from_value(after["side_frame"].clone()).unwrap();
|
||||
let art: Node = serde_json::from_value(after["side"].clone()).unwrap();
|
||||
let art = art.geometric_bounds().unwrap();
|
||||
assert!((frame.width() - 24.0).abs() < 1e-6 && (art.x0 - frame.x0 - 2.0).abs() < 1e-6, "{frame:?} around {art:?}");
|
||||
assert!(after["outer_corner_frame"].is_null() || after.get("outer_corner_frame").is_none());
|
||||
}
|
||||
|
||||
/// Art that is not the tiles `brush.placeArt` places becomes a pattern brush's side tile, and the
|
||||
/// other tiles stay; one tile group alone replaces only that tile.
|
||||
#[test]
|
||||
fn other_art_replaces_the_side_tile_of_a_pattern_brush() {
|
||||
let mut s = session();
|
||||
let name = framed_pattern_brush(&mut s);
|
||||
let before = s.execute("brush.get", &json!({"name": name})).unwrap();
|
||||
let r = rect(&mut s, 100.0, 100.0, 30.0, 12.0);
|
||||
s.execute("brush.replaceArt", &json!({"name": name, "ids": [r.0]})).unwrap();
|
||||
let after = s.execute("brush.get", &json!({"name": name})).unwrap();
|
||||
let side: Node = serde_json::from_value(after["side"].clone()).unwrap();
|
||||
assert!(close(side.geometric_bounds().unwrap(), Rect::new(100.0, 100.0, 130.0, 112.0), 1e-6));
|
||||
assert!(after.get("side_frame").is_none_or(Value::is_null), "the old frame goes with the old art");
|
||||
assert_eq!((&after["outer_corner"], &after["start"]), (&before["outer_corner"], &before["start"]));
|
||||
// One placed tile, its group dragged back alone: only the start tile changes.
|
||||
let id = NodeId(s.execute("brush.placeArt", &json!({"name": name})).unwrap()["id"].as_u64().unwrap());
|
||||
let start = node(&s, id).children().unwrap()[2].clone();
|
||||
assert_eq!(start.name.as_deref(), Some("Start Tile"));
|
||||
s.execute("brush.replaceArt", &json!({"name": name, "ids": [start.id.0]})).unwrap();
|
||||
let last = s.execute("brush.get", &json!({"name": name})).unwrap();
|
||||
assert_eq!((&last["side"], &last["outer_corner"]), (&after["side"], &after["outer_corner"]));
|
||||
let art: Node = serde_json::from_value(last["start"].clone()).unwrap();
|
||||
assert!(close(art.geometric_bounds().unwrap(), start.geometric_bounds().unwrap(), 1e-6), "the start tile is the placed one");
|
||||
assert!(art.name.is_none(), "the tile's name stays on the canvas");
|
||||
}
|
||||
|
||||
/// `brush.replaceArt` gives a brush new art in one undo step: strokes that use it redraw with it,
|
||||
/// or with `applyToStrokes: false` keep the brush as it was while a copy with the new art becomes
|
||||
/// the current brush. A brush no stroke uses changes in place either way.
|
||||
#[test]
|
||||
fn replace_art_applies_to_strokes_or_leaves_them_on_the_old_brush() {
|
||||
let mut s = session();
|
||||
let r = rect(&mut s, 10.0, 200.0, 40.0, 8.0);
|
||||
s.execute("brush.new", &json!({"type": "art", "name": "Bar", "ids": [r.0]})).unwrap();
|
||||
let path = line(&mut s);
|
||||
s.execute("brush.apply", &json!({"name": "Bar", "ids": [path.0]})).unwrap();
|
||||
let thin = brushed_bounds(&s, path).height();
|
||||
// A path painted with a brush made from the taller art: what the stroke should draw.
|
||||
let tall = rect(&mut s, 10.0, 220.0, 40.0, 20.0);
|
||||
s.execute("brush.new", &json!({"type": "art", "name": "Tall", "ids": [tall.0]})).unwrap();
|
||||
let reference = line(&mut s);
|
||||
s.execute("brush.apply", &json!({"name": "Tall", "ids": [reference.0]})).unwrap();
|
||||
let want = brushed_bounds(&s, reference).height();
|
||||
assert!(want > thin * 2.0, "{want} against {thin}");
|
||||
// Apply to Strokes: the stroke redraws with the taller art.
|
||||
let steps = undo_steps(&s);
|
||||
let r = s.execute("brush.replaceArt", &json!({"name": "Bar", "ids": [tall.0]})).unwrap();
|
||||
assert_eq!(r["name"], "Bar");
|
||||
assert_eq!(undo_steps(&s), steps + 1);
|
||||
assert!((brushed_bounds(&s, path).height() - want).abs() < 1e-6);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert!((brushed_bounds(&s, path).height() - thin).abs() < 1e-9, "undo puts the old art back");
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
// Leave Strokes: the stroke keeps Bar as it was; Bar copy has the new art, after Bar, current.
|
||||
let short = rect(&mut s, 10.0, 260.0, 40.0, 4.0);
|
||||
let bar = s.execute("brush.get", &json!({"name": "Bar"})).unwrap();
|
||||
let r = s.execute("brush.replaceArt", &json!({"name": "Bar", "ids": [short.0], "applyToStrokes": false})).unwrap();
|
||||
assert_eq!(r["name"], "Bar copy");
|
||||
assert_eq!(brush_of(&s, path).as_deref(), Some("Bar"));
|
||||
assert_eq!(s.execute("brush.get", &json!({"name": "Bar"})).unwrap(), bar);
|
||||
assert!((brushed_bounds(&s, path).height() - want).abs() < 1e-6);
|
||||
let copy: Node = serde_json::from_value(s.execute("brush.get", &json!({"name": "Bar copy"})).unwrap()["art"].clone()).unwrap();
|
||||
assert!((copy.geometric_bounds().unwrap().height() - 4.0).abs() < 1e-6);
|
||||
let list = s.execute("brush.list", &json!({})).unwrap();
|
||||
assert_eq!(list["current"], "Bar copy");
|
||||
let names: Vec<&str> = list["brushes"].as_array().unwrap().iter().map(|b| b["name"].as_str().unwrap()).collect();
|
||||
let at = names.iter().position(|n| *n == "Bar").unwrap();
|
||||
assert_eq!(names.get(at + 1), Some(&"Bar copy"));
|
||||
// No stroke uses Bar copy: its art changes in place, with or without applying.
|
||||
s.execute("brush.replaceArt", &json!({"name": "Bar copy", "ids": [tall.0], "applyToStrokes": false})).unwrap();
|
||||
assert!(s.execute("brush.get", &json!({"name": "Bar copy 2"})).is_err());
|
||||
}
|
||||
|
||||
/// `brush.replaceArt` refuses a brush without art, an unknown brush, an empty selection, art with no
|
||||
/// width and an `applyToStrokes` that is not a boolean, and changes nothing then.
|
||||
#[test]
|
||||
fn replace_art_refuses_what_it_cannot_take() {
|
||||
let mut s = session();
|
||||
let r = rect(&mut s, 10.0, 20.0, 40.0, 8.0);
|
||||
let flat = s.execute("shape.line", &json!({"x1": 50, "y1": 100, "x2": 50, "y2": 160})).unwrap()["id"].as_u64().unwrap();
|
||||
let lib = s.execute("brush.list", &json!({})).unwrap();
|
||||
let steps = undo_steps(&s);
|
||||
for (p, msg) in [
|
||||
(json!({"name": "3 pt. Round", "ids": [r.0]}), "`3 pt. Round` has no art (only scatter, art and pattern brushes do)"),
|
||||
(json!({"name": "Bristle Round", "ids": [r.0]}), "`Bristle Round` has no art (only scatter, art and pattern brushes do)"),
|
||||
(json!({"name": "Nope", "ids": [r.0]}), "no brush named `Nope`"),
|
||||
(json!({"name": "Arrow", "ids": [flat]}), "the selected art has no width"),
|
||||
(json!({"name": "Chain", "ids": [flat]}), "the selected art has no width"),
|
||||
(json!({"name": "Arrow", "ids": [r.0], "applyToStrokes": "no"}), "`applyToStrokes` must be true or false"),
|
||||
] {
|
||||
let e = s.execute("brush.replaceArt", &p).unwrap_err();
|
||||
assert!(e.to_string().contains(msg), "{p}: {e}");
|
||||
}
|
||||
s.select(|_, sel| sel.clear()).unwrap();
|
||||
let e = s.execute("brush.replaceArt", &json!({"name": "Arrow"})).unwrap_err();
|
||||
assert!(e.to_string().contains("nothing selected"), "{e}");
|
||||
assert_eq!(undo_steps(&s), steps);
|
||||
assert_eq!(s.execute("brush.list", &json!({})).unwrap(), lib);
|
||||
}
|
||||
|
||||
/// An instance of a symbol whose art has no width is art with no width for `brush.new` and
|
||||
/// `brush.replaceArt`, although an instance's box without its document has width.
|
||||
#[test]
|
||||
fn a_symbol_whose_art_has_no_width_makes_no_brush_art() {
|
||||
let mut s = session();
|
||||
let flat = NodeId(s.execute("shape.line", &json!({"x1": 50, "y1": 100, "x2": 50, "y2": 160})).unwrap()["id"].as_u64().unwrap());
|
||||
let art = node(&s, flat);
|
||||
s.execute("edit.clear", &json!({"ids": [flat.0]})).unwrap();
|
||||
let st = s.doc_mut().unwrap();
|
||||
let d = std::sync::Arc::make_mut(&mut st.doc);
|
||||
d.symbols.push(vectorcraft_doc::Symbol { dynamic: false, name: "Flat".into(), art: std::sync::Arc::new(art) });
|
||||
let layer = d.layers[0].id;
|
||||
let inst = d.alloc_id();
|
||||
d.insert(Some(layer), usize::MAX, Node::new(inst, NodeKind::SymbolInstance { symbol: "Flat".into(), xf: vectorcraft_geom::Affine::IDENTITY }))
|
||||
.unwrap();
|
||||
assert!(node(&s, inst).geometric_bounds().is_some_and(|b| b.width() > 1.0), "the box an instance has without its document");
|
||||
for (cmd, p) in [("brush.new", json!({"type": "art", "ids": [inst.0]})), ("brush.replaceArt", json!({"name": "Arrow", "ids": [inst.0]}))] {
|
||||
let e = s.execute(cmd, &p).unwrap_err();
|
||||
assert!(e.to_string().contains("the selected art has no width"), "{cmd}: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
/// `brush.replaceArt` checks only the art it is given: a tile the pattern brush already has that
|
||||
/// has no width does not stop another tile from being replaced.
|
||||
#[test]
|
||||
fn replace_art_checks_only_the_tiles_it_is_given() {
|
||||
let mut s = session();
|
||||
let flat = NodeId(s.execute("shape.line", &json!({"x1": 50, "y1": 100, "x2": 50, "y2": 160})).unwrap()["id"].as_u64().unwrap());
|
||||
let end = art_json(&mut s, flat);
|
||||
s.execute("brush.options", &json!({"name": "Chain", "params": {"end": end}})).unwrap();
|
||||
let r = rect(&mut s, 10.0, 20.0, 40.0, 8.0);
|
||||
s.execute("brush.replaceArt", &json!({"name": "Chain", "ids": [r.0]})).unwrap();
|
||||
let side: Node = serde_json::from_value(s.execute("brush.get", &json!({"name": "Chain"})).unwrap()["side"].clone()).unwrap();
|
||||
assert!(close(side.geometric_bounds().unwrap(), bounds(&s, r), 1e-6));
|
||||
}
|
||||
|
||||
/// Tile `key` (`side`, `start`…) of pattern brush `name`.
|
||||
fn tile_art(s: &mut Session, name: &str, key: &str) -> Node {
|
||||
serde_json::from_value(s.execute("brush.get", &json!({"name": name})).unwrap()[key].clone()).unwrap()
|
||||
}
|
||||
|
||||
/// A pattern brush tile placed with `brush.placeArt` and given back with `brush.replaceArt` is the
|
||||
/// art it was, not that art inside the tile's group, however many times it goes out and back.
|
||||
#[test]
|
||||
fn pattern_tiles_go_out_and_back_without_gaining_a_group() {
|
||||
let mut s = session();
|
||||
let name = framed_pattern_brush(&mut s);
|
||||
let size = |n: &Node| {
|
||||
let b = n.geometric_bounds().unwrap();
|
||||
(b.width(), b.height())
|
||||
};
|
||||
let first = tile_art(&mut s, &name, "side");
|
||||
assert!(matches!(first.kind, NodeKind::Path { .. }), "{:?}", first.kind);
|
||||
for round in 1..=2 {
|
||||
let id = s.execute("brush.placeArt", &json!({"name": name})).unwrap()["id"].as_u64().unwrap();
|
||||
s.execute("brush.replaceArt", &json!({"name": name, "ids": [id]})).unwrap();
|
||||
let side = tile_art(&mut s, &name, "side");
|
||||
assert!(matches!(side.kind, NodeKind::Path { .. }), "round {round}: {:?}", side.kind);
|
||||
let (a, b) = (size(&first), size(&side));
|
||||
assert!((a.0 - b.0).abs() < 1e-6 && (a.1 - b.1).abs() < 1e-6, "round {round}: {a:?} → {b:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A tile group whose art was deleted, leaving only the rectangle that marks its frame, is art with
|
||||
/// no width: the brush keeps its tile.
|
||||
#[test]
|
||||
fn a_tile_group_holding_only_its_frame_is_refused() {
|
||||
let mut s = session();
|
||||
let name = framed_pattern_brush(&mut s);
|
||||
let before = s.execute("brush.get", &json!({"name": name})).unwrap();
|
||||
let id = NodeId(s.execute("brush.placeArt", &json!({"name": name})).unwrap()["id"].as_u64().unwrap());
|
||||
let side = node(&s, id).children().unwrap()[0].clone();
|
||||
assert_eq!(side.name.as_deref(), Some("Side Tile"));
|
||||
let art = side.children().unwrap()[1].id;
|
||||
s.execute("edit.clear", &json!({"ids": [art.0]})).unwrap();
|
||||
let steps = undo_steps(&s);
|
||||
let e = s.execute("brush.replaceArt", &json!({"name": name, "ids": [side.id.0]})).unwrap_err();
|
||||
assert!(e.to_string().contains("the selected art has no width"), "{e}");
|
||||
assert_eq!(undo_steps(&s), steps);
|
||||
assert_eq!(s.execute("brush.get", &json!({"name": name})).unwrap(), before);
|
||||
}
|
||||
|
||||
/// Two groups named for the same tile: the frontmost one is the tile's art.
|
||||
#[test]
|
||||
fn the_frontmost_group_named_for_a_tile_is_that_tile() {
|
||||
let mut s = session();
|
||||
let name = framed_pattern_brush(&mut s);
|
||||
let back = rect(&mut s, 10.0, 10.0, 20.0, 10.0);
|
||||
let front = rect(&mut s, 10.0, 40.0, 30.0, 10.0);
|
||||
let (back, front) = (node(&s, back), node(&s, front));
|
||||
s.execute("edit.clear", &json!({"ids": [back.id.0, front.id.0]})).unwrap();
|
||||
let st = s.doc_mut().unwrap();
|
||||
let d = std::sync::Arc::make_mut(&mut st.doc);
|
||||
let tile = |d: &mut Document, n: Node| {
|
||||
let mut g = Node::group(d.alloc_id(), vec![std::sync::Arc::new(n)]);
|
||||
g.name = Some("Start Tile".into());
|
||||
std::sync::Arc::new(g)
|
||||
};
|
||||
let tiles = vec![tile(d, back), tile(d, front)];
|
||||
let both = Node::group(d.alloc_id(), tiles);
|
||||
let both_id = both.id;
|
||||
let layer = d.layers[0].id;
|
||||
d.insert(Some(layer), usize::MAX, both).unwrap();
|
||||
s.execute("brush.replaceArt", &json!({"name": name, "ids": [both_id.0]})).unwrap();
|
||||
let start = tile_art(&mut s, &name, "start");
|
||||
assert!((start.geometric_bounds().unwrap().width() - 30.0).abs() < 1e-6, "{:?}", start.geometric_bounds());
|
||||
}
|
||||
|
||||
/// Type is art for `brush.replaceArt` as it is for `brush.new`: taken as it is.
|
||||
#[test]
|
||||
fn replace_art_takes_type_as_brush_new_does() {
|
||||
let mut s = session();
|
||||
let t = s.execute("text.create", &json!({"x": 20, "y": 60, "text": "Hi", "size": 24})).unwrap()["id"].as_u64().unwrap();
|
||||
let want = art_json(&mut s, NodeId(t));
|
||||
s.execute("brush.replaceArt", &json!({"name": "Arrow", "ids": [t]})).unwrap();
|
||||
assert_eq!(s.execute("brush.get", &json!({"name": "Arrow"})).unwrap()["art"], want);
|
||||
let made = s.execute("brush.new", &json!({"type": "art", "ids": [t]})).unwrap()["name"].as_str().unwrap().to_string();
|
||||
assert_eq!(s.execute("brush.get", &json!({"name": made})).unwrap()["art"], want);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn brush_options_rename_duplicate_and_delete_update_strokes() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -293,9 +293,7 @@ pub(super) fn drag_art_out(app: &VectorcraftApp, ui: &Ui, resp: &egui::Response,
|
||||
let tool = app.session.tool_id();
|
||||
let Some(st) = app.session.active().filter(|_| matches!(tool, "selection" | "directSelection" | "groupSelection")) else { return false };
|
||||
// The tool's interaction while it moves (or Alt-copies) the selection.
|
||||
if !st.interaction.as_ref().is_some_and(|i| i.label == "Move" || i.label == "Copy") {
|
||||
return false;
|
||||
}
|
||||
let Some(it) = st.interaction.as_ref().filter(|i| i.label == "Move" || i.label == "Copy") else { return false };
|
||||
if tool != "selection" && st.selection.objects.iter().any(|id| st.selection.partial(*id).is_some() || st.selection.segments.contains_key(id)) {
|
||||
return false;
|
||||
}
|
||||
@@ -305,7 +303,9 @@ pub(super) fn drag_art_out(app: &VectorcraftApp, ui: &Ui, resp: &egui::Response,
|
||||
if on_canvas(ui, resp, p) && ui.input(|i| i.pointer.has_pointer()) {
|
||||
return false;
|
||||
}
|
||||
let ids = st.selection.objects.clone();
|
||||
// The art the drag started with: the release rolls the move back to it, and an Alt-copy's
|
||||
// copies, selected while it previews, go with that.
|
||||
let ids = it.selection.objects.clone();
|
||||
egui::DragAndDrop::set_payload(ui.ctx(), widgets::PanelDrag::Art(ids));
|
||||
true
|
||||
}
|
||||
|
||||
@@ -7206,6 +7206,36 @@ fn art_moved_off_the_canvas_waits_and_drops_on_the_panel() {
|
||||
assert_eq!(st.history.undo.len(), undo);
|
||||
}
|
||||
|
||||
/// Art Alt-dragged off the canvas (a copy while it moves there) reaches the panels as the art the
|
||||
/// drag started with, which is what stays when the release over a panel takes the copy back.
|
||||
#[test]
|
||||
fn art_alt_dragged_off_the_canvas_reaches_the_panels_as_the_original() {
|
||||
use egui::{Event, Modifiers};
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.session.execute("file.new", &json!({"width": 400, "height": 300})).unwrap();
|
||||
let id = app.session.execute("shape.rectangle", &json!({"x": 50, "y": 50, "width": 100, "height": 100})).unwrap()["id"].as_u64().unwrap();
|
||||
let id = vectorcraft_doc::NodeId(id);
|
||||
app.select_tool("selection");
|
||||
let ctx = egui::Context::default();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
let xf = Xf::new(app.canvas_rect.unwrap(), app.view().unwrap());
|
||||
let before = app.session.active().unwrap().doc.clone();
|
||||
let button = |pos: Pos2, pressed: bool| Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Modifiers::ALT };
|
||||
let start = xf.to_screen(Point::new(100.0, 100.0));
|
||||
frame(&mut app, &ctx, vec![Event::ModifiersChanged(Modifiers::ALT), Event::PointerMoved(start), button(start, true)]);
|
||||
frame(&mut app, &ctx, vec![Event::PointerMoved(start + vec2(40.0, 0.0))]);
|
||||
let st = app.session.active().unwrap();
|
||||
assert_eq!(st.interaction.as_ref().map(|i| i.label.as_str()), Some("Copy"));
|
||||
assert!(!st.selection.objects.contains(&id), "the copy is selected while it moves");
|
||||
frame(&mut app, &ctx, vec![Event::PointerMoved(pos2(850.0, 100.0))]);
|
||||
assert_eq!(egui::DragAndDrop::payload::<widgets::PanelDrag>(&ctx).as_deref(), Some(&widgets::PanelDrag::Art(vec![id])));
|
||||
frame(&mut app, &ctx, vec![button(pos2(850.0, 100.0), false)]);
|
||||
let st = app.session.active().unwrap();
|
||||
assert!(st.interaction.is_none());
|
||||
assert_eq!(*st.doc, *before, "the copy goes, the original stays");
|
||||
assert!(st.doc.node(id).is_some());
|
||||
}
|
||||
|
||||
/// #4233: the Direct and Group Selection tools hand art they move whole to the panels too (Asset
|
||||
/// Export, Graphic Styles…), as the Selection tool does; the move waits and nothing is recorded.
|
||||
#[test]
|
||||
|
||||
@@ -18,6 +18,7 @@ pub mod blend_options;
|
||||
mod brush_art_options;
|
||||
pub mod brush_delete;
|
||||
pub mod brush_options;
|
||||
pub mod brush_replace_art;
|
||||
pub mod bullets_numbering;
|
||||
pub mod char_style_options;
|
||||
pub mod color_balance;
|
||||
@@ -322,6 +323,7 @@ registry! {
|
||||
SwatchOptions: [swatch_options::KIND] => swatch_options::SPEC,
|
||||
Confirm: [confirm::KIND] => confirm::SPEC,
|
||||
BrushDelete: [brush_delete::KIND] => brush_delete::SPEC,
|
||||
BrushReplaceArt: [brush_replace_art::KIND] => brush_replace_art::SPEC,
|
||||
Message: [confirm::MESSAGE] => confirm::MESSAGE_SPEC,
|
||||
Replace: [confirm::REPLACE] => confirm::REPLACE_SPEC,
|
||||
ResetPreferences: [confirm::RESET_PREFS] => confirm::RESET_PREFS_SPEC,
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
//! The Brushes panel's question when art Alt-dragged (Option-dragged on macOS) onto a brush that
|
||||
//! strokes use is to replace its art ([`ask`]): Apply to Strokes, Leave Strokes or Cancel. Apply to
|
||||
//! Strokes runs `brush.replaceArt` and the strokes redraw with the new art; Leave Strokes runs it
|
||||
//! with `applyToStrokes: false`, which keeps the brush and its strokes as they were and adds a copy
|
||||
//! of the brush with the new art.
|
||||
//!
|
||||
//! Fields: `name` (the brush), `ids` (the art), `apply` (set by the button pressed) and `__doc` (the
|
||||
//! uid of the document it asks about).
|
||||
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use super::{DialogAction, DialogSpec};
|
||||
use crate::VectorcraftApp;
|
||||
use crate::state::Dialog;
|
||||
use crate::widgets;
|
||||
|
||||
/// The dialog kind of the question.
|
||||
pub const KIND: &str = "brushReplaceArt";
|
||||
|
||||
pub(super) const SPEC: DialogSpec = DialogSpec {
|
||||
heading: |_| {
|
||||
tl!("Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art?")
|
||||
.to_string()
|
||||
},
|
||||
body_with_actions: Some(body),
|
||||
confirm,
|
||||
ok: None,
|
||||
max_width: Some(540.0),
|
||||
..DialogSpec::FORM
|
||||
};
|
||||
|
||||
/// The field that holds the uid of the document the question is about.
|
||||
const DOC: &str = "__doc";
|
||||
|
||||
/// Replace the art of brush `name` with the objects `ids`: at once when no stroke uses the brush,
|
||||
/// else after asking whether the strokes take the new art. Art the brush cannot take (art with no
|
||||
/// width, say) is refused before anything asks, with the reason in the status bar.
|
||||
pub fn replace(app: &mut VectorcraftApp, name: &str, ids: &[u64]) {
|
||||
let params = json!({"name": name, "ids": ids});
|
||||
if super::brush_delete::used(app, &[name.to_string()]) != Some(true) {
|
||||
if let Err(e) = app.run("brush.replaceArt", params) {
|
||||
app.status(e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// A preview on a copy of the document checks the art without changing anything.
|
||||
if !app.session.in_interaction() && app.session.begin_interaction("Replace Brush Art").is_ok() {
|
||||
let checked = app.session.preview("brush.replaceArt", ¶ms);
|
||||
// The interaction began above, on the active document: ending it puts that document back
|
||||
// as it was, and can fail only when no document is open, when there is nothing to put back.
|
||||
let _ = app.session.cancel_interaction();
|
||||
if let Err(e) = checked {
|
||||
app.status(e.to_string());
|
||||
return;
|
||||
}
|
||||
}
|
||||
ask(app, name, ids);
|
||||
}
|
||||
|
||||
/// Ask whether the strokes that use brush `name` take the art of the objects `ids`.
|
||||
pub fn ask(app: &mut VectorcraftApp, name: &str, ids: &[u64]) {
|
||||
let doc = app.session.active().map(|d| d.uid);
|
||||
app.ui.dialog = Some(Dialog::new(KIND, json!({"name": name, "ids": ids, "apply": true, DOC: doc})));
|
||||
}
|
||||
|
||||
fn body(_: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> DialogAction {
|
||||
let mut action = DialogAction::None;
|
||||
ui.horizontal(|ui| {
|
||||
if widgets::primary_button_enabled(ui, tl!("Apply to Strokes"), true).clicked() {
|
||||
d.fields.insert("apply".into(), json!(true));
|
||||
action = DialogAction::Confirm;
|
||||
}
|
||||
if widgets::secondary_button(ui, tl!("Leave Strokes")).clicked() {
|
||||
d.fields.insert("apply".into(), json!(false));
|
||||
action = DialogAction::Confirm;
|
||||
}
|
||||
if widgets::secondary_button(ui, tl!("Cancel")).clicked() {
|
||||
action = DialogAction::Cancel;
|
||||
}
|
||||
});
|
||||
action
|
||||
}
|
||||
|
||||
/// Closes before running. When another document has become the active one, it closes as Cancel does
|
||||
/// and changes no brush.
|
||||
fn confirm(app: &mut VectorcraftApp, d: &Dialog) -> Result<Value, String> {
|
||||
app.ui.dialog = None;
|
||||
if d.fields.get(DOC).and_then(Value::as_u64) != app.session.active().map(|doc| doc.uid) {
|
||||
return Ok(json!({}));
|
||||
}
|
||||
let params = json!({
|
||||
"name": d.fields.get("name").cloned().unwrap_or(Value::Null),
|
||||
"ids": d.fields.get("ids").cloned().unwrap_or_else(|| json!([])),
|
||||
"applyToStrokes": d.bool("apply"),
|
||||
});
|
||||
app.run("brush.replaceArt", params)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -0,0 +1,133 @@
|
||||
use egui::{Pos2, Rect, pos2, vec2};
|
||||
use serde_json::json;
|
||||
use vectorcraft_doc::NodeId;
|
||||
use vectorcraft_engine::Session;
|
||||
|
||||
use super::*;
|
||||
|
||||
fn frame(ctx: &egui::Context, app: &mut VectorcraftApp, events: Vec<egui::Event>, time: f64) -> egui::FullOutput {
|
||||
let screen_rect = Some(Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0)));
|
||||
let input = egui::RawInput { screen_rect, time: Some(time), events, ..Default::default() };
|
||||
let mut out = ctx.run_ui(input, |ui| crate::dialogs::show(app, ui.ctx()));
|
||||
out.textures_delta.clear();
|
||||
out
|
||||
}
|
||||
|
||||
fn press(ctx: &egui::Context, app: &mut VectorcraftApp, label: &str, time: f64) {
|
||||
frame(ctx, app, vec![], time);
|
||||
let out = frame(ctx, app, vec![], time + 0.1);
|
||||
let nodes = &out.platform_output.accesskit_update.as_ref().expect("dialog accessibility tree").nodes;
|
||||
let button = nodes.iter().find(|(_, node)| node.label().map(str::trim) == Some(label));
|
||||
let bounds = button.and_then(|(_, node)| node.bounds()).expect("visible button");
|
||||
let at = pos2(((bounds.x0 + bounds.x1) / 2.0) as f32, ((bounds.y0 + bounds.y1) / 2.0) as f32);
|
||||
let button = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE };
|
||||
frame(ctx, app, vec![egui::Event::PointerMoved(at), button(true), button(false)], time + 0.2);
|
||||
}
|
||||
|
||||
fn context() -> egui::Context {
|
||||
let ctx = egui::Context::default();
|
||||
ctx.enable_accesskit();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
crate::theme::apply(&ctx, Default::default());
|
||||
ctx
|
||||
}
|
||||
|
||||
fn rect(app: &mut VectorcraftApp, x: f64, y: f64, w: f64, h: f64) -> u64 {
|
||||
app.run("shape.rectangle", json!({"x": x, "y": y, "width": w, "height": h})).unwrap()["id"].as_u64().unwrap()
|
||||
}
|
||||
|
||||
fn art_height(app: &mut VectorcraftApp, name: &str) -> f64 {
|
||||
let art: vectorcraft_doc::Node = serde_json::from_value(app.run("brush.get", json!({"name": name})).unwrap()["art"].clone()).unwrap();
|
||||
art.geometric_bounds().unwrap().height()
|
||||
}
|
||||
|
||||
/// An art brush "Bar" (40 × 8 pt) painting a path, and a 40 × 20 pt rectangle: → (path, rectangle).
|
||||
fn used_brush(app: &mut VectorcraftApp) -> (NodeId, u64) {
|
||||
app.run("file.new", json!({"width": 300, "height": 200})).unwrap();
|
||||
let bar = rect(app, 10.0, 10.0, 40.0, 8.0);
|
||||
app.run("brush.new", json!({"type": "art", "name": "Bar", "ids": [bar]})).unwrap();
|
||||
let path = NodeId(rect(app, 100.0, 100.0, 80.0, 40.0));
|
||||
app.run("brush.apply", json!({"name": "Bar", "ids": [path.0]})).unwrap();
|
||||
(path, rect(app, 10.0, 40.0, 40.0, 20.0))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unused_brush_takes_the_art_without_asking() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 300, "height": 200})).unwrap();
|
||||
let bar = rect(&mut app, 10.0, 10.0, 40.0, 8.0);
|
||||
app.run("brush.new", json!({"type": "art", "name": "Bar", "ids": [bar]})).unwrap();
|
||||
let tall = rect(&mut app, 10.0, 40.0, 40.0, 20.0);
|
||||
replace(&mut app, "Bar", &[tall]);
|
||||
assert!(app.ui.dialog.is_none());
|
||||
assert!((art_height(&mut app, "Bar") - 20.0).abs() < 1e-6);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn apply_to_strokes_gives_the_brush_the_new_art() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
let (path, tall) = used_brush(&mut app);
|
||||
replace(&mut app, "Bar", &[tall]);
|
||||
assert!(app.ui.dialog.as_ref().is_some_and(|d| d.kind == KIND), "strokes use Bar: it asks");
|
||||
let ctx = context();
|
||||
let before = app.session.active().unwrap().history.undo.len();
|
||||
press(&ctx, &mut app, "Apply to Strokes", 0.0);
|
||||
assert!(app.ui.dialog.is_none());
|
||||
assert_eq!(app.session.active().unwrap().history.undo.len(), before + 1);
|
||||
assert!((art_height(&mut app, "Bar") - 20.0).abs() < 1e-6);
|
||||
let stroke = app.session.active().unwrap().doc.node(path).and_then(|n| n.appearance.stroke()).unwrap();
|
||||
assert_eq!(stroke.brush.as_deref(), Some("Bar"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn leave_strokes_adds_a_copy_and_cancel_changes_nothing() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
let (path, tall) = used_brush(&mut app);
|
||||
let ctx = context();
|
||||
let before = app.session.active().unwrap().history.undo.len();
|
||||
replace(&mut app, "Bar", &[tall]);
|
||||
press(&ctx, &mut app, "Cancel", 0.0);
|
||||
assert!(app.ui.dialog.is_none());
|
||||
assert_eq!(app.session.active().unwrap().history.undo.len(), before);
|
||||
assert!((art_height(&mut app, "Bar") - 8.0).abs() < 1e-6);
|
||||
replace(&mut app, "Bar", &[tall]);
|
||||
press(&ctx, &mut app, "Leave Strokes", 1.0);
|
||||
assert_eq!(app.session.active().unwrap().history.undo.len(), before + 1);
|
||||
assert!((art_height(&mut app, "Bar") - 8.0).abs() < 1e-6, "Bar stays as it was");
|
||||
assert!((art_height(&mut app, "Bar copy") - 20.0).abs() < 1e-6);
|
||||
let stroke = app.session.active().unwrap().doc.node(path).and_then(|n| n.appearance.stroke()).unwrap();
|
||||
assert_eq!(stroke.brush.as_deref(), Some("Bar"));
|
||||
}
|
||||
|
||||
/// Art a used brush cannot take is refused before the question: no dialog, the reason in the status
|
||||
/// bar, and the document and its undo history as they were.
|
||||
#[test]
|
||||
fn art_with_no_width_is_refused_before_it_asks() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
let _ = used_brush(&mut app);
|
||||
let flat = app.run("shape.line", json!({"x1": 50, "y1": 100, "x2": 50, "y2": 160})).unwrap()["id"].as_u64().unwrap();
|
||||
let st = app.session.active().unwrap();
|
||||
let (doc, steps) = (st.doc.clone(), st.history.undo.len());
|
||||
replace(&mut app, "Bar", &[flat]);
|
||||
assert!(app.ui.dialog.is_none(), "nothing asks");
|
||||
assert!(app.ui.status.contains("the selected art has no width"), "{}", app.ui.status);
|
||||
let st = app.session.active().unwrap();
|
||||
assert!(st.interaction.is_none());
|
||||
assert_eq!(*st.doc, *doc);
|
||||
assert_eq!(st.history.undo.len(), steps);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_button_changes_no_brush_after_another_document_became_active() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
let (_, tall) = used_brush(&mut app);
|
||||
let ctx = context();
|
||||
replace(&mut app, "Bar", &[tall]);
|
||||
app.run("file.new", json!({"width": 200, "height": 100})).unwrap();
|
||||
app.run("document.activate", json!({"index": 0})).unwrap();
|
||||
app.run("document.activate", json!({"index": 1})).unwrap();
|
||||
press(&ctx, &mut app, "Apply to Strokes", 0.0);
|
||||
assert!(app.ui.dialog.is_none());
|
||||
app.run("document.activate", json!({"index": 0})).unwrap();
|
||||
assert!((art_height(&mut app, "Bar") - 8.0).abs() < 1e-6);
|
||||
}
|
||||
@@ -6365,6 +6365,10 @@ breakText Glyphs Глифи
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Щрихи използват една или повече от тези четки. Да се премахнат ли четките от тези щрихи и да се изтрият четките?
|
||||
Remove Strokes Премахване на щрихи
|
||||
Place Brush Art Поставяне на графика на четка
|
||||
Replace Brush Art Замяна на графика на четка
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Щрихи използват тази четка. Да се приложи ли новата графика към тези щрихи, или те да останат както са и да се добави копие на четката с новата графика?
|
||||
Apply to Strokes Прилагане към щрихите
|
||||
Leave Strokes Оставяне на щрихите
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` няма графика (имат я само разпръснатите и артистичните четки и четките с мостра)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Инструменти за подреждане
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6415,6 +6415,10 @@ shape Open Otvoren
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Potezi koriste jednu ili više ovih četkica. Ukloniti četkice s tih poteza i izbrisati četkice?
|
||||
Remove Strokes Ukloni poteze
|
||||
Place Brush Art Postavi crtež četkice
|
||||
Replace Brush Art Zamijeni crtež četkice
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Potezi koriste ovu četkicu. Primijeniti novi crtež na te poteze ili ih ostaviti kakvi jesu i dodati kopiju četkice s novim crtežom?
|
||||
Apply to Strokes Primijeni na poteze
|
||||
Leave Strokes Ostavi poteze
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` nema crtež (imaju ga samo raspršene i umjetničke četkice i četkice uzorka)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Alati za raspoređivanje
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6621,6 +6621,10 @@ breakText Glyphs Glifs
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Hi ha traços que fan servir un o més d’aquests pinzells. Voleu treure els pinzells d’aquests traços i suprimir els pinzells?
|
||||
Remove Strokes Elimina els traços
|
||||
Place Brush Art Col·loca l’art del pinzell
|
||||
Replace Brush Art Substitueix l’art del pinzell
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Hi ha traços que fan servir aquest pinzell. Voleu aplicar l’art nou a aquests traços, o deixar-los com estan i afegir una còpia del pinzell amb l’art nou?
|
||||
Apply to Strokes Aplica als traços
|
||||
Leave Strokes Deixa els traços
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` no té art (només en tenen els pinzells de dispersió, artístics i de motiu)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Eines d’organització
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6640,6 +6640,10 @@ breakText Glyphs Glyfy
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Tahy používají jeden nebo více z těchto štětců. Odebrat štětce z těchto tahů a odstranit štětce?
|
||||
Remove Strokes Odebrat tahy
|
||||
Place Brush Art Umístit kresbu štětce
|
||||
Replace Brush Art Nahradit kresbu štětce
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Tahy používají tento štětec. Použít novou kresbu na tyto tahy, nebo je ponechat beze změny a přidat kopii štětce s novou kresbou?
|
||||
Apply to Strokes Použít na tahy
|
||||
Leave Strokes Ponechat tahy
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` nemá kresbu (mají ji jen rozptylové, obrazové a vzorkové štětce)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Nástroje uspořádání
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6379,6 +6379,10 @@ breakText Glyphs Glyffer
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Streger bruger en eller flere af disse pensler. Fjern penslerne fra stregerne, og slet penslerne?
|
||||
Remove Strokes Fjern streger
|
||||
Place Brush Art Placér penselgrafik
|
||||
Replace Brush Art Erstat penselgrafik
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Streger bruger denne pensel. Anvend den nye grafik på stregerne, eller lad dem være, som de er, og tilføj en kopi af penslen med den nye grafik?
|
||||
Apply to Strokes Anvend på streger
|
||||
Leave Strokes Bevar streger
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` har ingen grafik (det har kun sprednings-, grafik- og mønsterpensler)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Arrangeringsværktøjer
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6227,6 +6227,10 @@ breakText Glyphs Glyphen
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Konturen verwenden einen oder mehrere dieser Pinsel. Pinsel von diesen Konturen entfernen und die Pinsel löschen?
|
||||
Remove Strokes Konturen entfernen
|
||||
Place Brush Art Pinselgrafik platzieren
|
||||
Replace Brush Art Pinselgrafik ersetzen
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Konturen verwenden diesen Pinsel. Die neue Grafik auf diese Konturen anwenden oder sie unverändert lassen und eine Kopie des Pinsels mit der neuen Grafik hinzufügen?
|
||||
Apply to Strokes Auf Konturen anwenden
|
||||
Leave Strokes Konturen beibehalten
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` hat keine Grafik (nur Spezial-, Bild- und Musterpinsel haben eine)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Anordnungswerkzeuge
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6592,6 +6592,10 @@ breakText Glyphs Γλύφοι
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Περιγράμματα χρησιμοποιούν ένα ή περισσότερα από αυτά τα πινέλα. Να αφαιρεθούν τα πινέλα από αυτά τα περιγράμματα και να διαγραφούν τα πινέλα;
|
||||
Remove Strokes Αφαίρεση περιγραμμάτων
|
||||
Place Brush Art Τοποθέτηση σχεδίου πινέλου
|
||||
Replace Brush Art Αντικατάσταση σχεδίου πινέλου
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Περιγράμματα χρησιμοποιούν αυτό το πινέλο. Να εφαρμοστεί το νέο σχέδιο σε αυτά τα περιγράμματα ή να μείνουν ως έχουν και να προστεθεί αντίγραφο του πινέλου με το νέο σχέδιο;
|
||||
Apply to Strokes Εφαρμογή στα περιγράμματα
|
||||
Leave Strokes Διατήρηση περιγραμμάτων
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` δεν έχει σχέδιο (έχουν μόνο τα πινέλα διασποράς, σχεδίου και μοτίβου)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Εργαλεία διάταξης
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6583,6 +6583,10 @@ breakText Glyphs Glifos
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Algunos trazos usan uno o más de estos pinceles. ¿Quitar los pinceles de esos trazos y eliminar los pinceles?
|
||||
Remove Strokes Quitar trazos
|
||||
Place Brush Art Colocar ilustración del pincel
|
||||
Replace Brush Art Reemplazar ilustración del pincel
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Algunos trazos usan este pincel. ¿Aplicar la nueva ilustración a esos trazos, o dejarlos como están y añadir una copia del pincel con la nueva ilustración?
|
||||
Apply to Strokes Aplicar a los trazos
|
||||
Leave Strokes Dejar los trazos
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` no tiene ilustración (solo la tienen los pinceles de dispersión, de arte y de motivo)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Herramientas de organización
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6670,6 +6670,10 @@ breakText Glyphs Merkit
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Viivat käyttävät yhtä tai useampaa näistä siveltimistä. Irrotetaanko siveltimet näistä viivoista ja poistetaanko siveltimet?
|
||||
Remove Strokes Poista viivat
|
||||
Place Brush Art Sijoita siveltimen kuvitus
|
||||
Replace Brush Art Korvaa siveltimen kuvitus
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Viivat käyttävät tätä sivellintä. Käytetäänkö uutta kuvitusta näissä viivoissa, vai jätetäänkö ne ennalleen ja lisätään siveltimestä kopio, jossa on uusi kuvitus?
|
||||
Apply to Strokes Käytä viivoihin
|
||||
Leave Strokes Jätä viivat ennalleen
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` ei sisällä kuvitusta (kuvitus on vain sirote-, taide- ja kuviosiveltimissä)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Järjestelytyökalut
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6635,6 +6635,10 @@ breakText Glyphs Glyphes
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Des contours utilisent une ou plusieurs de ces formes. Retirer les formes de ces contours et supprimer les formes ?
|
||||
Remove Strokes Supprimer les contours
|
||||
Place Brush Art Placer l’illustration de la forme
|
||||
Replace Brush Art Remplacer l’illustration de la forme
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Des contours utilisent cette forme. Appliquer la nouvelle illustration à ces contours, ou les laisser tels quels et ajouter une copie de la forme avec la nouvelle illustration ?
|
||||
Apply to Strokes Appliquer aux contours
|
||||
Leave Strokes Conserver les contours
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` n’a pas d’illustration (seules les formes diffuses, artistiques et de motif en ont)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Outils de disposition
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3763,6 +3763,10 @@ antiAlias Sharp शार्प
|
||||
Remove Selected Entry सिलेक्टेड प्रविष्टि निकालें
|
||||
Remove Strokes स्ट्रोक हटाएँ
|
||||
Place Brush Art ब्रश आर्टवर्क रखें
|
||||
Replace Brush Art ब्रश आर्टवर्क बदलें
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? स्ट्रोक्स इस ब्रश का उपयोग कर रहे हैं। नया आर्टवर्क उन स्ट्रोक्स पर लागू करें, या उन्हें जैसा है वैसा छोड़कर नए आर्टवर्क वाले ब्रश की एक कॉपी जोड़ें?
|
||||
Apply to Strokes स्ट्रोक्स पर लागू करें
|
||||
Leave Strokes स्ट्रोक्स जैसे हैं वैसे छोड़ें
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` में कोई आर्टवर्क नहीं है (आर्टवर्क केवल स्कैटर, आर्ट और पैटर्न ब्रश में होता है)
|
||||
Remove the shortcut शॉर्टकट निकालें
|
||||
Remove Threading थ्रेडिंग निकालें
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6624,6 +6624,10 @@ breakText Glyphs Glifák
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Körvonalak használnak egyet vagy többet ezek közül az ecsetek közül. Leveszed az ecseteket ezekről a körvonalakról, és törlöd az ecseteket?
|
||||
Remove Strokes Körvonalak eltávolítása
|
||||
Place Brush Art Ecsetgrafika elhelyezése
|
||||
Replace Brush Art Ecsetgrafika cseréje
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Körvonalak használják ezt az ecsetet. Alkalmazod az új grafikát ezekre a körvonalakra, vagy változatlanul hagyod őket, és hozzáadod az ecset egy másolatát az új grafikával?
|
||||
Apply to Strokes Alkalmazás a körvonalakra
|
||||
Leave Strokes Körvonalak megtartása
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` ecsetnek nincs grafikája (csak a szóró-, a grafikus és a mintázatecseteknek van)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Elrendezőeszközök
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6379,6 +6379,10 @@ breakText Glyphs Glif
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Stroke menggunakan satu atau beberapa kuas ini. Lepaskan kuas dari stroke tersebut dan hapus kuasnya?
|
||||
Remove Strokes Hapus Stroke
|
||||
Place Brush Art Tempatkan karya seni kuas
|
||||
Replace Brush Art Ganti karya seni kuas
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Stroke menggunakan kuas ini. Terapkan karya seni baru ke stroke tersebut, atau biarkan apa adanya dan tambahkan salinan kuas dengan karya seni baru?
|
||||
Apply to Strokes Terapkan ke Stroke
|
||||
Leave Strokes Biarkan Stroke
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` tidak memiliki karya seni (hanya kuas sebar, kuas seni, dan kuas pola yang memilikinya)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Alat penyusunan
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2350 and column 5.
|
@@ -6261,6 +6261,10 @@ breakText Glyphs Glifi
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Alcune tracce usano uno o più di questi pennelli. Rimuovere i pennelli da queste tracce ed eliminare i pennelli?
|
||||
Remove Strokes Rimuovi tracce
|
||||
Place Brush Art Inserisci grafica del pennello
|
||||
Replace Brush Art Sostituisci grafica del pennello
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Alcune tracce usano questo pennello. Applicare la nuova grafica a queste tracce, o lasciarle come sono e aggiungere una copia del pennello con la nuova grafica?
|
||||
Apply to Strokes Applica alle tracce
|
||||
Leave Strokes Lascia le tracce
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` non ha una grafica (ce l’hanno solo i pennelli a dispersione, artistici e motivo)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Strumenti di disposizione
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6326,6 +6326,10 @@ breakText Glyphs 字形
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? これらのブラシの 1 つ以上が線で使われています。それらの線からブラシを外して、ブラシを削除しますか?
|
||||
Remove Strokes 線を削除
|
||||
Place Brush Art ブラシのアートを配置
|
||||
Replace Brush Art ブラシのアートを置き換え
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? このブラシは線で使われています。新しいアートをそれらの線に適用しますか?それとも線をそのままにして、新しいアートを持つブラシのコピーを追加しますか?
|
||||
Apply to Strokes 線に適用
|
||||
Leave Strokes 線を保持
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` にはアートがありません (アートを持つのは散布ブラシ、アートブラシ、パターンブラシだけです)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools 配置ツール
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6666,6 +6666,10 @@ breakText Glyphs გლიფები
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? კონტურები იყენებს ამ ფუნჯებიდან ერთს ან მეტს. მოიხსნას ფუნჯები ამ კონტურებიდან და წაიშალოს ფუნჯები?
|
||||
Remove Strokes კონტურების მოხსნა
|
||||
Place Brush Art ფუნჯის ნახატის განთავსება
|
||||
Replace Brush Art ფუნჯის ნახატის ჩანაცვლება
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? კონტურები იყენებს ამ ფუნჯს. გამოყენებულ იქნას ახალი ნახატი ამ კონტურებზე, თუ დარჩეს ისინი როგორც არის და დაემატოს ფუნჯის ასლი ახალი ნახატით?
|
||||
Apply to Strokes კონტურებზე გამოყენება
|
||||
Leave Strokes კონტურების დატოვება
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` ნახატი არ აქვს (ნახატი მხოლოდ გაფანტვის, მხატვრულ და პატერნის ფუნჯებს აქვს)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools განლაგების ხელსაწყოები
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6222,6 +6222,10 @@ breakText Glyphs 글리프
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? 선에서 이 브러시 중 하나 이상을 사용합니다. 해당 선에서 브러시를 제거하고 브러시를 삭제하시겠습니까?
|
||||
Remove Strokes 선 제거
|
||||
Place Brush Art 브러시 아트 배치
|
||||
Replace Brush Art 브러시 아트 바꾸기
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? 선에서 이 브러시를 사용합니다. 새 아트를 해당 선에 적용하시겠습니까, 아니면 선을 그대로 두고 새 아트로 브러시 사본을 추가하시겠습니까?
|
||||
Apply to Strokes 선에 적용
|
||||
Leave Strokes 선 유지
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}`에는 아트가 없습니다 (흩뿌리기, 아트, 패턴 브러시에만 아트가 있습니다)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools 배치 도구
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6430,6 +6430,10 @@ breakText Glyphs Glyphs
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Contouren gebruiken een of meer van deze kwasten. De kwasten van deze contouren halen en de kwasten verwijderen?
|
||||
Remove Strokes Contouren verwijderen
|
||||
Place Brush Art Penseelillustratie plaatsen
|
||||
Replace Brush Art Penseelillustratie vervangen
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Contouren gebruiken dit penseel. De nieuwe illustratie op deze contouren toepassen, of ze laten zoals ze zijn en een kopie van het penseel met de nieuwe illustratie toevoegen?
|
||||
Apply to Strokes Op contouren toepassen
|
||||
Leave Strokes Contouren behouden
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` heeft geen illustratie (alleen verspreidings-, art- en patroonpenselen hebben er een)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Schikgereedschappen
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6496,6 +6496,10 @@ breakText Glyphs Glify
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Obrysy używają co najmniej jednego z tych pędzli. Zdjąć pędzle z tych obrysów i usunąć pędzle?
|
||||
Remove Strokes Usuń obrysy
|
||||
Place Brush Art Umieść kompozycję pędzla
|
||||
Replace Brush Art Zastąp kompozycję pędzla
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Obrysy używają tego pędzla. Zastosować nową kompozycję do tych obrysów, czy pozostawić je bez zmian i dodać kopię pędzla z nową kompozycją?
|
||||
Apply to Strokes Zastosuj do obrysów
|
||||
Leave Strokes Pozostaw obrysy
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` nie ma kompozycji (mają ją tylko pędzle rozproszone, artystyczne i wzorka)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Narzędzia układania
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6558,6 +6558,10 @@ breakText Glyphs Glifos
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Traçados usam um ou mais destes pincéis. Remover os pincéis desses traçados e excluir os pincéis?
|
||||
Remove Strokes Remover Traçados
|
||||
Place Brush Art Colocar Arte do Pincel
|
||||
Replace Brush Art Substituir Arte do Pincel
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Traçados usam este pincel. Aplicar a nova arte a esses traçados, ou deixá-los como estão e adicionar uma cópia do pincel com a nova arte?
|
||||
Apply to Strokes Aplicar aos Traçados
|
||||
Leave Strokes Manter Traçados
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` não tem arte (só os pincéis de dispersão, de arte e de padrão têm)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Ferramentas de Organização
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -6617,6 +6617,10 @@ breakText Glyphs Глифы
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Обводки используют одну или несколько из этих кистей. Убрать кисти с этих обводок и удалить кисти?
|
||||
Remove Strokes Убрать обводки
|
||||
Place Brush Art Поместить рисунок кисти
|
||||
Replace Brush Art Заменить рисунок кисти
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Обводки используют эту кисть. Применить новый рисунок к этим обводкам или оставить их как есть и добавить копию кисти с новым рисунком?
|
||||
Apply to Strokes Применить к обводкам
|
||||
Leave Strokes Оставить обводки
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) у `{name}` нет рисунка (он есть только у кистей-распылений, художественных и узорных кистей)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Инструменты размещения
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6688,6 +6688,10 @@ breakText Glyphs Glyfer
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Konturer använder en eller flera av de här penslarna. Ta bort penslarna från konturerna och radera penslarna?
|
||||
Remove Strokes Ta bort konturer
|
||||
Place Brush Art Placera penselgrafik
|
||||
Replace Brush Art Ersätt penselgrafik
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Konturer använder den här penseln. Använd den nya grafiken på konturerna, eller låt dem vara som de är och lägg till en kopia av penseln med den nya grafiken?
|
||||
Apply to Strokes Använd på konturer
|
||||
Leave Strokes Behåll konturer
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` har ingen grafik (bara spridnings-, konst- och mönsterpenslar har grafik)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Ordningsverktyg
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 5 and column 25.
|
@@ -6596,6 +6596,10 @@ breakText Glyphs Glifler
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Konturlar bu fırçalardan birini veya daha fazlasını kullanıyor. Fırçalar bu konturlardan kaldırılsın ve fırçalar silinsin mi?
|
||||
Remove Strokes Konturları Kaldır
|
||||
Place Brush Art Fırça Çizimini Yerleştir
|
||||
Replace Brush Art Fırça Çizimini Değiştir
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Konturlar bu fırçayı kullanıyor. Yeni çizim bu konturlara uygulansın mı, yoksa konturlar olduğu gibi bırakılıp fırçanın yeni çizimli bir kopyası mı eklensin?
|
||||
Apply to Strokes Konturlara Uygula
|
||||
Leave Strokes Konturları Bırak
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` fırçasının çizimi yok (yalnızca serpme, resim ve desen fırçalarının çizimi vardır)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Düzenleme Araçları
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 5 and column 25.
|
@@ -6241,6 +6241,10 @@ breakText Glyphs Гліфи
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Обведення використовують один або кілька з цих пензлів. Забрати пензлі з цих обведень і видалити пензлі?
|
||||
Remove Strokes Забрати обведення
|
||||
Place Brush Art Розмістити малюнок пензля
|
||||
Replace Brush Art Замінити малюнок пензля
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Обведення використовують цей пензель. Застосувати новий малюнок до цих обведень чи залишити їх як є і додати копію пензля з новим малюнком?
|
||||
Apply to Strokes Застосувати до обведень
|
||||
Leave Strokes Залишити обведення
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) у `{name}` немає малюнка (він є лише в пензлів-розпорошень, художніх і візерункових пензлів)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Інструменти розміщення
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 182 and column 5.
|
@@ -6242,6 +6242,10 @@ breakText Glyphs Glyph
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? Có nét đang dùng một hoặc nhiều cọ này. Gỡ cọ khỏi các nét đó và xóa cọ?
|
||||
Remove Strokes Gỡ nét
|
||||
Place Brush Art Đặt đối tượng của cọ
|
||||
Replace Brush Art Thay đối tượng của cọ
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? Có nét đang dùng cọ này. Áp dụng đối tượng mới cho các nét đó, hay giữ nguyên chúng và thêm một bản sao của cọ với đối tượng mới?
|
||||
Apply to Strokes Áp dụng cho nét
|
||||
Leave Strokes Giữ nguyên nét
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` không có đối tượng (chỉ cọ phân tán, cọ bản vẽ và cọ họa tiết mới có)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools Công cụ sắp xếp
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 204 and column 5.
|
@@ -6481,6 +6481,10 @@ breakText Glyphs 字形
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? 有描边使用了其中一个或多个画笔。要从这些描边移除画笔并删除画笔吗?
|
||||
Remove Strokes 移除描边
|
||||
Place Brush Art 置入画笔图稿
|
||||
Replace Brush Art 替换画笔图稿
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? 有描边使用了此画笔。要将新图稿应用到这些描边,还是保留描边不变并添加一个使用新图稿的画笔副本?
|
||||
Apply to Strokes 应用于描边
|
||||
Leave Strokes 保留描边
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` 没有图稿 (只有散布画笔、艺术画笔和图案画笔有图稿)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools 排列工具
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6279,6 +6279,10 @@ breakText Glyphs 字符
|
||||
Strokes use one or more of these brushes. Take the brushes off those strokes and delete the brushes? 有筆畫使用了其中一個或多個筆刷。要從這些筆畫移除筆刷並刪除筆刷嗎?
|
||||
Remove Strokes 移除筆畫
|
||||
Place Brush Art 置入筆刷圖稿
|
||||
Replace Brush Art 取代筆刷圖稿
|
||||
Strokes use this brush. Apply the new art to those strokes, or leave them as they are and add a copy of the brush with the new art? 有筆畫使用了此筆刷。要將新圖稿套用到這些筆畫,還是保留筆畫不變並加入一個使用新圖稿的筆刷複本?
|
||||
Apply to Strokes 套用至筆畫
|
||||
Leave Strokes 保留筆畫
|
||||
@msg `{name}` has no art (only scatter, art and pattern brushes do) `{name}` 沒有圖稿 (只有散佈筆刷、藝術筆刷和圖樣筆刷有圖稿)
|
||||
# Arrange Tools add-on (Object › Plug-ins › Arrange Tools).
|
||||
Arrange Tools 排列工具
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3,7 +3,8 @@
|
||||
//! one opens its Brush Options. Shift-click selects a range of brushes, Cmd/Ctrl-click adds or
|
||||
//! removes one, and the panel menu's Select All Unused selects the brushes no stroke paints with,
|
||||
//! for Delete Brush and Duplicate Brush. A scatter, art or pattern brush dragged onto an empty part
|
||||
//! of the canvas places a copy of its art there. Brush libraries open in library panels
|
||||
//! of the canvas places a copy of its art there, and art from the canvas Alt-dragged (Option-dragged
|
||||
//! on macOS) onto such a brush replaces its art. Brush libraries open in library panels
|
||||
//! ([`BrushLibraries`]).
|
||||
|
||||
use std::cell::RefCell;
|
||||
@@ -270,6 +271,22 @@ fn reorder_drop(
|
||||
}
|
||||
}
|
||||
|
||||
/// Art dragged off the canvas and held over the tile or row `resp` of a scatter, art or pattern
|
||||
/// brush `name` (of type `ty`) with Alt (Option on macOS) held: the tile is outlined, and released
|
||||
/// there it sets `replaced` to the brush and the art's ids, whose art then replaces the brush's.
|
||||
/// Without Alt, or on another type of brush, the drop is left to the list, which opens New Brush.
|
||||
fn replace_drop(ui: &Ui, resp: &egui::Response, name: &str, ty: &str, replaced: &mut Option<(String, Vec<u64>)>) {
|
||||
if !matches!(ty, "scatter" | "art" | "pattern") || !ui.input(|i| i.modifiers.alt) {
|
||||
return;
|
||||
}
|
||||
let Some(drag) = resp.dnd_hover_payload::<PanelDrag>() else { return };
|
||||
let PanelDrag::Art(ids) = &*drag else { return };
|
||||
ui.painter().rect_stroke(resp.rect, 0.0, egui::Stroke::new(1.5, Tokens::get(ui.ctx()).accent), egui::StrokeKind::Inside);
|
||||
if resp.dnd_release_payload::<PanelDrag>().is_some() {
|
||||
*replaced = Some((name.to_string(), ids.iter().map(|id| id.0).collect()));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let (list, current) = brushes(app);
|
||||
@@ -285,6 +302,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let mut clicked: Option<(String, egui::Modifiers)> = None;
|
||||
let mut options: Option<String> = None;
|
||||
let mut moved: Option<Value> = None;
|
||||
let mut replaced: Option<(String, Vec<u64>)> = None;
|
||||
let list_rect = widgets::list_box(ui, |ui| {
|
||||
ui.set_min_height(110.0);
|
||||
ui.set_width(ui.available_width());
|
||||
@@ -347,6 +365,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
for (i, (name, _)) in group.into_iter().enumerate() {
|
||||
let resp = row(ui, name, vec2(ui.available_width(), 26.0), true);
|
||||
reorder_drop(ui, &resp, &list, (name, ty, i), true, &mut moved);
|
||||
replace_drop(ui, &resp, name, ty, &mut replaced);
|
||||
pick(resp, name);
|
||||
}
|
||||
} else {
|
||||
@@ -354,6 +373,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
for (i, (name, _)) in group.into_iter().enumerate() {
|
||||
let resp = row(ui, name, vec2(64.0, 28.0), false);
|
||||
reorder_drop(ui, &resp, &list, (name, ty, i), false, &mut moved);
|
||||
replace_drop(ui, &resp, name, ty, &mut replaced);
|
||||
pick(resp, name);
|
||||
}
|
||||
});
|
||||
@@ -362,6 +382,11 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
}
|
||||
ui.min_rect()
|
||||
});
|
||||
// Art Alt-dragged onto a scatter, art or pattern brush replaces its art, asking first when
|
||||
// strokes use the brush.
|
||||
if let Some((name, ids)) = replaced {
|
||||
crate::dialogs::brush_replace_art::replace(app, &name, &ids);
|
||||
}
|
||||
// Art dragged off the canvas and dropped on the list opens New Brush for that art, as the New
|
||||
// Brush button opens it for the selection; a brush library's brush dropped there is added.
|
||||
let zone = ui.interact(list_rect, ui.scope_id().with("brushes-drop"), Sense::hover());
|
||||
|
||||
@@ -461,6 +461,54 @@ fn art_dropped_on_the_panel_becomes_an_art_brush_and_a_brush_drags_out() {
|
||||
assert!(matches!(drag.as_deref(), Some(PanelDrag::Brush { name, def }) if *name == after[0].0 && def["name"] == json!(name)), "{drag:?}");
|
||||
}
|
||||
|
||||
/// Art dragged off the canvas and released on a scatter, art or pattern brush with Alt held
|
||||
/// replaces that brush's art (no stroke uses it, so nothing asks); without Alt, or on a
|
||||
/// calligraphic brush, the list opens New Brush as before.
|
||||
#[test]
|
||||
fn art_alt_dropped_on_a_brush_with_art_replaces_its_art() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 200, "height": 100})).unwrap();
|
||||
let id = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 30, "height": 12})).unwrap()["id"].as_u64().unwrap();
|
||||
let ctx = egui::Context::default();
|
||||
ctx.enable_accesskit();
|
||||
let out = frame_with(&ctx, &mut app, vec![], egui::Modifiers::NONE, 0.0, show);
|
||||
let tiles: Vec<Rect> = clickable(&out).into_iter().map(|c| c.1).filter(|r| r.width() == 64.0).collect();
|
||||
assert_eq!(shown(&brushes(&mut app).0, &[])[3], "Dots");
|
||||
let dots = app.run("brush.get", json!({"name": "Dots"})).unwrap();
|
||||
let drop = |app: &mut VectorcraftApp, at: Pos2, modifiers: egui::Modifiers, time: f64| {
|
||||
egui::DragAndDrop::set_payload(&ctx, PanelDrag::Art(vec![NodeId(id)]));
|
||||
frame_with(&ctx, app, vec![egui::Event::PointerMoved(at)], modifiers, time, show);
|
||||
frame_with(&ctx, app, vec![button(at, false)], modifiers, time + 0.1, show);
|
||||
};
|
||||
// Without Alt: New Brush, and Dots stays as it was.
|
||||
drop(&mut app, tiles[3].center(), egui::Modifiers::NONE, 1.0);
|
||||
assert!(app.ui.dialog.as_ref().is_some_and(|d| d.kind == crate::dialogs::new_brush::KIND));
|
||||
app.ui.dialog = None;
|
||||
// Alt on a calligraphic or a bristle brush: New Brush too.
|
||||
let list = brushes(&mut app).0;
|
||||
let names = shown(&list, &[]);
|
||||
let at = |name: &str| tiles[names.iter().position(|n| *n == name).unwrap()].center();
|
||||
for (i, name) in ["3 pt. Round", "Bristle Round"].into_iter().enumerate() {
|
||||
let lib = app.run("brush.list", json!({})).unwrap();
|
||||
drop(&mut app, at(name), egui::Modifiers::ALT, 2.0 + i as f64);
|
||||
assert!(app.ui.dialog.as_ref().is_some_and(|d| d.kind == crate::dialogs::new_brush::KIND), "{name}");
|
||||
app.ui.dialog = None;
|
||||
assert_eq!(app.run("brush.list", json!({})).unwrap(), lib, "{name}");
|
||||
}
|
||||
assert_eq!(app.run("brush.get", json!({"name": "Dots"})).unwrap(), dots);
|
||||
// Alt on Dots (scatter), Arrow (art) and Chain (pattern, its side tile): the rectangle is its
|
||||
// art now, in one undo step each.
|
||||
for (i, (name, key)) in [("Dots", "art"), ("Arrow", "art"), ("Chain", "side")].into_iter().enumerate() {
|
||||
let steps = app.session.active().unwrap().history.undo.len();
|
||||
drop(&mut app, at(name), egui::Modifiers::ALT, 4.0 + i as f64);
|
||||
assert!(app.ui.dialog.is_none(), "no stroke uses {name}: nothing asks");
|
||||
assert_eq!(app.session.active().unwrap().history.undo.len(), steps + 1, "{name}");
|
||||
let art: vectorcraft_doc::Node = serde_json::from_value(app.run("brush.get", json!({"name": name})).unwrap()[key].clone()).unwrap();
|
||||
let b = art.geometric_bounds().unwrap();
|
||||
assert!((b.width() - 30.0).abs() < 1e-6 && (b.height() - 12.0).abs() < 1e-6, "{name}: {b:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A brush dragged onto the left half of another brush of its type goes before it, with a bar
|
||||
/// marking the slot while it is held there, as one undo step; dropped on a brush of another
|
||||
/// type, it stays where it is and the status bar says why.
|
||||
|
||||
+15
@@ -2904,6 +2904,21 @@ Tile, Start Tile or End Tile. A tile with a repeat frame has an unpainted rectan
|
||||
the frame. A symbol instance in the art is measured by its symbol's art. A calligraphic or bristle brush is refused
|
||||
with "`<name>` has no art (only scatter, art and pattern brushes do)".
|
||||
|
||||
`brush.replaceArt {name, ids?|id?, applyToStrokes?}` makes the selected art the brush's art and keeps its other
|
||||
options; several objects become one group, as in `brush.new`. A pattern brush takes a group named for a tile, or a
|
||||
group of such groups, tile by tile: an unpainted rectangle at the back of a tile group becomes that tile's repeat frame,
|
||||
a tile group's art goes back without that group, and the tiles that are not given stay as they are. Of two groups named
|
||||
for the same tile, the frontmost one counts. Other art becomes the side tile. When strokes use the brush and
|
||||
`applyToStrokes` is `false`, the brush and its strokes stay as they were, and a copy of the brush with the new art,
|
||||
named "`<name>` copy", goes after it and becomes the current brush. Otherwise, and for a brush no stroke uses, the brush
|
||||
changes and its strokes redraw. It replies `{name}`, the brush that has the new art, and refuses a calligraphic or
|
||||
bristle brush, an empty selection and art (or a tile it is given, such as a tile group left with only its frame's
|
||||
rectangle) with no width. `brush.replaceArt` and `brush.new` measure a symbol instance in the art by its symbol's art.
|
||||
In the app, art Alt-dragged (Option-dragged on macOS) from the canvas onto a scatter, art or pattern brush in the
|
||||
Brushes panel runs it. When strokes use the brush, the app checks the art first and shows why in the status bar when
|
||||
the brush cannot take it; otherwise a dialog (`brushReplaceArt`) asks: Apply to Strokes, Leave Strokes
|
||||
(`applyToStrokes: false`) or Cancel.
|
||||
|
||||
`variable.bind`, `variable.unbind`, `variable.delete`, `dataset.set`, `dataset.update`, `dataset.delete`,
|
||||
`dataset.select`, `dataset.next` and `dataset.prev` add no undo step when they leave the document as it was, such as
|
||||
binding art to a variable it already has or applying the active data set again: the steps to redo stay, and a saved
|
||||
|
||||
@@ -1338,6 +1338,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
The Brushes panel menu's Select All Unused selects the brushes that are not used in the document, as the [Brushes](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html) page (archived copy) describes. A brush counts as used when a stroke paints with it in the art (opacity masks included), in symbols, graph designs, pattern tiles or graphic styles, or in the art of a used brush (`brush.unused`).
|
||||
A rename in Brush Options and Delete Brush change every stroke that paints with the brush: in the layers and opacity masks, symbols, graph designs, pattern tiles, graphic styles and the art of other brushes. A rename gives those strokes the new name, and Delete Brush makes them plain strokes, in one undo step.
|
||||
A scatter, art or pattern brush dragged from the Brushes panel onto an empty part of the canvas places a copy of its art there to edit, as the [Modify brushes](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/modify-brushes.html) page describes (`brush.placeArt`). The copy is centered where it is dropped. A pattern brush comes out as its tiles in a row, 10 pt apart, each in a group named for its tile, with an unpainted rectangle at the back of a tile that has a repeat frame. The centering and the tile layout are VectorCraft's own rules. Evidence: `tests::brushsym::place_art_puts_a_copy_of_the_brush_art_where_it_is_dropped`, `tests::brushsym::pattern_brushes_place_their_tiles_in_a_row` (vectorcraft-engine), `canvas::tests::a_brush_with_art_dropped_off_the_art_places_a_copy_of_its_art_there` (vectorcraft-ui-egui).
|
||||
Art Alt-dragged (Option-dragged on macOS) from the canvas onto a scatter, art or pattern brush in the Brushes panel becomes the brush's art, as the [Modify brushes](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/modify-brushes.html) page describes (`brush.replaceArt`). When strokes use the brush, a dialog asks whether to change those strokes (Apply to Strokes) or leave them as they are (Leave Strokes), or to cancel, the choice the [help reference](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=263) (archived copy, p. 263) describes for a modified brush in use. Leave Strokes keeps the brush and its strokes as they were and adds a copy of the brush with the new art, named "`<name>` copy", which becomes the current brush. That copy is VectorCraft's own rule. A pattern brush takes back the tile groups `brush.placeArt` places, frames included, and takes other art as its side tile, which is also VectorCraft's own rule. Evidence: `tests::brushsym::replace_art_applies_to_strokes_or_leaves_them_on_the_old_brush`, `tests::brushsym::placed_pattern_tiles_go_back_into_the_brush_tile_by_tile`, `tests::brushsym::other_art_replaces_the_side_tile_of_a_pattern_brush` (vectorcraft-engine), `dialogs::brush_replace_art::tests::leave_strokes_adds_a_copy_and_cancel_changes_nothing`, `panels::brushes::tests::art_alt_dropped_on_a_brush_with_art_replaces_its_art`, `canvas::tests::art_alt_dragged_off_the_canvas_reaches_the_panels_as_the_original` (vectorcraft-ui-egui).
|
||||
In Pattern Brush Options, a menu below the Outer Corner Tile and the Inner Corner Tile sets each to the brush's own corner art (Original), None, or a tile made from the side tile: Auto-Centered stretches one side tile around the corner, Auto-Between bends a side tile on each side into the corner's diagonal, Auto-Sliced cuts a side tile on each side along the diagonal, and Auto-Overlap runs a side tile on each side past the corner. Auto-Sliced masks the tiles at the diagonal, so their outlines stay as drawn. Brushes saved without these choices draw their corners as before (`brush.options` `outer_source`, `inner_source`). Evidence: `tests::pattern_auto_corners_fill_each_corner_of_a_square`, `tests::pattern_corner_source_none_leaves_that_kind_of_corner_empty` (vectorcraft-brush), `dialogs::brush_options::tests::pattern_options_set_each_corner_tile_to_original_none_or_an_automatic_tile` (vectorcraft-ui-egui).
|
||||
|
||||
Pattern brush corner tiles are square to the side tiles at a right-angle corner and turn 90° from one corner to the next, as the [Using Illustrator CS5](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf) help (About patterns) describes. That document's steps for making corner tiles build both the outer and the inner tile as the corner joining a side tile on its right to one below it, and the brush reads corner art that way, with Flip Along and Flip Across or without (#6110). At corners that are not right angles, the tile is turned halfway between the two sides, which is VectorCraft's own rule. Evidence: `tests::pattern_corner_tiles_are_square_to_the_sides`, `tests::pattern_corner_tiles_sit_on_the_corners_diagonal` (vectorcraft-brush).
|
||||
|
||||
Reference in new issue
Block a user