mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-20 17:37:10 +01:00
Merge main into fix/live-paint-bucket-gradient-aspect
This commit is contained in:
commit
d5ab3f8654
86 files changed
+3315
-129
No files matched your search
@@ -221,6 +221,7 @@ Generated-in-code art is original and has no file to list. This covers the defau
|
||||
| `assets/icons/dc-polygon.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-pucker.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-puppet.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-quick-pen.svg` | VectorCraft contributors | Original work, drawn for VectorCraft (a line and a half circle with a dot at each point) | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-rearrange.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-rect-cut.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-rect-grid.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
|
||||
@@ -145,6 +145,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap
|
||||
- 2026-11-17: Curvature Circle tool (after the Circle tool in its group): a click on a path draws the circle that touches it there and bends as it bends, on the side it bends toward, or with Shift on the other side; a segment that is the usual cubic of a circular arc of 90° or less gives the arc's own radius, so a click on a circle draws that circle; the tool shows the circle, its center and its radius (with an asterisk for an arc's radius) until the click, or "Straight segment", "Cusp", "Corner" or "Circle too large" where it draws none (`shape.curvatureCircle`). One undo step per circle. A VectorCraft addition: headline numbers unchanged.
|
||||
- 2026-11-15: Circle through three points: three Shift-clicks with the Ellipse tool, or `shape.circleThroughPoints` with three points or three selected anchor points, draw the circle whose edge passes through them, with the current paint, in one undo step; after two points the tool previews the circle through the pointer, and two points that are the same or three on one line are refused with a message. Scores and estimates unchanged.
|
||||
- 2026-11-17: Circle tool (after the Ellipse tool in its group): two clicks or a drag draw the circle on that diameter, and a click followed by a drag from a second point to a third draws the circle through the three; Shift keeps the diameter at 45° steps, Alt rounds a two-point circle's diameter to the rulers' ticks at the current zoom, points snap to Smart Guides, and the tool shows the circle, its center, its radii and its diameter until the release, or "Circle too large" for points on one line or a circle past the canvas. `shape.circleThroughPoints` also takes two points or two selected anchor points as the ends of a diameter. One undo step per circle. A VectorCraft addition: headline numbers unchanged.
|
||||
- 2026-11-19: Quick Pen tool, in the Pen tool's group (Alt+P, Option+P on macOS): clicks or drags add straight lines, continuous arcs or sharp-corner arcs; Alt tapped on its own switches the action, C flips the last arc, `[` and `]` size it, a click on the first point closes the path and a click on an open end continues it (`path.quickPen`, part of #2660). Headline numbers unchanged.
|
||||
- 2026-10-31: Pattern libraries: Window › Swatch Libraries › Patterns and the Swatches panel's library menu open Geometric Patterns, a built-in library of eleven pattern swatches (dots, stripes, checks, a grid and shapes); clicking one adds its pattern and swatch to the document, once, and applies it to the active fill or stroke (`swatch.library.add`).
|
||||
- 2026-11-11: Pattern libraries: Patterns › Grit Textures, a second built-in pattern library, holds eight seamless black textures (Fine Grain, Coarse Grit, Sand, Speckle, Stipple, Scratches, Sparse Flecks and Dense Flecks) on tiles of 18 to 36 pt, each drawn the same way every time; marks that reach past a tile edge continue on the next tile, so the tiles join without a seam (`swatch.library.add`). Scores and estimates unchanged.
|
||||
- 2026-11-11: Pattern libraries: Patterns › Optical Effects, a third built-in pattern library, of VectorCraft's own designs, holds eight black wave, moiré and op-art tiles (Sine Bands, Ripple Lines, Interference Rings, Offset Rings, Warped Checks, Pinched Stripes, Chevron Pulse and Radiating Lenses) of 32 to 48 pt, each drawn the same way every time; each tile is one period of its design, and art that reaches past a tile edge continues on the next tile, so the tiles join without a seam (`swatch.library.add`). Scores and estimates unchanged.
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M3 18 L9.5 18 A5.75 5.75 0 0 1 21 18"/><circle cx="3" cy="18" r="1.6" fill="currentColor"/><circle cx="9.5" cy="18" r="1.6" fill="currentColor"/><circle cx="21" cy="18" r="1.6" fill="currentColor"/></svg>
|
||||
|
After Width: | Height: | Size: 397 B |
@@ -195,12 +195,14 @@ impl StrokeLayer {
|
||||
wheel: None,
|
||||
}
|
||||
}
|
||||
/// The least weight an arrowhead is drawn at, in points ([`Self::arrow_weight`]).
|
||||
pub const LEAST_ARROW_WEIGHT: f64 = 0.25;
|
||||
/// Weight of the start (`end == false`) or end arrowhead: stroke weight × its scale, at least
|
||||
/// a quarter point. A head of weight `hw` fits a box about `4·hw` long and wide (see
|
||||
/// [`Self::LEAST_ARROW_WEIGHT`]. A head of weight `hw` fits a box about `4·hw` long and wide (see
|
||||
/// [`Arrowhead::reach`] and [`Arrowhead::half_width`]).
|
||||
pub fn arrow_weight(&self, end: bool) -> f64 {
|
||||
let pct = if end { self.arrow_scale.1 } else { self.arrow_scale.0 };
|
||||
(self.width * pct / 100.0).max(0.25)
|
||||
(self.width * pct / 100.0).max(Self::LEAST_ARROW_WEIGHT)
|
||||
}
|
||||
/// How far the start (`end == false`) or end arrowhead can reach from its end point (0
|
||||
/// without one): the head's diagonal, or with [`ArrowAlign::Extend`] its length, plus the cap.
|
||||
|
||||
@@ -68,6 +68,10 @@ pub struct CustomArrowhead {
|
||||
/// across it, positive to the right of the direction the head points. A head is 4 units wide,
|
||||
/// as the built-in heads are, and a unit is the head's weight.
|
||||
pub path: PathData,
|
||||
/// Where the stroke ends under the head, in head units back from the tip, when the head says
|
||||
/// so ([`Self::with_stop`]); `None`: halfway along its length ([`Self::stop`]).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub stop: Option<f64>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@@ -75,11 +79,17 @@ struct CustomArrowheadData {
|
||||
name: String,
|
||||
#[serde(default)]
|
||||
path: PathData,
|
||||
#[serde(default)]
|
||||
stop: Option<f64>,
|
||||
}
|
||||
|
||||
impl From<CustomArrowheadData> for CustomArrowhead {
|
||||
fn from(d: CustomArrowheadData) -> Self {
|
||||
CustomArrowhead::new(d.name, d.path)
|
||||
let head = CustomArrowhead::new(d.name, d.path);
|
||||
match d.stop {
|
||||
Some(stop) => head.with_stop(stop),
|
||||
None => head,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +104,17 @@ impl CustomArrowhead {
|
||||
/// than [`Self::MAX_UNITS`] from the tip is dropped: the head then draws nothing.
|
||||
pub fn new(name: String, path: PathData) -> Self {
|
||||
let path = if Self::fits(&path) { path } else { PathData::default() };
|
||||
CustomArrowhead { name, path }
|
||||
CustomArrowhead { name, path, stop: None }
|
||||
}
|
||||
/// The head with the stroke ending `stop` head units back from its tip (an arrowhead an
|
||||
/// Illustrator file defines draws its line to a point of its own). A stop that is not finite,
|
||||
/// is negative or is farther than [`Self::MAX_UNITS`] is left out: the stroke then ends
|
||||
/// halfway along the head.
|
||||
/// A head whose outline was dropped ([`Self::new`]) draws nothing and keeps no stop.
|
||||
pub fn with_stop(mut self, stop: f64) -> Self {
|
||||
let fits = !self.path.subpaths.is_empty() && stop.is_finite() && (0.0..=Self::MAX_UNITS).contains(&stop);
|
||||
self.stop = fits.then_some(stop);
|
||||
self
|
||||
}
|
||||
/// Whether outline `path` has at most [`Self::MAX_ANCHORS`] anchors and as many subpaths, with
|
||||
/// finite points within [`Self::MAX_UNITS`] only.
|
||||
@@ -116,10 +136,10 @@ impl CustomArrowhead {
|
||||
pub fn half_width(&self) -> f64 {
|
||||
self.bounds().map_or(0.0, |b| b.y0.abs().max(b.y1.abs()))
|
||||
}
|
||||
/// Where the stroke ends under the head, in head units back from the tip: halfway along the
|
||||
/// head's length.
|
||||
/// Where the stroke ends under the head, in head units back from the tip: its own stop
|
||||
/// ([`Self::with_stop`]), else halfway along the head's length.
|
||||
pub fn stop(&self) -> f64 {
|
||||
self.bounds().map_or(0.0, |b| b.x1.max(0.0) / 2.0)
|
||||
self.stop.unwrap_or_else(|| self.bounds().map_or(0.0, |b| b.x1.max(0.0) / 2.0))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -383,6 +383,15 @@ fn custom_arrowheads_carry_their_art_and_measure_it() {
|
||||
assert_eq!(head.half_width(), 2.0);
|
||||
let Arrowhead::Custom(c) = &head else { panic!("custom") };
|
||||
assert_eq!(c.stop(), 1.5, "the line stops halfway along the head");
|
||||
// A head with a stop of its own (an Illustrator file's arrowhead) keeps it, saved and read back.
|
||||
let stopped = (**c).clone().with_stop(0.5);
|
||||
assert_eq!(stopped.stop(), 0.5);
|
||||
let back: CustomArrowhead = serde_json::from_value(serde_json::to_value(&stopped).unwrap()).unwrap();
|
||||
assert_eq!(back, stopped);
|
||||
assert!(!serde_json::to_string(&**c).unwrap().contains("stop"), "a head without one writes none");
|
||||
for odd in [f64::NAN, -0.5, CustomArrowhead::MAX_UNITS + 1.0] {
|
||||
assert_eq!((**c).clone().with_stop(odd).stop(), 1.5, "{odd} is left out");
|
||||
}
|
||||
// Saved with the stroke, art and all, beside the built-in heads' names.
|
||||
let mut st = StrokeLayer::new(Paint::solid(Color::BLACK), 2.0);
|
||||
(st.start_arrow, st.end_arrow) = (Some(Arrowhead::Triangle), Some(head.clone()));
|
||||
@@ -404,7 +413,7 @@ fn custom_arrowheads_out_of_bounds_draw_nothing() {
|
||||
let mut path = c.path.clone();
|
||||
path.subpaths[0].anchors[1] = vectorcraft_geom::Anchor::corner(vectorcraft_geom::Point::new(1e9, 0.0));
|
||||
// A file can hold what `new` drops: reading it drops it too.
|
||||
let json = serde_json::to_value(CustomArrowhead { name: "Wedge".into(), path }).unwrap();
|
||||
let json = serde_json::to_value(CustomArrowhead { name: "Wedge".into(), path, stop: None }).unwrap();
|
||||
let far: CustomArrowhead = serde_json::from_value(json).unwrap();
|
||||
assert_eq!((far.name.as_str(), far.path.subpaths.len()), ("Wedge", 0));
|
||||
assert_eq!((far.reach(), far.half_width(), far.stop()), (0.0, 0.0, 0.0));
|
||||
@@ -415,7 +424,7 @@ fn custom_arrowheads_out_of_bounds_draw_nothing() {
|
||||
let mut hollow = c.path.clone();
|
||||
hollow.subpaths.extend(std::iter::repeat_n(vectorcraft_geom::SubPath::new(vec![], false), CustomArrowhead::MAX_ANCHORS));
|
||||
assert!(!CustomArrowhead::fits(&hollow), "too many subpaths");
|
||||
let json = serde_json::to_value(CustomArrowhead { name: "Hollow".into(), path: hollow }).unwrap();
|
||||
let json = serde_json::to_value(CustomArrowhead { name: "Hollow".into(), path: hollow, stop: None }).unwrap();
|
||||
let hollow: CustomArrowhead = serde_json::from_value(json).unwrap();
|
||||
assert!(hollow.path.subpaths.is_empty(), "too many subpaths, read back");
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
//! corner. With [`ArrowAlign::Tip`] the tip sits on the end point and the stroke is shortened by
|
||||
//! the inset; with [`ArrowAlign::Extend`] the path keeps its length and the tip sits the inset
|
||||
//! past the end point. Heads added after the first ten are drawn in local units ([`local`]), as are
|
||||
//! custom heads, whose stroke ends halfway along their length.
|
||||
//! custom heads, whose stroke ends at their own stop or else halfway along their length
|
||||
//! ([`vectorcraft_doc::CustomArrowhead::stop`]).
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
|
||||
@@ -278,6 +278,28 @@ 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`]).
|
||||
pub(crate) fn targets_for(self, s: &Session, p: &Value, fill: bool) -> Result<Vec<NodeId>> {
|
||||
Ok(self.targets_and_skipped(s, p, fill)?.0)
|
||||
}
|
||||
|
||||
/// [`ItemTarget::targets_for`], and whether it left out any object inside a Live Paint group: a
|
||||
/// group with no part of the edited kind was still given or selected, so the edit does not go
|
||||
/// 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;
|
||||
}
|
||||
Ok((ids, skipped_any))
|
||||
}
|
||||
|
||||
/// The target of a fill (`fill`) or stroke edit: the panel's active item stands only for edits
|
||||
/// of its own kind, so a fill row leaves stroke edits on the topmost stroke of the painted
|
||||
/// leaves (as without an active item) and vice versa. Explicit items are kept (and checked).
|
||||
|
||||
@@ -28,6 +28,7 @@ mod commands;
|
||||
mod common;
|
||||
mod cut;
|
||||
mod freehand;
|
||||
mod quickpen;
|
||||
mod smooth;
|
||||
|
||||
pub use commands::specs;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use super::anchors::{convert_anchor, curvature, curvature_edit, remove_anchor, remove_anchors, reshape_segment};
|
||||
use super::cut::{erase_region, erase_segments, knife, split};
|
||||
use super::freehand::{blob, freehand};
|
||||
use super::quickpen::quick_pen;
|
||||
use super::smooth::{join_scrub, smooth_region};
|
||||
use super::{CommandSpec, cmd, has_anchors, has_doc, has_selection};
|
||||
|
||||
@@ -33,6 +34,15 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
has_doc,
|
||||
curvature_edit
|
||||
),
|
||||
cmd!(
|
||||
"path.quickPen",
|
||||
"Quick Pen",
|
||||
[],
|
||||
None,
|
||||
"{start?: [x, y] (a new path starts there), id? (or: draw on this path), subpath?: index (0), keep?: count (default: all its points; the points after the first `keep` are replaced), pieces?: [{x, y, action?: \"line\" (default)|\"continuousArc\"|\"sharpArc\", turn?: 1..359 degrees (180), flip?: bool}] (at most 10000), closed?: bool} draw a path of straight lines and circular arcs as the Quick Pen tool does, each piece from the path's last point to x, y: a line; a continuous arc, which leaves its start in the direction the path arrives in (with no direction, the first piece of a path, it is drawn as a sharp-corner arc; with its end straight ahead or straight behind, as a line); a sharp-corner arc, which turns through `turn` degrees and bulges to the left of the direction drawn (with flip, to the right). A piece that ends where the path does adds nothing. closed: a last piece that ends on the first point joins it, otherwise a straight segment closes the path. A new path takes the current paint (a black stroke when it has neither fill nor stroke); the path is selected, as one undo step → {id}. Without id, `start` must be given; with id, the subpath must be open and `start` is refused",
|
||||
has_doc,
|
||||
quick_pen
|
||||
),
|
||||
cmd!(
|
||||
"path.removeAnchor",
|
||||
"Delete Anchor Point",
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
//! The Quick Pen tool's command (`path.quickPen`): a path of straight lines and circular arcs.
|
||||
|
||||
use vectorcraft_tools::quickpen::{self as qp, Piece, Stroke};
|
||||
|
||||
use super::common::{path_kind, path_mut, point_entry, usize_opt, within_input_bound};
|
||||
use super::{Color, Paint, PathData, Result, Session, SubPath, Value, add_look, bad, json, number_or, object_param, switch_or};
|
||||
|
||||
const C: &str = "path.quickPen";
|
||||
/// The most pieces one request takes.
|
||||
const MAX_PIECES: usize = 10_000;
|
||||
|
||||
/// The `pieces` param.
|
||||
fn pieces(p: &Value) -> Result<Vec<Piece>> {
|
||||
let list = match p.get("pieces") {
|
||||
None | Some(Value::Null) => return Ok(vec![]),
|
||||
Some(Value::Array(list)) if list.len() <= MAX_PIECES => list,
|
||||
Some(_) => return Err(bad(C, "`pieces` must be a list of at most 10000 pieces")),
|
||||
};
|
||||
list.iter()
|
||||
.map(|v| {
|
||||
let to = point_entry(v, C)?;
|
||||
if !within_input_bound(to) {
|
||||
return Err(bad(C, "x and y must be finite"));
|
||||
}
|
||||
let stroke = match v.get("action") {
|
||||
None | Some(Value::Null) => Stroke::Line,
|
||||
Some(a) => a.as_str().and_then(Stroke::parse).ok_or_else(|| {
|
||||
let key = "action";
|
||||
bad(C, format!("`{key}` must be one of {}", Stroke::ALL.map(Stroke::name).join(", ")))
|
||||
})?,
|
||||
};
|
||||
let turn = number_or(v, "turn", qp::DEFAULT_TURN, C)?;
|
||||
if !(qp::MIN_TURN..=qp::MAX_TURN).contains(&turn) {
|
||||
let (key, min, max) = ("turn", qp::MIN_TURN, qp::MAX_TURN);
|
||||
return Err(bad(C, format!("{key} must be a number from {min} to {max}")));
|
||||
}
|
||||
let flip = switch_or(v, "flip", false, C)?;
|
||||
Ok(Piece { to, stroke, turn, flip })
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub(super) fn quick_pen(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let pieces = pieces(p)?;
|
||||
let closed = switch_or(p, "closed", false, C)?;
|
||||
let start_given = p.get("start").is_some_and(|v| !v.is_null());
|
||||
let either = "give either `start` for a new path or `id`, not both";
|
||||
let Some(id) = object_param(p, "id", C)? else {
|
||||
let start = match p.get("start") {
|
||||
Some(v) if start_given => point_entry(v, C)?,
|
||||
_ => return Err(bad(C, either)),
|
||||
};
|
||||
if !within_input_bound(start) {
|
||||
return Err(bad(C, "x and y must be finite"));
|
||||
}
|
||||
if ["subpath", "keep"].iter().any(|key| p.get(key).is_some_and(|v| !v.is_null())) {
|
||||
return Err(bad(C, "`subpath` and `keep` need `id`"));
|
||||
}
|
||||
let sp = qp::build(&SubPath::new(vec![vectorcraft_geom::Anchor::corner(start)], false), &pieces, closed);
|
||||
let mut look = s.new_art_look(s.paint.fill.clone(), s.paint.stroke.clone(), s.paint.stroke_width);
|
||||
let ap = &mut look.appearance;
|
||||
if ap.stroke_paint().is_none() && ap.fill_paint().is_none() {
|
||||
ap.set_stroke(Paint::solid(Color::BLACK));
|
||||
}
|
||||
return add_look(s, "Quick Pen", path_kind(PathData::single(sp)), look, None);
|
||||
};
|
||||
if start_given {
|
||||
return Err(bad(C, either));
|
||||
}
|
||||
let si = usize_opt(p, "subpath", C)?.unwrap_or(0);
|
||||
let d = &s.doc()?.doc;
|
||||
if !d.is_editable(id) {
|
||||
return Err(bad(C, "the path is locked or hidden"));
|
||||
}
|
||||
let path = d.node(id).and_then(|n| n.path_data()).ok_or_else(|| bad(C, "`id` is not a path"))?;
|
||||
let sp = path.subpaths.get(si).ok_or_else(|| bad(C, "no such subpath"))?;
|
||||
if sp.closed {
|
||||
return Err(bad(C, "the subpath is closed"));
|
||||
}
|
||||
let n = sp.anchors.len();
|
||||
let keep = usize_opt(p, "keep", C)?.unwrap_or(n);
|
||||
if keep == 0 || keep > n {
|
||||
let (key, min, max) = ("keep", 1, n);
|
||||
return Err(bad(C, format!("{key} must be a number from {min} to {max}")));
|
||||
}
|
||||
let base = SubPath::new(sp.anchors.get_range(..keep).unwrap_or_default(), false);
|
||||
let out = qp::build(&base, &pieces, closed);
|
||||
let top = super::super::path::compound_or_self(d, id);
|
||||
s.edit("Quick Pen", |d, sel| {
|
||||
let slot = path_mut(d, id)?.subpaths.get_mut(si).ok_or_else(|| crate::EngineError::Other("no such subpath".into()))?;
|
||||
*slot = out;
|
||||
sel.set([top]);
|
||||
Ok(())
|
||||
})?;
|
||||
Ok(json!({ "id": id.0 }))
|
||||
}
|
||||
@@ -19,7 +19,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Add Freeform Point",
|
||||
[],
|
||||
None,
|
||||
"{at: [x,y] (document coordinates), color? (default: the gradient's colour there; #rrggbbaa and #rgba are refused), keepModel?: bool (as paint.setFill), opacity?: 0..1 (or 0..100), spread?: 0..1 (or 0..100 %; the radius of pure colour around the point, a fraction of half the object's larger side; default 0), line?: true (join it to the selected point: extends the line ending there, else starts one), ids?|id?, stroke?: bool (default: the targeted item's kind, else the active proxy), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind), aligned?: bool (as paint.editGradient), target?: \"object\"|\"contents\"} add a point to the freeform gradient (an unplaced one keeps its automatic points first) and select it. On a path directly in a graph series, the graph also stores the edited gradient when it is on the topmost visible fill or stroke, as for the other paint.freeform edits (docs/mcp.md); on a graph label's row, or on a graph's axis line, tick mark or radar ring, the graph stores that object's topmost visible fill and stroke rows for every label or line of its kind (a line's gradient without its points); the points on a label's characters are not stored → {index}",
|
||||
"{at: [x,y] (document coordinates), color? (default: the gradient's colour there; #rrggbbaa and #rgba are refused), keepModel?: bool (as paint.setFill), opacity?: 0..1 (or 0..100), spread?: 0..1 (or 0..100 %; the radius of pure colour around the point, a fraction of half the object's larger side; default 0), line?: true (join it to the selected point: extends the line ending there, else starts one), ids?|id?, stroke?: bool (default: the targeted item's kind, else the active proxy), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind; without one, a Live Paint group's faces take a fill edit and its edges take a stroke edit), aligned?: bool (as paint.editGradient), target?: \"object\"|\"contents\"} add a point to the freeform gradient (an unplaced one keeps its automatic points first) and select it. On a path directly in a graph series, the graph also stores the edited gradient when it is on the topmost visible fill or stroke, as for the other paint.freeform edits (docs/mcp.md); on a graph label's row, or on a graph's axis line, tick mark or radar ring, the graph stores that object's topmost visible fill and stroke rows for every label or line of its kind (a line's gradient without its points); the points on a label's characters are not stored → {index}",
|
||||
has_doc,
|
||||
add_point
|
||||
),
|
||||
@@ -28,7 +28,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Edit Freeform Point",
|
||||
[],
|
||||
None,
|
||||
"{index? (default: the selected point), at?: [x,y] (document coordinates), color? (#rrggbbaa and #rgba are refused), keepModel?: bool (as paint.setFill), opacity?: 0..1 (or 0..100), spread?: 0..1 (or 0..100 %), ids?|id?, stroke?: bool (default: the targeted item's kind, else the active proxy), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind), aligned?: bool (as paint.editGradient), target?: \"object\"|\"contents\"} move or recolour a point of the freeform gradient → {index}",
|
||||
"{index? (default: the selected point), at?: [x,y] (document coordinates), color? (#rrggbbaa and #rgba are refused), keepModel?: bool (as paint.setFill), opacity?: 0..1 (or 0..100), spread?: 0..1 (or 0..100 %), ids?|id?, stroke?: bool (default: the targeted item's kind, else the active proxy), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind; without one, a Live Paint group's faces take a fill edit and its edges take a stroke edit), aligned?: bool (as paint.editGradient), target?: \"object\"|\"contents\"} move or recolour a point of the freeform gradient → {index}",
|
||||
has_doc,
|
||||
set_point
|
||||
),
|
||||
@@ -37,7 +37,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Delete Freeform Point",
|
||||
[],
|
||||
None,
|
||||
"{index? (default: the selected point), ids?|id?, stroke?: bool (default: the targeted item's kind, else the active proxy), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind), aligned?: bool (as paint.editGradient), target?: \"object\"|\"contents\"} remove a point (never the last one); lines through it close up around it and lines left with one point go → {index}",
|
||||
"{index? (default: the selected point), ids?|id?, stroke?: bool (default: the targeted item's kind, else the active proxy), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind; without one, a Live Paint group's faces take a fill edit and its edges take a stroke edit), aligned?: bool (as paint.editGradient), target?: \"object\"|\"contents\"} remove a point (never the last one); lines through it close up around it and lines left with one point go → {index}",
|
||||
has_doc,
|
||||
delete_point
|
||||
),
|
||||
@@ -46,7 +46,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Add Freeform Line",
|
||||
[],
|
||||
None,
|
||||
"{points: [index, …] (at least two), ids?|id?, stroke?: bool (default: the targeted item's kind, else the active proxy), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind), aligned?: bool (as paint.editGradient), target?: \"object\"|\"contents\"} join points with a smooth line through them, in order → {line}",
|
||||
"{points: [index, …] (at least two), ids?|id?, stroke?: bool (default: the targeted item's kind, else the active proxy), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind; without one, a Live Paint group's faces take a fill edit and its edges take a stroke edit), aligned?: bool (as paint.editGradient), target?: \"object\"|\"contents\"} join points with a smooth line through them, in order → {line}",
|
||||
has_doc,
|
||||
add_line
|
||||
),
|
||||
@@ -55,7 +55,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Split Freeform Line",
|
||||
[],
|
||||
None,
|
||||
"{line: line index, segment: the segment from the line's point `segment` to the next, t?: 0..1 along it (default 0.5), ids?|id?, stroke?: bool (default: the targeted item's kind, else the active proxy), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind), aligned?: bool (as paint.editGradient), target?: \"object\"|\"contents\"} add a point on a line there (colour, opacity and spread between the segment's ends) and select it → {index}",
|
||||
"{line: line index, segment: the segment from the line's point `segment` to the next, t?: 0..1 along it (default 0.5), ids?|id?, stroke?: bool (default: the targeted item's kind, else the active proxy), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind; without one, a Live Paint group's faces take a fill edit and its edges take a stroke edit), aligned?: bool (as paint.editGradient), target?: \"object\"|\"contents\"} add a point on a line there (colour, opacity and spread between the segment's ends) and select it → {index}",
|
||||
has_doc,
|
||||
split_line
|
||||
),
|
||||
@@ -182,8 +182,9 @@ fn edit<R>(s: &mut Session, p: &Value, cmd: &str, mut f: impl FnMut(&mut Freefor
|
||||
let item = item_target(s, p, cmd)?;
|
||||
let stroke = edits_stroke(s, p, item, !s.fill_active, cmd)?;
|
||||
let item = item.of_kind(s, !stroke);
|
||||
// The art of a graph design in a series keeps the design's gradient.
|
||||
let ids = super::appearance::without_design_art(&s.doc()?.doc, item.targets(s, p)?, cmd)?;
|
||||
// The art of a graph design in a series keeps the design's gradient; a Live Paint group's fill is on its faces and its
|
||||
// stroke on its edges.
|
||||
let ids = super::appearance::without_design_art(&s.doc()?.doc, item.targets_for(s, p, !stroke)?, cmd)?;
|
||||
if ids.is_empty() {
|
||||
return Err(bad(cmd, "select an object with a freeform gradient"));
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Gradient",
|
||||
["Window", "Gradient"],
|
||||
None,
|
||||
"{stroke?: bool (default: the targeted item's kind, else the active proxy), kind?: linear|radial|conic|diamond|freeform (conic, also accepted as angle or conical, sweeps the stops once around the center, clockwise from the vector, with a seam where the last stop meets the first; diamond runs the stops from the center out to a square with a corner at the end of the vector; freeform places points on each object, coloured along the stops), mode?: points|lines (freeform: how the Gradient tool adds points), method?: classic|perceptual|hue-clockwise|hue-counterclockwise (how the colours between the stops mix: in display RGB, perceptually (OKLab) so the steps look even, or around the hue wheel: hue, saturation and brightness each change evenly from one stop to the next, the hue angle falling with hue-clockwise (red, magenta, blue, cyan, green, yellow) and rising with hue-counterclockwise; two stops whose hues are less than half a color level apart keep that hue; a stop whose RGB numbers are less than half a color level apart is gray and takes the hue of the stop it mixes with, and black that stop's saturation too; these two methods are VectorCraft's own, and SVG and PDF exports draw their gradients as RGB images, CMYK and spot color stops included; SVG exports draw a Perceptual gradient as an image, and PDF exports do too unless it is linear, radial, conic or diamond, has spot color stops, every other stop is paper white or written in CMYK or gray (an export that converts colors to a CMYK destination profile writes RGB and Lab stops in CMYK, and so does a CMYK document unless the export converts colors to an RGB destination profile), it is not a dithered fill and its curve does not have too many stops: then PDF writes tints of one spot ink as a Separation shading in that ink, and spot inks mixed with other spot, CMYK or gray inks as a DeviceN shading; freeform gradients mix their own way), spread?: pad|repeat|reflect (linear, radial, conic and diamond: what the gradient paints past the ends of its stops: pad carries the end colors on; repeat and reflect run the stops `repeats` times along the vector (around the circle, for a conic) and on past both ends, reflect mirroring every other run; an error on a freeform gradient), repeats?: 1..100 (a whole number: how many times repeat and reflect run the stops along the vector; VectorCraft's own limit; pad keeps it unused), stops?: [{offset 0..1, color? (needed without swatch; #rrggbbaa and #rgba are refused), opacity? 0..1 (or 0..100), midpoint? 0.13..0.87, swatch?: colour swatch name (a global or spot colour or tint swatch links the stop, so swatch edits recolour it and a spot stop prints on its plate; a process colour just gives its colour), tint?: 0..100 (% of the linked swatch; default 100, or a tint swatch's own)}] (at least 2; a freeform gradient's points are recoloured along them), keepModel?: bool (as paint.setFill; a stop color the gradient already has keeps its model), angle?: deg counter-clockwise (0: the gradient runs left to right; radial, conic and diamond: the vector turns about the center), aspect?: % (radial, conic and diamond; a negative one mirrors a conic's sweep and is an error for the other kinds; an error when no object is edited, as with nothing selected or the Live Paint Bucket's gradient: the default gradient fits each new object and keeps no aspect), reverse?: bool (the same ramp the other way round: the stops in reverse order, and a hue method turned the other way unless `method` is given too), dither?: bool (fills only: a linear, radial, conic or diamond gradient fill is drawn with fine noise that hides banding, and as pixels in SVG and PDF exports), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind), aligned?: bool (as paint.setFill; without stroke, the kind of the row edited), ids?|id?, strokeMode?: within|along|across (strokes only: the gradient lies on the page and shows through the stroke, runs from the start of each subpath to its end, or runs from the stroke's left edge to its right all along it; with nothing selected, for the next object drawn; type characters' own strokes always paint within), target?: \"object\"|\"contents\"} edit the gradient in place (keeps its placement); solid/none paints become the default gradient. On a path directly in a graph series, the graph also stores the gradient when it is on the topmost visible fill or stroke (docs/mcp.md); on a graph label's row, or on a graph's axis line, tick mark or radar ring, the graph stores that object's topmost visible fill and stroke rows for every label or line of its kind (a line's gradient without its placement), and on its characters their gradient without its placement, fitted to each label. While the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), only the default changes (the paint the bucket paints with)",
|
||||
"{stroke?: bool (default: the targeted item's kind, else the active proxy), kind?: linear|radial|conic|diamond|freeform (conic, also accepted as angle or conical, sweeps the stops once around the center, clockwise from the vector, with a seam where the last stop meets the first; diamond runs the stops from the center out to a square with a corner at the end of the vector; freeform places points on each object, coloured along the stops), mode?: points|lines (freeform: how the Gradient tool adds points), method?: classic|perceptual|hue-clockwise|hue-counterclockwise (how the colours between the stops mix: in display RGB, perceptually (OKLab) so the steps look even, or around the hue wheel: hue, saturation and brightness each change evenly from one stop to the next, the hue angle falling with hue-clockwise (red, magenta, blue, cyan, green, yellow) and rising with hue-counterclockwise; two stops whose hues are less than half a color level apart keep that hue; a stop whose RGB numbers are less than half a color level apart is gray and takes the hue of the stop it mixes with, and black that stop's saturation too; these two methods are VectorCraft's own, and SVG and PDF exports draw their gradients as RGB images, CMYK and spot color stops included; SVG exports draw a Perceptual gradient as an image, and PDF exports do too unless it is linear, radial, conic or diamond, has spot color stops, every other stop is paper white or written in CMYK or gray (an export that converts colors to a CMYK destination profile writes RGB and Lab stops in CMYK, and so does a CMYK document unless the export converts colors to an RGB destination profile), it is not a dithered fill and its curve does not have too many stops: then PDF writes tints of one spot ink as a Separation shading in that ink, and spot inks mixed with other spot, CMYK or gray inks as a DeviceN shading; freeform gradients mix their own way), spread?: pad|repeat|reflect (linear, radial, conic and diamond: what the gradient paints past the ends of its stops: pad carries the end colors on; repeat and reflect run the stops `repeats` times along the vector (around the circle, for a conic) and on past both ends, reflect mirroring every other run; an error on a freeform gradient), repeats?: 1..100 (a whole number: how many times repeat and reflect run the stops along the vector; VectorCraft's own limit; pad keeps it unused), stops?: [{offset 0..1, color? (needed without swatch; #rrggbbaa and #rgba are refused), opacity? 0..1 (or 0..100), midpoint? 0.13..0.87, swatch?: colour swatch name (a global or spot colour or tint swatch links the stop, so swatch edits recolour it and a spot stop prints on its plate; a process colour just gives its colour), tint?: 0..100 (% of the linked swatch; default 100, or a tint swatch's own)}] (at least 2; a freeform gradient's points are recoloured along them), keepModel?: bool (as paint.setFill; a stop color the gradient already has keeps its model), angle?: deg counter-clockwise (0: the gradient runs left to right; radial, conic and diamond: the vector turns about the center), aspect?: % (radial, conic and diamond; a negative one mirrors a conic's sweep and is an error for the other kinds; an error when no object is edited, as with nothing selected or the Live Paint Bucket's gradient: the default gradient fits each new object and keeps no aspect), reverse?: bool (the same ramp the other way round: the stops in reverse order, and a hue method turned the other way unless `method` is given too), dither?: bool (fills only: a linear, radial, conic or diamond gradient fill is drawn with fine noise that hides banding, and as pixels in SVG and PDF exports), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind), aligned?: bool (as paint.setFill; without stroke, the kind of the row edited), ids?|id?, strokeMode?: within|along|across (strokes only: the gradient lies on the page and shows through the stroke, runs from the start of each subpath to its end, or runs from the stroke's left edge to its right all along it; with nothing selected, for the next object drawn; type characters' own strokes always paint within), target?: \"object\"|\"contents\"} edit the gradient in place (keeps its placement); solid/none paints become the default gradient. Without `item`, a Live Paint group's faces take a fill edit and its edges take a stroke edit. On a path directly in a graph series, the graph also stores the gradient when it is on the topmost visible fill or stroke (docs/mcp.md); on a graph label's row, or on a graph's axis line, tick mark or radar ring, the graph stores that object's topmost visible fill and stroke rows for every label or line of its kind (a line's gradient without its placement), and on its characters their gradient without its placement, fitted to each label. While the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), o
Line truncated
|
||||
has_doc,
|
||||
edit_gradient
|
||||
),
|
||||
@@ -33,7 +33,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Gradient Vector",
|
||||
[],
|
||||
None,
|
||||
"{start?: [x,y], end?: [x,y] (document coordinates; both or neither: omitted, the vector stays), aspect?: % (radial, conic and diamond: the extent's height / width across the vector, a negative one mirroring a conic's sweep and an error for the other kinds; default: kept), focal?: [x,y] (document coordinates) | null (radial: the focal point, where the first stop sits, pulled inside the extent ellipse; null centres it; default: it keeps its place in the ellipse; an error on a conic or diamond gradient), ids?|id?, stroke?: bool (default: the targeted item's kind, else the active proxy), item?: fill/stroke item index|null (alias: index; omitted: the Appearance panel's active item when it is of the edited kind), aligned?: bool (as paint.editGradient), target?: \"object\"|\"contents\", index?: appearance item index (as item)} set the gradient vector, aspect ratio and focal point (solid paints become the default gradient; type objects set it on their runs, in text space). On a path directly in a graph series, the graph also stores the gradient with its placement relative to the path's box when it is on the topmost visible fill or stroke, and every path of the series takes it at the same place on its own box (docs/mcp.md); on a graph label's row, or on a graph's axis line, tick mark or radar ring, the graph stores that object's topmost visible fill and stroke rows for every label or line of its kind (a line's gradient without its placement), and on its characters their gradient without the placement this command sets, fitted to each label",
|
||||
"{start?: [x,y], end?: [x,y] (document coordinates; both or neither: omitted, the vector stays), aspect?: % (radial, conic and diamond: the extent's height / width across the vector, a negative one mirroring a conic's sweep and an error for the other kinds; default: kept), focal?: [x,y] (document coordinates) | null (radial: the focal point, where the first stop sits, pulled inside the extent ellipse; null centres it; default: it keeps its place in the ellipse; an error on a conic or diamond gradient), ids?|id?, stroke?: bool (default: the targeted item's kind, else the active proxy), item?: fill/stroke item index|null (alias: index; omitted: the Appearance panel's active item when it is of the edited kind), aligned?: bool (as paint.editGradient), target?: \"object\"|\"contents\", index?: appearance item index (as item)} set the gradient vector, aspect ratio and focal point (solid paints become the default gradient; type objects set it on their runs, in text space). On a path directly in a graph series, the graph also stores the gradient with its placement relative to the path's box when it is on the topmost visible fill or stroke, and every path of the series takes it at the same place on its own box (docs/mcp.md); on a graph label's row, or on a graph's axis line, tick mark or radar ring, the graph stores that object's topmost visible fill and stroke rows for every label or line of its kind (a line's gradient without its placement), and on its characters their gradient without the placement this command sets, fitted to each label; without item, a Live Paint group's faces take a fill edit and its edges take a stroke edit",
|
||||
has_doc,
|
||||
set_gradient_geom
|
||||
),
|
||||
@@ -92,6 +92,9 @@ fn select_stop(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
pub(crate) struct StopOwner {
|
||||
doc: Option<usize>,
|
||||
object: Option<NodeId>,
|
||||
/// The object whose paint the active proxy shows: a Live Paint group without faces (or edges)
|
||||
/// first in the selection shows the next object's.
|
||||
source: Option<NodeId>,
|
||||
part: bool,
|
||||
fill: bool,
|
||||
item: Option<usize>,
|
||||
@@ -104,6 +107,7 @@ impl StopOwner {
|
||||
Self {
|
||||
doc: s.active,
|
||||
object: st.and_then(|d| d.selection.objects.first().copied()),
|
||||
source: s.proxy_source(!s.fill_active).map(|(n, _)| n.id),
|
||||
part: st.is_some_and(|d| d.selection.symbol_part.is_some()),
|
||||
fill: s.fill_active,
|
||||
item: s.appearance_item(),
|
||||
@@ -549,10 +553,10 @@ fn edit_gradient(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
check_switches(p, &["reverse", "dither"], C)?;
|
||||
check_numbers(p, &["angle"], C)?;
|
||||
let item = item.of_kind(s, !stroke);
|
||||
let ids = item.targets(s, p)?;
|
||||
// Objects were given or selected, even when all of them are graph design art left out below: the stroke mode is then
|
||||
// not one for new art.
|
||||
let selected = !ids.is_empty();
|
||||
let (ids, skipped) = item.targets_and_skipped(s, p, !stroke)?;
|
||||
// Objects were given or selected, even when all of them are graph design art left out below, or Live Paint group parts
|
||||
// of the other kind left out above: the stroke mode is then not one for new art.
|
||||
let selected = !ids.is_empty() || skipped;
|
||||
// The default gradient for new art (and the bucket's) is fitted to each object, so it has no aspect of its own.
|
||||
if !selected && p.get("aspect").is_some() {
|
||||
return Err(bad(C, "`aspect` needs objects to place the gradient on: give ids or select objects"));
|
||||
@@ -792,7 +796,10 @@ fn set_gradient_geom(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let item = item.of_kind(s, !stroke);
|
||||
let targets = match item {
|
||||
ItemTarget::Top => {
|
||||
leaf_targets(s, &super::given_objects(s, p, C)?.map_or_else(|| selected_roots(s), |ids| Ok(outermost(&s.doc()?.doc, ids)))?)?
|
||||
let roots = super::given_objects(s, p, C)?.map_or_else(|| selected_roots(s), |ids| Ok(outermost(&s.doc()?.doc, ids)))?;
|
||||
// A Live Paint group's fill gradient is on its faces and its stroke gradient on its edges.
|
||||
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)?,
|
||||
};
|
||||
|
||||
@@ -228,9 +228,11 @@ impl Session {
|
||||
if !self.prefs.new_art_basic {
|
||||
return;
|
||||
}
|
||||
let has_paint = self
|
||||
.proxy_source(false)
|
||||
.is_some_and(|(n, _)| matches!(n.kind, NodeKind::Text(_)) || !n.appearance.items.is_empty() || n.extras().colorize.is_some());
|
||||
// A Live Paint group with edges and no faces shows only a stroke.
|
||||
let has_paint = [false, true].into_iter().any(|stroke| {
|
||||
self.proxy_source(stroke)
|
||||
.is_some_and(|(n, _)| matches!(n.kind, NodeKind::Text(_)) || !n.appearance.items.is_empty() || n.extras().colorize.is_some())
|
||||
});
|
||||
if !has_paint {
|
||||
return;
|
||||
}
|
||||
|
||||
+222
-35
@@ -4,7 +4,9 @@ use std::borrow::Cow;
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_color::{BlendMode, Color, GradientPaint, Paint};
|
||||
use vectorcraft_doc::{Appearance, CharStyle, Document, GraySource, Node, NodeId, NodeKind};
|
||||
use vectorcraft_doc::appearance::{FillLayer, StrokeLayer};
|
||||
use vectorcraft_doc::{Appearance, AppearanceItem, CharStyle, Document, GraySource, Node, NodeId, NodeKind};
|
||||
use vectorcraft_tools::builder::{edges, faces, is_live_paint};
|
||||
|
||||
use super::appearance::{ItemTarget, edit_items, edit_items_then, item_target, row_targets};
|
||||
use super::gradient::{item_paint_bounds, place_paint, place_run_paint, run_paint_mut, run_stroke_weight, unplaced};
|
||||
@@ -25,7 +27,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Fill",
|
||||
[],
|
||||
None,
|
||||
"{color?: \"#rrggbb\"|[r,g,b]|{c,m,y,k}|{gray}|{l,a,b} (CIE Lab; #rrggbbaa and #rgba are refused), none?: true, swatch?: name (a global or spot colour stays linked, so swatch edits recolour it; a tint swatch links to its base at its tint; a gradient swatch is recorded as the gradient's swatch and fits each object, keeping its aspect; the built-in \"[Registration]\" prints on every plate), tint?: 0..100 (% of a global or spot `swatch`; default 100, or a tint swatch's own), gradient?: {kind?: linear|radial|conic|diamond|freeform (conic, also accepted as angle or conical: the stops sweep once around the center `start`, clockwise from the vector; diamond: the stops run from the center `start` out to a square with a corner at `end`), method?: classic|perceptual|hue-clockwise|hue-counterclockwise (as paint.editGradient; default classic), spread?: pad|repeat|reflect (as paint.editGradient; default pad), repeats?: 1..100 (as paint.editGradient; default 1), stops?: [{offset 0..1, color, opacity? 0..1 (or 0..100), midpoint? 0.13..0.87, swatch?: global or spot colour (or tint) swatch the stop links to (its colour comes from the swatch), tint?: 0..100}] (at least 2; default white→black), angle?: deg counter-clockwise (0: the gradient runs left to right), start?: [x,y], end?: [x,y] (the vector in document coordinates, both or neither; type objects keep it in text space), aspect?: % (radial, conic and diamond; a negative one mirrors a conic's sweep, counterclockwise, and is an error for the other kinds; without start/end the gradient is placed on each object's bounds), focal?: [x,y] (radial, with start/end: the focal point, where the first stop sits; an error with a conic or diamond), dither?: bool (linear, radial, conic and diamond fills: drawn with fine noise that hides banding, and as pixels in SVG and PDF exports; strokes ignore it), swatch?: linked gradient swatch name}, item?: appearance item index|null (omitted: the Appearance panel's active item if it is a fill, else the top fill), aligned?: bool (index and item are rows of the first target's stack: each other target edits its equal one, as the Appearance panel does for a mixed selection; with the art of a graph design in a series given first, rows of the art's stack: docs/mcp.md), ids?|id?, focus?: true (false keeps the active proxy), keepModel?: false (in a CMYK document, RGB colours and gradient stops are stored as CMYK unless true; Gray stays Gray), target?: \"object\"|\"contents\", span?: \"object\" (default: each target fits a gradient to its own bounds)|\"selection\" (a linear, radial, conic or diamond `gradient` without start/end is placed once on the union of the targets' bounds, so it runs across them)} sets the selection's fill and the default (new art fits a gradient to itself); a solid color recolors only the gradient mesh points picked with the Mesh tool, Direct Selection or the Lasso (unless an `item` index is given or the Appearance panel's active item is a fill); while the Type tool has characters selected (and no ids or item are given), the paint goes to those characters only; without `item`, a grayscale or 1-bit image takes a solid color as the color it is drawn in (white pixels transparent; `none` takes it off; an image with an alpha channel takes only a spot color, black or white; a colorized image whose link is missing takes a solid color as its new colorize color, and refuses a process color while its color is a spot color, black or white); with an object of a dynamic symbol instance selected by Direct Selection and no ids, id or item, that object's fill changes for this instance only (solid, none, gradient or pattern). On a path directly in a graph series, the graph also stores the paint of the topmost visible fill when the command wrote that row or changed it (exceptions: docs/mcp.md); on a graph label, the graph stores the paint for every label of its kind, as a character fill when the characters took it and with the label's rows when a row did; on a graph's axis line, tick mark or radar ring, its rows for every line of its kind. While the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), only the default changes (the color the bucket paints with) and the selection keeps its paint → {objects: how many objects took the paint (the objects inside a group, unless an appearance item of the group's own is targeted; 0 when only the default changed)}",
|
||||
"{color?: \"#rrggbb\"|[r,g,b]|{c,m,y,k}|{gray}|{l,a,b} (CIE Lab; #rrggbbaa and #rgba are refused), none?: true, swatch?: name (a global or spot colour stays linked, so swatch edits recolour it; a tint swatch links to its base at its tint; a gradient swatch is recorded as the gradient's swatch and fits each object, keeping its aspect; the built-in \"[Registration]\" prints on every plate), tint?: 0..100 (% of a global or spot `swatch`; default 100, or a tint swatch's own), gradient?: {kind?: linear|radial|conic|diamond|freeform (conic, also accepted as angle or conical: the stops sweep once around the center `start`, clockwise from the vector; diamond: the stops run from the center `start` out to a square with a corner at `end`), method?: classic|perceptual|hue-clockwise|hue-counterclockwise (as paint.editGradient; default classic), spread?: pad|repeat|reflect (as paint.editGradient; default pad), repeats?: 1..100 (as paint.editGradient; default 1), stops?: [{offset 0..1, color, opacity? 0..1 (or 0..100), midpoint? 0.13..0.87, swatch?: global or spot colour (or tint) swatch the stop links to (its colour comes from the swatch), tint?: 0..100}] (at least 2; default white→black), angle?: deg counter-clockwise (0: the gradient runs left to right), start?: [x,y], end?: [x,y] (the vector in document coordinates, both or neither; type objects keep it in text space), aspect?: % (radial, conic and diamond; a negative one mirrors a conic's sweep, counterclockwise, and is an error for the other kinds; without start/end the gradient is placed on each object's bounds), focal?: [x,y] (radial, with start/end: the focal point, where the first stop sits; an error with a conic or diamond), dither?: bool (linear, radial, conic and diamond fills: drawn with fine noise that hides banding, and as pixels in SVG and PDF exports; strokes ignore it), swatch?: linked gradient swatch name}, item?: appearance item index|null (omitted: the Appearance panel's active item if it is a fill, else the top fill), aligned?: bool (index and item are rows of the first target's stack: each other target edits its equal one, as the Appearance panel does for a mixed selection; with the art of a graph design in a series given first, rows of the art's stack: docs/mcp.md), ids?|id?, focus?: true (false keeps the active proxy), keepModel?: false (in a CMYK document, RGB colours and gradient stops are stored as CMYK unless true; Gray stays Gray), target?: \"object\"|\"contents\", span?: \"object\" (default: each target fits a gradient to its own bounds)|\"selection\" (a linear, radial, conic or diamond `gradient` without start/end is placed once on the union of the targets' bounds, so it runs across them)} sets the selection's fill and the default (new art fits a gradient to itself); a solid color recolors only the gradient mesh points picked with the Mesh tool, Direct Selection or the Lasso (unless an `item` index is given or the Appearance panel's active item is a fill); while the Type tool has characters selected (and no ids or item are given), the paint goes to those characters only; without `item`, a Live Paint group among the targets (or inside one) takes the fill on its faces only; without `item`, a grayscale or 1-bit image takes a solid color as the color it is drawn in (white pixels transparent; `none` takes it off; an image with an alpha channel takes only a spot color, black or white; a colorized image whose link is missing takes a solid color as its new colorize color, and refuses a process color while its color is a spot color, black or white); with an object of a dynamic symbol instance selected by Direct Selection and no ids, id or item, that object's fill changes for this instance only (solid, none, gradient or pattern). On a path directly in a graph series, the graph also stores the paint of the topmost visible fill when the command wrote that row or changed it (exceptions: docs/mcp.md); on a graph label, the graph stores the paint for every label of its kind, as a character fill when the characters took it and with the label's rows when a row did; on a graph's axis line, tick mark or radar ring, its rows for every line of its kind. While the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), only the default changes (the color the bucket paints with) and the selection keeps its paint → {objects: how many objects took the paint (the objects inside a group, unless an appearance item of the group's own is targeted; 0 when only the default changed)}",
|
||||
has_doc,
|
||||
|s, p| set_paint(s, p, true)
|
||||
),
|
||||
@@ -34,7 +36,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Stroke",
|
||||
[],
|
||||
None,
|
||||
"{…as paint.setFill, item?: the stroke item to set, aligned?: bool (as paint.setFill)} same as paint.setFill, for the stroke; with an object of a dynamic symbol instance selected by Direct Selection and no ids, id or item, that object's stroke changes for this instance only (solid, none, gradient or pattern). On a path directly in a graph series, the graph also stores the paint and weight of the topmost visible stroke when the command wrote that row or changed it (exceptions: docs/mcp.md); on a graph label, as paint.setFill",
|
||||
"{…as paint.setFill, item?: the stroke item to set, aligned?: bool (as paint.setFill)} same as paint.setFill, for the stroke; without `item`, a Live Paint group among the targets (or inside one) takes the stroke on its edges only; with an object of a dynamic symbol instance selected by Direct Selection and no ids, id or item, that object's stroke changes for this instance only (solid, none, gradient or pattern). On a path directly in a graph series, the graph also stores the paint and weight of the topmost visible stroke when the command wrote that row or changed it (exceptions: docs/mcp.md); on a graph label, as paint.setFill",
|
||||
has_doc,
|
||||
|s, p| { set_paint(s, p, false) }
|
||||
),
|
||||
@@ -43,7 +45,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Swap Fill and Stroke",
|
||||
[],
|
||||
Some("Shift+X"),
|
||||
"{ids?|id?} swap the fill and stroke of the selection (type too) and of the defaults. On a path directly in a graph series, the graph also stores the swapped paints and the stroke weight, and on a graph label the swapped paints of its characters for every label of its kind, and on a graph's axis line, tick mark or radar ring what the swap changes on its rows for every line of its kind (exceptions: docs/mcp.md). While the Live Paint Bucket is the active tool and no ids or id are given (a null one counts as none), only the defaults change",
|
||||
"{ids?|id?} swap the fill and stroke of the selection (type too) and of the defaults. A Live Paint group's faces take the stroke its edges share and its edges take the fill its faces share, a gradient fitted to each face or edge; a group whose faces' fills or edges' strokes differ (a freeform gradient counts as differing), or that has no face or no edge, keeps its paint. On a path directly in a graph series, the graph also stores the swapped paints and the stroke weight, and on a graph label the swapped paints of its characters for every label of its kind, and on a graph's axis line, tick mark or radar ring what the swap changes on its rows for every line of its kind (exceptions: docs/mcp.md). While the Live Paint Bucket is the active tool and no ids or id are given (a null one counts as none), only the defaults change",
|
||||
has_doc,
|
||||
swap
|
||||
),
|
||||
@@ -52,7 +54,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Default Fill and Stroke",
|
||||
[],
|
||||
Some("D"),
|
||||
"{ids?|id?} white fill and 1 pt black stroke for the selection and the defaults (in a document whose Default Graphic Style differs from the shipped one, as a New Document profile can redefine it: that style's fills, strokes and effects, without its opacity or a link to it); type gets black fill and no stroke. 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 on a graph label the black fill and no stroke of its characters for every label of its kind, and on a graph's axis line, tick mark or radar ring its rows for every line of its kind (exceptions: docs/mcp.md). While the Live Paint Bucket is the active tool and no ids or id are given (a null one counts as none), only the defaults change",
|
||||
"{ids?|id?} white fill and 1 pt black stroke for the selection and the defaults (in a document whose Default Graphic Style differs from the shipped one, as a New Document profile can redefine it: that style's fills, strokes and effects, without its opacity or a link to it); type gets black fill and no stroke. A Live Paint group's faces get no fill and its edges get a 0.5 pt black stroke, in place of their whole appearance and also when the Default Graphic Style is redefined, and with only Live Paint groups selected (or in ids) the defaults 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). 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 on a graph label the black fill and no stroke of its characters for every label of its kind, and on a graph's axis line, tick mark or radar ring its rows for every line of its kind (exceptions: docs/mcp.md). While the Live Paint Bucket is the active tool and no ids or id are given (a null one counts as none), only the defaults change",
|
||||
has_doc,
|
||||
default_paint
|
||||
),
|
||||
@@ -100,7 +102,7 @@ pub fn proxy_specs() -> Vec<CommandSpec> {
|
||||
"Invert",
|
||||
[],
|
||||
None,
|
||||
"{stroke?: bool (default: the active proxy), ids?|id?, item?: appearance item index|null, aligned?: bool (as paint.setFill), target?: \"object\"|\"contents\"} invert the active proxy's colours of the selection (or ids; groups recolour their contents and, except with target \"contents\", their own fills and strokes; a compound path's member stands for its compound path) keeping each colour's model, as edit.colors.invert does; the Appearance panel's active fill/stroke item (appearance.setActiveItem) is inverted instead when it is of that kind and no ids are given; with an object of a dynamic symbol instance selected by Direct Selection and no ids, id or item, that object's solid color changes for this instance only, and a gradient or pattern, or type whose characters differ in color, is refused; with nothing selected, or while the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), invert the default. On a path directly in a graph series, the graph also stores the new color of the topmost visible fill or stroke, and on a graph label the new color of its characters and rows for every label of its kind, and on a graph's axis line, tick mark or radar ring its rows for every line of its kind (docs/mcp.md); no undo step when no color changes → {changed}",
|
||||
"{stroke?: bool (default: the active proxy), ids?|id?, item?: appearance item index|null, aligned?: bool (as paint.setFill), target?: \"object\"|\"contents\"} invert the active proxy's colours of the selection (or ids; groups recolour their contents and, except with target \"contents\", their own fills and strokes; a compound path's member stands for its compound path; a Live Paint group recolors its faces' fills or its edges' strokes) keeping each colour's model, as edit.colors.invert does; the Appearance panel's active fill/stroke item (appearance.setActiveItem) is inverted instead when it is of that kind and no ids are given; with an object of a dynamic symbol instance selected by Direct Selection and no ids, id or item, that object's solid color changes for this instance only, and a gradient or pattern, or type whose characters differ in color, is refused; with nothing selected, or while the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), invert the default. On a path directly in a graph series, the graph also stores the new color of the topmost visible fill or stroke, and on a graph label the new color of its characters and rows for every label of its kind, and on a graph's axis line, tick mark or radar ring its rows for every line of its kind (docs/mcp.md); no undo step when no color changes → {changed}",
|
||||
has_doc,
|
||||
|s, p| proxy_recolor(s, p, "paint.invert", "Invert", &super::colorcmds::invert)
|
||||
),
|
||||
@@ -109,7 +111,7 @@ pub fn proxy_specs() -> Vec<CommandSpec> {
|
||||
"Complement",
|
||||
[],
|
||||
None,
|
||||
"{stroke?: bool (default: the active proxy), ids?|id?, item?: appearance item index|null, aligned?: bool (as paint.setFill), target?: \"object\"|\"contents\"} replace the active proxy's colours by their complements ((highest + lowest) − each component, over RGB or CMY; grey unchanged) keeping each colour's model; honours the Appearance panel's active item and a selected object of a dynamic symbol instance as paint.invert does; with nothing selected, or while the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), the default; no undo step when no color changes → {changed}",
|
||||
"{stroke?: bool (default: the active proxy), ids?|id?, item?: appearance item index|null, aligned?: bool (as paint.setFill), target?: \"object\"|\"contents\"} replace the active proxy's colours by their complements ((highest + lowest) − each component, over RGB or CMY; grey unchanged) keeping each colour's model; a Live Paint group recolors its faces' fills or its edges' strokes as with paint.invert; honours the Appearance panel's active item and a selected object of a dynamic symbol instance as paint.invert does; with nothing selected, or while the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), the default; no undo step when no color changes → {changed}",
|
||||
has_doc,
|
||||
|s, p| proxy_recolor(s, p, "paint.complement", "Complement", &|c: Color| c.complement_keep_model())
|
||||
),
|
||||
@@ -158,7 +160,7 @@ pub fn proxy_specs() -> Vec<CommandSpec> {
|
||||
"Fill and Stroke",
|
||||
[],
|
||||
None,
|
||||
"{} → {fill, stroke: the paints the Fill/Stroke proxies show (the Appearance panel's active item for the proxy of its kind, else the first selected object's, a group's first painted object's, type: its first run's; else the defaults for new art; when that object is a gradient mesh with points picked by the Mesh tool, Direct Selection or the Lasso and no fill item is active, the fill is its first picked point's color), fillActive, fillMixed, strokeMixed: the selected objects' (or a selected group's contents') fills (strokes) differ, shown as a \"?\" proxy (a gradient mesh with points picked counts with their colors)}",
|
||||
"{} → {fill, stroke: the paints the Fill/Stroke proxies show (the Appearance panel's active item for the proxy of its kind, else the first selected object's, a group's first painted object's, a Live Paint group's first face's fill and first edge's stroke, type: its first run's; else the defaults for new art; when that object is a gradient mesh with points picked by the Mesh tool, Direct Selection or the Lasso and no fill item is active, the fill is its first picked point's color), fillActive, fillMixed, strokeMixed: the selected objects' (or a selected group's contents') fills (strokes) differ, a Live Paint group counting with its faces' fills and its edges' strokes, shown as a \"?\" proxy (a gradient mesh with points picked counts with their colors)}",
|
||||
always,
|
||||
proxies
|
||||
),
|
||||
@@ -182,10 +184,11 @@ impl Session {
|
||||
|
||||
/// The fill and stroke the Fill/Stroke proxies show: the Appearance panel's active item (in the
|
||||
/// first selected object's own stack) for the proxy of its kind, else the first selected
|
||||
/// object's (a group's first painted object's; type: its first run's), else the defaults for
|
||||
/// new art. When the object whose fill the proxy shows is a gradient mesh with points picked
|
||||
/// ([`Session::fill_mesh_points`]), the fill is its first picked point's color, which a solid
|
||||
/// fill color changes.
|
||||
/// object's (a group's first painted object's; a Live Paint group's first face's fill and first
|
||||
/// edge's stroke, or the next selected object's when it has no face or edge; type: its first
|
||||
/// run's), else the defaults for new art. When the object whose fill the proxy shows is a
|
||||
/// gradient mesh with points picked ([`Session::fill_mesh_points`]), the fill is its first
|
||||
/// picked point's color, which a solid fill color changes.
|
||||
pub fn proxy_paints(&self) -> (Paint, Paint) {
|
||||
let points = self.fill_mesh_points();
|
||||
let show = |stroke: bool| match self.proxy_source(stroke) {
|
||||
@@ -215,9 +218,20 @@ impl Session {
|
||||
if first.appearance.item_of_kind(item, !stroke).is_some() {
|
||||
return Some((Cow::Borrowed(first), item));
|
||||
}
|
||||
let mut nodes = vec![];
|
||||
painted(first, true, &mut nodes);
|
||||
nodes.first().map(|n| (Cow::Borrowed(*n), None))
|
||||
// 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() {
|
||||
let Some(n) = st.doc.node(*id) else { continue };
|
||||
let mut nodes = vec![];
|
||||
painted(n, true, stroke, &mut nodes);
|
||||
if let Some(n) = nodes.first() {
|
||||
return Some((Cow::Borrowed(*n), None));
|
||||
}
|
||||
if !is_live_paint(n) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub(crate) fn remember_paint_now(&mut self, p: &Paint) {
|
||||
@@ -258,21 +272,35 @@ 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.
|
||||
pub(crate) fn painted<'a>(n: &'a Node, top: bool, out: &mut Vec<&'a Node>) {
|
||||
/// other containers inside them), a compound path for its parts. A Live Paint group stands for its
|
||||
/// faces in the fill proxy (`stroke` false) and for its edges in the stroke proxy, the parts a fill
|
||||
/// or a stroke given to it changes ([`live_paint_parts_skipped`]).
|
||||
pub(crate) fn painted<'a>(n: &'a Node, top: bool, stroke: bool, out: &mut Vec<&'a Node>) {
|
||||
// A ruler guide has no paints.
|
||||
if n.is_ruler_guide() {
|
||||
return;
|
||||
}
|
||||
if is_live_paint(n) {
|
||||
out.extend(if stroke { edges(n) } else { faces(n) }.into_iter().map(|part| &**part));
|
||||
return;
|
||||
}
|
||||
let expand = match n.kind {
|
||||
NodeKind::Group { .. } | NodeKind::Layer { .. } => true,
|
||||
NodeKind::Compound { .. } => false,
|
||||
_ => !top && n.is_container(),
|
||||
};
|
||||
if expand {
|
||||
n.children().into_iter().flatten().for_each(|c| painted(c, false, out));
|
||||
n.children().into_iter().flatten().for_each(|c| painted(c, false, stroke, out));
|
||||
} else {
|
||||
out.push(n);
|
||||
}
|
||||
@@ -301,18 +329,31 @@ 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 nodes) = (vec![], vec![]);
|
||||
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();
|
||||
// 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()) {
|
||||
#[cfg(test)]
|
||||
tests::note_gathered();
|
||||
selected.push(n);
|
||||
painted(n, true, &mut nodes);
|
||||
if covered.contains(&n.id) {
|
||||
continue;
|
||||
}
|
||||
covered.extend(live_paint_parts(n));
|
||||
painted(n, true, false, &mut fills);
|
||||
painted(n, true, true, &mut strokes);
|
||||
}
|
||||
let differ = |stroke: bool| {
|
||||
let item = first.and_then(|f| f.appearance.item_of_kind(item, !stroke));
|
||||
let set = if item.is_some() { &selected } else { &nodes };
|
||||
let set = if item.is_some() {
|
||||
&selected
|
||||
} else if stroke {
|
||||
&strokes
|
||||
} else {
|
||||
&fills
|
||||
};
|
||||
let mut paints = set.iter().flat_map(|n| match picked_colors(n, if stroke || item.is_some() { &[] } else { points }) {
|
||||
c if c.is_empty() => vec![proxy_paint(n, stroke, item)],
|
||||
c => c.into_iter().map(Paint::solid).collect(),
|
||||
@@ -568,7 +609,7 @@ pub(crate) fn apply_paint(s: &mut Session, p: &Value, paint: Paint, fill: bool)
|
||||
}
|
||||
// Resolve the requested targets before mutating defaults or the active proxy.
|
||||
let item = item_target(s, p, cmd)?.of_kind(s, fill);
|
||||
let selected = item.targets(s, p)?;
|
||||
let selected = item.targets_for(s, p, fill)?;
|
||||
let ids = super::graph::paint_targets(&s.doc()?.doc, &selected);
|
||||
let of = super::appearance::reference_of(s, p, item, cmd)?;
|
||||
let paint = if span {
|
||||
@@ -717,6 +758,68 @@ pub(crate) fn bucket_color_params(s: &Session, p: &Value, cmd: &str) -> Result<O
|
||||
Ok(Some(Value::Object(v)))
|
||||
}
|
||||
|
||||
/// The Live Paint groups in `roots` (or inside them), given or selected whole, with the ids of
|
||||
/// their faces and of their edges, found where [`leaf_targets`] finds the objects a paint command
|
||||
/// changes: a given or selected object other than a group or layer (a blend, say) and a compound
|
||||
/// shape are painted as one object, and a Live Paint group kept among another one's hidden sources
|
||||
/// is not one of them. The art of graph designs drawn in graph series is left out.
|
||||
fn live_paint_groups(d: &Document, roots: &[NodeId]) -> Vec<(NodeId, Vec<NodeId>, Vec<NodeId>)> {
|
||||
fn find<'a>(n: &'a Node, top: bool, out: &mut Vec<&'a Node>) {
|
||||
let group = matches!(n.kind, NodeKind::Group { .. } | NodeKind::Layer { .. });
|
||||
if is_live_paint(n) {
|
||||
out.push(n);
|
||||
} else if (group || !top) && !n.is_compound_shape() && !matches!(n.kind, NodeKind::Compound { .. }) {
|
||||
n.children().into_iter().flatten().for_each(|c| find(c, false, out));
|
||||
}
|
||||
}
|
||||
let mut found = vec![];
|
||||
for n in roots.iter().filter_map(|r| d.node(*r)) {
|
||||
find(n, true, &mut found);
|
||||
}
|
||||
let mut seen = std::collections::HashSet::new();
|
||||
found.retain(|g| seen.insert(g.id));
|
||||
// A given or selected compound shape or compound path (or one inside a given or selected object) paints its members,
|
||||
// also when one of them is given as well. A Live Paint group given inside one that is not given stays a Live Paint group.
|
||||
let owns = |id: &NodeId| d.node(*id).is_some_and(|n| n.is_compound_shape() || matches!(n.kind, NodeKind::Compound { .. }));
|
||||
let given: std::collections::HashSet<NodeId> = roots.iter().copied().collect();
|
||||
found.retain(|g| {
|
||||
!d.ancestry(g.id).is_some_and(|up| {
|
||||
let outer = up.iter().position(|a| given.contains(a)).unwrap_or(up.len());
|
||||
up.iter().skip(outer).any(|a| *a != g.id && owns(a))
|
||||
})
|
||||
});
|
||||
let kept: std::collections::HashSet<NodeId> = super::appearance::drop_design_art(d, found.iter().map(|g| g.id).collect()).into_iter().collect();
|
||||
let ids = |parts: Vec<&std::sync::Arc<Node>>| parts.into_iter().map(|part| part.id).collect();
|
||||
found.into_iter().filter(|g| kept.contains(&g.id)).map(|g| (g.id, ids(faces(g)), ids(edges(g)))).collect()
|
||||
}
|
||||
|
||||
/// Every object inside the Live Paint groups `groups` (faces, edges and the hidden source paths).
|
||||
fn inside_live_paint(d: &Document, groups: &[(NodeId, Vec<NodeId>, Vec<NodeId>)]) -> std::collections::HashSet<NodeId> {
|
||||
let mut out = std::collections::HashSet::new();
|
||||
for n in groups.iter().filter_map(|(g, _, _)| d.node(*g)) {
|
||||
n.walk(&mut |c| {
|
||||
if c.id != n.id {
|
||||
out.insert(c.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The objects inside the Live Paint groups in `roots` (or inside them) that a fill (`fill`) or a
|
||||
/// stroke given to the whole group leaves as they are: a fill paints the group's faces only, and a
|
||||
/// stroke its edges only. Their edges (faces) and hidden source paths are left out.
|
||||
pub(crate) fn live_paint_parts_skipped(d: &Document, roots: &[NodeId], fill: bool) -> std::collections::HashSet<NodeId> {
|
||||
let groups = live_paint_groups(d, roots);
|
||||
let mut out = inside_live_paint(d, &groups);
|
||||
for (_, faces, edges) in &groups {
|
||||
for id in if fill { faces } else { edges } {
|
||||
out.remove(id);
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// 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.
|
||||
@@ -1021,20 +1124,62 @@ pub(super) fn restore_unpainted_stroke(ap: &mut Appearance, index: Option<usize>
|
||||
}
|
||||
}
|
||||
|
||||
/// The paint every one of `parts` has on top as its fill (`fill`) or stroke, swatch link included
|
||||
/// and gradient placement left out ([`unplaced`]: each part fits it to its own bounds), or None
|
||||
/// when they differ or there are none. A freeform gradient's points and their colors belong to the
|
||||
/// part they sit on, so a freeform gradient on any part counts as a paint the parts do not share.
|
||||
fn shared_paint(d: &Document, parts: &[NodeId], fill: bool) -> Option<Paint> {
|
||||
let mut paints = parts.iter().filter_map(|id| d.node(*id)).map(|n| if fill { n.appearance.fill_paint() } else { n.appearance.stroke_paint() });
|
||||
let first = paints.next()?;
|
||||
let freeform =
|
||||
|p: &Paint| matches!(p, Paint::Gradient(g) if g.gradient.kind == vectorcraft_color::GradientKind::Freeform || g.freeform.is_some());
|
||||
if freeform(&first) {
|
||||
return None;
|
||||
}
|
||||
let first = unplaced(&first);
|
||||
paints.all(|p| !freeform(&p) && unplaced(&p) == first).then_some(first)
|
||||
}
|
||||
|
||||
fn swap(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let bucket = bucket_color_params(s, p, "paint.swap")?;
|
||||
let p = bucket.as_ref().unwrap_or(p);
|
||||
let targets = paint_targets(s, p)?;
|
||||
let given = !targets.is_empty();
|
||||
let ids = super::appearance::drop_design_art(&s.doc()?.doc, targets);
|
||||
// A whole Live Paint group: its faces take the stroke its edges share and its edges the fill its faces share.
|
||||
let groups = live_paint_groups(&s.doc()?.doc, &super::targets(s, p)?);
|
||||
let inside = inside_live_paint(&s.doc()?.doc, &groups);
|
||||
let ids = super::appearance::drop_design_art(&s.doc()?.doc, targets.into_iter().filter(|id| !inside.contains(id)).collect());
|
||||
// Only design art was given or selected: nothing changes, the defaults included.
|
||||
if given && ids.is_empty() {
|
||||
if given && ids.is_empty() && groups.is_empty() {
|
||||
return ok();
|
||||
}
|
||||
if !ids.is_empty() {
|
||||
if !ids.is_empty() || !groups.is_empty() {
|
||||
// When every object comes out as it was, the document and its undo history stay as they are.
|
||||
let before = s.doc()?.doc.clone();
|
||||
// A group whose faces' fills (or edges' strokes) differ or are freeform gradients, or that has no face or no edge,
|
||||
// keeps its paint.
|
||||
let swaps: Vec<(&[NodeId], &[NodeId], Paint, Paint)> = groups
|
||||
.iter()
|
||||
.filter_map(|(_, faces, edges)| {
|
||||
Some((faces.as_slice(), edges.as_slice(), shared_paint(&before, faces, true)?, shared_paint(&before, edges, false)?))
|
||||
})
|
||||
.collect();
|
||||
let parts: Vec<NodeId> = groups.iter().flat_map(|(_, faces, edges)| faces.iter().chain(edges)).copied().collect();
|
||||
super::overprint::edit_counted(s, "Swap Fill and Stroke", |d| {
|
||||
for (faces, edges, fill, stroke) in &swaps {
|
||||
for id in *faces {
|
||||
if let Some(n) = d.node_mut(*id) {
|
||||
n.appearance.set_fill(stroke.clone());
|
||||
}
|
||||
}
|
||||
for id in *edges {
|
||||
if let Some(n) = d.node_mut(*id) {
|
||||
restore_unpainted_stroke(&mut n.appearance, None, fill);
|
||||
n.appearance.set_stroke(fill.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
let parts_changed = super::appearance::count_changed(d, &before, &parts);
|
||||
for id in &ids {
|
||||
let Some(n) = d.node_mut(*id) else { continue };
|
||||
if let NodeKind::Text(t) = &mut n.kind {
|
||||
@@ -1054,7 +1199,7 @@ fn swap(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
// The swap writes the paint of the topmost fill and stroke, not their opacity.
|
||||
let kept = super::appearance::capture_series_writes(&before, d, &ids, (true, true), (false, false), true, false);
|
||||
let labels = super::graph::capture_label_changes(&before, d, &ids, false, None);
|
||||
Ok(super::appearance::count_changed(d, &before, &ids) + usize::from(kept || labels))
|
||||
Ok(super::appearance::count_changed(d, &before, &ids) + parts_changed + usize::from(kept || labels))
|
||||
})?;
|
||||
}
|
||||
if s.paint.stroke.is_none() && !s.paint.fill.is_none() && s.paint.stroke_width == 0.0 {
|
||||
@@ -1064,22 +1209,44 @@ fn swap(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
ok()
|
||||
}
|
||||
|
||||
/// The weight of the stroke [`paint.default`](default_paint) gives the edges of a whole Live Paint group.
|
||||
const LIVE_PAINT_DEFAULT_WEIGHT: f64 = 0.5;
|
||||
|
||||
fn default_paint(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let bucket = bucket_color_params(s, p, "paint.default")?;
|
||||
let p = bucket.as_ref().unwrap_or(p);
|
||||
let targets = paint_targets(s, p)?;
|
||||
let given = !targets.is_empty();
|
||||
let ids = super::appearance::drop_design_art(&s.doc()?.doc, targets);
|
||||
// A whole Live Paint group: its faces lose their fill and its edges take a black 0.5 pt stroke.
|
||||
let groups = live_paint_groups(&s.doc()?.doc, &super::targets(s, p)?);
|
||||
let inside = inside_live_paint(&s.doc()?.doc, &groups);
|
||||
let ids = super::appearance::drop_design_art(&s.doc()?.doc, targets.into_iter().filter(|id| !inside.contains(id)).collect());
|
||||
// Only design art was given or selected: nothing changes, the defaults included.
|
||||
if given && ids.is_empty() {
|
||||
if given && ids.is_empty() && groups.is_empty() {
|
||||
return ok();
|
||||
}
|
||||
if !ids.is_empty() {
|
||||
if !ids.is_empty() || !groups.is_empty() {
|
||||
// When every object comes out as it was, the document and its undo history stay as they are.
|
||||
let before = s.doc()?.doc.clone();
|
||||
// A redefined Default Graphic Style gives other art its fills, strokes and effects, placed on each object.
|
||||
let style = super::newart::redefined_default_style(&before).cloned();
|
||||
let parts: Vec<NodeId> = groups.iter().flat_map(|(_, faces, edges)| faces.iter().chain(edges)).copied().collect();
|
||||
super::overprint::edit_counted(s, "Default Fill and Stroke", |d| {
|
||||
for (_, faces, edges) in &groups {
|
||||
let face = Appearance { items: vec![AppearanceItem::Fill(FillLayer::new(Paint::None))], ..Appearance::default() };
|
||||
let edge = Appearance {
|
||||
items: vec![AppearanceItem::Stroke(StrokeLayer::new(Paint::solid(Color::BLACK), LIVE_PAINT_DEFAULT_WEIGHT))],
|
||||
..Appearance::default()
|
||||
};
|
||||
for (ids, look) in [(faces, &face), (edges, &edge)] {
|
||||
for id in ids {
|
||||
if let Some(n) = d.node_mut(*id) {
|
||||
n.appearance = look.clone().into();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let parts_changed = super::appearance::count_changed(d, &before, &parts);
|
||||
for id in &ids {
|
||||
let Some(n) = d.node_mut(*id) else { continue };
|
||||
match &mut n.kind {
|
||||
@@ -1106,10 +1273,20 @@ fn default_paint(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
st.stroke = Paint::None;
|
||||
});
|
||||
let lines = super::graph::capture_line_fill_stroke_rows(d, &ids);
|
||||
Ok(super::appearance::count_changed(d, &before, &ids) + usize::from(kept || labels || lines))
|
||||
Ok(super::appearance::count_changed(d, &before, &ids) + parts_changed + usize::from(kept || labels || lines))
|
||||
})?;
|
||||
}
|
||||
super::newart::reset(s);
|
||||
if ids.is_empty() && !groups.is_empty() {
|
||||
// With only whole Live Paint groups given or selected, new art takes what their parts took, and nothing else.
|
||||
s.paint = vectorcraft_tools::PaintDefaults {
|
||||
fill: Paint::None,
|
||||
stroke: Paint::solid(Color::BLACK),
|
||||
stroke_width: LIVE_PAINT_DEFAULT_WEIGHT,
|
||||
..Default::default()
|
||||
};
|
||||
} else {
|
||||
super::newart::reset(s);
|
||||
}
|
||||
ok()
|
||||
}
|
||||
|
||||
@@ -1215,11 +1392,20 @@ fn proxy_recolor(s: &mut Session, p: &Value, cmd: &str, label: &str, f: &dyn Fn(
|
||||
if roots.is_empty() {
|
||||
return Ok(json!({ "changed": 0 }));
|
||||
}
|
||||
let art = super::appearance::design_art_in(d, &roots).into_iter().collect();
|
||||
// The fill or stroke the proxy shows of each group among the roots, before the edit.
|
||||
// A Live Paint group's fill is its faces' fills and its stroke its edges' strokes, also with `target: "contents"`;
|
||||
// like any group, it recolors rows of its own as well.
|
||||
let parts_skipped = live_paint_parts_skipped(d, &ids, !stroke);
|
||||
let roots: Vec<NodeId> = roots.into_iter().filter(|id| !parts_skipped.contains(id)).collect();
|
||||
if roots.is_empty() {
|
||||
return Ok(json!({ "changed": 0 }));
|
||||
}
|
||||
let mut art: std::collections::HashSet<NodeId> = super::appearance::design_art_in(d, &roots).into_iter().collect();
|
||||
art.extend(parts_skipped.iter().copied());
|
||||
// The fill or stroke the proxy shows of each group among the roots, before the edit (a Live Paint group shows
|
||||
// its faces' or edges').
|
||||
let own = |d: &Document, id: NodeId| {
|
||||
d.node(id)
|
||||
.filter(|n| matches!(n.kind, NodeKind::Group { .. } | NodeKind::Layer { .. }))
|
||||
.filter(|n| matches!(n.kind, NodeKind::Group { .. } | NodeKind::Layer { .. }) && !is_live_paint(n))
|
||||
.and_then(|n| n.proxy_paint_only(stroke, None))
|
||||
.cloned()
|
||||
};
|
||||
@@ -1237,7 +1423,8 @@ fn proxy_recolor(s: &mut Session, p: &Value, cmd: &str, label: &str, f: &dyn Fn(
|
||||
shown_at = Some((*id, None));
|
||||
break;
|
||||
}
|
||||
if let Some(leaf) = super::appearance::drop_design_art(d, leaf_targets(s, &[*id])?).first() {
|
||||
let leaves = leaf_targets(s, &[*id])?.into_iter().filter(|leaf| !parts_skipped.contains(leaf)).collect();
|
||||
if let Some(leaf) = super::appearance::drop_design_art(d, leaves).first() {
|
||||
shown_at = Some((*leaf, None));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -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::{painted, picked_colors, proxy_paint, same_in_proxy};
|
||||
use super::{live_paint_parts, painted, picked_colors, proxy_paint, same_in_proxy};
|
||||
use crate::{DocState, Session};
|
||||
|
||||
thread_local! {
|
||||
@@ -38,17 +38,28 @@ fn walked(st: &DocState, item: Option<usize>, points: &[(NodeId, Vec<usize>)]) -
|
||||
return (false, false);
|
||||
}
|
||||
let ids: HashSet<NodeId> = st.selection.objects.iter().copied().collect();
|
||||
let (mut selected, mut nodes) = (vec![], vec![]);
|
||||
let (mut selected, mut fills, mut strokes) = (vec![], vec![], vec![]);
|
||||
let mut covered = HashSet::new();
|
||||
st.doc.walk(|n| {
|
||||
if ids.contains(&n.id) {
|
||||
selected.push(n);
|
||||
painted(n, true, &mut nodes);
|
||||
if !covered.contains(&n.id) {
|
||||
covered.extend(live_paint_parts(n));
|
||||
painted(n, true, false, &mut fills);
|
||||
painted(n, true, true, &mut strokes);
|
||||
}
|
||||
}
|
||||
});
|
||||
let first = st.selection.objects.first().and_then(|id| st.doc.node(*id));
|
||||
let differ = |stroke: bool| {
|
||||
let item = first.and_then(|f| f.appearance.item_of_kind(item, !stroke));
|
||||
let set = if item.is_some() { &selected } else { &nodes };
|
||||
let set = if item.is_some() {
|
||||
&selected
|
||||
} else if stroke {
|
||||
&strokes
|
||||
} else {
|
||||
&fills
|
||||
};
|
||||
let mut paints = set.iter().flat_map(|n| match picked_colors(n, if stroke || item.is_some() { &[] } else { points }) {
|
||||
c if c.is_empty() => vec![proxy_paint(n, stroke, item)],
|
||||
c => c.into_iter().map(Paint::solid).collect(),
|
||||
|
||||
@@ -463,6 +463,7 @@ pub(super) const ALLOWED: &[&str] = &[
|
||||
"path.mirrorCut",
|
||||
"path.moveAnchor",
|
||||
"path.moveAnchors",
|
||||
"path.quickPen",
|
||||
"path.rectCut",
|
||||
"path.removeAnchor",
|
||||
"path.removeAnchors",
|
||||
|
||||
@@ -8,9 +8,10 @@ use vectorcraft_doc::{
|
||||
Unit, WidthProfile,
|
||||
};
|
||||
use vectorcraft_geom::PathData;
|
||||
use vectorcraft_tools::builder::is_live_paint;
|
||||
|
||||
use super::appearance::{ItemTarget, edit_items, item_target};
|
||||
use super::paint::painted;
|
||||
use super::paint::{live_paint_parts, 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};
|
||||
@@ -22,7 +23,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Stroke Options",
|
||||
["Window", "Stroke"],
|
||||
None,
|
||||
"{weight?: pt, cap?: butt|round|square, join?: miter|round|bevel, miterLimit?, align?: center|inside|outside, dash?: [d,g,…]|null (a 0 dash with a round or projecting cap draws dots or squares; a new pattern keeps the current offset and alignment), dashOffset? (exact dashes only), alignDashes?: bool (true: dashes fitted to corners and path ends, every run between them holding whole periods with a dash centred on each corner and end; false, the default for a new pattern: exact lengths), startArrow?, endArrow?: Arrow|ArrowOpen|LineArrow|Barbed|Concave|DoubleArrow|HalfArrowLeft|HalfArrowRight|Chevron|Feather|Swallowtail|Triangle|TriangleOpen|TriangleReverse|TriangleBar|Kite|Leaf|Drop|Circle|CircleOpen|HalfCircle|Oval|Target|Square|SquareOpen|Tag|TagOpen|Diamond|DiamondOpen|Hexagon|HexagonOpen|Star|Cross|Plus|Bar|DoubleBar|DotOnBar|Slash|DoubleSlash|Bracket|Fork|null|{custom: name} (a custom arrowhead of the arrowheads file, stroke.arrowheads.list)|{Custom: {name, path}} (a custom head with its art, as document.inspect reports one; refused when the path fills no area, parts thinner than a millionth of a head unit counting as none, or has more than 4096 anchors, more than 4096 subpaths or a point more than 64 head units from the tip) (HalfArrowLeft/Right: one barb, left or right of the direction the head points), arrowAlign?: \"extend\" (tip past the end point, default)|\"tip\" (tip on the end point; the stroke is shortened), profile?: \"uniform\"|\"lens\"|\"taperStart\"|\"taperEnd\"|\"pinch\"|\"teardrop\"|\"wave\"|a saved profile's name (stroke.widthProfile.list), widthPoints?, gradientMode? (as document.inspect reports them in strokeOptions, so those read back unchanged; ignored here: a custom profile is set with the Width tool, gradientMode with paint.editGradient), item?: stroke item index|null (omitted: the Appearance panel's active item if it is a stroke, else the top stroke, created when missing), ids?|id?, target?: \"object\"|\"contents\", aligned?: bool (index and item are rows of the first target's stack: each other target edits its equal one, as the Appearance panel does for a mixed selection; with the art of a graph design in a series given first, rows of the art's stack: docs/mcp.md)} Without a stroke item, type takes weight, cap, join, miterLimit, align (around its glyph outlines; the type stays live) and the dash options as its characters' stroke (every run; text.setRangeStyle `strokeOptions` styles a range), and images and symbol instances (also in groups) are left alone. With nothing selected (and no ids) they set up the next object drawn (appearance.newArt; weight always does). On a path directly in a graph series, the graph also stores a weight it changes on the topmost visible stroke (docs/mcp.md); on a graph label's stroke row, the graph stores the label's topmost visible fill and stroke rows for every label of its kind, and on its characters the stroke options they take; on a graph's axis line, tick mark or radar ring, the graph stores the paint, weight, opacity and blend mode of its topmost visible fill and stroke rows that the edit changes, and the weight it writes to the topmost visible stroke, for every line of its kind, and not its caps, joins, dashes, alignment or arrowheads. While the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), only the stroke for new art changes (the bucket paints edges with its color and weight) → {objects: how many objects took the stroke options}",
|
||||
"{weight?: pt, cap?: butt|round|square, join?: miter|round|bevel, miterLimit?, align?: center|inside|outside, dash?: [d,g,…]|null (a 0 dash with a round or projecting cap draws dots or squares; a new pattern keeps the current offset and alignment), dashOffset? (exact dashes only), alignDashes?: bool (true: dashes fitted to corners and path ends, every run between them holding whole periods with a dash centred on each corner and end; false, the default for a new pattern: exact lengths), startArrow?, endArrow?: Arrow|ArrowOpen|LineArrow|Barbed|Concave|DoubleArrow|HalfArrowLeft|HalfArrowRight|Chevron|Feather|Swallowtail|Triangle|TriangleOpen|TriangleReverse|TriangleBar|Kite|Leaf|Drop|Circle|CircleOpen|HalfCircle|Oval|Target|Square|SquareOpen|Tag|TagOpen|Diamond|DiamondOpen|Hexagon|HexagonOpen|Star|Cross|Plus|Bar|DoubleBar|DotOnBar|Slash|DoubleSlash|Bracket|Fork|null|{custom: name} (a custom arrowhead of the arrowheads file, stroke.arrowheads.list)|{Custom: {name, path, stop?}} (a custom head with its art, as document.inspect reports one; stop: where the stroke ends under the head, in head units back from the tip, 0..64 (otherwise, or without one, halfway along the head); refused when the path fills no area, parts thinner than a millionth of a head unit counting as none, or has more than 4096 anchors, more than 4096 subpaths or a point more than 64 head units from the tip) (HalfArrowLeft/Right: one barb, left or right of the direction the head points), arrowAlign?: \"extend\" (tip past the end point, default)|\"tip\" (tip on the end point; the stroke is shortened), profile?: \"uniform\"|\"lens\"|\"taperStart\"|\"taperEnd\"|\"pinch\"|\"teardrop\"|\"wave\"|a saved profile's name (stroke.widthProfile.list), widthPoints?, gradientMode? (as document.inspect reports them in strokeOptions, so those read back unchanged; ignored here: a custom profile is set with the Width tool, gradientMode with paint.editGradient), item?: stroke item index|null (omitted: the Appearance panel's active item if it is a stroke, else the top stroke, created when missing), ids?|id?, target?: \"object\"|\"contents\", aligned?: bool (index and item are rows of the first target's stack: each other target edits its equal one, as the Appearance panel does for a mixed selection; with the art of a graph design in a series given first, rows of the art's stack: docs/mcp.md)} Without a stroke item, type takes weight, cap, join, miterLimit, align (around its glyph outlines; the type stays live) and the dash options as its characters' stroke (every run; text.setRangeStyle `strokeOptions` styles a range), and images and symbol instances (also in groups) are left alone; a Live Paint group takes them on its edges only. With nothing selected (and no ids) they set up the next object drawn (appearance.newArt; weight always does). On a path directly in a graph series, the graph also stores a weight it changes on the topmost visible stroke (docs/mcp.md); on a graph label's stroke row, the graph stores the label's topmost visible fill and stroke rows for every label of its kind, and on its characters the stroke options they take; on a graph's axis line, tick mark or radar ring, the graph stores the paint, weight, opacity and blend mode of its topmost visible fill and stroke rows that the edit changes, and the weight it writes to the topmost visible stroke, for every line of its kind, and not its caps, joins, dashes, alignment or arrowheads. While the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), only the stroke for new art changes (the bucket paints edges with its color and weight) → {objects: how many objects took the stroke options}",
|
||||
has_doc,
|
||||
stroke_set
|
||||
),
|
||||
@@ -31,7 +32,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Stroke Weight Up",
|
||||
[],
|
||||
Some("Cmd+Alt+."),
|
||||
"{ids?|id?} raise each selected stroke's weight by one step of Units › Stroke (a quarter unit below one unit, then whole units; up to 1000 pt), each from its own weight: the selected objects' active or top stroke, type's stroked characters; objects without a stroke are left alone. With nothing selected (and no ids), the weight of the next object drawn, and so while the Live Paint Bucket is the active tool and no ids or id are given (a null one counts as none). On a path directly in a graph series, the graph also stores the new weight of the topmost visible stroke, and on a graph label the new weight of its characters' stroke or its stroke row for every label of its kind, and on a graph's axis line, tick mark or radar ring its rows for every line of its kind (docs/mcp.md) → {objects}",
|
||||
"{ids?|id?} raise each selected stroke's weight by one step of Units › Stroke (a quarter unit below one unit, then whole units; up to 1000 pt), each from its own weight: the selected objects' active or top stroke, type's stroked characters; objects without a stroke, and a Live Paint group's faces, are left alone. With nothing selected (and no ids), the weight of the next object drawn, and so while the Live Paint Bucket is the active tool and no ids or id are given (a null one counts as none). On a path directly in a graph series, the graph also stores the new weight of the topmost visible stroke, and on a graph label the new weight of its characters' stroke or its stroke row for every label of its kind, and on a graph's axis line, tick mark or radar ring its rows for every line of its kind (docs/mcp.md) → {objects}",
|
||||
has_doc,
|
||||
|s, p| stroke_step(s, p, true)
|
||||
),
|
||||
@@ -49,7 +50,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Stroke Options",
|
||||
[],
|
||||
None,
|
||||
"{arrowScale?: [start %, end %], swapArrows?: bool, flipProfile?: \"along\"|\"across\", brush?: name|null, item?: stroke item index|null, aligned?: bool (as stroke.set), ids?|id?, target?: \"object\"|\"contents\"} Stroke panel extras (with nothing selected, all but brush set up the next object drawn, and so while the Live Paint Bucket is the active tool and no ids, id, item or brush are given, a null ids or id counting as none)",
|
||||
"{arrowScale?: [start %, end %], swapArrows?: bool, flipProfile?: \"along\"|\"across\", brush?: name|null, item?: stroke item index|null, aligned?: bool (as stroke.set), ids?|id?, target?: \"object\"|\"contents\"} Stroke panel extras (with nothing selected, all but brush set up the next object drawn, and so while the Live Paint Bucket is the active tool and no ids, id, item or brush are given, a null ids or id counting as none; without item, a Live Paint group's edges take them and its faces are left alone)",
|
||||
has_doc,
|
||||
stroke_advanced
|
||||
),
|
||||
@@ -210,20 +211,25 @@ fn no_targets(ids: &[vectorcraft_doc::NodeId], p: &Value) -> bool {
|
||||
|
||||
/// The objects `stroke.set` edits with no `item`: a selected group or layer with a stroke row of
|
||||
/// its own edits that row, as the Stroke panel does with the group targeted (#6739); the other
|
||||
/// targets reach their painted leaves, as before.
|
||||
/// targets reach their painted leaves, as before (a Live Paint group's edges, not its faces).
|
||||
fn own_stroke_or_leaves(s: &Session, p: &Value) -> Result<Vec<vectorcraft_doc::NodeId>> {
|
||||
let picked = super::targets(s, p)?;
|
||||
let d = &s.doc()?.doc;
|
||||
// A Live Paint group's stroke is its edges' strokes, also when it has a stroke row of its own.
|
||||
let own = |id: &vectorcraft_doc::NodeId| {
|
||||
d.node(*id).is_some_and(|n| {
|
||||
matches!(n.kind, NodeKind::Group { .. } | NodeKind::Layer { .. }) && !n.is_compound_shape() && n.appearance.stroke().is_some()
|
||||
matches!(n.kind, NodeKind::Group { .. } | NodeKind::Layer { .. })
|
||||
&& !n.is_compound_shape()
|
||||
&& n.appearance.stroke().is_some()
|
||||
&& !is_live_paint(n)
|
||||
})
|
||||
};
|
||||
let (mut out, rest): (Vec<_>, Vec<_>) = picked.into_iter().partition(own);
|
||||
let faces = live_paint_parts_skipped(d, &rest, false);
|
||||
// A leaf already listed is skipped; a set keeps this linear in the number of leaves.
|
||||
let mut seen: std::collections::HashSet<vectorcraft_doc::NodeId> = out.iter().copied().collect();
|
||||
for id in super::leaf_targets(s, &rest)? {
|
||||
if seen.insert(id) {
|
||||
if !faces.contains(&id) && seen.insert(id) {
|
||||
out.push(id);
|
||||
}
|
||||
}
|
||||
@@ -246,11 +252,13 @@ fn stroke_set(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
} else {
|
||||
item.targets(s, p)?
|
||||
};
|
||||
let new_art = bucket || no_targets(&ids, p);
|
||||
let given = !ids.is_empty();
|
||||
// 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 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.
|
||||
ids = super::appearance::drop_design_art_rows(s, ids, item, false, C)?;
|
||||
// With only design art, the weight for new art stays as it is too.
|
||||
// With only design art, or only Live Paint groups without edges, the weight for new art stays as it is too.
|
||||
let only_design_art = given && ids.is_empty();
|
||||
if item == ItemTarget::Top {
|
||||
// Images and symbol instances take no stroke from the panel.
|
||||
@@ -388,8 +396,8 @@ fn stroke_step(s: &mut Session, p: &Value, up: bool) -> Result<Value> {
|
||||
let bucket = bucket_p.is_some();
|
||||
let p = bucket_p.as_ref().unwrap_or(p);
|
||||
let item = item_target(s, p, c)?.of_kind(s, false);
|
||||
let ids = if bucket { vec![] } else { item.targets(s, p)? };
|
||||
if bucket || no_targets(&ids, p) {
|
||||
let (ids, skipped) = if bucket { (vec![], false) } else { item.targets_and_skipped(s, p, false)? };
|
||||
if bucket || (no_targets(&ids, p) && !skipped) {
|
||||
let w = step_weight(s.paint.stroke_width, unit, up);
|
||||
s.paint.stroke_width = w;
|
||||
if let Some(st) = s.new_art_stroke_mut() {
|
||||
@@ -428,8 +436,9 @@ impl Session {
|
||||
|
||||
/// The stroke the Stroke panel, the Control bar and the Properties panel show, picked as the
|
||||
/// Stroke proxy picks its paint: the Appearance panel's active item when it is a stroke, else
|
||||
/// the first selected object's (a group's first painted object's) top stroke, type's first
|
||||
/// run's character stroke; with an object of a dynamic symbol instance selected
|
||||
/// the first selected object's (a group's first painted object's, a Live Paint group's first
|
||||
/// edge's, or the next selected object's when a Live Paint group has no edge) top stroke, type's
|
||||
/// first run's character stroke; with an object of a dynamic symbol instance selected
|
||||
/// ([`DocState::selected_symbol_part`]), that object's as the instance draws it; with nothing
|
||||
/// selected, the next object drawn's ([`Session::new_art_stroke`]), and so while the Live Paint
|
||||
/// Bucket is the active tool (the stroke it paints with). None without a document or the
|
||||
@@ -447,9 +456,20 @@ impl Session {
|
||||
if let Some(i) = first.appearance.item_of_kind(self.appearance_item(), false) {
|
||||
return first.appearance.stroke_at(Some(i)).cloned();
|
||||
}
|
||||
let mut nodes = vec![];
|
||||
painted(first, true, &mut nodes);
|
||||
node_stroke(nodes.first()?)
|
||||
// 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 {
|
||||
let Some(n) = st.doc.node(*id) else { continue };
|
||||
let mut nodes = vec![];
|
||||
painted(n, true, true, &mut nodes);
|
||||
if let Some(n) = nodes.first() {
|
||||
return node_stroke(n);
|
||||
}
|
||||
if !is_live_paint(n) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Do all the strokes that `stroke.set` edits without `ids` or `item` draw with a brush
|
||||
@@ -508,12 +528,13 @@ impl DocState {
|
||||
let part = self.selected_symbol_part();
|
||||
let mut nodes = vec![];
|
||||
if let Some(part) = &part {
|
||||
painted(part, true, &mut nodes);
|
||||
painted(part, true, true, &mut nodes);
|
||||
} else {
|
||||
for id in &self.selection.objects {
|
||||
if let Some(n) = self.doc.node(*id) {
|
||||
painted(n, true, &mut nodes);
|
||||
}
|
||||
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();
|
||||
for n in selected.into_iter().filter(|n| !covered.contains(&n.id)) {
|
||||
painted(n, true, true, &mut nodes);
|
||||
}
|
||||
}
|
||||
let mut strokes = vec![];
|
||||
@@ -594,8 +615,8 @@ fn stroke_advanced(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let bucket = bucket_p.is_some();
|
||||
let p = bucket_p.as_ref().unwrap_or(p);
|
||||
let item = item_target(s, p, C)?.of_kind(s, false);
|
||||
let ids = if bucket { vec![] } else { item.targets(s, p)? };
|
||||
let new_art = bucket || no_targets(&ids, p);
|
||||
let (ids, skipped) = if bucket { (vec![], false) } else { item.targets_and_skipped(s, p, false)? };
|
||||
let new_art = bucket || (no_targets(&ids, p) && !skipped);
|
||||
// The art of a graph design in a series keeps the design's stroke.
|
||||
let ids = super::appearance::drop_design_art_rows(s, ids, item, false, C)?;
|
||||
let arrows_and_profile = |st: &mut StrokeLayer| {
|
||||
|
||||
@@ -155,6 +155,7 @@ mod printps;
|
||||
mod printtiling;
|
||||
mod proxyitems;
|
||||
mod puppetwarp;
|
||||
mod quickpen;
|
||||
mod rasterfilters;
|
||||
mod rastersettings;
|
||||
mod recolor;
|
||||
|
||||
@@ -3836,6 +3836,419 @@ fn live_paint_fill_skips_hidden_faces() {
|
||||
assert!(!node(&s, hidden).visible);
|
||||
}
|
||||
|
||||
/// The appearance of each face and each edge of Live Paint group `g`.
|
||||
fn part_looks(s: &Session, g: NodeId) -> (Vec<vectorcraft_doc::Appearance>, Vec<vectorcraft_doc::Appearance>) {
|
||||
use vectorcraft_tools::builder::{edges, faces};
|
||||
let n = node(s, g);
|
||||
let looks = |parts: Vec<&Arc<Node>>| parts.iter().map(|p| (*p.appearance).clone()).collect();
|
||||
(looks(faces(&n)), looks(edges(&n)))
|
||||
}
|
||||
|
||||
/// The appearance of each hidden source path of Live Paint group `g`.
|
||||
fn sources_looks(s: &Session, g: NodeId) -> Vec<vectorcraft_doc::Appearance> {
|
||||
let n = node(s, g);
|
||||
let src = vectorcraft_tools::builder::sources(&n).unwrap();
|
||||
src.children().unwrap().iter().map(|c| (*c.appearance).clone()).collect()
|
||||
}
|
||||
|
||||
/// With a tool other than the Live Paint Bucket, a fill given to a whole selected Live Paint group
|
||||
/// paints its faces and leaves its edges as they are, and a stroke paints its edges and leaves its
|
||||
/// faces as they are. The Fill and Stroke proxies show the faces' fill and the edges' stroke.
|
||||
#[test]
|
||||
fn live_paint_group_fill_goes_to_faces_and_stroke_to_edges() {
|
||||
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 magenta = Paint::solid(Color::from_hex("#ff00ff").unwrap());
|
||||
let sources0 = sources_looks(&s, g);
|
||||
assert_eq!(s.execute("paint.setFill", &json!({"color": "#ff00ff"})).unwrap()["objects"], faces0.len());
|
||||
let (faces1, edges1) = part_looks(&s, g);
|
||||
assert!(faces1.iter().all(|f| f.fill_paint() == magenta));
|
||||
assert_eq!(edges1, edges0, "edges take no fill");
|
||||
let p = s.execute("paint.proxies", &json!({})).unwrap();
|
||||
assert_eq!(p["fillMixed"], false);
|
||||
assert_eq!(p["fill"], serde_json::to_value(&magenta).unwrap());
|
||||
let blue = Paint::solid(Color::from_hex("#0000ff").unwrap());
|
||||
assert_eq!(s.execute("paint.setStroke", &json!({"color": "#0000ff"})).unwrap()["objects"], edges0.len());
|
||||
assert_eq!(sources_looks(&s, g), sources0, "the hidden source paths keep their paint");
|
||||
let (faces2, edges2) = part_looks(&s, g);
|
||||
assert!(edges2.iter().all(|e| e.stroke_paint() == blue));
|
||||
assert_eq!(faces2, faces1, "faces take no stroke");
|
||||
let p = s.execute("paint.proxies", &json!({})).unwrap();
|
||||
assert_eq!(p["strokeMixed"], false);
|
||||
assert_eq!(p["stroke"], serde_json::to_value(&blue).unwrap());
|
||||
// The same with the group given by id, and inside a selected group.
|
||||
s.execute("paint.setFill", &json!({"ids": [g.0], "color": "#00ff00"})).unwrap();
|
||||
let (faces3, edges3) = part_looks(&s, g);
|
||||
assert_eq!(edges3, edges2, "edges take no fill given by id");
|
||||
let green = Paint::solid(Color::from_hex("#00ff00").unwrap());
|
||||
assert!(faces3.iter().all(|f| f.fill_paint() == green));
|
||||
s.execute("object.group", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("paint.setStroke", &json!({"color": "#ff0000"})).unwrap();
|
||||
let (faces4, edges4) = part_looks(&s, g);
|
||||
assert_eq!(faces4, faces3, "faces of a grouped Live Paint group take no stroke");
|
||||
assert!(edges4.iter().all(|e| e.stroke_paint() == Paint::solid(Color::from_hex("#ff0000").unwrap())));
|
||||
// The bucket then paints one face, and nothing in the group draws a fill over it.
|
||||
let r = s.execute("livePaint.fill", &json!({"group": g.0, "point": [75, 50], "color": "#ffff00"})).unwrap();
|
||||
let face = NodeId(r["face"].as_u64().unwrap());
|
||||
assert_eq!(node(&s, face).appearance.fill_paint(), Paint::solid(Color::from_hex("#ffff00").unwrap()));
|
||||
assert!(part_looks(&s, g).1.iter().all(|e| e.fill_paint().is_none()));
|
||||
}
|
||||
|
||||
/// Swap Fill and Stroke on a whole selected Live Paint group gives its faces the stroke its edges
|
||||
/// share and its edges the fill its faces share; with faces of different fills, or without faces,
|
||||
/// it leaves the group as it is.
|
||||
#[test]
|
||||
fn live_paint_group_swap_trades_the_faces_fill_and_the_edges_stroke() {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
let sources0 = sources_looks(&s, g);
|
||||
// The faces are red and blue: nothing on the group changes, in no undo step.
|
||||
let (faces0, edges0) = part_looks(&s, g);
|
||||
let depth = history_state(&s).0;
|
||||
s.execute("paint.swap", &json!({})).unwrap();
|
||||
assert_eq!(part_looks(&s, g), (faces0, edges0));
|
||||
assert_eq!(history_state(&s).0, depth);
|
||||
// One fill on every face: the faces take the edges' black, the edges the faces' red, at their weight.
|
||||
s.execute("paint.setFill", &json!({"color": "#ff0000"})).unwrap();
|
||||
s.execute("stroke.set", &json!({"weight": 2})).unwrap();
|
||||
s.execute("paint.swap", &json!({})).unwrap();
|
||||
let (faces1, edges1) = part_looks(&s, g);
|
||||
assert!(faces1.iter().all(|f| f.fill_paint() == Paint::solid(Color::BLACK)));
|
||||
assert!(edges1.iter().all(|e| e.stroke_paint() == Paint::solid(Color::rgb(1.0, 0.0, 0.0)) && e.stroke_width() == 2.0));
|
||||
assert!(edges1.iter().all(|e| e.fill_paint().is_none()), "edges take no fill");
|
||||
assert_eq!(sources_looks(&s, g), sources0);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert!(part_looks(&s, g).0.iter().all(|f| f.fill_paint() == Paint::solid(Color::rgb(1.0, 0.0, 0.0))), "one undo step");
|
||||
// A gradient placed on each face's own bounds is one shared fill: the edges take it, fitted to each edge.
|
||||
s.execute("paint.setFill", &json!({"gradient": {"aspect": 50}})).unwrap();
|
||||
let placed: Vec<Paint> = part_looks(&s, g).0.iter().map(|f| f.fill_paint()).collect();
|
||||
assert!(placed.iter().all(|p| matches!(p, Paint::Gradient(gr) if gr.geom.is_some())) && placed[0] != placed[1]);
|
||||
s.execute("paint.swap", &json!({})).unwrap();
|
||||
let (faces2, edges2) = part_looks(&s, g);
|
||||
assert!(faces2.iter().all(|f| f.fill_paint() == Paint::solid(Color::BLACK)));
|
||||
assert!(edges2.iter().all(|e| matches!(e.stroke_paint(), Paint::Gradient(gr) if gr.geom.is_none() && gr.freeform.is_none())));
|
||||
// A freeform gradient's points belong to its face: faces with freeform fills keep their paint, in no undo step.
|
||||
s.execute("paint.setFill", &json!({"gradient": {"kind": "freeform"}})).unwrap();
|
||||
assert!(
|
||||
part_looks(&s, g)
|
||||
.0
|
||||
.iter()
|
||||
.all(|f| matches!(f.fill_paint(), Paint::Gradient(gr) if gr.gradient.kind == vectorcraft_color::GradientKind::Freeform))
|
||||
);
|
||||
let looks = part_looks(&s, g);
|
||||
let depth = history_state(&s).0;
|
||||
s.execute("paint.swap", &json!({})).unwrap();
|
||||
assert_eq!(part_looks(&s, g), looks);
|
||||
assert_eq!(history_state(&s).0, depth);
|
||||
// A group with edges and no faces keeps its paint.
|
||||
let line = NodeId(s.execute("shape.line", &json!({"x1": 0, "y1": 300, "x2": 100, "y2": 300})).unwrap()["id"].as_u64().unwrap());
|
||||
let edges_only = NodeId(s.execute("livePaint.make", &json!({"ids": [line.0]})).unwrap()["id"].as_u64().unwrap());
|
||||
assert!(part_looks(&s, edges_only).0.is_empty());
|
||||
s.execute("select.set", &json!({"ids": [edges_only.0]})).unwrap();
|
||||
let looks = part_looks(&s, edges_only);
|
||||
s.execute("paint.swap", &json!({})).unwrap();
|
||||
assert_eq!(part_looks(&s, edges_only), looks);
|
||||
}
|
||||
|
||||
/// Default Fill and Stroke on a whole selected Live Paint group leaves its faces with no fill and
|
||||
/// gives its edges a 0.5 pt black stroke, and new art takes the same; other art selected with it
|
||||
/// takes the white fill and 1 pt black stroke.
|
||||
#[test]
|
||||
fn live_paint_group_default_clears_the_faces_and_gives_the_edges_a_thin_black_stroke() {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
let sources0 = sources_looks(&s, g);
|
||||
s.execute("paint.setStroke", &json!({"color": "#0000ff"})).unwrap();
|
||||
s.execute("paint.default", &json!({})).unwrap();
|
||||
let (faces, edges) = part_looks(&s, g);
|
||||
assert!(faces.iter().all(|f| f.fill_paint().is_none() && f.stroke_paint().is_none()));
|
||||
assert!(edges.iter().all(|e| e.stroke_paint() == Paint::solid(Color::BLACK) && e.stroke_width() == 0.5 && e.fill_paint().is_none()));
|
||||
assert_eq!(sources_looks(&s, g), sources0);
|
||||
assert_eq!((s.paint.fill.clone(), s.paint.stroke.clone(), s.paint.stroke_width), (Paint::None, Paint::solid(Color::BLACK), 0.5));
|
||||
let p = s.execute("paint.proxies", &json!({})).unwrap();
|
||||
assert_eq!((p["fillMixed"].clone(), p["strokeMixed"].clone()), (json!(false), json!(false)));
|
||||
// The next shape drawn has no fill and a 0.5 pt black stroke.
|
||||
let next = rect(&mut s, 400.0, 0.0, 50.0, 50.0);
|
||||
let look = node(&s, next).appearance.clone();
|
||||
assert!(!look.has_visible_fill());
|
||||
assert_eq!((look.stroke_paint(), look.stroke_width()), (Paint::solid(Color::BLACK), 0.5));
|
||||
// With a plain rectangle selected too, the rectangle and new art take the white fill and 1 pt black stroke.
|
||||
let r = rect(&mut s, 300.0, 0.0, 50.0, 50.0);
|
||||
s.execute("paint.setFill", &json!({"ids": [r.0], "color": "#00ff00"})).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [g.0, r.0]})).unwrap();
|
||||
s.execute("paint.default", &json!({})).unwrap();
|
||||
assert_eq!(node(&s, r).appearance.fill_paint(), Paint::solid(Color::WHITE));
|
||||
assert_eq!(part_looks(&s, g), (faces.clone(), edges.clone()));
|
||||
assert_eq!((s.paint.fill.clone(), s.paint.stroke_width), (Paint::solid(Color::WHITE), 1.0));
|
||||
// A redefined Default Graphic Style goes to other art; the parts still take no fill and a 0.5 pt black stroke.
|
||||
s.execute("select.set", &json!({"ids": [r.0]})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#00ff00"})).unwrap();
|
||||
s.execute("graphicStyle.redefine", &json!({"name": "Default Graphic Style"})).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#ff0000"})).unwrap();
|
||||
s.execute("stroke.set", &json!({"weight": 3})).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [g.0, r.0]})).unwrap();
|
||||
s.execute("paint.default", &json!({})).unwrap();
|
||||
assert_eq!(part_looks(&s, g), (faces, edges), "the parts do not take the redefined style");
|
||||
assert_eq!(node(&s, r).appearance.fill_paint(), Paint::solid(Color::from_hex("#00ff00").unwrap()));
|
||||
}
|
||||
|
||||
/// Invert on a whole selected Live Paint group recolors its faces' fills and leaves its edges and
|
||||
/// hidden source paths as they are.
|
||||
#[test]
|
||||
fn live_paint_group_invert_recolors_the_faces_fill() {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#ff0000"})).unwrap();
|
||||
let sources0 = sources_looks(&s, g);
|
||||
let (_, edges0) = part_looks(&s, g);
|
||||
s.execute("paint.invert", &json!({"stroke": false})).unwrap();
|
||||
let (faces, edges) = part_looks(&s, g);
|
||||
assert!(faces.iter().all(|f| f.fill_paint() == Paint::solid(Color::rgb(0.0, 1.0, 1.0))));
|
||||
assert_eq!(edges, edges0);
|
||||
assert_eq!(sources_looks(&s, g), sources0);
|
||||
// The same with `target: "contents"`, for the stroke.
|
||||
s.execute("paint.invert", &json!({"stroke": true, "target": "contents"})).unwrap();
|
||||
let (faces1, edges1) = part_looks(&s, g);
|
||||
assert_eq!(faces1, faces);
|
||||
assert!(edges1.iter().all(|e| e.stroke_paint() == Paint::solid(Color::WHITE)));
|
||||
assert_eq!(sources_looks(&s, g), sources0);
|
||||
// A gradient edit of the fill goes to the faces only.
|
||||
s.execute("paint.setFill", &json!({"gradient": {}})).unwrap();
|
||||
s.execute("paint.editGradient", &json!({"stroke": false, "angle": 45})).unwrap();
|
||||
let (faces2, edges2) = part_looks(&s, g);
|
||||
assert!(faces2.iter().all(|f| matches!(f.fill_paint(), Paint::Gradient(_))));
|
||||
assert_eq!(edges2, edges1, "edges take no fill gradient");
|
||||
assert_eq!(sources_looks(&s, g), sources0);
|
||||
// Selecting a Live Paint group with edges and no faces gives new art its edges' stroke.
|
||||
let line = NodeId(s.execute("shape.line", &json!({"x1": 0, "y1": 300, "x2": 100, "y2": 300})).unwrap()["id"].as_u64().unwrap());
|
||||
let edges_only = NodeId(s.execute("livePaint.make", &json!({"ids": [line.0]})).unwrap()["id"].as_u64().unwrap());
|
||||
s.execute("paint.setStroke", &json!({"ids": [edges_only.0], "color": "#00ff00"})).unwrap();
|
||||
s.execute("select.none", &json!({})).unwrap();
|
||||
s.paint.stroke = Paint::None;
|
||||
s.execute("select.set", &json!({"ids": [edges_only.0]})).unwrap();
|
||||
assert_eq!(s.paint.stroke, Paint::solid(Color::from_hex("#00ff00").unwrap()));
|
||||
}
|
||||
|
||||
/// A gradient vector or freeform point edit of a whole selected Live Paint group's fill changes its
|
||||
/// faces' gradients and leaves its edges and hidden source paths as they are.
|
||||
#[test]
|
||||
fn live_paint_group_gradient_vector_and_freeform_edits_change_its_faces() {
|
||||
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();
|
||||
let sources0 = sources_looks(&s, g);
|
||||
let (_, edges0) = part_looks(&s, g);
|
||||
let face_ids: Vec<u64> = vectorcraft_tools::builder::faces(&node(&s, g)).iter().map(|f| f.id.0).collect();
|
||||
let r = s.execute("paint.setGradientGeom", &json!({"stroke": false, "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();
|
||||
let mut faces = face_ids.clone();
|
||||
faces.sort_unstable();
|
||||
assert_eq!(changed, faces, "only the faces take the vector");
|
||||
assert_eq!(part_looks(&s, g).1, edges0);
|
||||
assert_eq!(sources_looks(&s, g), sources0);
|
||||
s.execute("paint.setFill", &json!({"gradient": {"kind": "freeform"}})).unwrap();
|
||||
s.execute("paint.freeform.addPoint", &json!({"stroke": false, "at": [25, 50], "color": "#00ff00"})).unwrap();
|
||||
assert!(part_looks(&s, g).0.iter().all(|f| matches!(f.fill_paint(), Paint::Gradient(gr) if gr.freeform.is_some())));
|
||||
assert_eq!(part_looks(&s, g).1, edges0);
|
||||
assert_eq!(sources_looks(&s, g), sources0);
|
||||
}
|
||||
|
||||
/// The Live Paint rules stop where a paint command stops: a Live Paint group in a compound shape or
|
||||
/// a blend keeps its parts' paint when the compound shape or blend takes the default, Invert
|
||||
/// remembers the faces' color the proxy shows, and a Live Paint group without faces lets the Fill
|
||||
/// proxy show the next selected object's fill, while an empty plain group does not.
|
||||
#[test]
|
||||
fn live_paint_group_rules_stop_where_paint_commands_stop() {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
let looks = part_looks(&s, g);
|
||||
let r = rect(&mut s, 300.0, 0.0, 50.0, 50.0);
|
||||
s.execute("select.set", &json!({"ids": [g.0, r.0]})).unwrap();
|
||||
let c = NodeId(s.execute("object.compoundShape.make", &json!({"mode": "add"})).unwrap()["id"].as_u64().unwrap());
|
||||
s.execute("select.set", &json!({"ids": [c.0]})).unwrap();
|
||||
s.execute("paint.default", &json!({})).unwrap();
|
||||
s.execute("paint.swap", &json!({})).unwrap();
|
||||
assert_eq!(part_looks(&s, g), looks, "a compound shape's member keeps its paint");
|
||||
s.execute("paint.default", &json!({"ids": [c.0, g.0]})).unwrap();
|
||||
assert_eq!(part_looks(&s, g), looks, "a compound shape's member given as well keeps its paint");
|
||||
// Given alone, the member is a Live Paint group: a fill paints its faces and leaves its edges.
|
||||
s.execute("paint.setFill", &json!({"ids": [g.0], "color": "#ff00ff"})).unwrap();
|
||||
let (faces, edges) = part_looks(&s, g);
|
||||
assert!(faces.iter().all(|f| f.fill_paint() == Paint::solid(Color::from_hex("#ff00ff").unwrap())));
|
||||
assert_eq!(edges, looks.1, "the edges of a member given alone take no fill");
|
||||
|
||||
// A Live Paint group selected with one of its edges: the edge counts with the group.
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
let edge = vectorcraft_tools::builder::edges(&node(&s, g))[0].id;
|
||||
s.execute("select.set", &json!({"ids": [g.0, edge.0]})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#ff0000"})).unwrap();
|
||||
assert_eq!(s.execute("paint.proxies", &json!({})).unwrap()["fillMixed"], false);
|
||||
assert!(node(&s, edge).appearance.fill_paint().is_none(), "an edge selected with its group takes no fill");
|
||||
// The same for an edge given in `ids` with its group.
|
||||
s.execute("paint.setFill", &json!({"ids": [g.0, edge.0], "color": "#0000ff"})).unwrap();
|
||||
assert!(node(&s, edge).appearance.fill_paint().is_none(), "an edge given with its group takes no fill");
|
||||
|
||||
// The same for a blend's key.
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
let looks = part_looks(&s, g);
|
||||
let r = rect(&mut s, 300.0, 0.0, 50.0, 50.0);
|
||||
s.execute("select.set", &json!({"ids": [g.0, r.0]})).unwrap();
|
||||
let b = NodeId(s.execute("object.blend.make", &json!({})).unwrap()["id"].as_u64().unwrap());
|
||||
s.execute("select.set", &json!({"ids": [b.0]})).unwrap();
|
||||
s.execute("paint.default", &json!({})).unwrap();
|
||||
s.execute("paint.swap", &json!({})).unwrap();
|
||||
assert_eq!(part_looks(&s, g), looks, "a blend's key keeps its paint");
|
||||
|
||||
// A Live Paint group inside a selected group: Invert recolors its faces' fills only.
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#ff0000"})).unwrap();
|
||||
let sources0 = sources_looks(&s, g);
|
||||
let (_, edges0) = part_looks(&s, g);
|
||||
s.execute("object.group", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("paint.invert", &json!({"stroke": false})).unwrap();
|
||||
assert!(part_looks(&s, g).0.iter().all(|f| f.fill_paint() == Paint::solid(Color::rgb(0.0, 1.0, 1.0))));
|
||||
assert_eq!(part_looks(&s, g).1, edges0);
|
||||
assert_eq!(sources_looks(&s, g), sources0);
|
||||
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#ff0000"})).unwrap();
|
||||
s.edit("t", |d, _| {
|
||||
d.node_mut(g).unwrap().appearance.set_fill(Paint::solid(Color::rgb(0.0, 0.0, 1.0)));
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
s.execute("paint.invert", &json!({"stroke": false})).unwrap();
|
||||
// Like any group's, the group's own row is recolored too; the color remembered is the faces' one the proxy shows.
|
||||
assert_eq!(node(&s, g).appearance.fill_paint(), Paint::solid(Color::rgb(1.0, 1.0, 0.0)));
|
||||
assert!(part_looks(&s, g).0.iter().all(|f| f.fill_paint() == Paint::solid(Color::rgb(0.0, 1.0, 1.0))));
|
||||
assert_eq!(s.last_solid, Color::rgb(0.0, 1.0, 1.0));
|
||||
|
||||
let mut s = session();
|
||||
let line = NodeId(s.execute("shape.line", &json!({"x1": 0, "y1": 0, "x2": 100, "y2": 0})).unwrap()["id"].as_u64().unwrap());
|
||||
let edges_only = NodeId(s.execute("livePaint.make", &json!({"ids": [line.0]})).unwrap()["id"].as_u64().unwrap());
|
||||
assert!(part_looks(&s, edges_only).0.is_empty());
|
||||
let r = rect(&mut s, 300.0, 0.0, 50.0, 50.0);
|
||||
set_fill(&mut s, r, Color::from_hex("#00ff00").unwrap());
|
||||
s.execute("select.set", &json!({"ids": [edges_only.0, r.0]})).unwrap();
|
||||
let p = s.execute("paint.proxies", &json!({})).unwrap();
|
||||
assert_eq!(p["fill"], serde_json::to_value(Paint::solid(Color::from_hex("#00ff00").unwrap())).unwrap());
|
||||
// The edges-only group shows its edges' stroke in the Stroke panel.
|
||||
let edge_width = part_looks(&s, edges_only).1[0].stroke_width();
|
||||
assert_eq!(s.shown_stroke().map(|st| st.width), Some(edge_width));
|
||||
|
||||
// Any other object with nothing painted in it first in the selection (a group left empty) shows
|
||||
// the defaults for new art, not the next object's paint.
|
||||
let inner = rect(&mut s, 0.0, 300.0, 50.0, 50.0);
|
||||
let empty = NodeId(s.execute("object.group", &json!({"ids": [inner.0]})).unwrap()["id"].as_u64().unwrap());
|
||||
s.edit("t", |d, _| {
|
||||
d.children_mut(Some(empty)).unwrap().clear();
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
s.execute("stroke.set", &json!({"ids": [r.0], "weight": 7})).unwrap();
|
||||
s.paint.fill = Paint::None;
|
||||
s.execute("select.set", &json!({"ids": [empty.0, r.0]})).unwrap();
|
||||
let p = s.execute("paint.proxies", &json!({})).unwrap();
|
||||
assert_eq!(p["fill"], serde_json::to_value(Paint::None).unwrap());
|
||||
assert!(s.shown_stroke().is_none());
|
||||
}
|
||||
|
||||
/// Stroke panel edits of a whole selected Live Paint group (a weight, a step up or down, options)
|
||||
/// change its edges and leave its faces as they are, and the panel shows the edges' stroke.
|
||||
#[test]
|
||||
fn live_paint_group_stroke_panel_edits_change_its_edges() {
|
||||
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);
|
||||
assert_eq!(s.execute("stroke.set", &json!({"weight": 5})).unwrap()["objects"], edges0.len());
|
||||
let (faces1, edges1) = part_looks(&s, g);
|
||||
assert_eq!(faces1, faces0, "faces take no stroke weight");
|
||||
assert!(edges1.iter().all(|e| e.stroke().is_some_and(|st| st.width == 5.0)));
|
||||
assert_eq!(s.shown_stroke().map(|st| st.width), Some(5.0));
|
||||
assert!(!s.doc().unwrap().stroke_mixed().weight);
|
||||
s.execute("stroke.weightUp", &json!({})).unwrap();
|
||||
s.execute("stroke.set", &json!({"cap": "round"})).unwrap();
|
||||
let (faces2, edges2) = part_looks(&s, g);
|
||||
assert_eq!(faces2, faces0, "faces take no stroke step or cap");
|
||||
assert!(edges2.iter().all(|e| e.stroke().is_some_and(|st| st.width == 6.0 && st.cap == LineCap::Round)));
|
||||
// A stroke on the faces (from a file, say) leaves the panel showing the edges' stroke.
|
||||
let face_ids: Vec<NodeId> = vectorcraft_tools::builder::faces(&node(&s, g)).iter().map(|f| f.id).collect();
|
||||
s.edit("t", |d, _| {
|
||||
for id in &face_ids {
|
||||
let face = d.node_mut(*id).unwrap();
|
||||
face.appearance.set_stroke(Paint::solid(Color::BLACK));
|
||||
face.appearance.stroke_at_mut(None).unwrap().width = 2.0;
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(s.shown_stroke().map(|st| st.width), Some(6.0));
|
||||
assert!(!s.doc().unwrap().stroke_mixed().weight);
|
||||
// A face selected with its group counts with the group, whose stroke is its edges'.
|
||||
s.execute("select.set", &json!({"ids": [g.0, face_ids[0].0]})).unwrap();
|
||||
assert!(!s.doc().unwrap().stroke_mixed().weight);
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
// A stroke row on the group itself: a weight still goes to the edges the panel shows.
|
||||
s.edit("t", |d, _| {
|
||||
d.node_mut(g).unwrap().appearance.set_stroke(Paint::solid(Color::BLACK));
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
s.execute("stroke.set", &json!({"weight": 3})).unwrap();
|
||||
assert!(part_looks(&s, g).1.iter().all(|e| e.stroke_width() == 3.0));
|
||||
assert_eq!(node(&s, g).appearance.stroke().map(|st| st.width), Some(1.0));
|
||||
}
|
||||
|
||||
/// 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.
|
||||
#[test]
|
||||
fn live_paint_group_without_parts_of_the_edited_kind_leaves_new_art_alone() {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
let edge_ids: Vec<NodeId> = vectorcraft_tools::builder::edges(&node(&s, g)).iter().map(|e| e.id).collect();
|
||||
s.edit("t", |d, _| {
|
||||
d.children_mut(Some(g)).unwrap().retain(|c| !edge_ids.contains(&c.id));
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
assert!(part_looks(&s, g).1.is_empty());
|
||||
s.execute("select.set", &json!({"ids": [g.0]})).unwrap();
|
||||
let looks = part_looks(&s, g);
|
||||
let (paint0, stroke0) = (s.paint.clone(), s.new_art_stroke());
|
||||
s.execute("stroke.set", &json!({"cap": "round"})).unwrap();
|
||||
s.execute("stroke.set", &json!({"weight": 4})).unwrap();
|
||||
s.execute("stroke.weightUp", &json!({})).unwrap();
|
||||
s.execute("stroke.setAdvanced", &json!({"arrowScale": [200, 150]})).unwrap();
|
||||
assert_eq!((s.paint.clone(), s.new_art_stroke()), (paint0, stroke0), "new art keeps its stroke");
|
||||
assert_eq!(part_looks(&s, g), looks);
|
||||
|
||||
let mut s = session();
|
||||
let line = NodeId(s.execute("shape.line", &json!({"x1": 0, "y1": 0, "x2": 100, "y2": 0})).unwrap()["id"].as_u64().unwrap());
|
||||
let edges_only = NodeId(s.execute("livePaint.make", &json!({"ids": [line.0]})).unwrap()["id"].as_u64().unwrap());
|
||||
s.execute("select.set", &json!({"ids": [edges_only.0]})).unwrap();
|
||||
let looks = part_looks(&s, edges_only);
|
||||
let paint0 = s.paint.clone();
|
||||
s.execute("paint.editGradient", &json!({"stroke": false, "angle": 45})).unwrap();
|
||||
assert_eq!(s.paint, paint0, "new art keeps its fill");
|
||||
assert_eq!(part_looks(&s, edges_only), looks);
|
||||
}
|
||||
|
||||
/// A Live Paint group of 50 pt squares side by side, 50 pt tall, with their left sides at each of
|
||||
/// `xs`.
|
||||
fn live_squares(s: &mut Session, xs: &[f64]) -> NodeId {
|
||||
|
||||
@@ -0,0 +1,300 @@
|
||||
//! The Quick Pen tool driven through the session, and `path.quickPen`.
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_doc::{NodeId, NodeKind};
|
||||
use vectorcraft_geom::{PathData, Point, SubPath};
|
||||
use vectorcraft_tools::{Mods, PointerEvent, PointerKind, ToolKey};
|
||||
|
||||
use crate::tooling::ViewInfo;
|
||||
use crate::*;
|
||||
|
||||
fn session() -> Session {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 800, "height": 600})).unwrap();
|
||||
s
|
||||
}
|
||||
|
||||
fn view() -> ViewInfo {
|
||||
ViewInfo { smart_guides: false, ..Default::default() }
|
||||
}
|
||||
|
||||
fn undo_steps(s: &Session) -> usize {
|
||||
s.doc().unwrap().history.undo.len()
|
||||
}
|
||||
|
||||
fn paths(s: &Session) -> Vec<(NodeId, PathData)> {
|
||||
let mut v = vec![];
|
||||
s.doc().unwrap().doc.walk(|n| {
|
||||
if let NodeKind::Path { path, .. } = &n.kind {
|
||||
v.push((n.id, path.clone()));
|
||||
}
|
||||
});
|
||||
v
|
||||
}
|
||||
|
||||
fn only_path(s: &Session) -> SubPath {
|
||||
let all = paths(s);
|
||||
assert_eq!(all.len(), 1, "one path");
|
||||
all[0].1.subpaths[0].clone()
|
||||
}
|
||||
|
||||
fn pt(x: f64, y: f64) -> Point {
|
||||
Point::new(x, y)
|
||||
}
|
||||
|
||||
fn press(s: &mut Session, pts: &[(f64, f64)]) {
|
||||
let v = view();
|
||||
s.pointer(&PointerEvent::new(PointerKind::Down, pts[0].0, pts[0].1), v).unwrap();
|
||||
for &(x, y) in &pts[1..] {
|
||||
s.pointer(&PointerEvent::new(PointerKind::Drag, x, y), v).unwrap();
|
||||
}
|
||||
let l = pts[pts.len() - 1];
|
||||
s.pointer(&PointerEvent::new(PointerKind::Up, l.0, l.1), v).unwrap();
|
||||
}
|
||||
|
||||
fn click(s: &mut Session, x: f64, y: f64) {
|
||||
press(s, &[(x, y)]);
|
||||
}
|
||||
|
||||
fn key(s: &mut Session, k: ToolKey) {
|
||||
s.tool_key(k, Mods::default(), view()).unwrap();
|
||||
}
|
||||
|
||||
fn quick_pen(s: &mut Session) {
|
||||
s.select_tool("quickPen", view()).unwrap();
|
||||
}
|
||||
|
||||
/// Clicks draw lines; Alt tapped alone switches to the next action, so the next clicks draw a
|
||||
/// continuous arc and a sharp-corner half circle. Each piece is one undo step.
|
||||
#[test]
|
||||
fn clicks_draw_lines_and_arcs_one_undo_step_each() {
|
||||
let mut s = session();
|
||||
quick_pen(&mut s);
|
||||
click(&mut s, 100.0, 100.0);
|
||||
let undo = undo_steps(&s);
|
||||
click(&mut s, 200.0, 100.0);
|
||||
assert_eq!(undo_steps(&s), undo + 1);
|
||||
key(&mut s, ToolKey::AltTap);
|
||||
assert_eq!(s.tool_options()["action"], "continuousArc");
|
||||
click(&mut s, 300.0, 200.0);
|
||||
key(&mut s, ToolKey::AltTap);
|
||||
assert_eq!(s.tool_options()["action"], "sharpArc");
|
||||
click(&mut s, 300.0, 300.0);
|
||||
assert_eq!(undo_steps(&s), undo + 3);
|
||||
let sp = only_path(&s);
|
||||
assert!(!sp.closed);
|
||||
let ends: Vec<Point> = sp.anchors.iter().map(|a| a.p).collect();
|
||||
assert_eq!(ends.first(), Some(&pt(100.0, 100.0)));
|
||||
assert_eq!(ends.last(), Some(&pt(300.0, 300.0)));
|
||||
// Line (2 points), quarter circle (1 more), half circle in two quarters (2 more).
|
||||
assert_eq!(ends.len(), 5);
|
||||
// The continuous arc left (200, 100) heading right, as the line arrived.
|
||||
let joint = sp.anchors.get(1).unwrap();
|
||||
assert!((joint.h_out - joint.p).y.abs() < 1e-9 && joint.h_out.x > joint.p.x);
|
||||
// The half circle on (300, 200)–(300, 300) bulges to the left of the way it was drawn
|
||||
// (downward, so to the right on the page): its middle point is at x = 350.
|
||||
assert!(sp.anchors.get(3).unwrap().p.distance(pt(350.0, 250.0)) < 1e-9);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(only_path(&s).anchors.len(), 3);
|
||||
}
|
||||
|
||||
/// C flips the last sharp-corner arc, and [ and ] make it 15° smaller or larger, each as one
|
||||
/// undo step; the next arc keeps the new size. C is not taken while the last piece is a line.
|
||||
#[test]
|
||||
fn c_flips_and_brackets_size_the_last_sharp_arc() {
|
||||
let mut s = session();
|
||||
quick_pen(&mut s);
|
||||
s.set_tool_option_cmd(&json!({"tool": "quickPen", "key": "action", "value": "sharpArc"})).unwrap();
|
||||
click(&mut s, 100.0, 300.0);
|
||||
click(&mut s, 300.0, 300.0);
|
||||
assert!(only_path(&s).anchors.get(1).unwrap().p.distance(pt(200.0, 200.0)) < 1e-9, "above the chord");
|
||||
assert!(s.tool_claims_key(ToolKey::Letter('c'), view()));
|
||||
let undo = undo_steps(&s);
|
||||
key(&mut s, ToolKey::Letter('c'));
|
||||
assert!(only_path(&s).anchors.get(1).unwrap().p.distance(pt(200.0, 400.0)) < 1e-9, "below once flipped");
|
||||
assert_eq!(undo_steps(&s), undo + 1);
|
||||
key(&mut s, ToolKey::BracketLeft);
|
||||
assert_eq!(s.tool_options()["turn"], 165.0);
|
||||
let sp = only_path(&s);
|
||||
// A 165° arc is two segments; its middle point lies on the chord's perpendicular bisector,
|
||||
// still below.
|
||||
assert_eq!(sp.anchors.len(), 3);
|
||||
let mid = sp.anchors.get(1).unwrap().p;
|
||||
assert!((mid.x - 200.0).abs() < 1e-9 && mid.y > 300.0);
|
||||
assert_eq!(undo_steps(&s), undo + 2);
|
||||
s.set_tool_option_cmd(&json!({"tool": "quickPen", "key": "action", "value": "line"})).unwrap();
|
||||
click(&mut s, 400.0, 300.0);
|
||||
assert!(!s.tool_claims_key(ToolKey::Letter('c'), view()));
|
||||
}
|
||||
|
||||
/// Alt tapped during a drag draws the piece with the next action: a continuous arc becomes a
|
||||
/// sharp-corner arc with a corner where it starts, and the path goes on drawing after it.
|
||||
#[test]
|
||||
fn an_alt_tap_during_a_drag_switches_the_piece_and_drawing_goes_on() {
|
||||
let mut s = session();
|
||||
quick_pen(&mut s);
|
||||
click(&mut s, 100.0, 100.0);
|
||||
click(&mut s, 200.0, 100.0);
|
||||
s.set_tool_option_cmd(&json!({"tool": "quickPen", "key": "action", "value": "continuousArc"})).unwrap();
|
||||
// A quarter circle that arrives at (300, 200) heading down.
|
||||
click(&mut s, 300.0, 200.0);
|
||||
let joint = only_path(&s).anchors.len() - 1;
|
||||
let v = view();
|
||||
s.pointer(&PointerEvent::new(PointerKind::Down, 200.0, 300.0), v).unwrap();
|
||||
s.pointer(&PointerEvent::new(PointerKind::Drag, 210.0, 310.0), v).unwrap();
|
||||
assert_eq!(only_path(&s).anchors.get(joint).unwrap().kind, vectorcraft_geom::AnchorKind::Smooth);
|
||||
key(&mut s, ToolKey::AltTap);
|
||||
s.pointer(&PointerEvent::new(PointerKind::Drag, 200.0, 300.0), v).unwrap();
|
||||
s.pointer(&PointerEvent::new(PointerKind::Up, 200.0, 300.0), v).unwrap();
|
||||
assert_eq!(s.tool_options()["action"], "sharpArc");
|
||||
assert_eq!(only_path(&s).anchors.get(joint).unwrap().kind, vectorcraft_geom::AnchorKind::Corner);
|
||||
click(&mut s, 100.0, 300.0);
|
||||
assert_eq!(only_path(&s).anchors.last().unwrap().p, pt(100.0, 300.0), "the same path");
|
||||
}
|
||||
|
||||
/// A click on the first point closes the path; the next click starts a new one.
|
||||
#[test]
|
||||
fn a_click_on_the_first_point_closes_the_path() {
|
||||
let mut s = session();
|
||||
quick_pen(&mut s);
|
||||
for (x, y) in [(100.0, 100.0), (200.0, 100.0), (200.0, 200.0), (101.0, 101.0)] {
|
||||
click(&mut s, x, y);
|
||||
}
|
||||
let sp = only_path(&s);
|
||||
assert!(sp.closed);
|
||||
assert_eq!(sp.anchors.len(), 3);
|
||||
click(&mut s, 400.0, 400.0);
|
||||
assert_eq!(paths(&s).len(), 2);
|
||||
}
|
||||
|
||||
/// Escape ends the path: the next click starts a new path. A press dragged places the piece
|
||||
/// where it is let go.
|
||||
#[test]
|
||||
fn escape_ends_the_path_and_a_drag_places_the_piece() {
|
||||
let mut s = session();
|
||||
quick_pen(&mut s);
|
||||
click(&mut s, 100.0, 100.0);
|
||||
press(&mut s, &[(150.0, 100.0), (180.0, 120.0), (250.0, 150.0)]);
|
||||
assert_eq!(only_path(&s).anchors.last().unwrap().p, pt(250.0, 150.0));
|
||||
assert!(s.tool_ends_on_escape(view()));
|
||||
key(&mut s, ToolKey::Escape);
|
||||
assert!(!s.tool_ends_on_escape(view()));
|
||||
click(&mut s, 500.0, 500.0);
|
||||
assert_eq!(paths(&s).len(), 2);
|
||||
}
|
||||
|
||||
/// An anchor moved by another command ends the path being drawn: C does not flip the old arc back
|
||||
/// over the edit, and the next click starts a new path instead of rebuilding the old one.
|
||||
#[test]
|
||||
fn an_edit_from_outside_ends_the_path() {
|
||||
let mut s = session();
|
||||
quick_pen(&mut s);
|
||||
s.set_tool_option_cmd(&json!({"tool": "quickPen", "key": "action", "value": "sharpArc"})).unwrap();
|
||||
click(&mut s, 100.0, 300.0);
|
||||
click(&mut s, 300.0, 300.0);
|
||||
let (id, _) = paths(&s)[0].clone();
|
||||
s.execute("path.moveAnchor", &json!({"id": id.0, "anchor": 2, "x": 320, "y": 280})).unwrap();
|
||||
assert!(!s.tool_claims_key(ToolKey::Letter('c'), view()));
|
||||
click(&mut s, 500.0, 500.0);
|
||||
let all = paths(&s);
|
||||
assert_eq!(all.len(), 2, "a new path");
|
||||
assert_eq!(all[0].1.subpaths[0].anchors.last().unwrap().p, pt(320.0, 280.0), "the edit stays");
|
||||
// The same for a point of a path the tool went on from, and for the first point of a new path.
|
||||
for new in [true, false] {
|
||||
let mut s = session();
|
||||
let id = if new {
|
||||
quick_pen(&mut s);
|
||||
click(&mut s, 100.0, 100.0);
|
||||
click(&mut s, 200.0, 100.0);
|
||||
paths(&s)[0].0
|
||||
} else {
|
||||
let r = s.execute("shape.line", &json!({"x1": 100, "y1": 100, "x2": 200, "y2": 100})).unwrap();
|
||||
let id = NodeId(r["id"].as_u64().unwrap());
|
||||
s.execute("select.set", &json!({"ids": [id.0]})).unwrap();
|
||||
quick_pen(&mut s);
|
||||
click(&mut s, 200.0, 100.0);
|
||||
click(&mut s, 200.0, 200.0);
|
||||
id
|
||||
};
|
||||
s.execute("path.moveAnchor", &json!({"id": id.0, "anchor": 0, "x": 90, "y": 90})).unwrap();
|
||||
click(&mut s, 400.0, 400.0);
|
||||
assert_eq!(paths(&s).len(), 2, "a new path (new: {new})");
|
||||
assert_eq!(s.doc().unwrap().doc.node(id).unwrap().path_data().unwrap().subpaths[0].anchors.first().unwrap().p, pt(90.0, 90.0));
|
||||
}
|
||||
}
|
||||
|
||||
/// A click on an end of an open path goes on drawing from it, in the same path; from its start,
|
||||
/// the path is reversed first.
|
||||
#[test]
|
||||
fn a_click_on_an_open_end_continues_the_path() {
|
||||
let mut s = session();
|
||||
let r = s.execute("shape.line", &json!({"x1": 100, "y1": 100, "x2": 200, "y2": 100})).unwrap();
|
||||
let id = NodeId(r["id"].as_u64().unwrap());
|
||||
s.execute("select.set", &json!({"ids": [id.0]})).unwrap();
|
||||
quick_pen(&mut s);
|
||||
click(&mut s, 100.0, 100.0);
|
||||
click(&mut s, 100.0, 200.0);
|
||||
let all = paths(&s);
|
||||
assert_eq!(all.len(), 1);
|
||||
assert_eq!(all[0].0, id);
|
||||
let ends: Vec<Point> = all[0].1.subpaths[0].anchors.iter().map(|a| a.p).collect();
|
||||
assert_eq!(ends, [pt(200.0, 100.0), pt(100.0, 100.0), pt(100.0, 200.0)]);
|
||||
}
|
||||
|
||||
/// `path.quickPen` makes a new path with the current paint, or a black stroke without any.
|
||||
#[test]
|
||||
fn path_quick_pen_makes_a_stroked_path() {
|
||||
let mut s = session();
|
||||
s.execute("paint.setStroke", &json!({"none": true})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"none": true})).unwrap();
|
||||
let r = s
|
||||
.execute(
|
||||
"path.quickPen",
|
||||
&json!({"start": [0, 0], "pieces": [{"x": 100, "y": 0}, {"x": 100, "y": 100, "action": "sharpArc", "turn": 90, "flip": true}]}),
|
||||
)
|
||||
.unwrap();
|
||||
let id = r["id"].as_u64().unwrap();
|
||||
let n = s.doc().unwrap().doc.node(NodeId(id)).unwrap().clone();
|
||||
assert!(!n.appearance.stroke_paint().is_none(), "a black stroke");
|
||||
assert_eq!(n.path_data().unwrap().subpaths[0].anchors.len(), 3);
|
||||
}
|
||||
|
||||
/// Bad params are refused and change nothing.
|
||||
#[test]
|
||||
fn path_quick_pen_refuses_bad_params() {
|
||||
let mut s = session();
|
||||
let r = s.execute("path.quickPen", &json!({"start": [0, 0], "pieces": [{"x": 100, "y": 0}]})).unwrap();
|
||||
let id = r["id"].as_u64().unwrap();
|
||||
let before = paths(&s);
|
||||
let bad: [Value; 11] = [
|
||||
json!({}),
|
||||
json!({"pieces": []}),
|
||||
json!({"start": [0, 0], "pieces": [{"x": 1, "y": 1, "action": "arc"}]}),
|
||||
json!({"start": [0, 0], "pieces": [{"x": 1, "y": 1, "action": "sharpArc", "turn": 0}]}),
|
||||
json!({"start": [0, 0], "pieces": [{"x": 1, "y": 1, "turn": 360}]}),
|
||||
json!({"start": [0, 0], "pieces": [{"x": "1", "y": 1}]}),
|
||||
json!({"start": [0, 0], "pieces": [{"x": 1, "y": 1, "flip": "yes"}]}),
|
||||
json!({"start": [0, 0], "keep": 1}),
|
||||
json!({"id": id, "keep": 0}),
|
||||
json!({"id": id, "keep": 3}),
|
||||
json!({"id": id, "start": [0, 0]}),
|
||||
];
|
||||
for p in bad {
|
||||
assert!(s.execute("path.quickPen", &p).is_err(), "{p}");
|
||||
}
|
||||
assert!(s.execute("path.quickPen", &json!({"start": [0, 0], "pieces": vec![json!({"x": 1, "y": 1}); 10_001]})).is_err());
|
||||
s.execute("path.quickPen", &json!({"id": id, "closed": true})).unwrap();
|
||||
assert!(s.execute("path.quickPen", &json!({"id": id, "pieces": [{"x": 5, "y": 5}]})).is_err(), "closed");
|
||||
assert_eq!(paths(&s).len(), before.len());
|
||||
}
|
||||
|
||||
/// With `id` and `keep`, the points after the first `keep` are replaced by the pieces.
|
||||
#[test]
|
||||
fn path_quick_pen_replaces_the_points_after_keep() {
|
||||
let mut s = session();
|
||||
let r = s.execute("path.quickPen", &json!({"start": [0, 0], "pieces": [{"x": 100, "y": 0}, {"x": 100, "y": 100}]})).unwrap();
|
||||
let id = r["id"].as_u64().unwrap();
|
||||
s.execute("path.quickPen", &json!({"id": id, "keep": 2, "pieces": [{"x": 200, "y": 0}]})).unwrap();
|
||||
let ends: Vec<Point> = only_path(&s).anchors.iter().map(|a| a.p).collect();
|
||||
assert_eq!(ends, [pt(0.0, 0.0), pt(100.0, 0.0), pt(200.0, 0.0)]);
|
||||
}
|
||||
@@ -8465,3 +8465,51 @@ proptest! {
|
||||
prop_assert_eq!(paths, 2, "{:?}", notes);
|
||||
}
|
||||
}
|
||||
|
||||
proptest! {
|
||||
#![proptest_config(config())]
|
||||
|
||||
/// A stroke's arrowheads (#8188): its arrowhead entries with any scale of any kind, naming a
|
||||
/// symbol the file defines, one it doesn't or one named in Chinese, the symbol's art any run of
|
||||
/// paths (frames, samples of the line, heads, open and closed, filled, stroked or neither), at
|
||||
/// any weight, the style section cut anywhere, the line drawn as any look. Read as a `.ai` and
|
||||
/// as an EPS, then rendered.
|
||||
#[test]
|
||||
fn ai_arrowhead_strokes_never_panic(
|
||||
scale in prop_oneof![arb_num(), Just("50".to_string())],
|
||||
kind in prop::sample::select(vec!["Real", "Int", "Bool"]),
|
||||
named in prop::sample::select(vec!["W", "Missing", "\u{6954}"]),
|
||||
both in any::<bool>(),
|
||||
art in prop::collection::vec(prop::sample::select(vec![
|
||||
"-10 5 m\n10 5 L\n10 -5 L\n-10 -5 L\nn\n",
|
||||
"0 G\n1 w\n-9 0 m\n4 0 l\nS\n",
|
||||
"0 G\n0.5 w\n-9 0 m\n4 0 l\nS\n",
|
||||
"0 g\n2 3 m\n8 0 l\n2 -3 l\nf\n",
|
||||
"0 G\n1 w\n2 3 m\n8 0 l\n2 -3 l\nS\n",
|
||||
"0 g\n1e300 0 m\n-1e300 1 l\nf\n",
|
||||
"0 g\n0 0 m\n0 0 l\nf\n",
|
||||
]), 0..6),
|
||||
width in arb_num(),
|
||||
cut in 0usize..2000,
|
||||
look in prop::sample::select(vec!["0 G\n2 w\n0 50 m\n96 50 l\nS\n0 g\n94 53 m\n100 50 l\n94 47 l\nf\n", "0 G\n2 w\n0 50 m\n100 50 l\nS\n", ""]),
|
||||
) {
|
||||
use vectorcraft_testkit::ai;
|
||||
let symbol = format!("%AI5_Begin_NonPrinting\n%AI14_BeginSymbol\n(W)\n0 A\n0 Xw\n0 Ae\nu\n{}U\n%AI10_EndSymbol\n%AI5_End_NonPrinting--\n", art.concat());
|
||||
let start = if both { format!("{scale} /{kind} (BSArrowBeginScale) ,\n/GObjRef : ({named}) /SymbolArt ; (BSArrowBeginSymbol) ,\n") } else { String::new() };
|
||||
let styles = format!(
|
||||
"%AI9_BeginArtStyles\n/KnownStyle :\n(Arrowed) /Name ,\n/ActiveStyle :\n/CompoundFilter :\n(Chain Style Filter) 0 0 /Filter ,\n1 /Visible ,\n\
|
||||
/CompoundFilter :\n(Stack Style Filter) 0 0 /Filter ,\n1 /Visible ,\n\
|
||||
/BasicFilter :\n(Stroke Style Filter) 0 0 /Filter ,\n1 /Visible ,\n/Dictionary : /NotRecorded ,\n/Dictionary : /NotRecorded ,\n\
|
||||
{start}{scale} /{kind} (BSArrowEndScale) ,\n/GObjRef : ({named}) /SymbolArt ; (BSArrowEndSymbol) ,\n; (kAIBeautifulStrokesParamsDictKey) ,\n\
|
||||
/StrokeStyle : 0 R\n0 0 0 1 0 0 0 XA\n0 J 0 j {width} w 10 M []0 d\n0 XR\n1 0 Xd\n/Def ;\n (StrokeStyle) ,\n; /Dict ;\n /Part ,\n\
|
||||
/BasicFilter :\n(Conduit Filter) 0 0 /Filter ,\n1 /Visible ,\n;\n /Part ,\n;\n /Part ,\n;\n%AI9_EndArtStyles\n\
|
||||
%AI9_BeginArtStyleList\n(Arrowed)\n%AI9_EndArtStyleList\n"
|
||||
);
|
||||
let styles: String = styles.chars().take(cut).collect();
|
||||
let line = format!("0 Ae\nu\n{look}U\n%_0 50 m\n%_100 50 L\n%_N\n1 (Arrowed) XW\n");
|
||||
let data = ai::editing_data(200.0, 100.0, &format!("{symbol}{styles}{}", ai::layer("L", &line)));
|
||||
survive("arrowhead strokes", || Some(vectorcraft_eps::layered_ai(data.as_bytes(), Document::new(200.0, 100.0), vec![], false, false, 1.0).0))?;
|
||||
let eps = ai::eps(data.as_bytes(), ai::page_ps());
|
||||
survive("arrowhead strokes in an EPS", || vectorcraft_engine::cmd::fileio::load("x.eps", &eps).ok().map(|l| l.doc))?;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
//! objects and points. Anything it doesn't read is an error: the caller opens the file the way it
|
||||
//! did before (the printed page, or the PDF), with a warning saying why.
|
||||
|
||||
mod arrowhead;
|
||||
mod blend;
|
||||
mod brush;
|
||||
mod envelope;
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
//! Arrowheads a file defines: the art of a symbol that a stroke's arrowhead entry names
|
||||
//! ([`super::style::StrokeArrows`]), read into a head ([`head`]).
|
||||
//!
|
||||
//! Not publicly documented. As the files have it, an arrowhead symbol's art (y down here, as the
|
||||
//! document's symbols are) points right along a straight, level sample of the line it ends: an
|
||||
//! open stroked path with no fill whose anchors and handles all lie on that line, 1 pt wide. The
|
||||
//! sample ends where the line stops under the head. The rest of the art that paints is the head;
|
||||
//! its tip is its rightmost point, and a symbol unit is one point on a 1 pt stroke at 100 %, so a
|
||||
//! unit is the head's weight as it is for VectorCraft's own heads. Art that paints nothing (the
|
||||
//! frame of the symbol's box, hidden or fully transparent art) is left out.
|
||||
|
||||
use vectorcraft_doc::{AppearanceItem, CustomArrowhead, Node, NodeKind, StrokeLayer};
|
||||
use vectorcraft_geom::{Affine, FillRule, PathData, Point};
|
||||
|
||||
/// The most anchors an arrowhead symbol's art is read with, outlined strokes included, before its
|
||||
/// shapes are united.
|
||||
const MAX_ART_ANCHORS: usize = 65_536;
|
||||
/// How deep the groups of an arrowhead symbol's art are read.
|
||||
const MAX_DEPTH: usize = 16;
|
||||
|
||||
/// The head that symbol art `art` (in the document's symbol space) draws, named `name`. `None` when
|
||||
/// the art doesn't have exactly one sample of the line, its sample isn't 1 pt wide, it holds
|
||||
/// anything but paths, compound paths and groups (a clip group, say), has an effect, a brush, an
|
||||
/// opacity mask, partial opacity or a group with fills or strokes of its own, paints no head, or is
|
||||
/// too detailed for one; or when the
|
||||
/// line would stop past the head's tip or farther back than a head can reach
|
||||
/// ([`CustomArrowhead::MAX_UNITS`]).
|
||||
pub(super) fn head(name: &str, art: &Node) -> Option<CustomArrowhead> {
|
||||
let mut parts = Parts::default();
|
||||
match &art.kind {
|
||||
// The members of the symbol's group are its art's top level, where the sample is.
|
||||
NodeKind::Group { children, clip: false } if art.visible && plain(art) && !paints(art) => {
|
||||
for c in children {
|
||||
parts.member(c, true, 1)?;
|
||||
}
|
||||
}
|
||||
_ => parts.member(art, true, 0)?,
|
||||
}
|
||||
let [(axis, line_end)] = parts.lines.as_slice() else { return None };
|
||||
if parts.shapes.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let refs: Vec<(&PathData, FillRule)> = parts.shapes.iter().map(|(p, r)| (p, *r)).collect();
|
||||
let area = vectorcraft_pathops::try_unite_all(&refs).ok()?;
|
||||
let b = area.bounds().filter(|b| b.is_finite() && b.height() > 1e-9)?;
|
||||
let tip = b.x1;
|
||||
// Head units: x back from the tip, y across to the right of the way the head points (down).
|
||||
let h = CustomArrowhead::new(name.to_string(), area.transformed(Affine::new([-1.0, 0.0, 0.0, 1.0, tip, -axis])));
|
||||
let h = h.with_stop(tip - line_end);
|
||||
(!h.path.subpaths.is_empty() && h.stop.is_some()).then_some(h)
|
||||
}
|
||||
|
||||
/// What an arrowhead symbol's art is made of.
|
||||
#[derive(Default)]
|
||||
struct Parts {
|
||||
/// Each sample of the line: the line's y, and the x where the sample ends.
|
||||
lines: Vec<(f64, f64)>,
|
||||
/// The areas the head paints.
|
||||
shapes: Vec<(PathData, FillRule)>,
|
||||
anchors: usize,
|
||||
}
|
||||
|
||||
impl Parts {
|
||||
/// Read `n`, a member of the art (`top`: of its top level) `depth` groups down. `None` when it
|
||||
/// is something [`head`] doesn't read.
|
||||
fn member(&mut self, n: &Node, top: bool, depth: usize) -> Option<()> {
|
||||
if depth > MAX_DEPTH {
|
||||
return None;
|
||||
}
|
||||
// Hidden or fully transparent art paints nothing.
|
||||
if !n.visible || n.opacity <= 0.0 {
|
||||
return Some(());
|
||||
}
|
||||
if !plain(n) {
|
||||
return None;
|
||||
}
|
||||
match &n.kind {
|
||||
NodeKind::Group { children, clip: false } => {
|
||||
if paints(n) {
|
||||
return None;
|
||||
}
|
||||
children.iter().try_for_each(|c| self.member(c, false, depth + 1))
|
||||
}
|
||||
NodeKind::Path { guide: true, .. } => Some(()),
|
||||
NodeKind::Path { path, rule, .. } => self.painted(n, path, *rule, top),
|
||||
NodeKind::Compound { children, rule } => {
|
||||
let mut subpaths = vec![];
|
||||
for c in children {
|
||||
subpaths.extend(c.path_data()?.subpaths.iter().cloned());
|
||||
}
|
||||
self.painted(n, &PathData::new(subpaths), *rule, false)
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Read the fills and strokes of path or compound path `n`, its outline `path` filled under
|
||||
/// `rule` (`top`: a member of the art's top level, which may be the sample of the line).
|
||||
fn painted(&mut self, n: &Node, path: &PathData, rule: FillRule, top: bool) -> Option<()> {
|
||||
self.room(path.anchor_count())?;
|
||||
let mut filled = false;
|
||||
let mut strokes: Vec<&StrokeLayer> = vec![];
|
||||
for item in &n.appearance.items {
|
||||
match item {
|
||||
AppearanceItem::Fill(f) if f.visible && f.opacity > 0.0 && !f.paint.is_none() => {
|
||||
if !f.effects.is_empty() || f.opacity < 1.0 {
|
||||
return None;
|
||||
}
|
||||
filled = true;
|
||||
}
|
||||
AppearanceItem::Stroke(s) if s.visible && s.opacity > 0.0 && !s.paint.is_none() && s.width > 0.0 => {
|
||||
if !s.effects.is_empty() || s.brush.is_some() || s.opacity < 1.0 {
|
||||
return None;
|
||||
}
|
||||
strokes.push(s);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
if top
|
||||
&& !filled
|
||||
&& let [line] = strokes.as_slice()
|
||||
&& let Some(sample) = sample_line(path)
|
||||
{
|
||||
// The sample is 1 pt, the weight of a head at one unit; another weight (art stored
|
||||
// at another scale, as a Large Canvas file's) gives the units no known size.
|
||||
if (line.width - 1.0).abs() > 1e-6 {
|
||||
return None;
|
||||
}
|
||||
self.lines.push(sample);
|
||||
return Some(());
|
||||
}
|
||||
if filled {
|
||||
self.shapes.push((path.clone(), rule));
|
||||
}
|
||||
for s in strokes {
|
||||
let outline = vectorcraft_effects::stroke::outline_region(path, rule, s);
|
||||
self.room(outline.anchor_count())?;
|
||||
if !outline.subpaths.is_empty() {
|
||||
self.shapes.push((outline, FillRule::NonZero));
|
||||
}
|
||||
}
|
||||
Some(())
|
||||
}
|
||||
|
||||
/// Count `anchors` more; `None` past [`MAX_ART_ANCHORS`].
|
||||
fn room(&mut self, anchors: usize) -> Option<()> {
|
||||
self.anchors = self.anchors.saturating_add(anchors);
|
||||
(self.anchors <= MAX_ART_ANCHORS).then_some(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Does `n` draw as its shapes alone: fully opaque, with no effects and no opacity mask applied?
|
||||
/// A head is one opaque shape, so partly transparent or masked art isn't read as one.
|
||||
fn plain(n: &Node) -> bool {
|
||||
n.opacity >= 1.0 && n.appearance.effects.is_empty() && n.extras().mask.as_ref().is_none_or(|m| m.disabled)
|
||||
}
|
||||
|
||||
/// Does `n` (a group) have fills or strokes of its own that paint?
|
||||
fn paints(n: &Node) -> bool {
|
||||
n.appearance.items.iter().any(|i| match i {
|
||||
AppearanceItem::Fill(f) => f.visible && !f.paint.is_none(),
|
||||
AppearanceItem::Stroke(s) => s.visible && !s.paint.is_none(),
|
||||
})
|
||||
}
|
||||
|
||||
/// `path` as a sample of the line, when it is one open subpath of two anchors or more whose anchors
|
||||
/// and handles all lie level with its first anchor: that y, and the x where it ends (its
|
||||
/// rightmost anchor).
|
||||
fn sample_line(path: &PathData) -> Option<(f64, f64)> {
|
||||
let [sub] = path.subpaths.as_slice() else { return None };
|
||||
if sub.closed || sub.anchors.len() < 2 {
|
||||
return None;
|
||||
}
|
||||
let y = sub.anchors.first()?.p.y;
|
||||
let level = |q: Point| q.x.is_finite() && (q.y - y).abs() <= 1e-6 * (1.0 + y.abs());
|
||||
if !y.is_finite() || !sub.anchors.iter().all(|a| level(a.p) && level(a.h_in) && level(a.h_out)) {
|
||||
return None;
|
||||
}
|
||||
Some((y, sub.anchors.iter().map(|a| a.p.x).fold(f64::NEG_INFINITY, f64::max)))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
|
||||
use vectorcraft_color::{Color, Paint};
|
||||
use vectorcraft_doc::{Appearance, Node, NodeId, OpacityMask};
|
||||
use vectorcraft_geom::{PathData, Point, SubPath};
|
||||
|
||||
use super::head;
|
||||
|
||||
fn path(id: u64, points: &[(f64, f64)], closed: bool, appearance: Appearance) -> Arc<Node> {
|
||||
let points: Vec<Point> = points.iter().map(|(x, y)| Point::new(*x, *y)).collect();
|
||||
Arc::new(Node::path(NodeId(id), PathData::single(SubPath::polyline(&points, closed)), appearance))
|
||||
}
|
||||
|
||||
/// A 1 pt sample of the line from x = −9 to 4 on y = 0.
|
||||
fn sample() -> Arc<Node> {
|
||||
path(1, &[(-9.0, 0.0), (4.0, 0.0)], false, Appearance::basic(Paint::None, Paint::solid(Color::BLACK), 1.0))
|
||||
}
|
||||
|
||||
/// A filled wedge from x = 2 back to its tip at x = 8, 3 either side.
|
||||
fn wedge() -> Arc<Node> {
|
||||
path(2, &[(2.0, -3.0), (8.0, 0.0), (2.0, 3.0)], true, Appearance::basic(Paint::solid(Color::BLACK), Paint::None, 1.0))
|
||||
}
|
||||
|
||||
fn art(members: Vec<Arc<Node>>) -> Node {
|
||||
Node::group(NodeId(10), members)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_wedge_and_its_sample_make_a_head() {
|
||||
let h = head("W", &art(vec![sample(), wedge()])).expect("a head");
|
||||
assert_eq!(h.stop(), 4.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn partly_transparent_or_masked_art_makes_no_head() {
|
||||
// The head would come in opaque and whole, with the bounds of the art.
|
||||
let half = |n: Arc<Node>| Arc::new(Node { opacity: 0.5, ..(*n).clone() });
|
||||
let mut faint_fill = (*wedge()).clone();
|
||||
let mut ap = (*faint_fill.appearance).clone();
|
||||
if let Some(f) = ap.fill_mut() {
|
||||
f.opacity = 0.5;
|
||||
}
|
||||
faint_fill.appearance = ap.into();
|
||||
let mut masked = (*wedge()).clone();
|
||||
masked.extras_mut().mask = Some(Box::new(OpacityMask { art: sample(), clip: true, invert: false, disabled: false, linked: true }));
|
||||
let cases = [
|
||||
("a head at half opacity", art(vec![sample(), half(wedge())])),
|
||||
("a fill at half opacity", art(vec![sample(), Arc::new(faint_fill)])),
|
||||
("a group at half opacity", art(vec![sample(), half(Arc::new(art(vec![wedge()])))])),
|
||||
("the art at half opacity", Node { opacity: 0.5, ..art(vec![sample(), wedge()]) }),
|
||||
("a head with an opacity mask", art(vec![sample(), Arc::new(masked.clone())])),
|
||||
];
|
||||
for (why, a) in cases {
|
||||
assert!(head("W", &a).is_none(), "{why}");
|
||||
}
|
||||
// A disabled mask isn't applied.
|
||||
masked.extras_mut().mask.as_mut().unwrap().disabled = true;
|
||||
assert!(head("W", &art(vec![sample(), Arc::new(masked)])).is_some());
|
||||
}
|
||||
}
|
||||
@@ -124,8 +124,8 @@ use vectorcraft_color::swatch::Swatch;
|
||||
use vectorcraft_color::{BlendMode, Paint};
|
||||
use vectorcraft_doc::cmyk::Inks;
|
||||
use vectorcraft_doc::{
|
||||
Appearance, AppearanceItem, Artboard, ColorMode, Dash, Document, FillLayer, ImageBlob, ImageObject, Knockout, LayerColor, LineCap, LineJoin,
|
||||
LinkInfo, Node, NodeId, NodeKind, OpacityMask, PageBox, PatternDef, StrokeLayer, Unit,
|
||||
Appearance, AppearanceItem, Artboard, ColorMode, CustomArrowhead, Dash, Document, FillLayer, ImageBlob, ImageObject, Knockout, LayerColor,
|
||||
LineCap, LineJoin, LinkInfo, Node, NodeId, NodeKind, OpacityMask, PageBox, PatternDef, StrokeLayer, Unit,
|
||||
};
|
||||
use vectorcraft_geom::{AnchorKind, FillRule, PathData};
|
||||
|
||||
@@ -544,6 +544,10 @@ struct Reader<'a> {
|
||||
symbol_bounds: HashMap<String, Rect>,
|
||||
/// The symbols read, by their name in the file → their name in the document.
|
||||
symbol_names: HashMap<String, String>,
|
||||
/// The heads of the arrowhead symbols the art styles' strokes name, by the symbol's name in
|
||||
/// the file (`None`: not a symbol read, or not one read as a head), read with the styles
|
||||
/// ([`Reader::read_arrowheads`]).
|
||||
arrowheads: HashMap<String, Option<Arc<CustomArrowhead>>>,
|
||||
/// The names the symbols read have in the document, and for each name read more than once,
|
||||
/// the number its next copy is tried with.
|
||||
symbol_taken: HashSet<String>,
|
||||
@@ -843,6 +847,7 @@ impl<'a> Reader<'a> {
|
||||
unread: Vec::new(),
|
||||
symbol_bounds: HashMap::new(),
|
||||
symbol_names: HashMap::new(),
|
||||
arrowheads: HashMap::new(),
|
||||
symbol_taken: HashSet::new(),
|
||||
symbol_suffix: HashMap::new(),
|
||||
symbol_art_bounds: HashMap::new(),
|
||||
|
||||
@@ -752,6 +752,8 @@ impl<'a> Reader<'a> {
|
||||
if std::mem::replace(&mut self.symbols_checked, true) {
|
||||
return;
|
||||
}
|
||||
// The symbols are all read now: the heads of those defined after the styles.
|
||||
self.read_arrowheads();
|
||||
// Each symbol's name in the file (none for one named as an earlier one), and the names its
|
||||
// instances use.
|
||||
let files: HashMap<&str, &str> = self.symbol_names.iter().map(|(file, named)| (named.as_str(), file.as_str())).collect();
|
||||
|
||||
@@ -128,6 +128,7 @@ impl<'a> Reader<'a> {
|
||||
// section inside it would replace the file's own.
|
||||
if self.subreader_depth == 0 {
|
||||
self.styles = crate::import::ai::style::art_styles_in(section, &mut self.names);
|
||||
self.read_arrowheads();
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
@@ -398,6 +399,7 @@ impl<'a> Reader<'a> {
|
||||
sub.gradients = std::mem::take(&mut self.gradients);
|
||||
sub.global_names = std::mem::take(&mut self.global_names);
|
||||
sub.styles = std::mem::take(&mut self.styles);
|
||||
sub.arrowheads = std::mem::take(&mut self.arrowheads);
|
||||
sub.nodes = self.nodes;
|
||||
sub.template = self.template;
|
||||
self.lend_budgets(&mut sub);
|
||||
@@ -408,6 +410,7 @@ impl<'a> Reader<'a> {
|
||||
self.names.absorb(std::mem::take(&mut sub.names));
|
||||
self.global_names = std::mem::take(&mut sub.global_names);
|
||||
self.styles = std::mem::take(&mut sub.styles);
|
||||
self.arrowheads = std::mem::take(&mut sub.arrowheads);
|
||||
// Unread art in the definition, hidden or not, leaves the tile incomplete.
|
||||
let whole = read.is_ok()
|
||||
&& sub.unsupported.is_empty()
|
||||
@@ -429,6 +432,7 @@ impl<'a> Reader<'a> {
|
||||
sub.gradients = std::mem::take(&mut self.gradients);
|
||||
sub.global_names = std::mem::take(&mut self.global_names);
|
||||
sub.styles = std::mem::take(&mut self.styles);
|
||||
sub.arrowheads = std::mem::take(&mut self.arrowheads);
|
||||
sub.nodes = self.nodes;
|
||||
sub.template = self.template;
|
||||
self.lend_budgets(&mut sub);
|
||||
@@ -444,6 +448,7 @@ impl<'a> Reader<'a> {
|
||||
self.gradients = std::mem::take(&mut sub.gradients);
|
||||
self.global_names = std::mem::take(&mut sub.global_names);
|
||||
self.styles = std::mem::take(&mut sub.styles);
|
||||
self.arrowheads = std::mem::take(&mut sub.arrowheads);
|
||||
self.names.absorb(std::mem::take(&mut sub.names));
|
||||
let whole = read.is_ok()
|
||||
&& sub.unsupported.is_empty()
|
||||
@@ -597,6 +602,7 @@ impl<'a> Reader<'a> {
|
||||
sub.gradients = std::mem::take(&mut self.gradients);
|
||||
sub.global_names = std::mem::take(&mut self.global_names);
|
||||
sub.styles = std::mem::take(&mut self.styles);
|
||||
sub.arrowheads = std::mem::take(&mut self.arrowheads);
|
||||
sub.pattern_tiles = std::mem::take(&mut self.pattern_tiles);
|
||||
sub.v7_patterns.clone_from(&self.v7_patterns);
|
||||
sub.nodes = self.nodes;
|
||||
@@ -607,6 +613,7 @@ impl<'a> Reader<'a> {
|
||||
self.gradients = std::mem::take(&mut sub.gradients);
|
||||
self.global_names = std::mem::take(&mut sub.global_names);
|
||||
self.styles = std::mem::take(&mut sub.styles);
|
||||
self.arrowheads = std::mem::take(&mut sub.arrowheads);
|
||||
self.pattern_tiles = std::mem::take(&mut sub.pattern_tiles);
|
||||
self.names.absorb(std::mem::take(&mut sub.names));
|
||||
// Art stopped by a trailer, or with an array, type, image, placed file, gradient mesh or
|
||||
@@ -788,6 +795,7 @@ impl<'a> Reader<'a> {
|
||||
// version 7 form, lent.
|
||||
sub.gradients = std::mem::take(&mut self.gradients);
|
||||
sub.styles = std::mem::take(&mut self.styles);
|
||||
sub.arrowheads = std::mem::take(&mut self.arrowheads);
|
||||
sub.pattern_tiles = std::mem::take(&mut self.pattern_tiles);
|
||||
sub.v7_patterns = std::mem::take(&mut self.v7_patterns);
|
||||
sub.global_names = std::mem::take(&mut self.global_names);
|
||||
@@ -799,6 +807,7 @@ impl<'a> Reader<'a> {
|
||||
self.nodes = sub.nodes;
|
||||
self.gradients = std::mem::take(&mut sub.gradients);
|
||||
self.styles = std::mem::take(&mut sub.styles);
|
||||
self.arrowheads = std::mem::take(&mut sub.arrowheads);
|
||||
self.pattern_tiles = std::mem::take(&mut sub.pattern_tiles);
|
||||
self.v7_patterns = std::mem::take(&mut sub.v7_patterns);
|
||||
self.global_names = std::mem::take(&mut sub.global_names);
|
||||
|
||||
@@ -455,6 +455,8 @@ pub fn graphic_styles(data: &[u8], large_canvas: bool, names: &mut obj::Names) -
|
||||
r.large_canvas = large_canvas.then_some(1.0);
|
||||
// The styles come before the art, so an error in the art leaves them read.
|
||||
let _ = r.run();
|
||||
// No layer checks the symbols here: the heads of those defined after the styles.
|
||||
r.read_arrowheads();
|
||||
let styles = r.graphic_styles().0;
|
||||
let used: Vec<&str> = styles.iter().map(|s| s.name.as_str()).collect();
|
||||
names.absorb_among(std::mem::take(&mut r.names), &used);
|
||||
@@ -1183,7 +1185,7 @@ impl<'a> Reader<'a> {
|
||||
continue;
|
||||
}
|
||||
let Some(st) = self.styles.get(&name) else { continue };
|
||||
let Some(mut appearance) = appearance_from_art_style(st, &self.gradients) else { continue };
|
||||
let Some(mut appearance) = appearance_from_art_style(st, &self.gradients, &self.arrowheads) else { continue };
|
||||
// A Large Canvas copy's styles are at its art's scale ([`Self::ensure_space`]).
|
||||
if let Some(s) = self.large_canvas.filter(|s| *s != 1.0) {
|
||||
appearance.scale_strokes(s);
|
||||
|
||||
@@ -2,9 +2,12 @@ use super::containers::close;
|
||||
use super::document::slot_of;
|
||||
use super::types::{BLENDS, FLIP, Frame, GRAPH_UNENDED, IGNORED, Kind, MAX_DEPTH, MAX_NODES, MAX_TAG_TEXT, MAX_TAGS, Place, URL_TAG, line_width};
|
||||
use super::{
|
||||
Affine, Appearance, AppearanceItem, Arc, BlendMode, BrushesKept, Dash, FillLayer, FillRule, Global, Gradient, GradientDef, HashMap, HashSet,
|
||||
Instance, Knockout, LayerColor, LineCap, LineJoin, Node, NodeId, NodeKind, Paint, Reader, Rect, ShownNames, StrokeLayer, V, obj, paint,
|
||||
Affine, Appearance, AppearanceItem, Arc, BlendMode, BrushesKept, CustomArrowhead, Dash, FillLayer, FillRule, Global, Gradient, GradientDef,
|
||||
HashMap, HashSet, Instance, Knockout, LayerColor, LineCap, LineJoin, Node, NodeId, NodeKind, Paint, Reader, Rect, ShownNames, StrokeLayer, V,
|
||||
obj, paint,
|
||||
};
|
||||
use vectorcraft_doc::{ArrowAlign, Arrowhead};
|
||||
use vectorcraft_geom::PathData;
|
||||
|
||||
impl<'a> Reader<'a> {
|
||||
// ---- operators -------------------------------------------------------------------------
|
||||
@@ -707,6 +710,30 @@ impl<'a> Reader<'a> {
|
||||
self.note_state();
|
||||
}
|
||||
|
||||
/// Read the heads of the arrowhead symbols the art styles' strokes name into
|
||||
/// [`Reader::arrowheads`] ([`crate::import::ai::arrowhead::head`]), each symbol once. Called
|
||||
/// when the styles are read and again when the symbols have all been read ([`Self::check_symbols`]),
|
||||
/// for a file that defines its symbols after its styles: a name with no symbol read yet is
|
||||
/// left for then.
|
||||
pub(super) fn read_arrowheads(&mut self) {
|
||||
use crate::import::ai::style::StyleItem;
|
||||
for st in self.styles.values() {
|
||||
for item in &st.items {
|
||||
let StyleItem::Stroke { arrows: Some(arrows), .. } = item else { continue };
|
||||
for name in arrows.symbols() {
|
||||
if self.arrowheads.contains_key(name) {
|
||||
continue;
|
||||
}
|
||||
let symbol = self.symbol_names.get(name).and_then(|named| self.doc.symbols.iter().find(|s| &s.name == named));
|
||||
if let Some(s) = symbol {
|
||||
let head = crate::import::ai::arrowhead::head(name, &s.art).map(Arc::new);
|
||||
self.arrowheads.insert(name.to_string(), head);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Brings [`Reader::brushes_kept`] up to date with the brushes and brush art read so far.
|
||||
fn note_brushes_kept(&mut self) {
|
||||
use super::super::brush;
|
||||
@@ -818,6 +845,7 @@ impl<'a> Reader<'a> {
|
||||
brushes: &self.brush_drafts,
|
||||
kept: &self.brushes_kept.kept,
|
||||
bending: &self.brushes_kept.bending,
|
||||
arrowheads: &self.arrowheads,
|
||||
space,
|
||||
},
|
||||
)
|
||||
@@ -1061,6 +1089,8 @@ struct StylePaints<'a> {
|
||||
kept: &'a [bool],
|
||||
/// The art an Art brush draws as the file does, with its length ([`super::super::brush::bending_art`]).
|
||||
bending: &'a HashMap<String, f64>,
|
||||
/// The heads of the arrowhead symbols strokes name ([`Reader::arrowheads`]).
|
||||
arrowheads: &'a HashMap<String, Option<Arc<CustomArrowhead>>>,
|
||||
space: Affine,
|
||||
}
|
||||
|
||||
@@ -1411,7 +1441,7 @@ fn styled(object: &Node, look: &Node, st: &crate::import::ai::style::ArtStyle, p
|
||||
return None;
|
||||
}
|
||||
}
|
||||
stroke_layer(item)?
|
||||
stroke_layer(item, paints.arrowheads)?
|
||||
}
|
||||
};
|
||||
if let Some(look) = st.looks.get(n) {
|
||||
@@ -1430,6 +1460,88 @@ fn styled(object: &Node, look: &Node, st: &crate::import::ai::style::ArtStyle, p
|
||||
if !slot && st.effects.iter().any(|e| e.id == "distort.zigZag") && !draws_look_outline(object, &appearance, look) {
|
||||
return None;
|
||||
}
|
||||
heads_placed(object, look, appearance, paints.space)
|
||||
}
|
||||
|
||||
/// What `appearance` paints on path or compound path `object`: its fills' outline and its strokes'
|
||||
/// areas, heads included, measured exactly (a node's visual bounds allow a head its whole reach on
|
||||
/// every side). `None` for another object or an appearance that paints nothing.
|
||||
fn painted_bounds(object: &Node, appearance: &Appearance) -> Option<Rect> {
|
||||
let (path, rule) = match &object.kind {
|
||||
NodeKind::Path { path, rule, .. } => (path.clone(), *rule),
|
||||
NodeKind::Compound { children, rule } => {
|
||||
(PathData::new(children.iter().filter_map(|c| c.path_data()).flat_map(|p| p.subpaths.iter().cloned()).collect()), *rule)
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
let mut out = None;
|
||||
for item in &appearance.items {
|
||||
let painted = match item {
|
||||
AppearanceItem::Fill(f) if f.visible && !f.paint.is_none() => path.bounds(),
|
||||
AppearanceItem::Stroke(s) if s.visible && !s.paint.is_none() => vectorcraft_effects::stroke::outline_region(&path, rule, s).bounds(),
|
||||
_ => None,
|
||||
};
|
||||
out = vectorcraft_geom::union_opt(out, painted);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// `appearance` (on `object`, whose drawn look is `look`, in a space `space` takes to the
|
||||
/// document) with its strokes' arrowheads placed as the look draws them: the tips on the ends of
|
||||
/// the path, or past them by the line's length under each head (Extend), whichever gives the
|
||||
/// object the look's bounds within a quarter of the least distance a head moves between the two
|
||||
/// (at least 0.05 pt, at most 0.5 pt). `None`
|
||||
/// when neither does (the file draws the heads elsewhere: on other subpaths, say), or when both do
|
||||
/// and any head moves 0.2 pt or more between them (the bounds can't tell which the file draws).
|
||||
fn heads_placed(object: &Node, look: &Node, mut appearance: Appearance, space: Affine) -> Option<Appearance> {
|
||||
let k = space.determinant().abs().sqrt();
|
||||
let k = if k.is_finite() && k > 0.0 { k } else { 1.0 };
|
||||
// How far each head moves between the placements (its line's length under it): the least and
|
||||
// the most.
|
||||
let (mut shift, mut most) = (f64::INFINITY, 0.0f64);
|
||||
for item in &appearance.items {
|
||||
let AppearanceItem::Stroke(s) = item else { continue };
|
||||
for (head, end) in [(&s.start_arrow, false), (&s.end_arrow, true)] {
|
||||
if let Some(Arrowhead::Custom(c)) = head {
|
||||
let moves = c.stop() * s.arrow_weight(end) * k;
|
||||
(shift, most) = (shift.min(moves), most.max(moves));
|
||||
}
|
||||
}
|
||||
}
|
||||
if shift.is_infinite() {
|
||||
return Some(appearance);
|
||||
}
|
||||
let want = look.visual_bounds()?;
|
||||
// Well under the distance between the placements, and under half a point: a look without
|
||||
// those heads, or with them elsewhere, is off by more.
|
||||
let tolerance = (shift / 4.0).clamp(0.05, 0.5);
|
||||
let mut fits = vec![];
|
||||
for align in [ArrowAlign::Tip, ArrowAlign::Extend] {
|
||||
for item in &mut appearance.items {
|
||||
if let AppearanceItem::Stroke(s) = item {
|
||||
s.arrow_align = align;
|
||||
}
|
||||
}
|
||||
let mut scaled = appearance.clone();
|
||||
scaled.scale_strokes(k);
|
||||
let got = painted_bounds(object, &scaled)?;
|
||||
let off = [got.x0 - want.x0, got.y0 - want.y0, got.x1 - want.x1, got.y1 - want.y1].iter().fold(0.0f64, |m, d| m.max(d.abs()));
|
||||
if off <= tolerance {
|
||||
fits.push(align);
|
||||
}
|
||||
}
|
||||
// Both fit when the bounds can't tell the placements apart (the end inside the bounds of the
|
||||
// line's other segments), unless every head moves so little that either draws alike.
|
||||
let align = match fits.as_slice() {
|
||||
[one] => *one,
|
||||
[first, _] if most < 0.2 => *first,
|
||||
_ => return None,
|
||||
};
|
||||
for item in &mut appearance.items {
|
||||
if let AppearanceItem::Stroke(s) = item {
|
||||
s.arrow_align = align;
|
||||
}
|
||||
}
|
||||
Some(appearance)
|
||||
}
|
||||
|
||||
@@ -1559,7 +1671,11 @@ fn draws_look_outline(object: &Node, appearance: &Appearance, look: &Node) -> bo
|
||||
/// A style that is one paint is its fill and stroke ([`crate::import::ai::style::ArtStyle::one_paint`]).
|
||||
/// A style keeps only its gradients' names and angles, so each one's gradient, by VectorCraft's own
|
||||
/// rule, is fitted to the bounds of whatever object the style is applied to, at its angle.
|
||||
pub(super) fn appearance_from_art_style(st: &crate::import::ai::style::ArtStyle, gradients: &HashMap<String, Gradient>) -> Option<Appearance> {
|
||||
pub(super) fn appearance_from_art_style(
|
||||
st: &crate::import::ai::style::ArtStyle,
|
||||
gradients: &HashMap<String, Gradient>,
|
||||
arrowheads: &HashMap<String, Option<Arc<CustomArrowhead>>>,
|
||||
) -> Option<Appearance> {
|
||||
use crate::import::ai::style::StyleItem;
|
||||
if !st.plain {
|
||||
return None;
|
||||
@@ -1574,7 +1690,7 @@ pub(super) fn appearance_from_art_style(st: &crate::import::ai::style::ArtStyle,
|
||||
StyleItem::Fill(paint) => AppearanceItem::Fill(FillLayer::new(paint.clone())),
|
||||
// A graphic style's brush isn't checked against the file's brushes: it is left out.
|
||||
StyleItem::Stroke { brush: Some(_), .. } => return None,
|
||||
StyleItem::Stroke { .. } => stroke_layer(item)?,
|
||||
StyleItem::Stroke { .. } => stroke_layer(item, arrowheads)?,
|
||||
StyleItem::Gradient { name, angle } => AppearanceItem::Fill(FillLayer::new(named_gradient(name.as_deref()?, *angle, gradients)?)),
|
||||
StyleItem::Pattern { .. } => return None,
|
||||
};
|
||||
@@ -1665,7 +1781,7 @@ pub(crate) fn read_parsed_style(parsed: &ParsedStyle, own_gradient: Option<&Pain
|
||||
.collect();
|
||||
// No gradient is taken by name: on an object, one that isn't its own is placed where its drawn
|
||||
// look has it.
|
||||
let mut appearance = appearance_from_art_style(&st, &HashMap::new())?;
|
||||
let mut appearance = appearance_from_art_style(&st, &HashMap::new(), &HashMap::new())?;
|
||||
for (item, brush) in appearance.items.iter_mut().zip(brushes) {
|
||||
if let (AppearanceItem::Stroke(s), Some(brush)) = (item, brush) {
|
||||
s.brush = Some(brush);
|
||||
@@ -1680,12 +1796,27 @@ pub(crate) fn parsed_moves_with(parsed: &ParsedStyle, object: &Node) -> bool {
|
||||
!parsed.style.moves_outline() || moves_with(object, &parsed.style)
|
||||
}
|
||||
|
||||
/// A style's stroke as an appearance item (`None` for a fill).
|
||||
fn stroke_layer(item: &crate::import::ai::style::StyleItem) -> Option<AppearanceItem> {
|
||||
let crate::import::ai::style::StyleItem::Stroke { paint, width, cap, join, miter, dash, profile, align, brush } = item else { return None };
|
||||
/// A style's stroke as an appearance item, its arrowheads the heads of `arrowheads` by symbol
|
||||
/// name, each tip on its end of the path (where [`heads_placed`] finds the file draws them on an
|
||||
/// object; a graphic style keeps that). `None` for a fill, or for a stroke
|
||||
/// whose arrowhead symbol has no head there or whose head's weight would be under the least one
|
||||
/// draws at ([`StrokeLayer::arrow_weight`]), so the head would draw larger than in the file.
|
||||
fn stroke_layer(item: &crate::import::ai::style::StyleItem, arrowheads: &HashMap<String, Option<Arc<CustomArrowhead>>>) -> Option<AppearanceItem> {
|
||||
let crate::import::ai::style::StyleItem::Stroke { paint, width, cap, join, miter, dash, profile, align, brush, arrows } = item else {
|
||||
return None;
|
||||
};
|
||||
let mut layer = StrokeLayer::new(paint.clone(), line_width(*width));
|
||||
(layer.cap, layer.join, layer.miter_limit, layer.dash, layer.profile, layer.align) = (*cap, *join, *miter, dash.clone(), profile.clone(), *align);
|
||||
layer.brush = brush.as_ref().map(|(name, _)| name.clone());
|
||||
if let Some(arrows) = arrows {
|
||||
let head = |end: &Option<(String, f64)>| -> Option<(Option<Arrowhead>, f64)> {
|
||||
let Some((name, pct)) = end else { return Some((None, 100.0)) };
|
||||
let head = arrowheads.get(name)?.clone()?;
|
||||
(layer.width * pct / 100.0 >= StrokeLayer::LEAST_ARROW_WEIGHT).then_some((Some(Arrowhead::Custom(head)), *pct))
|
||||
};
|
||||
let ((start, start_pct), (end, end_pct)) = (head(&arrows.start)?, head(&arrows.end)?);
|
||||
(layer.start_arrow, layer.end_arrow, layer.arrow_scale, layer.arrow_align) = (start, end, (start_pct, end_pct), ArrowAlign::Tip);
|
||||
}
|
||||
Some(AppearanceItem::Stroke(layer))
|
||||
}
|
||||
|
||||
@@ -1914,6 +2045,7 @@ mod tests {
|
||||
brushes: &brushes,
|
||||
kept: &[true],
|
||||
bending: &bending,
|
||||
arrowheads: &HashMap::new(),
|
||||
space: Affine::IDENTITY,
|
||||
};
|
||||
let look = Node::group(NodeId(1), vec![square(2, Paint::solid(vectorcraft_color::Color::rgb(1.0, 0.0, 0.0)))]);
|
||||
@@ -1960,6 +2092,7 @@ mod tests {
|
||||
brushes: &[],
|
||||
kept: &[],
|
||||
bending: &bending,
|
||||
arrowheads: &HashMap::new(),
|
||||
space: Affine::IDENTITY,
|
||||
};
|
||||
let look = Node::group(NodeId(1), vec![square(2, Paint::solid(vectorcraft_color::Color::rgb(1.0, 0.0, 0.0)))]);
|
||||
|
||||
@@ -230,6 +230,8 @@ impl ArtStyle {
|
||||
}
|
||||
}
|
||||
|
||||
// A stroke takes about 300 bytes and the other items about 100; a style holds a few of each.
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub(super) enum StyleItem {
|
||||
Fill(Paint),
|
||||
@@ -258,9 +260,35 @@ pub(super) enum StyleItem {
|
||||
align: StrokeAlign,
|
||||
/// A brush: its name, and its settings for this object.
|
||||
brush: Option<(String, PathBrush)>,
|
||||
/// Its arrowheads, as symbols of the file (`None`: it has none).
|
||||
arrows: Option<Box<StrokeArrows>>,
|
||||
},
|
||||
}
|
||||
|
||||
/// A stroke's arrowheads: each end's symbol (`/GObjRef : (name) /SymbolArt ; (BSArrowBeginSymbol)`
|
||||
/// or `(BSArrowEndSymbol)` in the stroke's dictionary) by its name in the file, with its scale in
|
||||
/// percent (`BSArrowBeginScale`, `BSArrowEndScale`; 100 without one). The symbol's art is the head
|
||||
/// and a sample of the line it ends, which `read::ops` reads into a head once the symbols are read.
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub(super) struct StrokeArrows {
|
||||
pub start: Option<(String, f64)>,
|
||||
pub end: Option<(String, f64)>,
|
||||
}
|
||||
|
||||
impl StrokeArrows {
|
||||
/// The names of the symbols, start first.
|
||||
pub fn symbols(&self) -> impl Iterator<Item = &str> {
|
||||
[&self.start, &self.end].into_iter().flatten().map(|(name, _)| name.as_str())
|
||||
}
|
||||
}
|
||||
|
||||
/// The arrowhead entries of a stroke's dictionary that [`stroke_arrows`] reads. Beside heads, any
|
||||
/// other entry whose key starts with `BSArrow` isn't read, so the stroke keeps its drawn look.
|
||||
const ARROW_ENTRIES: [&str; 4] = ["BSArrowBeginSymbol", "BSArrowEndSymbol", "BSArrowBeginScale", "BSArrowEndScale"];
|
||||
|
||||
/// The scales an arrowhead takes, in percent.
|
||||
const ARROW_SCALES: std::ops::RangeInclusive<f64> = 1.0..=1000.0;
|
||||
|
||||
/// A fill's or stroke's own state in the stack.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub(super) struct ItemLook {
|
||||
@@ -320,6 +348,9 @@ struct Filter {
|
||||
/// The plug-in object it refers to (`/GObjRef : (name) (plug-in) /PluginObject`): its name and
|
||||
/// plug-in name.
|
||||
plugin_object: Option<(String, String)>,
|
||||
/// The symbols its dictionary refers to (`/GObjRef : (name) /SymbolArt ; (key) ,`): each one's
|
||||
/// name, by key.
|
||||
symbols: HashMap<String, String>,
|
||||
/// `mode opacity … Xy`.
|
||||
xy: Option<(usize, f32)>,
|
||||
/// `… isolate knockout … Xy`.
|
||||
@@ -352,6 +383,7 @@ impl Default for Filter {
|
||||
pattern: None,
|
||||
fill_last: LastPaint::None,
|
||||
plugin_object: None,
|
||||
symbols: HashMap::new(),
|
||||
xy: None,
|
||||
xy_group: None,
|
||||
data: None,
|
||||
@@ -533,6 +565,11 @@ pub(super) fn art_styles_in(data: &[u8], names: &mut Names) -> HashMap<String, A
|
||||
}
|
||||
}
|
||||
b"Array" => dict_array = Some(vec![]),
|
||||
// A symbol the dictionary refers to: `/GObjRef : (name) /SymbolArt ; (key) ,`.
|
||||
b"SymbolArt" => {
|
||||
symbol_entry(&mut lex, &mut operands, &mut other_entry, names, filters.last_mut().filter(|_| in_basic));
|
||||
continue;
|
||||
}
|
||||
b"PluginObject" if in_basic => {
|
||||
let mut texts = operands.iter().rev().filter_map(|v| names.text(v));
|
||||
if let (Some(plugin), Some(name), Some(f)) = (texts.next(), texts.next(), filters.last_mut()) {
|
||||
@@ -891,6 +928,7 @@ impl OnePaint {
|
||||
profile: None,
|
||||
align: StrokeAlign::Center,
|
||||
brush: None,
|
||||
arrows: None,
|
||||
}),
|
||||
_ => return Err(()),
|
||||
}
|
||||
@@ -1485,11 +1523,68 @@ fn stroke_item(f: &Filter, align: StrokeAlign) -> Result<Option<StyleItem>, ()>
|
||||
profile: width_profile(&f.arrays),
|
||||
align,
|
||||
brush: None,
|
||||
arrows: stroke_arrows(f)?,
|
||||
})),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
|
||||
/// The arrowheads of stroke filter `f` ([`StrokeArrows`]; `None` without any). `Err` for heads
|
||||
/// beside an arrowhead entry [`ARROW_ENTRIES`] doesn't name, a scale that isn't a number in
|
||||
/// [`ARROW_SCALES`], or a symbol entry with no symbol's name.
|
||||
fn stroke_arrows(f: &Filter) -> Result<Option<Box<StrokeArrows>>, ()> {
|
||||
let end = |symbol: &str, scale: &str| -> Result<Option<(String, f64)>, ()> {
|
||||
if !f.kinds.contains_key(symbol) {
|
||||
return Ok(None);
|
||||
}
|
||||
let name = f.symbols.get(symbol).ok_or(())?;
|
||||
let pct = match f.kinds.get(scale) {
|
||||
None => Some(100.0),
|
||||
Some(Kind::Real) => entry(f, scale, Kind::Real)?,
|
||||
Some(_) => entry(f, scale, Kind::Int)?,
|
||||
};
|
||||
Ok(Some((name.clone(), pct.filter(|p| ARROW_SCALES.contains(p)).ok_or(())?)))
|
||||
};
|
||||
let arrows = StrokeArrows { start: end("BSArrowBeginSymbol", "BSArrowBeginScale")?, end: end("BSArrowEndSymbol", "BSArrowEndScale")? };
|
||||
if arrows.start.is_none() && arrows.end.is_none() {
|
||||
return Ok(None);
|
||||
}
|
||||
// Another arrowhead entry may change how the heads draw.
|
||||
if f.kinds.keys().any(|k| k.starts_with("BSArrow") && !ARROW_ENTRIES.contains(&k.as_str())) {
|
||||
return Err(());
|
||||
}
|
||||
Ok(Some(Box::new(arrows)))
|
||||
}
|
||||
|
||||
/// A symbol the dictionary of `filter`, the basic filter being read, refers to,
|
||||
/// `/GObjRef : (name) /SymbolArt ; (key) ,`, whose `/SymbolArt` `lex` has just read (`operands`:
|
||||
/// the values before it, read by `names`): the symbol's name by its key in [`Filter::symbols`], the
|
||||
/// key an entry of another kind. Outside a basic filter (`None`) nothing is read.
|
||||
fn symbol_entry(lex: &mut Lexer, operands: &mut Vec<V>, other_entry: &mut Option<Option<String>>, names: &mut Names, filter: Option<&mut Filter>) {
|
||||
let Some(f) = filter else { return };
|
||||
let symbol = operands.iter().rev().find_map(|v| names.text(v));
|
||||
(*other_entry, *operands) = (None, vec![]);
|
||||
let at = lex.offset();
|
||||
// A comment line is no part of the entry.
|
||||
let mut next = || loop {
|
||||
match lex.next_token().map(|t| t.tok) {
|
||||
Some(Tok::Comment(_)) => continue,
|
||||
tok => return tok,
|
||||
}
|
||||
};
|
||||
let (close, key) = (next(), next());
|
||||
// Anything else is read as it comes (a `/KnownStyle` starting the next style, say).
|
||||
let (Some(Tok::Word(b";")), Some(Tok::Str(key))) = (close, key) else {
|
||||
lex.seek(at);
|
||||
return;
|
||||
};
|
||||
let key = String::from_utf8_lossy(&key).into_owned();
|
||||
f.repeated |= f.kinds.insert(key.clone(), Kind::Other).is_some();
|
||||
if let Some(symbol) = symbol {
|
||||
f.symbols.insert(key, symbol);
|
||||
}
|
||||
}
|
||||
|
||||
/// A Stroke Offset filter `f`: a stroke whose own style is in its dictionary, aligned inside its
|
||||
/// path when `StrokeOffsetInside` is 1 and outside when it is 0 (its `DisplayString` says which).
|
||||
/// `Err` when that switch is missing or not a switch, or for a stroke [`paint_item`] doesn't read.
|
||||
@@ -1552,6 +1647,7 @@ fn calligraphic_stroke(f: &Filter) -> Option<StyleItem> {
|
||||
profile: None,
|
||||
align: StrokeAlign::Center,
|
||||
brush: Some((name.clone(), PathBrush::Calligraphic(super::brush::calligraphic(values, variation, codes)))),
|
||||
arrows: None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1633,6 +1729,7 @@ fn art_stroke(f: &Filter) -> Option<StyleItem> {
|
||||
profile: None,
|
||||
align: StrokeAlign::Center,
|
||||
brush: Some((name.clone(), PathBrush::Art(settings))),
|
||||
arrows: None,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1558,8 +1558,10 @@ fn a_style_of_one_paint_reads_as_the_fill_and_stroke_its_xd_turns_on() {
|
||||
};
|
||||
let stroke = "0 R\n0 1 1 0 K\n1 J 2 j 3 w 4 M [2 1]0 d\n";
|
||||
let Some(Ok(items)) = one(&format!("0 O\n0 0 1 0 k\n{stroke}1 1 Xd\n")) else { panic!("{:?}", one(stroke)) };
|
||||
let [StyleItem::Fill(fill), StyleItem::Stroke { paint, width, cap, join, miter, dash, profile: None, align: StrokeAlign::Center, brush: None }] =
|
||||
items.as_slice()
|
||||
let [
|
||||
StyleItem::Fill(fill),
|
||||
StyleItem::Stroke { paint, width, cap, join, miter, dash, profile: None, align: StrokeAlign::Center, brush: None, arrows: _ },
|
||||
] = items.as_slice()
|
||||
else {
|
||||
panic!("{items:?}")
|
||||
};
|
||||
@@ -1600,3 +1602,30 @@ fn a_style_of_one_paint_reads_as_the_fill_and_stroke_its_xd_turns_on() {
|
||||
assert_eq!(one(&paint), Some(Err(())), "{paint}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A `/SymbolArt` entry cut short (no `; (key)` after it) leaves what follows to be read: here the
|
||||
/// next style.
|
||||
#[test]
|
||||
fn a_symbol_entry_cut_short_leaves_the_next_style_read() {
|
||||
let stroke = "/BasicFilter :\n(Stroke Style Filter) 0 0 /Filter ,\n1 /Visible ,\n/Dictionary : /NotRecorded ,\n\
|
||||
/StrokeStyle : 0 R\n0 0 0 1 0 0 0 XA\n0 J 0 j 1 w 10 M []0 d\n0 XR\n1 0 Xd\n/Def ;\n (StrokeStyle) ,\n";
|
||||
let text = format!(
|
||||
"/KnownStyle :\n(Cut) /Name ,\n/ActiveStyle :\n/CompoundFilter :\n(Chain Style Filter) 0 0 /Filter ,\n1 /Visible ,\n{stroke}/GObjRef : (W) /SymbolArt\n\
|
||||
/KnownStyle :\n(Next) /Name ,\n/ActiveStyle :\n/CompoundFilter :\n(Chain Style Filter) 0 0 /Filter ,\n1 /Visible ,\n{stroke}; /Dict ;\n /Part ,\n;\n"
|
||||
);
|
||||
let styles = art_styles(text.as_bytes());
|
||||
assert!(styles.contains_key("Cut") && styles.contains_key("Next"), "{:?}", styles.keys().collect::<Vec<_>>());
|
||||
assert!(matches!(styles["Next"].items.as_slice(), [StyleItem::Stroke { arrows: None, .. }]), "{:?}", styles["Next"].items);
|
||||
}
|
||||
|
||||
/// A comment line inside a `/SymbolArt` entry is skipped: the entry is still read.
|
||||
#[test]
|
||||
fn a_comment_inside_a_symbol_entry_is_skipped() {
|
||||
let text = "/KnownStyle :\n(Arrowed) /Name ,\n/ActiveStyle :\n/CompoundFilter :\n(Chain Style Filter) 0 0 /Filter ,\n1 /Visible ,\n\
|
||||
/BasicFilter :\n(Stroke Style Filter) 0 0 /Filter ,\n1 /Visible ,\n/Dictionary : /NotRecorded ,\n\
|
||||
/GObjRef : (W) /SymbolArt\n%a comment\n; (BSArrowEndSymbol) ,\n\
|
||||
/StrokeStyle : 0 R\n0 0 0 1 0 0 0 XA\n0 J 0 j 1 w 10 M []0 d\n0 XR\n1 0 Xd\n/Def ;\n (StrokeStyle) ,\n; /Dict ;\n /Part ,\n;\n";
|
||||
let styles = art_styles(text.as_bytes());
|
||||
let [StyleItem::Stroke { arrows: Some(arrows), .. }] = styles["Arrowed"].items.as_slice() else { panic!("{:?}", styles["Arrowed"].items) };
|
||||
assert_eq!(arrows.end, Some(("W".to_string(), 100.0)));
|
||||
}
|
||||
@@ -6638,6 +6638,243 @@ fn a_default_style_with_a_stroke_aligned_outside_comes_in() {
|
||||
assert_eq!(a[0].extras().graphic_style, Some(1));
|
||||
}
|
||||
|
||||
/// An arrowhead symbol's art: an unpainted frame, a 1 pt sample of the line from x = −9 to 4 on
|
||||
/// y = 0, and the head, a filled wedge from x = 2 back to its tip at x = 8, 3 either side.
|
||||
const WEDGE_ART: &str = "-10 5 m\n10 5 L\n10 -5 L\n-10 -5 L\n-10 5 L\nn\n0 G\n1 w\n-9 0 m\n4 0 l\nS\n0 g\n2 3 m\n8 0 l\n2 -3 l\nf\n";
|
||||
|
||||
/// The end arrowhead entries of a stroke's dictionary: symbol `Wedge` at 50 %.
|
||||
const END_WEDGE: &str = "50 /Real (BSArrowEndScale) ,\n/GObjRef : (Wedge) /SymbolArt ; (BSArrowEndSymbol) ,\n";
|
||||
|
||||
/// An art style named `name`: a black stroke of weight `width` whose stroke dictionary holds
|
||||
/// `entries`, as a stroke's arrowheads are written.
|
||||
fn arrow_style(name: &str, entries: &str, width: f64) -> String {
|
||||
format!(
|
||||
"/KnownStyle :\n({name}) /Name ,\n/ActiveStyle :\n/CompoundFilter :\n(Chain Style Filter) 0 0 /Filter ,\n1 /Visible ,\n\
|
||||
/CompoundFilter :\n(Stack Style Filter) 0 0 /Filter ,\n1 /Visible ,\n\
|
||||
/BasicFilter :\n(Stroke Style Filter) 0 0 /Filter ,\n1 /Visible ,\n2 /FillOrStroke ,\n/Dictionary : /NotRecorded ,\n\
|
||||
/Dictionary : /NotRecorded ,\n1 /Int (BSAdvStrokeDictionaryVersion) ,\n{entries}; (kAIBeautifulStrokesParamsDictKey) ,\n\
|
||||
/StrokeStyle : 0 R\n0 0 0 1 0 0 0 XA\n0 J 0 j {width} w 10 M []0 d\n0 XR\n1 0 Xd\n/Def ;\n (StrokeStyle) ,\n; /Dict ;\n /Part ,\n\
|
||||
/BasicFilter :\n(Conduit Filter) 0 0 /Filter ,\n1 /Visible ,\n;\n /Part ,\n;\n /Part ,\n;\n"
|
||||
)
|
||||
}
|
||||
|
||||
/// The drawn look of a 2 pt line from (0, 50) to (100, 50) with [`END_WEDGE`] (weight 1) on its end,
|
||||
/// the tip on the end: the line to 4 before it, under the head from x = 94 to 100, 3 either side.
|
||||
const END_WEDGE_LOOK: &str = "0 G\n2 w\n0 50 m\n96 50 l\nS\n0 g\n94 53 m\n100 50 l\n94 47 l\nf\n";
|
||||
|
||||
/// A line from (0, 50) to (100, 50) drawn as `look`, read as itself with the art style `name`.
|
||||
fn arrowed_line(name: &str, look: &str) -> String {
|
||||
format!("0 Ae\nu\n{look}U\n%_0 50 m\n%_100 50 L\n%_N\n1 ({name}) XW\n")
|
||||
}
|
||||
|
||||
/// A file with the arrowhead symbol `Wedge` (art `symbol_art`), the art style `Arrowed`
|
||||
/// ([`arrow_style`] with `entries` and `width`), listed, and a line drawn with it as `look`.
|
||||
fn arrowed_file(symbol_art: &str, entries: &str, width: f64, look: &str) -> String {
|
||||
named_arrowed_file("Wedge", symbol_art, entries, width, look)
|
||||
}
|
||||
|
||||
/// [`arrowed_file`] with the symbol named `name`.
|
||||
fn named_arrowed_file(name: &str, symbol_art: &str, entries: &str, width: f64, look: &str) -> String {
|
||||
format!(
|
||||
"{}{}{}",
|
||||
symbols(&symbol(name, symbol_art, 5)),
|
||||
styles_and_list(&[arrow_style("Arrowed", entries, width)], &["Arrowed"]),
|
||||
layer(&arrowed_line("Arrowed", look))
|
||||
)
|
||||
}
|
||||
|
||||
/// The object `r` reads, its path, and its stroke.
|
||||
fn arrowed(r: &Structure) -> (Arc<Node>, vectorcraft_doc::StrokeLayer) {
|
||||
let a = art(&r.doc);
|
||||
assert_eq!(a.len(), 1, "{a:#?}");
|
||||
assert!(matches!(a[0].kind, NodeKind::Path { .. }), "the object, not its look: {:#?} {:?}", a[0], r.warnings);
|
||||
assert!(!r.warnings.iter().any(|w| w.contains("drawn look")), "{:?}", r.warnings);
|
||||
let s = a[0].appearance.stroke().expect("a stroke").clone();
|
||||
(a[0].clone(), s)
|
||||
}
|
||||
|
||||
/// The bounds of the area stroke `s` paints along path `n` (its heads included).
|
||||
fn painted(n: &Node, s: &vectorcraft_doc::StrokeLayer) -> Rect {
|
||||
let NodeKind::Path { path, rule, .. } = &n.kind else { panic!("a path") };
|
||||
vectorcraft_effects::stroke::outline_region(path, *rule, s).bounds().unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_strokes_arrowhead_symbols_are_its_arrowheads() {
|
||||
// GUARDS: a stroke's arrowheads (#8188) were left out: the line came in without its heads.
|
||||
use vectorcraft_doc::{ArrowAlign, Arrowhead};
|
||||
let r = read_ok(&arrowed_file(WEDGE_ART, END_WEDGE, 2.0, END_WEDGE_LOOK));
|
||||
let (object, s) = arrowed(&r);
|
||||
assert_eq!((s.width, s.arrow_scale, s.arrow_align), (2.0, (100.0, 50.0), ArrowAlign::Tip));
|
||||
assert!(s.start_arrow.is_none(), "{:?}", s.start_arrow);
|
||||
let Some(Arrowhead::Custom(head)) = &s.end_arrow else { panic!("a head of the symbol's art: {:?}", s.end_arrow) };
|
||||
assert_eq!(head.name, "Wedge");
|
||||
// In head units, one a symbol unit: 6 long from the tip, 3 either side, the line stopping 4
|
||||
// back from the tip, where the sample ends.
|
||||
let b = head.path.bounds().expect("an outline");
|
||||
for (got, want) in [(b.x0, 0.0), (b.x1, 6.0), (b.y0, -3.0), (b.y1, 3.0), (head.stop(), 4.0)] {
|
||||
assert!((got - want).abs() < 1e-6, "{b:?}, stop {}", head.stop());
|
||||
}
|
||||
// Drawn with the tip on the line's end: a head of weight 1 (2 pt at 50 %), 6 pt long.
|
||||
let end = object.path_data().unwrap().subpaths[0].anchors.last().unwrap().p;
|
||||
let drawn = painted(&object, &s);
|
||||
assert!((drawn.x1 - end.x).abs() < 1e-6 && (drawn.height() - 6.0).abs() < 1e-6, "{drawn:?} for an end at {end:?}");
|
||||
// The listed graphic style has the head too.
|
||||
let style = r.doc.graphic_styles[0].appearance.stroke().expect("the style's stroke");
|
||||
assert!(matches!(&style.end_arrow, Some(Arrowhead::Custom(h)) if h == head), "{:?}", style.end_arrow);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_strokes_start_arrowhead_points_back_and_keeps_its_side() {
|
||||
use vectorcraft_doc::Arrowhead;
|
||||
// A head with one barb, below the line in the symbol (its space is y down): on the right of
|
||||
// the way it points. At the start of a 1 pt line drawn left to right it points left, the barb
|
||||
// above the line (the file's y up), the line starting 4 in.
|
||||
let barb = "0 G\n1 w\n-9 0 m\n4 0 l\nS\n0 g\n2 3 m\n8 0 l\n2 0 l\nf\n";
|
||||
let entries = "/GObjRef : (Wedge) /SymbolArt ; (BSArrowBeginSymbol) ,\n";
|
||||
let look = "0 G\n1 w\n4 50 m\n100 50 l\nS\n0 g\n6 53 m\n0 50 l\n6 50 l\nf\n";
|
||||
let r = read_ok(&arrowed_file(barb, entries, 1.0, look));
|
||||
let (object, s) = arrowed(&r);
|
||||
assert_eq!(s.arrow_scale, (100.0, 100.0));
|
||||
assert!(s.end_arrow.is_none());
|
||||
let Some(Arrowhead::Custom(head)) = &s.start_arrow else { panic!("{:?}", s.start_arrow) };
|
||||
let b = head.path.bounds().unwrap();
|
||||
assert!(b.y0.abs() < 1e-6 && (b.y1 - 3.0).abs() < 1e-6, "right of the way it points: {b:?}");
|
||||
// Drawn: the tip on the start, and 3 pt of head on the barb's side of the line (above it: the
|
||||
// document's y down) against the line's half point on the other.
|
||||
let start = object.path_data().unwrap().subpaths[0].anchors.first().unwrap().p;
|
||||
let drawn = painted(&object, &s);
|
||||
assert!((drawn.x0 - start.x).abs() < 1e-6, "{drawn:?} for a start at {start:?}");
|
||||
assert!((start.y - drawn.y0 - 3.0).abs() < 1e-6 && (drawn.y1 - start.y - 0.5).abs() < 1e-6, "{drawn:?} for a start at {start:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_stroke_takes_both_heads_at_their_own_scales() {
|
||||
use vectorcraft_doc::Arrowhead;
|
||||
// The start at 100 % written as a whole number (weight 2: 12 long, 6 either side, the line 8
|
||||
// in), the end at 50 %, both of a symbol named in Chinese ("wedge").
|
||||
let entries = "100 /Int (BSArrowBeginScale) ,\n/GObjRef : (楔) /SymbolArt ; (BSArrowBeginSymbol) ,\n\
|
||||
50 /Real (BSArrowEndScale) ,\n/GObjRef : (楔) /SymbolArt ; (BSArrowEndSymbol) ,\n";
|
||||
let look = "0 G\n2 w\n8 50 m\n96 50 l\nS\n0 g\n12 56 m\n0 50 l\n12 44 l\nf\n94 53 m\n100 50 l\n94 47 l\nf\n";
|
||||
let r = read_ok(&named_arrowed_file("楔", WEDGE_ART, entries, 2.0, look));
|
||||
let (object, s) = arrowed(&r);
|
||||
assert_eq!(s.arrow_scale, (100.0, 50.0));
|
||||
for head in [&s.start_arrow, &s.end_arrow] {
|
||||
assert!(matches!(head, Some(Arrowhead::Custom(h)) if h.name == "楔"), "{head:?}");
|
||||
}
|
||||
let drawn = painted(&object, &s);
|
||||
assert!((drawn.width() - 100.0).abs() < 1e-6 && (drawn.height() - 12.0).abs() < 1e-6, "{drawn:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn heads_drawn_past_the_path_extend_it() {
|
||||
use vectorcraft_doc::ArrowAlign;
|
||||
// The file draws the head's tip 4 past the end (the line's length under it at weight 1): the
|
||||
// line keeps its length.
|
||||
let look = "0 G\n2 w\n0 50 m\n100 50 l\nS\n0 g\n98 53 m\n104 50 l\n98 47 l\nf\n";
|
||||
let r = read_ok(&arrowed_file(WEDGE_ART, END_WEDGE, 2.0, look));
|
||||
let (object, s) = arrowed(&r);
|
||||
assert_eq!(s.arrow_align, ArrowAlign::Extend);
|
||||
let end = object.path_data().unwrap().subpaths[0].anchors.last().unwrap().p;
|
||||
assert!((painted(&object, &s).x1 - end.x - 4.0).abs() < 1e-6);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn arrowheads_this_does_not_read_keep_the_drawn_look() {
|
||||
let two_lines = format!("{WEDGE_ART}0 G\n1 w\n-9 0 m\n4 0 l\nS\n");
|
||||
let no_line = "0 g\n2 3 m\n8 0 l\n2 -3 l\nf\n";
|
||||
let thin_line = WEDGE_ART.replace("1 w", "0.5 w");
|
||||
let missing = "/GObjRef : (Elsewhere) /SymbolArt ; (BSArrowEndSymbol) ,\n";
|
||||
let unknown = format!("{END_WEDGE}1 /Int (BSArrowSomethingElse) ,\n");
|
||||
let too_large = "2000 /Real (BSArrowEndScale) ,\n/GObjRef : (Wedge) /SymbolArt ; (BSArrowEndSymbol) ,\n";
|
||||
let line_only = "0 G\n2 w\n0 50 m\n100 50 l\nS\n";
|
||||
let cases: [(&str, &str, &str, f64, &str); 8] = [
|
||||
("a symbol the file doesn't define", WEDGE_ART, missing, 2.0, END_WEDGE_LOOK),
|
||||
("an arrowhead entry this doesn't read", WEDGE_ART, &unknown, 2.0, END_WEDGE_LOOK),
|
||||
("a scale out of range", WEDGE_ART, too_large, 2.0, END_WEDGE_LOOK),
|
||||
("a head lighter than the least weight drawn", WEDGE_ART, END_WEDGE, 0.25, END_WEDGE_LOOK),
|
||||
("a symbol without a sample of the line", no_line, END_WEDGE, 2.0, END_WEDGE_LOOK),
|
||||
("a symbol with two samples of the line", &two_lines, END_WEDGE, 2.0, END_WEDGE_LOOK),
|
||||
("a sample of the line that isn't 1 pt", &thin_line, END_WEDGE, 2.0, END_WEDGE_LOOK),
|
||||
("heads drawn neither on nor past the ends", WEDGE_ART, END_WEDGE, 2.0, line_only),
|
||||
];
|
||||
for (why, symbol_art, entries, width, look) in cases {
|
||||
let r = read_ok(&arrowed_file(symbol_art, entries, width, look));
|
||||
let a = art(&r.doc);
|
||||
assert!(r.warnings.iter().any(|w| w.contains("drawn look")), "{why}: {:?} {a:#?}", r.warnings);
|
||||
assert!(!matches!(a[0].kind, NodeKind::Path { .. }), "{why}: the look, not the object");
|
||||
// A graphic style with an arrowhead it doesn't read isn't read either, rather than read
|
||||
// without its heads.
|
||||
let headless = |i: &AppearanceItem| matches!(i, AppearanceItem::Stroke(s) if s.end_arrow.is_none());
|
||||
let styles: Vec<_> = r.doc.graphic_styles.iter().filter(|g| g.name == "Arrowed").collect();
|
||||
assert!(styles.iter().all(|g| !g.appearance.items.iter().any(headless)), "{why}: {styles:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn heads_whose_placement_the_drawn_bounds_leave_open_keep_the_drawn_look() {
|
||||
// The line bends back so its end, and a head on it either on the end or 4 past it, lie inside
|
||||
// the bounds of its earlier segments: those bounds can't tell the two placements apart.
|
||||
let path = "%_0 50 m\n%_0 0 L\n%_200 0 L\n%_200 100 L\n%_100 100 L\n%_100 50 L\n%_N\n";
|
||||
let look = "0 G\n2 w\n0 50 m\n0 0 l\n200 0 l\n200 100 l\n100 100 l\n100 54 l\nS\n0 g\n97 56 m\n100 50 l\n103 56 l\nf\n";
|
||||
let line = format!("0 Ae\nu\n{look}U\n{path}1 (Arrowed) XW\n");
|
||||
let file = format!(
|
||||
"{}{}{}",
|
||||
symbols(&symbol("Wedge", WEDGE_ART, 5)),
|
||||
styles_and_list(&[arrow_style("Arrowed", END_WEDGE, 2.0)], &["Arrowed"]),
|
||||
layer(&line)
|
||||
);
|
||||
let r = read_ok(&file);
|
||||
let a = art(&r.doc);
|
||||
assert!(r.warnings.iter().any(|w| w.contains("drawn look")), "{:?} {a:#?}", r.warnings);
|
||||
assert!(!matches!(a[0].kind, NodeKind::Path { .. }), "the look, not the object");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_head_that_stays_put_leaves_a_moving_heads_placement_open() {
|
||||
// The bent line of the test above, its end head moving 4 between the placements, and a start
|
||||
// head whose line runs to its tip (a stop of 0), which stays put: the bounds still can't tell
|
||||
// where the end head goes.
|
||||
let flat = WEDGE_ART.replace("-9 0 m\n4 0 l", "-9 0 m\n8 0 l");
|
||||
let entries = format!("50 /Real (BSArrowBeginScale) ,\n/GObjRef : (Flat) /SymbolArt ; (BSArrowBeginSymbol) ,\n{END_WEDGE}");
|
||||
let path = "%_0 50 m\n%_0 0 L\n%_200 0 L\n%_200 100 L\n%_100 100 L\n%_100 50 L\n%_N\n";
|
||||
let look =
|
||||
"0 G\n2 w\n0 50 m\n0 0 l\n200 0 l\n200 100 l\n100 100 l\n100 54 l\nS\n0 g\n-3 44 m\n0 50 l\n3 44 l\nf\n97 56 m\n100 50 l\n103 56 l\nf\n";
|
||||
let line = format!("0 Ae\nu\n{look}U\n{path}1 (Arrowed) XW\n");
|
||||
let file = format!(
|
||||
"{}{}{}",
|
||||
symbols(&format!("{}{}", symbol("Wedge", WEDGE_ART, 5), symbol("Flat", &flat, 5))),
|
||||
styles_and_list(&[arrow_style("Arrowed", &entries, 2.0)], &["Arrowed"]),
|
||||
layer(&line)
|
||||
);
|
||||
let r = read_ok(&file);
|
||||
let a = art(&r.doc);
|
||||
assert!(r.warnings.iter().any(|w| w.contains("drawn look")), "{:?} {a:#?}", r.warnings);
|
||||
assert!(!matches!(a[0].kind, NodeKind::Path { .. }), "the look, not the object");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_style_library_reads_the_heads_of_symbols_defined_after_its_styles() {
|
||||
// A graphic style library has no layers, so nothing past its styles reads the heads again.
|
||||
use vectorcraft_doc::Arrowhead;
|
||||
let data = stream(&format!(
|
||||
"%AI9_BeginArtStyles\n{}%AI9_EndArtStyles\n{}%AI9_BeginArtStyleList\n(Arrowed)\n%AI9_EndArtStyleList\n",
|
||||
arrow_style("Arrowed", END_WEDGE, 2.0),
|
||||
symbols(&symbol("Wedge", WEDGE_ART, 5))
|
||||
));
|
||||
let (styles, _) = graphic_styles(data.as_bytes(), false, &mut obj::Names::default());
|
||||
let stroke = styles.iter().find(|g| g.name == "Arrowed").and_then(|g| g.appearance.stroke());
|
||||
assert!(matches!(stroke.and_then(|s| s.end_arrow.as_ref()), Some(Arrowhead::Custom(h)) if h.name == "Wedge"), "{styles:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_arrowhead_entry_without_heads_leaves_the_stroke_read() {
|
||||
// Only beside heads does an arrowhead entry this doesn't read keep the drawn look.
|
||||
let r = read_ok(&arrowed_file(WEDGE_ART, "1 /Int (BSArrowSomethingElse) ,\n", 2.0, "0 G\n2 w\n0 50 m\n100 50 l\nS\n"));
|
||||
let (_, s) = arrowed(&r);
|
||||
assert!(s.start_arrow.is_none() && s.end_arrow.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_symbol_defined_before_the_art_styles_reads_its_styled_objects() {
|
||||
// GUARDS: objects in a symbol defined ahead of `%AI9_BeginArtStyles` (as Illustrator 24 writes
|
||||
|
||||
@@ -1010,7 +1010,7 @@ fn an_edit_out_of_sight_builds_nothing() {
|
||||
let drawn_hidden = extruded(&mut d, 70.0);
|
||||
let ids = [d.insert(Some(l), 0, hidden).unwrap(), group.children().unwrap()[0].id, d.insert(Some(l), 0, drawn_hidden).unwrap()];
|
||||
d.insert(Some(l), 0, group).unwrap();
|
||||
let opts = RenderOptions { hidden: vec![ids[2]], ..Default::default() };
|
||||
let opts = RenderOptions { hidden: [ids[2]].into(), ..Default::default() };
|
||||
let mut r = Renderer::new();
|
||||
r.render(&d, 100, 100, Affine::IDENTITY, &opts);
|
||||
let mut e = d.clone();
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use super::geometry::region_pixels;
|
||||
use super::{Arc, NodeId, Rect, encode, proof};
|
||||
|
||||
@@ -39,8 +41,8 @@ pub struct RenderOptions {
|
||||
pub background: Option<[u8; 4]>,
|
||||
/// Draw artboards as white rectangles (screen view). Export sets this to false.
|
||||
pub artboards: bool,
|
||||
/// Objects not to draw (e.g. the object being edited by a live drag preview).
|
||||
pub hidden: Vec<NodeId>,
|
||||
/// Objects not to draw (e.g. the layers and fold lines the Fold Preview's print leaves out).
|
||||
pub hidden: HashSet<NodeId>,
|
||||
/// Draw the layers as their Layer Options show them on screen: Preview off in outline, Dim
|
||||
/// Images fading their images (a template layer's too), a template in Preview in Outline view.
|
||||
pub dim_templates: bool,
|
||||
@@ -194,7 +196,7 @@ impl Default for RenderOptions {
|
||||
outline: false,
|
||||
background: None,
|
||||
artboards: false,
|
||||
hidden: vec![],
|
||||
hidden: HashSet::new(),
|
||||
dim_templates: true,
|
||||
proof: None,
|
||||
overprint_preview: false,
|
||||
|
||||
@@ -224,6 +224,33 @@ fn hidden_and_culled() {
|
||||
assert_eq!(rr.stats.culled, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_render_leaves_out_every_object_of_a_large_hidden_set() {
|
||||
// 2,000 one-pixel-wide strips; the strips in even columns are in `hidden`.
|
||||
let mut d = Document::new(100.0, 100.0);
|
||||
let l = d.layers[0].id;
|
||||
let mut hidden = std::collections::HashSet::new();
|
||||
for row in 0..20 {
|
||||
for col in 0..100 {
|
||||
let r = Rect::new(f64::from(col), f64::from(row * 5), f64::from(col + 1), f64::from(row * 5 + 5));
|
||||
let n = rect_node(&mut d, r, Paint::solid(Color::BLACK), Paint::None, 0.0);
|
||||
let id = d.insert(Some(l), usize::MAX, n).unwrap();
|
||||
if col % 2 == 0 {
|
||||
hidden.insert(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
assert_eq!(hidden.len(), 1_000);
|
||||
let opts = RenderOptions { hidden, ..Default::default() };
|
||||
let r = Renderer::new().render(&d, 100, 100, Affine::IDENTITY, &opts);
|
||||
for row in 0..20 {
|
||||
for col in 0..100 {
|
||||
let want = if col % 2 == 0 { [0, 0, 0, 0] } else { [0, 0, 0, 255] };
|
||||
assert_eq!(r.pixel(col, row * 5 + 2), want, "column {col}, row {row}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A document with symbol "Far" holding a red rectangle `art`, and an instance of it moved by
|
||||
/// (-50, -50): its 20 × 20 square, (-60, -60) to (-40, -40), lies outside a view of the page.
|
||||
fn far_instance(art: Rect) -> Document {
|
||||
|
||||
@@ -473,7 +473,7 @@ fn invisible_and_hidden_nodes_are_not_drawn() {
|
||||
let mut b = DocBuilder::new(100.0, 100.0);
|
||||
let id = b.rect(Rect::new(0.0, 0.0, 100.0, 100.0), Color::BLACK, |_| {});
|
||||
let d = b.build();
|
||||
let opts = vectorcraft_render::RenderOptions { background: Some([255, 255, 255, 255]), hidden: vec![id], ..Default::default() };
|
||||
let opts = vectorcraft_render::RenderOptions { background: Some([255, 255, 255, 255]), hidden: [id].into(), ..Default::default() };
|
||||
let r = vectorcraft_render::Renderer::new().render(&d, 100, 100, vectorcraft_geom::Affine::IDENTITY, &opts);
|
||||
assert_eq!(Image::from_rendered(&r).ink(), 0);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ pub const TOOL_GROUPS: &[&[ToolInfo]] = &[
|
||||
t("addAnchor", "Add Anchor Point Tool", Some("+"), "tool-pen-add"),
|
||||
t("deleteAnchor", "Delete Anchor Point Tool", Some("-"), "tool-pen-delete"),
|
||||
t("anchorPoint", "Anchor Point Tool", Some("Shift+C"), "tool-anchor"),
|
||||
t(crate::quickpen::ID, "Quick Pen Tool", Some("Alt+P"), "tool-quick-pen"),
|
||||
],
|
||||
&[t("curvature", "Curvature Tool", Some("Shift+~"), "tool-curvature")],
|
||||
&[
|
||||
|
||||
@@ -217,6 +217,9 @@ pub enum ToolKey {
|
||||
/// A letter key a–z, lowercase (E while dragging a Selection or Group Selection marquee makes it
|
||||
/// select only the objects entirely inside it, and E again switches it back).
|
||||
Letter(char),
|
||||
/// Alt (Option on macOS) pressed and let go with no other key, click or wheel turn in between
|
||||
/// (the Quick Pen tool switches to its next action).
|
||||
AltTap,
|
||||
}
|
||||
|
||||
/// What a tool asks the engine to do.
|
||||
|
||||
@@ -36,6 +36,7 @@ pub mod pen;
|
||||
pub mod pie;
|
||||
pub mod place;
|
||||
pub mod printtiling;
|
||||
pub mod quickpen;
|
||||
pub mod repeat_grid;
|
||||
pub mod repeat_radial;
|
||||
pub mod rulerguide;
|
||||
@@ -388,6 +389,7 @@ pub fn create(id: &str) -> Box<dyn Tool> {
|
||||
"rectangle" | "roundedRectangle" | "ellipse" | "polygon" | "star" | "lineSegment" => Box::new(shape::ShapeTool::new(id)),
|
||||
circle::ID => Box::new(circle::CircleTool::default()),
|
||||
curvature_circle::ID => Box::new(curvature_circle::CurvatureCircleTool::default()),
|
||||
quickpen::ID => Box::new(quickpen::QuickPenTool::default()),
|
||||
// Not in the toolbar: `file.place.queue` loads it.
|
||||
"place" => Box::new(place::PlaceTool::default()),
|
||||
other => symbolism::create(other)
|
||||
|
||||
@@ -0,0 +1,616 @@
|
||||
//! The Quick Pen tool (Alt+P, Option+P on macOS) draws paths of straight lines and circular arcs
|
||||
//! (`path.quickPen`).
|
||||
//!
|
||||
//! A click sets the start point, and each click or drag after it adds a piece from the last point
|
||||
//! to where the pointer is let go, as the tool's action says: a straight line, a continuous arc
|
||||
//! (it leaves its start in the direction the path arrives in, so the two join smoothly) or a
|
||||
//! sharp-corner arc (it turns through the arc size, 180° by default, and meets the path before it
|
||||
//! at a corner). Alt (Option) pressed and let go on its own switches to the next action. C flips
|
||||
//! the last sharp-corner arc to the other side of its chord, and [ and ] make the arc size 15°
|
||||
//! smaller or larger, for the last sharp-corner arc and the ones after it. A click on the first
|
||||
//! point closes the path, a click on an end of an open path goes on drawing from it, and Escape
|
||||
//! or Enter ends the path. The path's points show as circles, without handles, and a preview
|
||||
//! shows the piece the next click adds. Points snap to Smart Guides. Each piece is one undo step.
|
||||
|
||||
use std::f64::consts::{FRAC_PI_2, PI};
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_doc::{NodeId, NodeKind};
|
||||
use vectorcraft_geom::{Anchor, AnchorKind, BezPath, Point, SubPath, Vec2};
|
||||
|
||||
use crate::draw2::FEEDBACK;
|
||||
use crate::guides::{DrawSnap, Leave};
|
||||
use crate::pen::{continue_from, open_end_at};
|
||||
use crate::{Action, Cursor, Mods, Overlay, PointerEvent, PointerKind, Tool, ToolContext, ToolKey};
|
||||
|
||||
/// The tool's id.
|
||||
pub const ID: &str = "quickPen";
|
||||
/// The command that draws the path.
|
||||
pub const COMMAND: &str = "path.quickPen";
|
||||
/// A sharp-corner arc's turn (degrees) until [ or ] changes it.
|
||||
pub const DEFAULT_TURN: f64 = 180.0;
|
||||
/// The degrees [ and ] take from or add to the arc size.
|
||||
pub const TURN_STEP: f64 = 15.0;
|
||||
/// The smallest and largest arc size (degrees).
|
||||
pub const MIN_TURN: f64 = 1.0;
|
||||
pub const MAX_TURN: f64 = 359.0;
|
||||
/// Screen points the pointer moves after a press before the press drags.
|
||||
const DRAG_PX: f64 = 3.0;
|
||||
/// A continuous arc whose end lies within this angle (radians) of straight ahead, or of straight
|
||||
/// behind, is drawn as a line: no circle runs there in the path's direction.
|
||||
const STRAIGHT: f64 = 1e-6;
|
||||
|
||||
/// What the next click adds.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub enum Stroke {
|
||||
#[default]
|
||||
Line,
|
||||
ContinuousArc,
|
||||
SharpArc,
|
||||
}
|
||||
|
||||
impl Stroke {
|
||||
pub const ALL: [Stroke; 3] = [Stroke::Line, Stroke::ContinuousArc, Stroke::SharpArc];
|
||||
|
||||
/// The name commands and the tool's `action` option use.
|
||||
pub fn name(self) -> &'static str {
|
||||
match self {
|
||||
Stroke::Line => "line",
|
||||
Stroke::ContinuousArc => "continuousArc",
|
||||
Stroke::SharpArc => "sharpArc",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse(s: &str) -> Option<Self> {
|
||||
Self::ALL.into_iter().find(|k| k.name() == s)
|
||||
}
|
||||
|
||||
/// The action after this one: Line, Continuous Arc, Sharp Corner Arc, and round again.
|
||||
pub fn next(self) -> Self {
|
||||
match self {
|
||||
Stroke::Line => Stroke::ContinuousArc,
|
||||
Stroke::ContinuousArc => Stroke::SharpArc,
|
||||
Stroke::SharpArc => Stroke::Line,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One piece of a Quick Pen path: from the path's last point to `to`. `turn` (degrees) and `flip`
|
||||
/// shape a sharp-corner arc, and a continuous arc with no direction to follow.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Piece {
|
||||
pub to: Point,
|
||||
pub stroke: Stroke,
|
||||
pub turn: f64,
|
||||
pub flip: bool,
|
||||
}
|
||||
|
||||
impl Piece {
|
||||
pub fn to_json(&self) -> Value {
|
||||
let mut v = json!({"x": self.to.x, "y": self.to.y, "action": self.stroke.name()});
|
||||
if self.stroke != Stroke::Line {
|
||||
v["turn"] = json!(self.turn);
|
||||
v["flip"] = json!(self.flip);
|
||||
}
|
||||
v
|
||||
}
|
||||
}
|
||||
|
||||
/// `v` turned by `a` radians (clockwise on the page, whose y runs down).
|
||||
fn rot(v: Vec2, a: f64) -> Vec2 {
|
||||
let (s, c) = a.sin_cos();
|
||||
Vec2::new(v.x * c - v.y * s, v.x * s + v.y * c)
|
||||
}
|
||||
|
||||
fn unit(v: Vec2) -> Option<Vec2> {
|
||||
let l = v.hypot();
|
||||
(l > 1e-12 && l.is_finite()).then(|| v / l)
|
||||
}
|
||||
|
||||
/// The direction an open subpath runs at its last point: along that point's incoming handle, or
|
||||
/// else from the segment before it. None for a single point, or a path that comes back on itself.
|
||||
pub fn arrival(sp: &SubPath) -> Option<Vec2> {
|
||||
let n = sp.anchors.len();
|
||||
let last = sp.anchors.last()?;
|
||||
if let Some(d) = unit(last.p - last.h_in) {
|
||||
return Some(d);
|
||||
}
|
||||
let prev = sp.anchors.get(n.checked_sub(2)?)?;
|
||||
unit(last.p - prev.h_out).or_else(|| unit(last.p - prev.p))
|
||||
}
|
||||
|
||||
/// The signed turn (radians) of the arc `piece` adds from `a` to `b` on `sp`, or None for a
|
||||
/// straight segment. Positive turns bulge to the left of the direction drawn.
|
||||
fn turn_of(sp: &SubPath, piece: &Piece, a: Point, b: Point) -> Option<f64> {
|
||||
let sharp = |p: &Piece| p.turn.to_radians() * if p.flip { -1.0 } else { 1.0 };
|
||||
match piece.stroke {
|
||||
Stroke::Line => None,
|
||||
Stroke::SharpArc => Some(sharp(piece)),
|
||||
Stroke::ContinuousArc => match arrival(sp) {
|
||||
None => Some(sharp(piece)),
|
||||
Some(t) => {
|
||||
let c = b - a;
|
||||
let phi = t.cross(c).atan2(t.dot(c));
|
||||
(phi.abs() > STRAIGHT && phi.abs() < PI - STRAIGHT).then_some(2.0 * phi)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Adds `piece` at the end of the open subpath `sp`. A piece that ends where the subpath does adds
|
||||
/// nothing (false). An arc is drawn as cubic segments of at most 90° each, its inner points smooth;
|
||||
/// the new end is a corner without an outgoing handle. The point the piece leaves from is smooth
|
||||
/// when a continuous arc goes on from a curve into it, and a corner otherwise.
|
||||
pub fn append(sp: &mut SubPath, piece: &Piece) -> bool {
|
||||
let Some(last) = sp.anchors.last().copied() else { return false };
|
||||
let (a, b) = (last.p, piece.to);
|
||||
let c = b - a;
|
||||
let l = c.hypot();
|
||||
if l <= 1e-9 || !l.is_finite() {
|
||||
return false;
|
||||
}
|
||||
let Some(s) = turn_of(sp, piece, a, b) else {
|
||||
if let Some(end) = sp.anchors.last_mut() {
|
||||
end.h_out = end.p;
|
||||
end.kind = AnchorKind::Corner;
|
||||
}
|
||||
sp.anchors.push(Anchor::corner(b));
|
||||
return true;
|
||||
};
|
||||
let continuous = piece.stroke == Stroke::ContinuousArc && arrival(sp).is_some();
|
||||
let n = ((s.abs() / FRAC_PI_2) - 1e-9).ceil().max(1.0) as usize;
|
||||
let step = s / n as f64;
|
||||
let r = l / (2.0 * (s.abs() / 2.0).sin());
|
||||
let k = 4.0 / 3.0 * (step.abs() / 4.0).tan() * r;
|
||||
let mut t = rot(c / l, -s / 2.0);
|
||||
if let Some(end) = sp.anchors.last_mut() {
|
||||
end.h_out = a + t * k;
|
||||
end.kind = if continuous && end.h_in != end.p { AnchorKind::Smooth } else { AnchorKind::Corner };
|
||||
}
|
||||
let mut p = a;
|
||||
for i in 1..=n {
|
||||
let chord = rot(t, step / 2.0) * (2.0 * r * (step.abs() / 2.0).sin());
|
||||
let t2 = rot(t, step);
|
||||
let q = if i == n { b } else { p + chord };
|
||||
let mut an = Anchor::with_handles(q, q - t2 * k, q);
|
||||
if i < n {
|
||||
an.h_out = q + t2 * k;
|
||||
an.kind = AnchorKind::Smooth;
|
||||
}
|
||||
sp.anchors.push(an);
|
||||
(p, t) = (q, t2);
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
/// Closes `sp`: a last point that lies on the first joins it (the first point takes its incoming
|
||||
/// handle); otherwise a straight segment closes the path. Fewer than two points stay open.
|
||||
pub fn close(sp: &mut SubPath) {
|
||||
let n = sp.anchors.len();
|
||||
if n < 2 {
|
||||
return;
|
||||
}
|
||||
if let (Some(first), Some(last)) = (sp.anchors.first().copied(), sp.anchors.last().copied())
|
||||
&& n >= 3
|
||||
&& first.p.distance(last.p) <= 1e-9
|
||||
{
|
||||
sp.anchors.pop();
|
||||
if let Some(f) = sp.anchors.first_mut() {
|
||||
f.h_in = last.h_in;
|
||||
}
|
||||
}
|
||||
sp.closed = true;
|
||||
}
|
||||
|
||||
/// `base` with `pieces` added after it, closed when `closed`.
|
||||
pub fn build(base: &SubPath, pieces: &[Piece], closed: bool) -> SubPath {
|
||||
let mut sp = base.clone();
|
||||
for piece in pieces {
|
||||
append(&mut sp, piece);
|
||||
}
|
||||
if closed {
|
||||
close(&mut sp);
|
||||
}
|
||||
sp
|
||||
}
|
||||
|
||||
/// The path being drawn: subpath `si` of `id`, whose points were `base` before the tool drew on
|
||||
/// (both none until the engine made a new path), then `pieces`. A new path starts at `start`.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
struct Drawing {
|
||||
id: Option<NodeId>,
|
||||
si: usize,
|
||||
base: Option<SubPath>,
|
||||
start: Option<Point>,
|
||||
pieces: Vec<Piece>,
|
||||
}
|
||||
|
||||
impl Drawing {
|
||||
/// The subpath as the tool drew it.
|
||||
fn drawn(&self) -> Option<SubPath> {
|
||||
Some(build(self.base.as_ref()?, &self.pieces, false))
|
||||
}
|
||||
}
|
||||
|
||||
/// The press in progress: where it went down, whether it has dragged, and whether it began an undo
|
||||
/// step (a piece it adds).
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
struct Press {
|
||||
at: Point,
|
||||
dragged: bool,
|
||||
begun: bool,
|
||||
}
|
||||
|
||||
pub struct QuickPenTool {
|
||||
action: Stroke,
|
||||
turn: f64,
|
||||
drawing: Option<Drawing>,
|
||||
press: Option<Press>,
|
||||
hover: Option<Point>,
|
||||
snap: DrawSnap,
|
||||
}
|
||||
|
||||
impl Default for QuickPenTool {
|
||||
fn default() -> Self {
|
||||
Self { action: Stroke::Line, turn: DEFAULT_TURN, drawing: None, press: None, hover: None, snap: DrawSnap::default() }
|
||||
}
|
||||
}
|
||||
|
||||
/// Is `id` selected on its own, itself or the compound path it is in?
|
||||
fn selected_alone(cx: &ToolContext, id: NodeId) -> bool {
|
||||
let sel = cx.selection.objects.as_slice();
|
||||
sel == [id] || cx.doc.parent_of(id).is_some_and(|p| sel == [p] && cx.doc.node(p).is_some_and(|n| matches!(n.kind, NodeKind::Compound { .. })))
|
||||
}
|
||||
|
||||
fn point_tol(cx: &ToolContext) -> f64 {
|
||||
cx.tol(5.0).max(cx.point_tol())
|
||||
}
|
||||
|
||||
impl QuickPenTool {
|
||||
/// The subpath being drawn, while it is selected, editable, open and still exactly what the tool
|
||||
/// drew: an edit made outside the tool (a point moved, the path it went on from changed) ends
|
||||
/// the drawing, so the next piece does not undo it.
|
||||
fn active<'a>(&self, cx: &'a ToolContext) -> Option<(NodeId, &'a SubPath)> {
|
||||
let dr = self.drawing.as_ref()?;
|
||||
let id = dr.id?;
|
||||
if !selected_alone(cx, id) || !cx.doc.is_editable(id) {
|
||||
return None;
|
||||
}
|
||||
let sp = cx.doc.node(id)?.path_data()?.subpaths.get(dr.si)?;
|
||||
(!sp.closed && dr.drawn()?.anchors == sp.anchors).then_some((id, sp))
|
||||
}
|
||||
|
||||
/// `path.quickPen`'s params for the path being drawn, closed when `closed`.
|
||||
fn params(&self, closed: bool) -> Value {
|
||||
let Some(dr) = &self.drawing else { return json!({}) };
|
||||
let pieces: Vec<Value> = dr.pieces.iter().map(Piece::to_json).collect();
|
||||
let mut v = json!({"pieces": pieces});
|
||||
match (dr.id, dr.start) {
|
||||
(Some(id), _) => {
|
||||
v["id"] = json!(id.0);
|
||||
v["subpath"] = json!(dr.si);
|
||||
v["keep"] = json!(dr.base.as_ref().map_or(1, |b| b.anchors.len().max(1)));
|
||||
}
|
||||
(None, Some(s)) => v["start"] = json!([s.x, s.y]),
|
||||
(None, None) => {}
|
||||
}
|
||||
if closed {
|
||||
v["closed"] = json!(true);
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
/// The last piece, while it is a sharp-corner arc and no press is under way.
|
||||
fn last_sharp_arc(&self, cx: &ToolContext) -> Option<Piece> {
|
||||
if self.press.is_some() {
|
||||
return None;
|
||||
}
|
||||
self.active(cx)?;
|
||||
self.drawing.as_ref()?.pieces.last().copied().filter(|p| p.stroke == Stroke::SharpArc)
|
||||
}
|
||||
|
||||
fn piece_to(&self, to: Point) -> Piece {
|
||||
Piece { to, stroke: self.action, turn: self.turn, flip: false }
|
||||
}
|
||||
|
||||
/// The segment from the path's last point the snapping leaves from.
|
||||
fn leave(&self, cx: &ToolContext) -> Option<(NodeId, Leave)> {
|
||||
let (id, sp) = self.active(cx)?;
|
||||
sp.anchors.last().map(|a| (id, Leave::segment(cx, a.p, false).without_contact()))
|
||||
}
|
||||
|
||||
/// What a press draws: a piece on the path being drawn, its closing piece, or a new path (from
|
||||
/// an end of an open path, the path goes on).
|
||||
fn press_down(&mut self, cx: &ToolContext, p: Point) -> Vec<Action> {
|
||||
if self.drawing.is_some() && self.active(cx).is_none() {
|
||||
self.drawing = None;
|
||||
}
|
||||
let tol = point_tol(cx);
|
||||
if let Some((id, sp)) = self.active(cx) {
|
||||
let (first, last) = match (sp.anchors.first(), sp.anchors.last()) {
|
||||
(Some(f), Some(l)) => (f.p, l.p),
|
||||
_ => return vec![],
|
||||
};
|
||||
if sp.anchors.len() >= 2 && p.distance(first) <= tol && p.distance(first) <= p.distance(last) {
|
||||
let piece = self.piece_to(first);
|
||||
if let Some(dr) = self.drawing.as_mut() {
|
||||
dr.pieces.push(piece);
|
||||
}
|
||||
let out = vec![Action::Exec(COMMAND.into(), self.params(true))];
|
||||
self.drawing = None;
|
||||
return out;
|
||||
}
|
||||
if p.distance(last) <= tol {
|
||||
return vec![];
|
||||
}
|
||||
let from = self.leave(cx).map(|l| l.1);
|
||||
let q = self.snap.press(cx, p, &[id], from.as_ref());
|
||||
let piece = self.piece_to(q);
|
||||
if let Some(dr) = self.drawing.as_mut() {
|
||||
dr.pieces.push(piece);
|
||||
}
|
||||
self.press = Some(Press { at: p, dragged: false, begun: true });
|
||||
return vec![Action::Begin("Quick Pen".into()), Action::Preview(COMMAND.into(), self.params(false))];
|
||||
}
|
||||
if let Some((id, si, at_first)) = open_end_at(cx, p, tol, None)
|
||||
&& cx.doc.is_editable(id)
|
||||
&& let Some(sp) = cx.doc.node(id).and_then(|n| n.path_data()).and_then(|pd| pd.subpaths.get(si))
|
||||
{
|
||||
// From its start, `continue_from` reverses the path first.
|
||||
let mut base = sp.clone();
|
||||
if at_first {
|
||||
base.reverse();
|
||||
}
|
||||
self.drawing = Some(Drawing { id: Some(id), si, base: Some(base), start: None, pieces: vec![] });
|
||||
return continue_from(cx, id, si, at_first);
|
||||
}
|
||||
let q = self.snap.press(cx, p, &[], None);
|
||||
self.drawing = Some(Drawing { id: None, si: 0, base: None, start: Some(q), pieces: vec![] });
|
||||
vec![Action::Exec(COMMAND.into(), self.params(false)), Action::Notify("created".into())]
|
||||
}
|
||||
|
||||
/// Ends the path being drawn; a press that added a piece is taken back.
|
||||
fn end(&mut self) -> Vec<Action> {
|
||||
self.drawing = None;
|
||||
self.snap.clear();
|
||||
match self.press.take() {
|
||||
Some(pr) if pr.begun => vec![Action::Cancel],
|
||||
_ => vec![],
|
||||
}
|
||||
}
|
||||
|
||||
/// The piece the next click adds, from the end of `sp` to `h`, as a path to preview.
|
||||
fn rubber_band(&self, sp: &SubPath, h: Point) -> Option<BezPath> {
|
||||
let n = sp.anchors.len();
|
||||
let mut tail = SubPath::new(sp.anchors.get_range(n.saturating_sub(2)..)?, false);
|
||||
let from = tail.anchors.len() - 1;
|
||||
if !append(&mut tail, &self.piece_to(h)) {
|
||||
return None;
|
||||
}
|
||||
let mut added = tail.anchors.get_range(from..)?;
|
||||
if let Some(a) = added.first_mut() {
|
||||
a.h_in = a.p;
|
||||
}
|
||||
let mut bp = BezPath::new();
|
||||
SubPath::new(added, false).to_bezpath_into(&mut bp);
|
||||
Some(bp)
|
||||
}
|
||||
}
|
||||
|
||||
impl Tool for QuickPenTool {
|
||||
fn id(&self) -> &'static str {
|
||||
ID
|
||||
}
|
||||
|
||||
fn busy(&self) -> bool {
|
||||
self.press.is_some()
|
||||
}
|
||||
|
||||
fn pointer(&mut self, cx: &ToolContext, ev: &PointerEvent) -> Vec<Action> {
|
||||
let p = ev.pos;
|
||||
match ev.kind {
|
||||
PointerKind::Move => {
|
||||
let (on, from) = self.leave(cx).unzip();
|
||||
self.hover = Some(self.snap.hover(cx, p, on.as_slice(), from.as_ref()));
|
||||
vec![]
|
||||
}
|
||||
PointerKind::Down => {
|
||||
if self.press.is_some() {
|
||||
return vec![];
|
||||
}
|
||||
self.press_down(cx, p)
|
||||
}
|
||||
PointerKind::Drag => {
|
||||
let Some(mut pr) = self.press else { return vec![] };
|
||||
if !pr.dragged && p.distance(pr.at) < cx.tol(DRAG_PX) {
|
||||
return vec![];
|
||||
}
|
||||
pr.dragged = true;
|
||||
self.press = Some(pr);
|
||||
// The snapping leaves from the point before the piece being dragged.
|
||||
let from = self.drawing.as_ref().and_then(|dr| {
|
||||
let sp = build(dr.base.as_ref()?, dr.pieces.split_last().map_or(&[][..], |(_, rest)| rest), false);
|
||||
sp.anchors.last().map(|a| Leave::segment(cx, a.p, false).without_contact())
|
||||
});
|
||||
let q = self.snap.drag(cx, p, from.as_ref());
|
||||
if let Some(last) = self.drawing.as_mut().and_then(|dr| dr.pieces.last_mut()) {
|
||||
last.to = q;
|
||||
}
|
||||
vec![Action::Preview(COMMAND.into(), self.params(false))]
|
||||
}
|
||||
PointerKind::Up => {
|
||||
self.snap.clear();
|
||||
match self.press.take() {
|
||||
Some(pr) if pr.begun => vec![Action::Commit],
|
||||
_ => vec![],
|
||||
}
|
||||
}
|
||||
PointerKind::DoubleClick | PointerKind::TripleClick => vec![],
|
||||
}
|
||||
}
|
||||
|
||||
fn notify(&mut self, cx: &ToolContext, what: &str) {
|
||||
if what == "created"
|
||||
&& let [id] = cx.selection.objects.as_slice()
|
||||
&& let Some(base) = cx.doc.node(*id).and_then(|n| n.path_data()).and_then(|pd| pd.subpaths.first())
|
||||
&& let Some(dr) = self.drawing.as_mut()
|
||||
&& dr.id.is_none()
|
||||
{
|
||||
(dr.id, dr.si, dr.base, dr.start) = (Some(*id), 0, Some(base.clone()), None);
|
||||
}
|
||||
}
|
||||
|
||||
/// A path being drawn: Escape ends it.
|
||||
fn ends_on_escape(&self, cx: &ToolContext) -> bool {
|
||||
self.active(cx).is_some()
|
||||
}
|
||||
|
||||
fn claims_key(&self, cx: &ToolContext, key: ToolKey) -> bool {
|
||||
match key {
|
||||
ToolKey::Letter('c') => self.last_sharp_arc(cx).is_some(),
|
||||
ToolKey::BracketLeft | ToolKey::BracketRight | ToolKey::AltTap => true,
|
||||
ToolKey::Enter => self.active(cx).is_some(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// A dropped press does not end the path being drawn: the piece it added goes.
|
||||
fn drop_press(&mut self, _cx: &ToolContext) -> Vec<Action> {
|
||||
if self.press.take().is_some_and(|pr| pr.begun)
|
||||
&& let Some(dr) = self.drawing.as_mut()
|
||||
{
|
||||
dr.pieces.pop();
|
||||
}
|
||||
self.snap.clear();
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn key(&mut self, cx: &ToolContext, key: ToolKey, _mods: Mods) -> Vec<Action> {
|
||||
match key {
|
||||
ToolKey::Escape | ToolKey::Enter => self.end(),
|
||||
ToolKey::Letter('c') => {
|
||||
if self.last_sharp_arc(cx).is_none() {
|
||||
return vec![];
|
||||
}
|
||||
if let Some(last) = self.drawing.as_mut().and_then(|dr| dr.pieces.last_mut()) {
|
||||
last.flip = !last.flip;
|
||||
}
|
||||
vec![Action::Exec(COMMAND.into(), self.params(false))]
|
||||
}
|
||||
ToolKey::BracketLeft | ToolKey::BracketRight => {
|
||||
let by = if key == ToolKey::BracketLeft { -TURN_STEP } else { TURN_STEP };
|
||||
let arc = self.last_sharp_arc(cx);
|
||||
let turn = arc.map_or(self.turn, |a| a.turn) + by;
|
||||
if !(MIN_TURN..=MAX_TURN).contains(&turn) {
|
||||
return vec![];
|
||||
}
|
||||
self.turn = turn;
|
||||
if arc.is_none() {
|
||||
return vec![];
|
||||
}
|
||||
if let Some(last) = self.drawing.as_mut().and_then(|dr| dr.pieces.last_mut()) {
|
||||
last.turn = turn;
|
||||
}
|
||||
vec![Action::Exec(COMMAND.into(), self.params(false))]
|
||||
}
|
||||
ToolKey::AltTap => {
|
||||
self.action = self.action.next();
|
||||
// A drag under way draws its piece with the new action.
|
||||
if self.press.is_some_and(|pr| pr.begun) {
|
||||
let (action, turn) = (self.action, self.turn);
|
||||
if let Some(last) = self.drawing.as_mut().and_then(|dr| dr.pieces.last_mut()) {
|
||||
(last.stroke, last.turn, last.flip) = (action, turn, false);
|
||||
}
|
||||
return vec![Action::Preview(COMMAND.into(), self.params(false))];
|
||||
}
|
||||
vec![]
|
||||
}
|
||||
_ => vec![],
|
||||
}
|
||||
}
|
||||
|
||||
fn deactivate(&mut self, _cx: &ToolContext) -> Vec<Action> {
|
||||
self.drawing = None;
|
||||
self.snap.clear();
|
||||
match self.press.take() {
|
||||
Some(pr) if pr.begun => vec![Action::Commit],
|
||||
_ => vec![],
|
||||
}
|
||||
}
|
||||
|
||||
fn chosen_again(&mut self, _cx: &ToolContext) -> Vec<Action> {
|
||||
if self.press.is_none() {
|
||||
self.drawing = None;
|
||||
}
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn hover_ended(&mut self, _cx: &ToolContext) {
|
||||
self.hover = None;
|
||||
}
|
||||
|
||||
fn overlays(&self, cx: &ToolContext) -> Vec<Overlay> {
|
||||
let mut o = self.snap.guides().to_vec();
|
||||
let Some((id, sp)) = self.active(cx) else { return o };
|
||||
if self.press.is_none()
|
||||
&& let Some(h) = self.hover
|
||||
{
|
||||
if cx.pen_rubber_band
|
||||
&& let Some(path) = self.rubber_band(sp, h)
|
||||
{
|
||||
o.push(Overlay::Path { path, color: cx.doc.layer_color(id), width: 1.0, dashed: false });
|
||||
}
|
||||
if let Some(last) = sp.anchors.last().map(|a| a.p)
|
||||
&& cx.measurement_labels
|
||||
&& last.distance(h) > 1e-9
|
||||
{
|
||||
o.push(Overlay::Measure { p: h + Vec2::new(cx.tol(12.0), cx.tol(12.0)), text: cx.segment_measure_label(last, h) });
|
||||
}
|
||||
}
|
||||
let n = sp.anchors.len();
|
||||
for (i, a) in sp.anchors.iter().enumerate() {
|
||||
o.push(Overlay::CurvePoint { p: a.p, color: FEEDBACK, filled: i + 1 == n, size: 6.0 });
|
||||
}
|
||||
o
|
||||
}
|
||||
|
||||
fn cursor(&self, cx: &ToolContext, p: Point, _m: Mods) -> Cursor {
|
||||
let tol = point_tol(cx);
|
||||
if let Some((_, sp)) = self.active(cx) {
|
||||
let close = sp.anchors.len() >= 2 && sp.anchors.first().is_some_and(|f| f.p.distance(p) <= tol);
|
||||
return if close { Cursor::PenClose } else { Cursor::PenDrawing };
|
||||
}
|
||||
if open_end_at(cx, p, tol, None).is_some() { Cursor::PenContinue } else { Cursor::Pen }
|
||||
}
|
||||
|
||||
fn options(&self) -> Value {
|
||||
json!({ "action": self.action.name(), "turn": self.turn })
|
||||
}
|
||||
|
||||
fn set_option(&mut self, key: &str, v: &Value) {
|
||||
match key {
|
||||
"action" => {
|
||||
if let Some(a) = v.as_str().and_then(Stroke::parse) {
|
||||
self.action = a;
|
||||
}
|
||||
}
|
||||
"turn" => {
|
||||
if let Some(t) = v.as_f64().filter(|t| (MIN_TURN..=MAX_TURN).contains(t)) {
|
||||
self.turn = t;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn check_option(&self, key: &str, v: &Value) -> Result<(), String> {
|
||||
match key {
|
||||
"action" => crate::option_check::one_of(key, v, &Stroke::ALL.map(Stroke::name)),
|
||||
"turn" => crate::option_check::number(key, v, MIN_TURN, MAX_TURN),
|
||||
_ => Err(crate::option_check::unknown(key)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -0,0 +1,214 @@
|
||||
use super::*;
|
||||
use crate::testutil::*;
|
||||
use vectorcraft_doc::Selection;
|
||||
use vectorcraft_geom::{ParamCurve, PathData};
|
||||
|
||||
fn pt(x: f64, y: f64) -> Point {
|
||||
Point::new(x, y)
|
||||
}
|
||||
|
||||
fn start(p: Point) -> SubPath {
|
||||
SubPath::new(vec![Anchor::corner(p)], false)
|
||||
}
|
||||
|
||||
fn piece(x: f64, y: f64, stroke: Stroke) -> Piece {
|
||||
Piece { to: pt(x, y), stroke, turn: DEFAULT_TURN, flip: false }
|
||||
}
|
||||
|
||||
/// Every sampled point of the segments from anchor `from` on lies `r` from `center`.
|
||||
fn on_circle(sp: &SubPath, from: usize, center: Point, r: f64) -> bool {
|
||||
(from..sp.segment_count()).all(|i| (0..=16).all(|k| (sp.segment(i).eval(k as f64 / 16.0).distance(center) - r).abs() < r * 1e-3))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_line_piece_adds_a_corner_point_and_no_handles() {
|
||||
let mut sp = start(pt(0.0, 0.0));
|
||||
assert!(append(&mut sp, &piece(100.0, 0.0, Stroke::Line)));
|
||||
assert_eq!(sp.anchors.len(), 2);
|
||||
assert!(sp.anchors.iter().all(|a| a.h_in == a.p && a.h_out == a.p && a.kind == AnchorKind::Corner));
|
||||
}
|
||||
|
||||
/// A sharp-corner arc turns 180° by default: a half circle on its chord, on the left of the
|
||||
/// direction drawn (above a chord drawn to the right, since y runs down), in two quarter segments.
|
||||
#[test]
|
||||
fn a_sharp_corner_arc_is_a_half_circle_bulging_left() {
|
||||
let mut sp = start(pt(0.0, 0.0));
|
||||
append(&mut sp, &piece(100.0, 0.0, Stroke::SharpArc));
|
||||
assert_eq!(sp.anchors.len(), 3);
|
||||
assert!(on_circle(&sp, 0, pt(50.0, 0.0), 50.0));
|
||||
assert!(sp.anchors.get(1).unwrap().p.distance(pt(50.0, -50.0)) < 1e-9);
|
||||
assert_eq!(sp.anchors.last().unwrap().p, pt(100.0, 0.0));
|
||||
// Flipped, it bulges the other way.
|
||||
let mut sp = start(pt(0.0, 0.0));
|
||||
append(&mut sp, &Piece { flip: true, ..piece(100.0, 0.0, Stroke::SharpArc) });
|
||||
assert!(sp.anchors.get(1).unwrap().p.distance(pt(50.0, 50.0)) < 1e-9);
|
||||
}
|
||||
|
||||
/// The turn sets how much of a circle the arc is: 90° is one segment, 270° three.
|
||||
#[test]
|
||||
fn the_turn_sets_the_arc_and_its_segments() {
|
||||
let mut sp = start(pt(0.0, 0.0));
|
||||
append(&mut sp, &Piece { turn: 90.0, ..piece(100.0, 0.0, Stroke::SharpArc) });
|
||||
assert_eq!(sp.anchors.len(), 2);
|
||||
let r = 100.0 / (2.0 * (45f64).to_radians().sin());
|
||||
// Bulging up, so its center is below the chord.
|
||||
assert!(on_circle(&sp, 0, pt(50.0, 50.0), r));
|
||||
let mut sp = start(pt(0.0, 0.0));
|
||||
append(&mut sp, &Piece { turn: 270.0, ..piece(100.0, 0.0, Stroke::SharpArc) });
|
||||
assert_eq!(sp.anchors.len(), 4);
|
||||
assert!(sp.anchors.iter().skip(1).take(2).all(|a| a.kind == AnchorKind::Smooth));
|
||||
}
|
||||
|
||||
/// A continuous arc leaves the end of the path in the direction the path arrives in: after a
|
||||
/// line drawn to the right, an arc to a point below and to the right starts heading right.
|
||||
#[test]
|
||||
fn a_continuous_arc_goes_on_in_the_paths_direction() {
|
||||
let mut sp = start(pt(0.0, 0.0));
|
||||
append(&mut sp, &piece(100.0, 0.0, Stroke::Line));
|
||||
append(&mut sp, &piece(200.0, 100.0, Stroke::ContinuousArc));
|
||||
let corner = sp.anchors.get(1).unwrap();
|
||||
let out = corner.h_out - corner.p;
|
||||
assert!(out.y.abs() < 1e-9 && out.x > 0.0, "{out:?}");
|
||||
// The quarter circle centered at (100, 100).
|
||||
assert!(on_circle(&sp, 1, pt(100.0, 100.0), 100.0));
|
||||
// Another continuous arc goes on smoothly from its end.
|
||||
append(&mut sp, &piece(100.0, 200.0, Stroke::ContinuousArc));
|
||||
let joint = sp.anchors.get(2).unwrap();
|
||||
assert!((joint.p - joint.h_in).cross(joint.h_out - joint.p).abs() < 1e-6);
|
||||
assert_eq!(joint.kind, AnchorKind::Smooth);
|
||||
}
|
||||
|
||||
/// With nothing to follow (the path's first piece) a continuous arc is drawn as a sharp-corner
|
||||
/// arc; an end straight ahead is a line.
|
||||
#[test]
|
||||
fn a_continuous_arc_without_a_direction_or_straight_ahead() {
|
||||
let mut a = start(pt(0.0, 0.0));
|
||||
let mut b = start(pt(0.0, 0.0));
|
||||
append(&mut a, &piece(100.0, 0.0, Stroke::ContinuousArc));
|
||||
append(&mut b, &piece(100.0, 0.0, Stroke::SharpArc));
|
||||
assert_eq!(a, b);
|
||||
let mut sp = start(pt(0.0, 0.0));
|
||||
append(&mut sp, &piece(100.0, 0.0, Stroke::Line));
|
||||
append(&mut sp, &piece(300.0, 0.0, Stroke::ContinuousArc));
|
||||
assert_eq!(sp.anchors.len(), 3);
|
||||
assert_eq!(sp.anchors.get(1).unwrap().h_out, pt(100.0, 0.0));
|
||||
}
|
||||
|
||||
/// A line or a sharp-corner arc leaves a corner behind it, also after a continuous arc and from
|
||||
/// the smooth end of a path it goes on from; a continuous arc leaves a smooth point.
|
||||
#[test]
|
||||
fn only_a_continuous_arc_leaves_a_smooth_point() {
|
||||
let mut sp = start(pt(0.0, 0.0));
|
||||
append(&mut sp, &piece(100.0, 0.0, Stroke::Line));
|
||||
append(&mut sp, &piece(200.0, 100.0, Stroke::ContinuousArc));
|
||||
append(&mut sp, &piece(100.0, 200.0, Stroke::ContinuousArc));
|
||||
assert_eq!(sp.anchors.get(2).unwrap().kind, AnchorKind::Smooth);
|
||||
let smooth_end = sp.anchors.len() - 1;
|
||||
let mut a = sp.clone();
|
||||
a.anchors.last_mut().unwrap().kind = AnchorKind::Smooth;
|
||||
let mut b = a.clone();
|
||||
append(&mut a, &piece(300.0, 300.0, Stroke::SharpArc));
|
||||
append(&mut b, &piece(300.0, 300.0, Stroke::Line));
|
||||
for sp in [a, b] {
|
||||
assert_eq!(sp.anchors.get(smooth_end).unwrap().kind, AnchorKind::Corner);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_piece_to_the_last_point_adds_nothing() {
|
||||
let mut sp = start(pt(5.0, 5.0));
|
||||
assert!(!append(&mut sp, &piece(5.0, 5.0, Stroke::SharpArc)));
|
||||
assert_eq!(sp.anchors.len(), 1);
|
||||
}
|
||||
|
||||
/// Closing on the first point joins the two; elsewhere a straight segment closes the path.
|
||||
#[test]
|
||||
fn closing_joins_a_last_point_on_the_first() {
|
||||
let pieces = [piece(100.0, 0.0, Stroke::Line), piece(100.0, 100.0, Stroke::Line), piece(0.0, 0.0, Stroke::SharpArc)];
|
||||
let sp = build(&start(pt(0.0, 0.0)), &pieces, true);
|
||||
assert!(sp.closed);
|
||||
assert_eq!(sp.anchors.first().unwrap().p, pt(0.0, 0.0));
|
||||
assert!(sp.anchors.iter().filter(|a| a.p == pt(0.0, 0.0)).count() == 1);
|
||||
assert_ne!(sp.anchors.first().unwrap().h_in, pt(0.0, 0.0), "the first point takes the arc's handle");
|
||||
let sp = build(&start(pt(0.0, 0.0)), &pieces[..2], true);
|
||||
assert!(sp.closed && sp.anchors.len() == 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn actions_cycle_and_name_themselves() {
|
||||
assert_eq!(Stroke::Line.next(), Stroke::ContinuousArc);
|
||||
assert_eq!(Stroke::ContinuousArc.next(), Stroke::SharpArc);
|
||||
assert_eq!(Stroke::SharpArc.next(), Stroke::Line);
|
||||
for s in Stroke::ALL {
|
||||
assert_eq!(Stroke::parse(s.name()), Some(s));
|
||||
}
|
||||
assert_eq!(Stroke::parse("arc"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn options_are_checked_and_set() {
|
||||
let mut t = QuickPenTool::default();
|
||||
assert_eq!(t.options(), json!({"action": "line", "turn": 180.0}));
|
||||
assert!(t.check_option("action", &json!("sharpArc")).is_ok());
|
||||
assert!(t.check_option("action", &json!("arc")).is_err());
|
||||
assert!(t.check_option("turn", &json!(0)).is_err());
|
||||
assert!(t.check_option("turn", &json!(360)).is_err());
|
||||
assert!(t.check_option("size", &json!(1)).is_err());
|
||||
t.set_option("action", &json!("continuousArc"));
|
||||
t.set_option("turn", &json!(90));
|
||||
assert_eq!(t.options(), json!({"action": "continuousArc", "turn": 90.0}));
|
||||
}
|
||||
|
||||
/// Alt tapped alone switches to the next action; [ and ] change the arc size by 15° within 1° to
|
||||
/// 359°, with no path being drawn.
|
||||
#[test]
|
||||
fn alt_tap_cycles_and_brackets_size_the_next_arc() {
|
||||
let (d, _) = doc_with_rect();
|
||||
let s = Selection::default();
|
||||
let p = paint();
|
||||
let cx = cx(&d, &s, &p);
|
||||
let mut t = QuickPenTool::default();
|
||||
assert!(t.claims_key(&cx, ToolKey::AltTap));
|
||||
for want in ["continuousArc", "sharpArc", "line"] {
|
||||
assert!(t.key(&cx, ToolKey::AltTap, Mods::default()).is_empty());
|
||||
assert_eq!(t.options()["action"], want);
|
||||
}
|
||||
assert!(t.key(&cx, ToolKey::BracketRight, Mods::default()).is_empty());
|
||||
assert_eq!(t.options()["turn"], 195.0);
|
||||
t.set_option("turn", &json!(10));
|
||||
t.key(&cx, ToolKey::BracketLeft, Mods::default());
|
||||
assert_eq!(t.options()["turn"], 10.0, "stays at or above 1°");
|
||||
// C is the Scissors' shortcut while no arc is being drawn.
|
||||
assert!(!t.claims_key(&cx, ToolKey::Letter('c')));
|
||||
}
|
||||
|
||||
/// The first click starts a new path and the tool picks it up once the engine made it.
|
||||
#[test]
|
||||
fn the_first_click_starts_a_path() {
|
||||
let (d, _) = doc_with_rect();
|
||||
let s = Selection::default();
|
||||
let p = paint();
|
||||
let cx = cx(&d, &s, &p);
|
||||
let mut t = QuickPenTool::default();
|
||||
let a = t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 10.0, 10.0));
|
||||
assert!(matches!(&a[0], Action::Exec(c, v) if c == COMMAND && v["start"] == json!([10.0, 10.0]) && v["pieces"] == json!([])), "{a:?}");
|
||||
assert_eq!(a[1], Action::Notify("created".into()));
|
||||
assert_eq!(t.cursor(&cx, pt(400.0, 400.0), Mods::default()), Cursor::Pen);
|
||||
}
|
||||
|
||||
/// The rubber band previews exactly the piece a click adds.
|
||||
#[test]
|
||||
fn the_rubber_band_is_the_next_piece() {
|
||||
let t = QuickPenTool { action: Stroke::SharpArc, ..Default::default() };
|
||||
let sp = build(&start(pt(0.0, 0.0)), &[piece(100.0, 0.0, Stroke::Line)], false);
|
||||
let band = t.rubber_band(&sp, pt(200.0, 0.0)).unwrap();
|
||||
let mut added = sp.clone();
|
||||
append(&mut added, &t.piece_to(pt(200.0, 0.0)));
|
||||
let whole = PathData::single(added);
|
||||
for seg in band.segments() {
|
||||
for k in 0..=8 {
|
||||
let q = seg.eval(k as f64 / 8.0);
|
||||
assert!(whole.nearest(q).is_some_and(|n| n.4 < 1e-6), "{q:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ pub const SYMBOLISM: &[&str] =
|
||||
|
||||
const ROWS: &[Row] = &[
|
||||
(&["dimension"], None, &["mode", "style"]),
|
||||
(&[crate::quickpen::ID], None, &["action", "turn"]),
|
||||
// Global Brush Dimensions.
|
||||
(LIQUIFY, Some("liquify"), &["width", "height", "angle", "intensity", "usePressure", "showBrush"]),
|
||||
(LIQUIFY, None, &["detail", "simplify", "simplifyOn", "rate", "complexity", "horizontal", "vertical", "affectAnchors", "affectIn", "affectOut"]),
|
||||
|
||||
@@ -275,7 +275,7 @@ impl Cache {
|
||||
let opts = vectorcraft_render::RenderOptions {
|
||||
skip_templates: true,
|
||||
image_mips: true,
|
||||
hidden: vectorcraft_engine::cmd::print_hidden(doc, key.fold_lines),
|
||||
hidden: vectorcraft_engine::cmd::print_hidden(doc, key.fold_lines).into_iter().collect(),
|
||||
..Default::default()
|
||||
};
|
||||
if let Some(w) = &self.worker {
|
||||
|
||||
@@ -203,6 +203,7 @@ impl VectorcraftApp {
|
||||
input_frames: vec![],
|
||||
shortcuts_frames: vec![],
|
||||
held_tool: Vec::new(),
|
||||
alt_tap: Default::default(),
|
||||
hold_keys: Default::default(),
|
||||
synthetic_injected: false,
|
||||
injected_events: vec![],
|
||||
|
||||
@@ -2682,6 +2682,8 @@ font-technology Variable Променливи
|
||||
PDF/A files carry their own output intent. Файловете PDF/A носят собствено предназначение за изход.
|
||||
PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. Файловете PDF/X-1a са в CMYK: всеки цвят се конвертира към дестинацията (при празно поле: CMYK профила на предназначението за изход), без етикет.
|
||||
Pen Tool Инструмент „Перо“
|
||||
Quick Pen Tool Инструмент „Бързо перо“
|
||||
Quick Pen Бързо перо
|
||||
Pencil Молив
|
||||
Pencil Tool Инструмент „Молив“
|
||||
per slice на отрязък
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4193,6 +4193,8 @@ theme Appearance Izgled
|
||||
Paste Offset Pomak lijepljenja
|
||||
Pattern Editing Uređivanje uzorka
|
||||
Pen Tool Alat pero
|
||||
Quick Pen Tool Alat brzo pero
|
||||
Quick Pen Brzo pero
|
||||
Picas Pice
|
||||
Portuguese Portugalski
|
||||
Preserve Appearance and Overprints Očuvaj izgled i pretiske
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3438,6 +3438,8 @@ digits Malayalam Malaiàlam
|
||||
PDF/X-4:2010 PDF/X-4:2010
|
||||
Pen Ploma
|
||||
Pen Tool Eina de ploma
|
||||
Quick Pen Tool Eina de ploma ràpida
|
||||
Quick Pen Ploma ràpida
|
||||
Pencil Llapis
|
||||
Pencil Tool Eina de llapis
|
||||
Pentagram Pentagrama
|
||||
@@ -6899,6 +6901,9 @@ liquify-list-end {0}, {1} {0} i {1}
|
||||
@msg `link` places a handle: give `handle` `link` col·loca una nansa: indiqueu `handle`
|
||||
@msg no such spine segment no existeix aquest segment de l’espina
|
||||
@msg no such subpath no existeix aquest subtraçat
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` ha de ser una llista d’un màxim de 10000 trams
|
||||
@msg give either `start` for a new path or `id`, not both indica `start` per a un traçat nou o bé `id`, però no tots dos
|
||||
@msg `subpath` and `keep` need `id` `subpath` i `keep` necessiten `id`
|
||||
@msg no such user library no existeix aquesta biblioteca d’usuari
|
||||
@msg no such view no existeix aquesta vista
|
||||
@msg no such width point no existeix aquest punt d’amplada
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4300,6 +4300,8 @@ theme Appearance Motiv
|
||||
Paste Offset Posun při vložení
|
||||
Pattern Editing Úpravy vzorku
|
||||
Pen Tool Nástroj Pero
|
||||
Quick Pen Tool Nástroj Rychlé pero
|
||||
Quick Pen Rychlé pero
|
||||
Picas Pica
|
||||
Portuguese Portugalština
|
||||
Preserve Appearance and Overprints Zachovat vzhled a přetisky
|
||||
@@ -5766,6 +5768,9 @@ liquify-list-end {0}, {1} {0} a {1}
|
||||
@msg `link` places a handle: give `handle` `link` umisťuje táhlo: zadejte `handle`
|
||||
@msg no such spine segment takový segment páteře neexistuje
|
||||
@msg no such subpath taková dílčí cesta neexistuje
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` musí být seznam nejvýše 10000 dílů
|
||||
@msg give either `start` for a new path or `id`, not both zadejte buď `start` pro novou cestu, nebo `id`, ne obojí
|
||||
@msg `subpath` and `keep` need `id` `subpath` a `keep` vyžadují `id`
|
||||
@msg no such user library taková uživatelská knihovna neexistuje
|
||||
@msg no such view takové zobrazení neexistuje
|
||||
@msg no such width point takový bod šířky neexistuje
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6754,6 +6754,8 @@ theme Appearance Udseende
|
||||
Paste Offset Indsætningsforskydning
|
||||
Pattern Editing Mønsterredigering
|
||||
Pen Tool Pen-værktøj
|
||||
Quick Pen Tool Hurtigpen-værktøj
|
||||
Quick Pen Hurtigpen
|
||||
Picas Pica
|
||||
Portuguese Portugisisk
|
||||
Preserve Appearance and Overprints Bevar udseende og overprint
|
||||
@@ -7949,6 +7951,9 @@ imageTrace Outline Kontur
|
||||
@msg no such saved selection ingen sådan gemt markering
|
||||
@msg no such segment intet sådant segment
|
||||
@msg no such subpath ingen sådan delsti
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` skal være en liste med højst 10000 stykker
|
||||
@msg give either `start` for a new path or `id`, not both angiv enten `start` til en ny sti eller `id`, ikke begge
|
||||
@msg `subpath` and `keep` need `id` `subpath` og `keep` kræver `id`
|
||||
@msg no such user library intet sådant brugerbibliotek
|
||||
@msg no such view ingen sådan visning
|
||||
@msg no such width point intet sådant breddepunkt
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2744,6 +2744,8 @@ file-filter Templates Vorlagen
|
||||
PDF/A files carry their own output intent. PDF/A-Dateien enthalten ihre eigene Ausgabemethode.
|
||||
PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. PDF/X-1a-Dateien sind CMYK: Jede Farbe wird in das Ziel konvertiert (leer: das CMYK-Profil der Ausgabemethode), ohne Profilkennzeichnung.
|
||||
Pen Tool Zeichenstift-Werkzeug
|
||||
Quick Pen Tool Schnellzeichenstift-Werkzeug
|
||||
Quick Pen Schnellzeichenstift
|
||||
Pencil Buntstift
|
||||
Pencil Tool Buntstift-Werkzeug
|
||||
per slice pro Slice
|
||||
@@ -5343,6 +5345,9 @@ liquify-list-end {0}, {1} {0} und {1}
|
||||
@msg `link` places a handle: give `handle` `link` platziert einen Griff: geben Sie `handle` an
|
||||
@msg no such spine segment kein solches Achsensegment
|
||||
@msg no such subpath kein solcher Teilpfad
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` muss eine Liste von höchstens 10000 Stücken sein
|
||||
@msg give either `start` for a new path or `id`, not both geben Sie entweder `start` für einen neuen Pfad oder `id` an, nicht beides
|
||||
@msg `subpath` and `keep` need `id` `subpath` und `keep` erfordern `id`
|
||||
@msg no such user library keine solche Benutzerbibliothek
|
||||
@msg no such view keine solche Ansicht
|
||||
@msg no such width point kein solcher Breitenpunkt
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2148,6 +2148,8 @@ font-technology Variable Μεταβλητές
|
||||
Paths Διαδρομές
|
||||
Pattern Μοτίβο
|
||||
Pen Tool Πένα (Pen Tool)
|
||||
Quick Pen Tool Εργαλείο γρήγορης πένας
|
||||
Quick Pen Γρήγορη πένα
|
||||
Pencil Μολύβι
|
||||
Pencil Tool Μολύβι (Pencil Tool)
|
||||
Percent: Ποσοστό:
|
||||
@@ -5402,6 +5404,9 @@ digits Malayalam Μαλαγιάλαμ
|
||||
@msg `link` places a handle: give `handle` το `link` τοποθετεί μια λαβή: δώστε `handle`
|
||||
@msg no such spine segment δεν υπάρχει τέτοιο τμήμα κεντρικής καμπύλης
|
||||
@msg no such subpath δεν υπάρχει τέτοια υποδιαδρομή
|
||||
@msg `pieces` must be a list of at most 10000 pieces το `pieces` πρέπει να είναι λίστα με έως 10000 τμήματα
|
||||
@msg give either `start` for a new path or `id`, not both δώστε είτε `start` για νέα διαδρομή είτε `id`, όχι και τα δύο
|
||||
@msg `subpath` and `keep` need `id` τα `subpath` και `keep` απαιτούν `id`
|
||||
@msg no such user library δεν υπάρχει τέτοια βιβλιοθήκη χρήστη
|
||||
@msg no such view δεν υπάρχει τέτοια προβολή
|
||||
@msg no such width point δεν υπάρχει τέτοιο σημείο πλάτους
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2786,6 +2786,8 @@ font-technology Variable Variables
|
||||
PDF/A files carry their own output intent. Los archivos PDF/A incluyen su propio propósito de salida.
|
||||
PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. Los archivos PDF/X-1a son CMYK: todos los colores se convierten al destino (en blanco: el perfil CMYK del propósito de salida), sin etiquetar.
|
||||
Pen Tool Herramienta Pluma
|
||||
Quick Pen Tool Herramienta Pluma rápida
|
||||
Quick Pen Pluma rápida
|
||||
Pencil Lápiz
|
||||
Pencil Tool Herramienta Lápiz
|
||||
per slice por sector
|
||||
@@ -5454,6 +5456,9 @@ liquify-list-end {0}, {1} {0}, {1}
|
||||
@msg `link` places a handle: give `handle` `link` coloca un manejador: indique `handle`
|
||||
@msg no such spine segment no existe ese segmento del eje
|
||||
@msg no such subpath no existe ese subtrazado
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` debe ser una lista de como máximo 10000 tramos
|
||||
@msg give either `start` for a new path or `id`, not both indica `start` para un trazado nuevo o `id`, pero no ambos
|
||||
@msg `subpath` and `keep` need `id` `subpath` y `keep` necesitan `id`
|
||||
@msg no such user library no existe esa biblioteca de usuario
|
||||
@msg no such view no existe esa vista
|
||||
@msg no such width point no existe ese punto de anchura
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4217,6 +4217,8 @@ theme Appearance Ulkoasu
|
||||
Paste Offset Liittämissiirtymä
|
||||
Pattern Editing Kuvion muokkaus
|
||||
Pen Tool Kynätyökalu
|
||||
Quick Pen Tool Pikakynätyökalu
|
||||
Quick Pen Pikakynä
|
||||
Picas Picat
|
||||
Portuguese Portugali
|
||||
Preserve Appearance and Overprints Säilytä ulkoasu ja päällepainatukset
|
||||
@@ -5687,6 +5689,9 @@ liquify-list-end {0}, {1} {0} ja {1}
|
||||
@msg `link` places a handle: give `handle` `link` sijoittaa kahvan: anna `handle`
|
||||
@msg no such spine segment selkärangan segmenttiä ei ole
|
||||
@msg no such subpath alipolkua ei ole
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces`-arvon on oltava luettelo, jossa on enintään 10000 osaa
|
||||
@msg give either `start` for a new path or `id`, not both anna joko `start` uutta polkua varten tai `id`, ei molempia
|
||||
@msg `subpath` and `keep` need `id` `subpath` ja `keep` edellyttävät `id`-arvoa
|
||||
@msg no such user library käyttäjäkirjastoa ei ole
|
||||
@msg no such view näkymää ei ole
|
||||
@msg no such width point leveyspistettä ei ole
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2774,6 +2774,8 @@ font-technology Variable Variables
|
||||
PDF/A files carry their own output intent. Les fichiers PDF/A contiennent leur propre mode de sortie.
|
||||
PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. Les fichiers PDF/X-1a sont en CMJN : chaque couleur est convertie vers la destination (vide : le profil CMJN du mode de sortie), sans balise.
|
||||
Pen Tool Outil Plume
|
||||
Quick Pen Tool Outil Plume rapide
|
||||
Quick Pen Plume rapide
|
||||
Pencil Crayon
|
||||
Pencil Tool Outil Crayon
|
||||
per slice par tranche
|
||||
@@ -5413,6 +5415,9 @@ liquify-list-end {0}, {1} {0} et {1}
|
||||
@msg `link` places a handle: give `handle` `link` place une poignée : indiquez `handle`
|
||||
@msg no such spine segment segment de la dorsale inexistant
|
||||
@msg no such subpath sous-tracé inexistant
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` doit être une liste d’au plus 10000 segments
|
||||
@msg give either `start` for a new path or `id`, not both indiquez soit `start` pour un nouveau tracé, soit `id`, mais pas les deux
|
||||
@msg `subpath` and `keep` need `id` `subpath` et `keep` nécessitent `id`
|
||||
@msg no such user library bibliothèque utilisateur inexistante
|
||||
@msg no such view vue inexistante
|
||||
@msg no such width point point de largeur inexistant
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2805,6 +2805,8 @@
|
||||
Pause For આ સમય માટે થોભાવો
|
||||
Pen પેન
|
||||
Pen Tool પેન ટૂલ
|
||||
Quick Pen Tool ક્વિક પેન ટૂલ
|
||||
Quick Pen ક્વિક પેન
|
||||
Pencil પેન્સિલ
|
||||
Pencil Tool પેન્સિલ ટૂલ
|
||||
Percent: ટકા:
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 72 and column 5.
|
@@ -3990,6 +3990,8 @@ antiAlias Sharp शार्प
|
||||
PDF/X-4:2010 PDF/X-4:2010
|
||||
Pen पेन
|
||||
Pen Tool पेन टूल
|
||||
Quick Pen Tool क्विक पेन टूल
|
||||
Quick Pen क्विक पेन
|
||||
Pencil पेंसिल
|
||||
Pencil Tool पेंसिल टूल
|
||||
Pentagram पेंटाग्राम
|
||||
@@ -8475,6 +8477,9 @@ liquify-list-end {0}, {1} {0} और {1}
|
||||
@msg no such spine point ऐसा कोई स्पाइन बिंदु नहीं
|
||||
@msg no such spine segment ऐसा कोई खंड नहीं
|
||||
@msg no such subpath ऐसा कोई उप-पाथ नहीं
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` में अधिकतम 10000 टुकड़ों की लिस्ट होनी चाहिए
|
||||
@msg give either `start` for a new path or `id`, not both नए पाथ के लिए `start` या `id` में से एक दें, दोनों नहीं
|
||||
@msg `subpath` and `keep` need `id` `subpath` और `keep` के लिए `id` चाहिए
|
||||
@msg no such user library ऐसी कोई उपयोगकर्ता लाइब्रेरी नहीं
|
||||
@msg no such view कोई ऐसा दृश्य नहीं
|
||||
@msg no such width point ऐसी कोई चौड़ाई बिंदु नहीं
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3318,6 +3318,8 @@ file-filter Templates Sablonok
|
||||
PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. A PDF/X-1a-fájlok CMYK-sok: minden szín a célprofilra alakul (üresen hagyva a kimeneti cél CMYK-profiljára), profilcímke nélkül.
|
||||
Pen Toll
|
||||
Pen Tool Toll
|
||||
Quick Pen Tool Gyorstoll
|
||||
Quick Pen Gyorstoll
|
||||
Pencil Ceruza
|
||||
Pencil Tool Ceruza
|
||||
Pentagram Pentagram
|
||||
@@ -6147,6 +6149,9 @@ liquify-list-end {0}, {1} {0} és {1}
|
||||
@msg `link` places a handle: give `handle` `link` fogantyút helyez el: adja meg a `handle` értéket
|
||||
@msg no such spine segment nincs ilyen gerincszakasz
|
||||
@msg no such subpath nincs ilyen részútvonal
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces`: legfeljebb 10000 darabból álló lista kell
|
||||
@msg give either `start` for a new path or `id`, not both adja meg vagy a `start` értéket egy új útvonalhoz, vagy az `id` értéket, de ne mindkettőt
|
||||
@msg `subpath` and `keep` need `id` a `subpath` és a `keep` mellé `id` kell
|
||||
@msg no such user library nincs ilyen felhasználói könyvtár
|
||||
@msg no such view nincs ilyen nézet
|
||||
@msg no such width point nincs ilyen szélességi pont
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4622,6 +4622,8 @@ theme Appearance Tampilan
|
||||
Paste Offset Offset tempel
|
||||
Pattern Editing Pengeditan pola
|
||||
Pen Tool Alat pena
|
||||
Quick Pen Tool Alat pena cepat
|
||||
Quick Pen Pena cepat
|
||||
Picas Pica
|
||||
Portuguese Portugis
|
||||
Preserve Appearance and Overprints Pertahankan tampilan dan overprint
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2829,6 +2829,8 @@ file-filter Templates Modelli
|
||||
PDF/A files carry their own output intent. I file PDF/A includono il proprio intento di output.
|
||||
PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. I file PDF/X-1a sono CMYK: ogni colore viene convertito nella destinazione (se vuota: il profilo CMYK dell'intento di output), senza tag.
|
||||
Pen Tool Strumento Penna
|
||||
Quick Pen Tool Strumento Penna rapida
|
||||
Quick Pen Penna rapida
|
||||
Pencil Matita
|
||||
Pencil Tool Strumento Matita
|
||||
per slice per sezione
|
||||
@@ -5480,6 +5482,9 @@ liquify-list-end {0}, {1} {0} e {1}
|
||||
@msg `link` places a handle: give `handle` `link` posiziona una maniglia: indica `handle`
|
||||
@msg no such spine segment segmento della dorsale inesistente
|
||||
@msg no such subpath sottotracciato inesistente
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` deve essere un elenco di al massimo 10000 tratti
|
||||
@msg give either `start` for a new path or `id`, not both indica `start` per un nuovo tracciato oppure `id`, non entrambi
|
||||
@msg `subpath` and `keep` need `id` `subpath` e `keep` richiedono `id`
|
||||
@msg no such user library libreria utente inesistente
|
||||
@msg no such view vista inesistente
|
||||
@msg no such width point punto di larghezza inesistente
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2924,6 +2924,8 @@ antiAlias Sharp シャープ
|
||||
Pattern Editing パターン編集
|
||||
Pattern options are available in pattern editing mode. パターンオプションはパターン編集モードで使用できます。
|
||||
Pen Tool ペンツール
|
||||
Quick Pen Tool クイックペンツール
|
||||
Quick Pen クイックペン
|
||||
Pencil 鉛筆
|
||||
Pencil Tool 鉛筆ツール
|
||||
Percent: パーセント:
|
||||
@@ -5024,6 +5026,9 @@ variable-list-end {0}, {1} {0}、{1}
|
||||
@msg `link` places a handle: give `handle` `link` はハンドルを配置します:`handle` を指定してください
|
||||
@msg no such spine segment 指定されたスパインセグメントが見つかりません
|
||||
@msg no such subpath 指定されたサブパスが見つかりません
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` には最大 10000 個のピースのリストを指定してください
|
||||
@msg give either `start` for a new path or `id`, not both 新しいパスの `start` か `id` のどちらか一方だけを指定してください
|
||||
@msg `subpath` and `keep` need `id` `subpath` と `keep` には `id` が必要です
|
||||
@msg object {id} is not a path オブジェクト {id} はパスではありません
|
||||
@msg object {id} is not a selected top-level object オブジェクト {id} は選択されている最上位のオブジェクトではありません
|
||||
@msg nothing to redo やり直す操作がありません
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6038,6 +6038,8 @@ theme Appearance იერსახე
|
||||
Paste Offset ჩასმის წანაცვლება
|
||||
Pattern Editing პატერნის რედაქტირება
|
||||
Pen Tool კალმის ხელსაწყო
|
||||
Quick Pen Tool სწრაფი კალმის ხელსაწყო
|
||||
Quick Pen სწრაფი კალამი
|
||||
Picas პიკები
|
||||
Portuguese პორტუგალიური
|
||||
Preserve Appearance and Overprints იერსახისა და ზედდაბეჭდვების შენარჩუნება
|
||||
@@ -7214,6 +7216,9 @@ font-technology Variable ცვლადი
|
||||
@msg no such saved selection ასეთი შენახული მონიშვნა არ არის
|
||||
@msg no such segment ასეთი სეგმენტი არ არის
|
||||
@msg no such subpath ასეთი ქვეტრაექტორია არ არის
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` უნდა იყოს არაუმეტეს 10000 ნაწილის სია
|
||||
@msg give either `start` for a new path or `id`, not both მიუთითეთ ან `start` ახალი ტრაექტორიისთვის, ან `id`, მაგრამ არა ორივე
|
||||
@msg `subpath` and `keep` need `id` `subpath`-სა და `keep`-ს სჭირდება `id`
|
||||
@msg no such user library მომხმარებლის ასეთი ბიბლიოთეკა არ არის
|
||||
@msg no such view ასეთი ხედი არ არის
|
||||
@msg no such width point ასეთი სიგანის წერტილი არ არის
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2914,6 +2914,8 @@ antiAlias Sharp 날카롭게
|
||||
Pattern Editing 패턴 편집
|
||||
Pattern options are available in pattern editing mode. 패턴 옵션은 패턴 편집 모드에서 사용할 수 있습니다.
|
||||
Pen Tool 펜 도구
|
||||
Quick Pen Tool 빠른 펜 도구
|
||||
Quick Pen 빠른 펜
|
||||
Pencil 연필
|
||||
Pencil Tool 연필 도구
|
||||
Percent: 퍼센트:
|
||||
@@ -4953,6 +4955,9 @@ variable-list-end {0}, {1} {0} 및 {1}
|
||||
@msg `link` places a handle: give `handle` `link`는 핸들을 배치합니다. `handle`을 지정하십시오
|
||||
@msg no such spine segment 해당 스파인 세그먼트가 없습니다
|
||||
@msg no such subpath 해당 하위 패스가 없습니다
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces`는 최대 10000개 조각의 목록이어야 합니다
|
||||
@msg give either `start` for a new path or `id`, not both 새 패스의 `start`와 `id` 중 하나만 지정하세요
|
||||
@msg `subpath` and `keep` need `id` `subpath`와 `keep`에는 `id`가 필요합니다
|
||||
@msg object {id} is not a path 개체 {id}은(는) 패스가 아닙니다
|
||||
@msg object {id} is not a selected top-level object 개체 {id}은(는) 선택된 최상위 개체가 아닙니다
|
||||
@msg nothing to redo 다시 실행할 항목이 없습니다
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4625,6 +4625,8 @@ theme Appearance Vormgeving
|
||||
Paste Offset Plakoffset
|
||||
Pattern Editing Patroonbewerking
|
||||
Pen Tool Pen-gereedschap
|
||||
Quick Pen Tool Snelpen-gereedschap
|
||||
Quick Pen Snelpen
|
||||
Picas Pica's
|
||||
Portuguese Portugees
|
||||
Preserve Appearance and Overprints Vormgeving en overprint behouden
|
||||
@@ -5825,6 +5827,9 @@ imageTrace Outline Contour
|
||||
@msg no such saved selection opgeslagen selectie bestaat niet
|
||||
@msg no such segment segment bestaat niet
|
||||
@msg no such subpath subpad bestaat niet
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` moet een lijst van hoogstens 10000 stukken zijn
|
||||
@msg give either `start` for a new path or `id`, not both geef `start` voor een nieuw pad of `id`, niet beide
|
||||
@msg `subpath` and `keep` need `id` `subpath` en `keep` vereisen `id`
|
||||
@msg no such user library gebruikersbibliotheek bestaat niet
|
||||
@msg no such view weergave bestaat niet
|
||||
@msg no such width point breedtepunt bestaat niet
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4165,6 +4165,8 @@ theme Appearance Wygląd
|
||||
Paste Offset Przesunięcie wklejania
|
||||
Pattern Editing Edycja wzorka
|
||||
Pen Tool Narzędzie Pióro
|
||||
Quick Pen Tool Narzędzie Szybkie pióro
|
||||
Quick Pen Szybkie pióro
|
||||
Picas Pica
|
||||
Portuguese Portugalski
|
||||
Preserve Appearance and Overprints Zachowaj wygląd i nadruki
|
||||
@@ -5583,6 +5585,9 @@ liquify-list-end {0}, {1} {0} i {1}
|
||||
@msg `link` places a handle: give `handle` `link` umieszcza uchwyt: podaj `handle`
|
||||
@msg no such spine segment brak takiego segmentu grzbietu
|
||||
@msg no such subpath brak takiej ścieżki podrzędnej
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` musi być listą co najwyżej 10000 fragmentów
|
||||
@msg give either `start` for a new path or `id`, not both podaj `start` dla nowej ścieżki albo `id`, ale nie oba
|
||||
@msg `subpath` and `keep` need `id` `subpath` i `keep` wymagają `id`
|
||||
@msg no such user library brak takiej biblioteki użytkownika
|
||||
@msg no such view brak takiego widoku
|
||||
@msg no such width point brak takiego punktu szerokości
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2297,6 +2297,8 @@ antiAlias Sharp Nítido
|
||||
Pattern Options Opções de Padrão
|
||||
Pattern options are available in pattern editing mode. As opções de padrão estão disponíveis no modo de edição de padrão.
|
||||
Pen Tool Ferramenta Caneta
|
||||
Quick Pen Tool Ferramenta Caneta rápida
|
||||
Quick Pen Caneta rápida
|
||||
Pencil Lápis
|
||||
Pencil Tool Ferramenta Lápis
|
||||
Percent: Porcentagem:
|
||||
@@ -4728,6 +4730,9 @@ axis Both Ambos
|
||||
@msg `link` places a handle: give `handle` `link` posiciona uma alça: informe `handle`
|
||||
@msg no such spine segment segmento da coluna inexistente
|
||||
@msg no such subpath subtraçado inexistente
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` deve ser uma lista de no máximo 10000 trechos
|
||||
@msg give either `start` for a new path or `id`, not both informe `start` para um novo caminho ou `id`, mas não ambos
|
||||
@msg `subpath` and `keep` need `id` `subpath` e `keep` exigem `id`
|
||||
@msg no such user library biblioteca do usuário inexistente
|
||||
@msg no such view vista inexistente
|
||||
@msg no such width point ponto de largura inexistente
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2811,6 +2811,8 @@ file-filter Templates Шаблоны
|
||||
PDF/A files carry their own output intent. Файлы PDF/A содержат собственное назначение вывода.
|
||||
PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. Файлы PDF/X-1a используют CMYK: каждый цвет преобразуется в целевой (пусто: профиль CMYK назначения вывода) без пометки.
|
||||
Pen Tool Инструмент «Перо»
|
||||
Quick Pen Tool Инструмент «Быстрое перо»
|
||||
Quick Pen Быстрое перо
|
||||
Pencil Карандаш
|
||||
Pencil Tool Инструмент «Карандаш»
|
||||
per slice на фрагмент
|
||||
@@ -5475,6 +5477,9 @@ liquify-list-end {0}, {1} {0} и {1}
|
||||
@msg `link` places a handle: give `handle` `link` размещает маркер: укажите `handle`
|
||||
@msg no such spine segment такого сегмента остова нет
|
||||
@msg no such subpath такого вложенного контура нет
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` должен быть списком не более чем из 10000 фрагментов
|
||||
@msg give either `start` for a new path or `id`, not both укажите либо `start` для нового контура, либо `id`, но не оба
|
||||
@msg `subpath` and `keep` need `id` для `subpath` и `keep` нужен `id`
|
||||
@msg no such user library такой пользовательской библиотеки нет
|
||||
@msg no such view такого вида нет
|
||||
@msg no such width point такой точки ширины нет
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2706,6 +2706,8 @@ font-technology Variable Variabla
|
||||
PDF/A files carry their own output intent. PDF/A-filer har sin egen utgångsavsikt.
|
||||
PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. PDF/X-1a-filer är CMYK: alla färger konverteras till målet (tomt: utgångsavsiktens CMYK-profil), otaggade.
|
||||
Pen Tool Pennverktyg
|
||||
Quick Pen Tool Snabbpennverktyg
|
||||
Quick Pen Snabbpenna
|
||||
Pencil Blyertspenna
|
||||
Pencil Tool Blyertsverktyg
|
||||
per slice per skiva
|
||||
@@ -5340,6 +5342,9 @@ liquify-list-end {0}, {1} {0} och {1}
|
||||
@msg `link` places a handle: give `handle` `link` placerar ett handtag: ange `handle`
|
||||
@msg no such spine segment ryggradssegmentet finns inte
|
||||
@msg no such subpath delbanan finns inte
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` måste vara en lista med högst 10000 delar
|
||||
@msg give either `start` for a new path or `id`, not both ange antingen `start` för en ny bana eller `id`, inte båda
|
||||
@msg `subpath` and `keep` need `id` `subpath` och `keep` kräver `id`
|
||||
@msg no such user library användarbiblioteket finns inte
|
||||
@msg no such view vyn finns inte
|
||||
@msg no such width point breddpunkten finns inte
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2555,6 +2555,8 @@ shape Open Açık
|
||||
PDF/A files carry their own output intent. PDF/A dosyaları kendi çıktı amaçlarını taşır.
|
||||
PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. PDF/X-1a dosyaları CMYK'dir: her renk hedefe dönüştürülür (boş: çıktı hedefinin CMYK profili), etiketsiz.
|
||||
Pen Tool Kalem Aracı
|
||||
Quick Pen Tool Hızlı Kalem Aracı
|
||||
Quick Pen Hızlı Kalem
|
||||
Pencil Kalem
|
||||
Pencil Tool Kurşun Kalem Aracı
|
||||
per slice dilim başına
|
||||
@@ -5157,6 +5159,9 @@ liquify-list-end {0}, {1} {0} ve {1}
|
||||
@msg no such saved selection böyle kayıtlı bir seçim yok
|
||||
@msg no such segment öyle bir bölüm yok
|
||||
@msg no such subpath böyle bir alt yol yok
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` en fazla 10000 parçadan oluşan bir liste olmalıdır
|
||||
@msg give either `start` for a new path or `id`, not both yeni bir yol için `start` ya da `id` verin, ikisini birden değil
|
||||
@msg `subpath` and `keep` need `id` `subpath` ve `keep` için `id` gerekir
|
||||
@msg no such user library böyle bir kullanıcı kütüphanesi yok
|
||||
@msg no such view öyle bir görüş yok
|
||||
@msg no such width point böyle bir genişlik noktası yok
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2821,6 +2821,8 @@ file-filter Templates Шаблони
|
||||
PDF/A files carry their own output intent. Файли PDF/A містять власне призначення.
|
||||
PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. Файли PDF/X-1a використовують CMYK: кожен колір перетворюється на цільовий (порожньо: профіль CMYK призначення виведення) без позначки.
|
||||
Pen Tool Інструмент «Перо»
|
||||
Quick Pen Tool Інструмент «Швидке перо»
|
||||
Quick Pen Швидке перо
|
||||
Pencil Олівець
|
||||
Pencil Tool Інструмент «Олівець»
|
||||
per slice на фрагмент
|
||||
@@ -5464,6 +5466,9 @@ liquify-list-end {0}, {1} {0} і {1}
|
||||
@msg `link` places a handle: give `handle` `link` розміщує маркер: укажіть `handle`
|
||||
@msg no such spine segment такого сегмента осі немає
|
||||
@msg no such subpath такого вкладеного контуру немає
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` має бути списком щонайбільше з 10000 фрагментів
|
||||
@msg give either `start` for a new path or `id`, not both вкажіть або `start` для нового контуру, або `id`, але не обидва
|
||||
@msg `subpath` and `keep` need `id` для `subpath` і `keep` потрібен `id`
|
||||
@msg no such user library такої користувацької бібліотеки немає
|
||||
@msg no such view такого виду немає
|
||||
@msg no such width point такої точки ширини немає
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3140,6 +3140,8 @@ digits Hindi Hindi
|
||||
PDF/A files carry their own output intent. Tệp PDF/A tích hợp mục đích đầu ra của riêng chúng.
|
||||
PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. Tệp PDF/X-1a là CMYK: mọi màu được chuyển đổi sang đích (trống: hồ sơ CMYK của mục đích đầu ra), không gắn thẻ.
|
||||
Pen Tool Công cụ Bút
|
||||
Quick Pen Tool Công cụ Bút nhanh
|
||||
Quick Pen Bút nhanh
|
||||
Pencil Bút chì
|
||||
Pencil Tool Công cụ Bút chì
|
||||
per slice mỗi lát cắt
|
||||
@@ -5846,6 +5848,9 @@ liquify-list-end {0}, {1} {0} và {1}
|
||||
@msg `link` places a handle: give `handle` `link` đặt một tay nắm: hãy cho `handle`
|
||||
@msg no such spine segment không có đoạn trục như vậy
|
||||
@msg no such subpath không có nhánh con như vậy
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` phải là danh sách tối đa 10000 đoạn
|
||||
@msg give either `start` for a new path or `id`, not both hãy đưa `start` cho đường dẫn mới hoặc `id`, không đưa cả hai
|
||||
@msg `subpath` and `keep` need `id` `subpath` và `keep` cần có `id`
|
||||
@msg no such user library không có thư viện người dùng như vậy
|
||||
@msg no such view không có chế độ xem như vậy
|
||||
@msg no such width point không có điểm chiều rộng như vậy
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2673,6 +2673,8 @@ file-filter Templates 模板
|
||||
PDF/A files carry their own output intent. PDF/A 文件自带输出意图。
|
||||
PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. PDF/X-1a 文件为 CMYK:所有颜色都会转换至目的地 (留空:输出意图的 CMYK 配置文件),且不加标记。
|
||||
Pen Tool 钢笔工具
|
||||
Quick Pen Tool 快速钢笔工具
|
||||
Quick Pen 快速钢笔
|
||||
Pencil 铅笔
|
||||
Pencil Tool 铅笔工具
|
||||
per slice 每个切片
|
||||
@@ -4713,6 +4715,9 @@ imageTrace Outline 轮廓
|
||||
@msg no such anchor 没有此锚点
|
||||
@msg no such segment 没有此线段
|
||||
@msg no such subpath 没有此子路径
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` 必须是最多 10000 个片段的列表
|
||||
@msg give either `start` for a new path or `id`, not both 请为新路径指定 `start`,或指定 `id`,不能同时指定
|
||||
@msg `subpath` and `keep` need `id` `subpath` 和 `keep` 需要 `id`
|
||||
@msg object {id} is not a path 对象 {id} 不是路径
|
||||
@msg object {id} is not a selected top-level object 对象 {id} 不是选中的顶层对象
|
||||
@msg nothing to redo 没有可重做的操作
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2100,6 +2100,9 @@ file-filter Templates 範本
|
||||
@msg no such anchor 沒有這個錨點
|
||||
@msg no such segment 沒有這個線段
|
||||
@msg no such subpath 沒有這個子路徑
|
||||
@msg `pieces` must be a list of at most 10000 pieces `pieces` 必須是最多 10000 個片段的清單
|
||||
@msg give either `start` for a new path or `id`, not both 請為新路徑指定 `start`,或指定 `id`,不可同時指定
|
||||
@msg `subpath` and `keep` need `id` `subpath` 與 `keep` 需要 `id`
|
||||
@msg object {id} is not a path 物件 {id} 不是路徑
|
||||
@msg object {id} is not a selected top-level object 物件 {id} 不是已選取的最上層物件
|
||||
@msg nothing to redo 沒有可重做的動作
|
||||
@@ -4101,6 +4104,8 @@ liquify-list-end {0}, {1} {0}和{1}
|
||||
PDF/A files carry their own output intent. PDF/A 檔案自帶輸出目的。
|
||||
PDF/X-1a files are CMYK: every colour is converted to the destination (blank: the output intent's CMYK profile), untagged. PDF/X-1a 檔案為 CMYK:所有顏色都會轉換至目的地 (留空:輸出目的的 CMYK 描述檔),且不加標記。
|
||||
Pen Tool 筆型工具
|
||||
Quick Pen Tool 快速筆型工具
|
||||
Quick Pen 快速筆型
|
||||
Pencil 鉛筆
|
||||
Pencil Tool 鉛筆工具
|
||||
per slice 每個切片
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -151,6 +151,7 @@ pub static ICONS: &[(&str, &[u8])] = &[
|
||||
("dc-polygon", include_bytes!("../../../assets/icons/dc-polygon.svg")),
|
||||
("dc-pucker", include_bytes!("../../../assets/icons/dc-pucker.svg")),
|
||||
("dc-puppet", include_bytes!("../../../assets/icons/dc-puppet.svg")),
|
||||
("dc-quick-pen", include_bytes!("../../../assets/icons/dc-quick-pen.svg")),
|
||||
("dc-rearrange", include_bytes!("../../../assets/icons/dc-rearrange.svg")),
|
||||
("dc-rect-cut", include_bytes!("../../../assets/icons/dc-rect-cut.svg")),
|
||||
("dc-rect-grid", include_bytes!("../../../assets/icons/dc-rect-grid.svg")),
|
||||
|
||||
@@ -28,6 +28,7 @@ pub fn tool_icon(name: &str) -> &'static str {
|
||||
"tool-pen-add" => "pen-tool-add",
|
||||
"tool-pen-delete" => "pen-tool-delete",
|
||||
"tool-anchor" => "dc-anchor",
|
||||
"tool-quick-pen" => "dc-quick-pen",
|
||||
"tool-curvature" => "spline",
|
||||
"tool-type" => "dc-type",
|
||||
"tool-type-area" => "dc-type-area",
|
||||
|
||||
@@ -395,6 +395,8 @@ pub struct VectorcraftApp {
|
||||
/// The single-key tool shortcuts held down, the last held last, and the tool each goes back to
|
||||
/// when it is let go ([`shortcuts::HeldTool`]).
|
||||
pub(crate) held_tool: Vec<shortcuts::HeldTool>,
|
||||
/// Alt held down on its own since a frame saw it go down ([`shortcuts::AltTap`]).
|
||||
pub(crate) alt_tap: shortcuts::AltTap,
|
||||
/// A key with a hold shortcut that waits for its release, and the keys whose repeats are held
|
||||
/// back until they are let go ([`shortcuts::HoldKeys`]).
|
||||
pub(crate) hold_keys: shortcuts::HoldKeys,
|
||||
|
||||
@@ -82,10 +82,12 @@ pub fn context_items(app: &VectorcraftApp) -> Vec<Item> {
|
||||
if !st.selection.anchors.is_empty() {
|
||||
v.extend([c("Remove Anchor Points", "path.removeAnchors"), c("Cut Path at Selected Anchor Points", "path.cutAtAnchors")]);
|
||||
}
|
||||
// Object › Path › Smooth…, which opens the Smooth slider (`invoke`). `prune` leaves it out
|
||||
// unless object.path.smooth can run: the selection holds a path, in a group or a compound
|
||||
// path too.
|
||||
v.push(c("Smooth…", "object.path.smooth"));
|
||||
// Object › Path › Simplify… and Smooth…, in that menu's order (#8344). Each opens what the
|
||||
// menu item opens (`invoke`): the Simplify slider, or the Simplify dialog when its "Open
|
||||
// this dialog with these settings next time" was ticked, and the Smooth slider. `prune`
|
||||
// leaves each out unless its command can run: the selection holds a path, in a group or a
|
||||
// compound path too.
|
||||
v.extend([c("Simplify…", "object.path.simplify"), c("Smooth…", "object.path.smooth")]);
|
||||
if several {
|
||||
v.push(c("Make Clipping Mask", "object.clippingMask.make"));
|
||||
}
|
||||
|
||||
@@ -802,9 +802,9 @@ fn listed(overrides: &Overrides, e: &Entry) -> bool {
|
||||
/// Options, Character, Set Bounds), the exports and saves that give the file back without a `path`
|
||||
/// (Save Document gives the file back when the document has no file yet; File › Save takes a key
|
||||
/// instead), the undo group's begin and end, and the commands that need a point, a value or a name
|
||||
/// (Create Dimension, Edit Freeform Point, Select by Color, Move Brush, Paintbrush, Map Art). New Symbol is left out
|
||||
/// because the Symbols panel runs it through the Symbol Options dialog.
|
||||
const NEEDS_A_PARAM: [&str; 76] = [
|
||||
/// (Create Dimension, Edit Freeform Point, Select by Color, Move Brush, Paintbrush, Map Art, Quick Pen). New
|
||||
/// Symbol is left out because the Symbols panel runs it through the Symbol Options dialog.
|
||||
const NEEDS_A_PARAM: [&str; 77] = [
|
||||
"transparency.set",
|
||||
"transparency.setOpacityMask",
|
||||
"stroke.set",
|
||||
@@ -867,6 +867,7 @@ const NEEDS_A_PARAM: [&str; 76] = [
|
||||
"paint.setFill",
|
||||
"paint.setGradientGeom",
|
||||
"paint.setStroke",
|
||||
"path.quickPen",
|
||||
"perspective.grid.define",
|
||||
"perspective.grid.set",
|
||||
"perspective.plane.move",
|
||||
|
||||
@@ -11,6 +11,7 @@ use vectorcraft_tools::{Mods, SurroundingUnit, ToolKey};
|
||||
|
||||
use crate::VectorcraftApp;
|
||||
|
||||
mod alt_tap;
|
||||
mod held_tool;
|
||||
mod hold_keys;
|
||||
mod labels;
|
||||
@@ -18,6 +19,7 @@ mod paste;
|
||||
mod presentation;
|
||||
mod typing;
|
||||
|
||||
pub(crate) use alt_tap::AltTap;
|
||||
pub(crate) use held_tool::{HeldTool, note_tool_use};
|
||||
pub(crate) use hold_keys::HoldKeys;
|
||||
#[cfg(test)]
|
||||
@@ -215,6 +217,7 @@ pub fn handle(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
hold_keys::guard(app, ctx, focused);
|
||||
// A held tool shortcut that is let go returns to the tool active before it.
|
||||
held_tool::follow(app, ctx, focused);
|
||||
let alt_tapped = alt_tap::follow(&mut app.alt_tap, ctx, focused);
|
||||
if !focused {
|
||||
crate::ime::controls_without_editor(app, ctx);
|
||||
return;
|
||||
@@ -375,6 +378,11 @@ pub fn handle(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
}
|
||||
crate::ime::controls_without_editor(app, ctx);
|
||||
let to_labels = handle_clipboard(app, ctx, textless_paste);
|
||||
// Alt tapped on its own: the Quick Pen tool's next action.
|
||||
if alt_tapped && app.session.tool_claims_key(ToolKey::AltTap, view) {
|
||||
let r = app.session.tool_key(ToolKey::AltTap, Mods::default(), view);
|
||||
crate::canvas::apply_requests(app, r);
|
||||
}
|
||||
if busy {
|
||||
busy_tool_keys(app, ctx, view);
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
//! Alt (Option on macOS) pressed and let go with no other key, click or wheel turn in between: the
|
||||
//! active tool gets [`ToolKey::AltTap`](vectorcraft_tools::ToolKey::AltTap) when it claims it (the
|
||||
//! Quick Pen tool switches to its next action).
|
||||
|
||||
/// Alt held down since it went down, and whether anything else happened since.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub(crate) struct AltTap {
|
||||
down: bool,
|
||||
spoiled: bool,
|
||||
}
|
||||
|
||||
impl AltTap {
|
||||
/// The modifiers changed: `alt` is whether Alt is held, `alone` whether it is held without
|
||||
/// Shift, Ctrl or Cmd. True when Alt was let go after a press with nothing else in between.
|
||||
pub(crate) fn modifiers(&mut self, alt: bool, alone: bool) -> bool {
|
||||
match (self.down, alt) {
|
||||
(false, true) => {
|
||||
(self.down, self.spoiled) = (true, !alone);
|
||||
false
|
||||
}
|
||||
(true, true) => {
|
||||
self.spoiled |= !alone;
|
||||
false
|
||||
}
|
||||
(true, false) => {
|
||||
let tap = !self.spoiled;
|
||||
*self = Self::default();
|
||||
tap
|
||||
}
|
||||
(false, false) => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// A key press, a click or a wheel turn: Alt held now is no tap.
|
||||
pub(crate) fn other(&mut self) {
|
||||
self.spoiled = true;
|
||||
}
|
||||
}
|
||||
|
||||
fn alt_alone(m: egui::Modifiers) -> (bool, bool) {
|
||||
(m.alt, !(m.shift || m.ctrl || m.command || m.mac_cmd))
|
||||
}
|
||||
|
||||
/// Follows the frame's events in order, then its modifiers at its end; true when Alt was tapped,
|
||||
/// also when it went down and up within the frame. A frame without the keyboard focus drops a
|
||||
/// press under way.
|
||||
pub(super) fn follow(tap: &mut AltTap, ctx: &egui::Context, focused: bool) -> bool {
|
||||
if !focused {
|
||||
*tap = AltTap::default();
|
||||
return false;
|
||||
}
|
||||
ctx.input(|i| {
|
||||
let mut tapped = false;
|
||||
for e in &i.events {
|
||||
match e {
|
||||
egui::Event::ModifiersChanged(m) => {
|
||||
let (alt, alone) = alt_alone(*m);
|
||||
tapped |= tap.modifiers(alt, alone);
|
||||
}
|
||||
egui::Event::Key { pressed: true, .. }
|
||||
| egui::Event::PointerButton { .. }
|
||||
| egui::Event::MouseWheel { .. }
|
||||
| egui::Event::Touch { .. } => tap.other(),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let (alt, alone) = alt_alone(i.modifiers);
|
||||
tapped | tap.modifiers(alt, alone)
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{AltTap, follow};
|
||||
|
||||
#[test]
|
||||
fn a_press_and_release_alone_is_a_tap() {
|
||||
let mut t = AltTap::default();
|
||||
assert!(!t.modifiers(true, true));
|
||||
assert!(!t.modifiers(true, true));
|
||||
assert!(t.modifiers(false, true));
|
||||
assert!(!t.modifiers(false, true), "once");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn anything_else_while_alt_is_down_is_no_tap() {
|
||||
// A key (Alt+P), a click or a wheel turn while held.
|
||||
let mut t = AltTap::default();
|
||||
t.modifiers(true, true);
|
||||
t.other();
|
||||
assert!(!t.modifiers(false, true));
|
||||
// With Shift held too.
|
||||
t.modifiers(true, false);
|
||||
assert!(!t.modifiers(false, true));
|
||||
// Something before Alt went down does not count, and the next press starts afresh.
|
||||
t.other();
|
||||
t.modifiers(true, true);
|
||||
assert!(t.modifiers(false, true));
|
||||
}
|
||||
|
||||
/// Alt down and up between two frames: both changes come in one frame's events, whose
|
||||
/// modifiers at its end hold no Alt.
|
||||
#[test]
|
||||
fn a_tap_within_one_frame_counts() {
|
||||
let ctx = egui::Context::default();
|
||||
let mut t = AltTap::default();
|
||||
let mut tapped = false;
|
||||
let events = vec![egui::Event::ModifiersChanged(egui::Modifiers::ALT), egui::Event::ModifiersChanged(egui::Modifiers::NONE)];
|
||||
let mut out = ctx.run_ui(egui::RawInput { events, ..Default::default() }, |ui| tapped = follow(&mut t, ui.ctx(), true));
|
||||
out.textures_delta.clear();
|
||||
assert!(tapped);
|
||||
assert_eq!(t, AltTap::default());
|
||||
}
|
||||
}
|
||||
@@ -380,6 +380,39 @@ fn alt_chords_outside_text_editing_type_nothing() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Alt+P (Option+P on macOS, which types π) chooses the Quick Pen tool, and is no Alt tap. Alt
|
||||
/// then pressed and let go on its own switches the tool to its next action; Alt let go after a
|
||||
/// click does not.
|
||||
#[test]
|
||||
fn alt_p_chooses_the_quick_pen_and_an_alt_tap_switches_its_action() {
|
||||
// One headless frame with `modifiers` held at its end.
|
||||
fn held(app: &mut VectorcraftApp, modifiers: Modifiers, mut events: Vec<egui::Event>) {
|
||||
events.insert(0, egui::Event::ModifiersChanged(modifiers));
|
||||
let ctx = egui::Context::default();
|
||||
let mut out = ctx.run_ui(egui::RawInput { events, ..Default::default() }, |ui| {
|
||||
app.logic(ui.ctx());
|
||||
handle(app, ui.ctx());
|
||||
});
|
||||
out.textures_delta.clear();
|
||||
}
|
||||
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
|
||||
crate::shortcut_editor::sync(&app.ui);
|
||||
app.run("file.new", json!({"width": 400, "height": 300})).unwrap();
|
||||
held(&mut app, Modifiers::ALT, alt_press(Key::P, false, Some("\u{3c0}")));
|
||||
assert_eq!(app.session.tool_id(), vectorcraft_tools::quickpen::ID);
|
||||
held(&mut app, Modifiers::NONE, vec![]);
|
||||
assert_eq!(app.session.tool_options()["action"], "line", "Alt+P is no tap");
|
||||
held(&mut app, Modifiers::ALT, vec![]);
|
||||
held(&mut app, Modifiers::NONE, vec![]);
|
||||
assert_eq!(app.session.tool_options()["action"], "continuousArc");
|
||||
held(&mut app, Modifiers::ALT, vec![]);
|
||||
let click =
|
||||
egui::Event::PointerButton { pos: egui::pos2(5.0, 5.0), button: egui::PointerButton::Primary, pressed: true, modifiers: Modifiers::ALT };
|
||||
held(&mut app, Modifiers::ALT, vec![click]);
|
||||
held(&mut app, Modifiers::NONE, vec![]);
|
||||
assert_eq!(app.session.tool_options()["action"], "continuousArc", "a click in between");
|
||||
}
|
||||
|
||||
/// Cmd as egui reports it on this platform: the Command key on macOS, Ctrl elsewhere.
|
||||
fn cmd() -> Modifiers {
|
||||
if crate::keymap::platform().is_mac() { Modifiers::MAC_CMD | Modifiers::COMMAND } else { Modifiers::CTRL | Modifiers::COMMAND }
|
||||
|
||||
@@ -354,10 +354,16 @@ fn isolation_context_item_skips_objects_outside_the_edited_symbol() {
|
||||
/// A closed path of 60 jagged anchors around (150, 150), filled so that a right-click inside it
|
||||
/// hits it, with nothing selected.
|
||||
fn jagged(app: &mut VectorcraftApp) -> NodeId {
|
||||
ring(app, 4.0)
|
||||
}
|
||||
|
||||
/// A closed path of 60 anchors around (150, 150), every other one `wobble` pt further out, filled
|
||||
/// so that a right-click inside it hits it, with nothing selected.
|
||||
fn ring(app: &mut VectorcraftApp, wobble: f64) -> NodeId {
|
||||
let anchors: Vec<_> = (0..60)
|
||||
.map(|i| {
|
||||
let a = f64::from(i) * std::f64::consts::TAU / 60.0;
|
||||
let r = 60.0 + f64::from(i % 2) * 4.0;
|
||||
let r = 60.0 + f64::from(i % 2) * wobble;
|
||||
json!({"x": 150.0 + r * a.cos(), "y": 150.0 + r * a.sin()})
|
||||
})
|
||||
.collect();
|
||||
@@ -405,15 +411,59 @@ fn right_click_on_a_path_opens_the_smooth_slider() {
|
||||
assert!(anchor_total(&app) < before, "the path was smoothed: {} anchor points from {before}", anchor_total(&app));
|
||||
}
|
||||
|
||||
/// Smooth… is listed while the selection holds a path: a path, a group of paths, a compound path,
|
||||
/// a path with type, and anchors selected with Direct Selection (whose Remove Anchor Points
|
||||
/// stays). It is left out with nothing, only type or a group of type selected.
|
||||
/// A right-click on a path lists Object › Path › Simplify… between Average… and Smooth…, as the
|
||||
/// Path menu orders them (#8344). Simplify… opens the Simplify slider at Auto-Simplify's level, as
|
||||
/// the menu item does, and adds no undo step while it is open; OK keeps the simplified path as one
|
||||
/// undo step. After the Simplify dialog was confirmed with "Open this dialog with these settings
|
||||
/// next time" ticked, Simplify… opens that dialog on its settings, as the menu item does.
|
||||
#[test]
|
||||
fn smooth_follows_the_selections_paths() {
|
||||
fn right_click_on_a_path_opens_simplify_as_the_menu_item_does() {
|
||||
let mut app = app();
|
||||
// A circle drawn with 60 anchors, which Auto-Simplify's tolerance refits with far fewer.
|
||||
let id = ring(&mut app, 0.0);
|
||||
let ctx = egui::Context::default();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
let p = screen(&app, 150.0, 150.0);
|
||||
let texts = click(&mut app, &ctx, p, PointerButton::Secondary);
|
||||
assert_eq!(app.session.active().unwrap().selection.objects, [id], "the path right-clicked is selected");
|
||||
let y = |label| at(&texts, label).y;
|
||||
assert!(y("Average…") < y("Simplify…") && y("Simplify…") < y("Smooth…"), "{texts:?}");
|
||||
let level = crate::dialogs::simplify_slider::fields(&app)["level"].as_f64().unwrap();
|
||||
let (undo, before) = (app.session.active().unwrap().history.undo.len(), anchor_total(&app));
|
||||
let after = click(&mut app, &ctx, at(&texts, "Simplify…"), PointerButton::Primary);
|
||||
assert!(!has(&after, "Arrange"), "choosing Simplify… closes the menu");
|
||||
let open = app.ui.dialog.as_ref().map(|d| (d.kind.clone(), d.f64("level", -1.0)));
|
||||
assert_eq!(open, Some((crate::dialogs::simplify_slider::KIND.to_string(), level)), "the slider at Auto-Simplify's level");
|
||||
assert_eq!(app.session.active().unwrap().history.undo.len(), undo, "no undo step while the slider is open");
|
||||
crate::dialogs::confirm(&mut app).unwrap();
|
||||
assert!(app.ui.dialog.is_none() && !app.session.in_interaction());
|
||||
assert_eq!(app.session.active().unwrap().history.undo.len(), undo + 1, "OK keeps the result as one undo step");
|
||||
assert!(anchor_total(&app) < before, "the path was simplified: {} anchor points from {before}", anchor_total(&app));
|
||||
|
||||
// The settings the Simplify dialog keeps for next time: Simplify… opens the dialog on them.
|
||||
app.ui.simplify = json!({"tolerance": 0.5, "cornerAngle": 150, "straightLines": true, "retain": true});
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
let texts = click(&mut app, &ctx, p, PointerButton::Secondary);
|
||||
click(&mut app, &ctx, at(&texts, "Simplify…"), PointerButton::Primary);
|
||||
let d = app.ui.dialog.clone().expect("the Simplify dialog");
|
||||
assert_eq!((d.kind.as_str(), d.f64("tolerance", 0.0), d.bool("straightLines"), d.bool("retain")), ("simplify", 0.5, true, true));
|
||||
}
|
||||
|
||||
/// Simplify… and Smooth… are listed while the selection holds a path: a path, a group of paths, a
|
||||
/// compound path, a path with type, and anchors selected with Direct Selection (whose Remove
|
||||
/// Anchor Points stays). They are left out with nothing, only type or a group of type selected.
|
||||
#[test]
|
||||
fn simplify_and_smooth_follow_the_selections_paths() {
|
||||
let mut app = app();
|
||||
let (a, b) = (rect(&mut app, 0.0, 0.0), rect(&mut app, 150.0, 0.0));
|
||||
let t = NodeId(app.run("text.create", json!({"x": 10, "y": 250, "text": "Type"})).unwrap()["id"].as_u64().unwrap());
|
||||
let smooth = |app: &VectorcraftApp| labels(&menus::context_items(app)).contains(&"Smooth…");
|
||||
// Both or neither, never one without the other.
|
||||
let smooth = |app: &VectorcraftApp| {
|
||||
let shown = labels(&menus::context_items(app));
|
||||
let (simplify, smooth) = (shown.contains(&"Simplify…"), shown.contains(&"Smooth…"));
|
||||
assert_eq!(simplify, smooth, "Simplify… and Smooth… follow the same rule: {shown:?}");
|
||||
smooth
|
||||
};
|
||||
app.run("select.none", json!({})).unwrap();
|
||||
assert!(!smooth(&app), "nothing selected");
|
||||
app.run("select.set", json!({"ids": [t.0]})).unwrap();
|
||||
|
||||
@@ -49,7 +49,7 @@ pub const BASIC: &[(&str, &[&[&str]])] = &[
|
||||
&["pencil", "smooth", "pathEraser", "join"],
|
||||
&["eraser", "scissors", "knife", "trimAtCrossings", "mirrorCut", "lineCut", "rectCut"],
|
||||
&["paintbrush", "blobBrush"],
|
||||
&["pen", "addAnchor", "deleteAnchor", "anchorPoint"],
|
||||
&["pen", "addAnchor", "deleteAnchor", "anchorPoint", "quickPen"],
|
||||
&["curvature"],
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# File format parity
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-18 · **Change:** minor (PDF import: type filled and stroked after a page of type filled only comes in filled and stroked, #8549 follow-up; previously: #8200: `.ai` and EPS import: an Art brush in Tints of a swatch-linked stroke color comes in brushed, its tints linked to the swatch; scores and estimates unchanged; previously: #8128: `.ai` and EPS import: clipping paths grouped in a compound path are its subpaths, so the compound clipping path clips its clipping group instead of reading as nested clipping groups that clip nothing or stop the editing data from being read; previously: PDF import: type filled and stroked by a `TJ` whose kerning starts a new line comes in filled and stroked, #8543; PDF export writes the document language as the catalog's `/Lang`, #3644; PDF import: a glyph filled only after a glyph filled and stroked comes in filled only, not stroked, #8300; PDF import: translucent type filled and stroked comes in as a filled type object and a stroked one, as the file composites them, and an upright glyph is never kept as the outline of its glyph alone, #8015; PDF import: type filled and stroked by one text-showing operator comes in as one type object, filled and stroked, not a stroked copy over a filled one, #8015; scores and estimates unchanged; previously: PDF import: stroked type keeps the line cap, line join and miter limit the file strokes it with, not butt caps and miter joins, #7741; `.ai` and EPS import: in layers that don't draw as the page, art that differs away from an envelope of type no longer costs it its editable type; it keeps its drawn art where, in the pixels it and its drawn art ink, the layers with it differ from the page more than its own check allows, or past the envelopes' share of the page check, #7141; `.ai` and EPS import: a top-object envelope whose mesh saves its sides' curves in pieces draws its contents along each whole curve, as its drawn art does, #7097; previously: PDF import: glyphs in a span with an empty ActualText come in as outlines, #6971; scores and estimates unchanged; previously: `.ai` and EPS import: type from the text document, type a PostScript program sets and legacy `.ai` type are set in an installed face of their font's PostScript name, exact name first, in the version a text document's record keeps; the `.ai` save writes a static font's version when its name alone gives another copy, #6983; `.ai` and EPS import: type keeps the manual kerning of its text document, #6899; `.ai` and EPS import: type in an envelope with Distort Appearance is also tried mapped from the box of what it paints, its strokes' miter tips and strokes a Transform effect moves included, after its glyphs grown by half its strokes' weight, #6824; `.ai` and EPS import: type filled or stroked with a pattern swatch keeps its pattern, from the art style its text document paint names, #6856; #6865: explicitly requested oversized editing artboard; PDF import: Indic type keeps its marks on their line, and a line whose type would not draw as the file does keeps the file's glyphs as outlines, #5235; previously: newly imported SVG/SVGZ titles are filtered and bounded without changing restored titles, #3626; `.ai` and EPS import, and what every export and `.ai` save draw: type's strokes in an envelope paint at their own weight along its bent outlines, Distort Appearance on or off, #6644; `.ai` and EPS import: centred and right-aligned lines of tracked type are aligned without the tracking after their last character, as the file's page aligns them, #6610; `.ai` and EPS import: an envelope saved in Edit Contents whose mesh lies away from its drawn art by a move opens live on that art, #6570; `.ai` save and open: layer colour presets Yellow, Magenta and Cyan keep their colour, as the `Lb` colour index now follows the file's numbering, #6502; `.ai` save: stroked type keeps its stroke's cap, join and miter limit in the text document, #6472; `.ai` and EPS import, PDF import: tracking and manual kerning in horizontally scaled type take the Horizontal Scale, as the file's page spaces such type; `.ai` and EPS import: stroked type in an envelope maps from its glyphs grown by half its stroke, #3179; `.ai` and EPS import: warps of type open as mesh envelopes on their saved grid, #3179; `.ai` and EPS import: stroked type keeps its stroke's cap, join and miter limit from the text document, #6472; `.ai` save: type in a variable font's named instance names its design-space setting, #6388; `.ai` and EPS import: envelopes of type open live where they draw as their drawn art and the layers with them draw as the page, #3179; `.ai` and EPS import: a note for type in an envelope, #3179; `.ai` and EPS import: the live envelope and warped type check sees white art; PDF import: DeviceN images of one ink or of process plates keep their inks, #6348; `.ai` import: images in a spot ink's Separation space keep their ink, #6350; PDF import: Separation imagesLine truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (`.ai` import: a stroke's arrowheads, the symbols its style names, come in as custom arrowheads with their tip on, or past, the path's end, as the drawn art places it, and the line stopping where the symbol's sample of it ends, #8188; PDF import: type filled and stroked after a page of type filled only comes in filled and stroked, #8549 follow-up; previously: #8200: `.ai` and EPS import: an Art brush in Tints of a swatch-linked stroke color comes in brushed, its tints linked to the swatch; scores and estimates unchanged; previously: #8128: `.ai` and EPS import: clipping paths grouped in a compound path are its subpaths, so the compound clipping path clips its clipping group instead of reading as nested clipping groups that clip nothing or stop the editing data from being read; previously: PDF import: type filled and stroked by a `TJ` whose kerning starts a new line comes in filled and stroked, #8543; PDF export writes the document language as the catalog's `/Lang`, #3644; PDF import: a glyph filled only after a glyph filled and stroked comes in filled only, not stroked, #8300; PDF import: translucent type filled and stroked comes in as a filled type object and a stroked one, as the file composites them, and an upright glyph is never kept as the outline of its glyph alone, #8015; PDF import: type filled and stroked by one text-showing operator comes in as one type object, filled and stroked, not a stroked copy over a filled one, #8015; scores and estimates unchanged; previously: PDF import: stroked type keeps the line cap, line join and miter limit the file strokes it with, not butt caps and miter joins, #7741; `.ai` and EPS import: in layers that don't draw as the page, art that differs away from an envelope of type no longer costs it its editable type; it keeps its drawn art where, in the pixels it and its drawn art ink, the layers with it differ from the page more than its own check allows, or past the envelopes' share of the page check, #7141; `.ai` and EPS import: a top-object envelope whose mesh saves its sides' curves in pieces draws its contents along each whole curve, as its drawn art does, #7097; previously: PDF import: glyphs in a span with an empty ActualText come in as outlines, #6971; scores and estimates unchanged; previously: `.ai` and EPS import: type from the text document, type a PostScript program sets and legacy `.ai` type are set in an installed face of their font's PostScript name, exact name first, in the version a text document's record keeps; the `.ai` save writes a static font's version when its name alone gives another copy, #6983; `.ai` and EPS import: type keeps the manual kerning of its text document, #6899; `.ai` and EPS import: type in an envelope with Distort Appearance is also tried mapped from the box of what it paints, its strokes' miter tips and strokes a Transform effect moves included, after its glyphs grown by half its strokes' weight, #6824; `.ai` and EPS import: type filled or stroked with a pattern swatch keeps its pattern, from the art style its text document paint names, #6856; #6865: explicitly requested oversized editing artboard; PDF import: Indic type keeps its marks on their line, and a line whose type would not draw as the file does keeps the file's glyphs as outlines, #5235; previously: newly imported SVG/SVGZ titles are filtered and bounded without changing restored titles, #3626; `.ai` and EPS import, and what every export and `.ai` save draw: type's strokes in an envelope paint at their own weight along its bent outlines, Distort Appearance on or off, #6644; `.ai` and EPS import: centred and right-aligned lines of tracked type are aligned without the tracking after their last character, as the file's page aligns them, #6610; `.ai` and EPS import: an envelope saved in Edit Contents whose mesh lies away from its drawn art by a move opens live on that art, #6570; `.ai` save and open: layer colour presets Yellow, Magenta and Cyan keep their colour, as the `Lb` colour index now follows the file's numbering, #6502; `.ai` save: stroked type keeps its stroke's cap, join and miter limit in the text document, #6472; `.ai` and EPS import, PDF import: tracking and manual kerning in horizontally scaled type take the Horizontal Scale, as the file's page spaces such type; `.ai` and EPS import: stroked type in an envelope maps from its glyphs grown by half its stroke, #3179; `.ai` and EPS import: warps of type open as mesh envelopes on their saved grid, #3179; `.ai` and EPS import: stroked type keeps its stroke's cap, join and miter limit from the text document, #6472; `.ai` save: type in a variable font's named instance names its design-space setting, #6388; `.ai` and EPS import: envelopes of type open live where they draw as their drawn art and the layers with them draw as the page, #3179; `.ai` and EPS import: a note for type in an envelope, #3179; `.ai` and EPS import: the live enLine truncated
|
||||
>
|
||||
> Oversized artboard import update (2026-11-12): Explicit editing-data import retains a single artboard beyond a capped 14,400 pt PDF page (#6865).
|
||||
|
||||
@@ -384,6 +384,7 @@ Stop opacity on translated artboards remains outside this regression coverage.
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-19 | minor | `.ai` import: a stroke's arrowheads were left out, so lines came in without their heads (#8188). A Stroke Style filter's stroke dictionary names each end's head as a symbol of the file (`/GObjRef : (name) /SymbolArt ; (BSArrowBeginSymbol)` or `(BSArrowEndSymbol)`), with its scale in percent (`BSArrowEndScale`, and `BSArrowBeginScale` read the same way; 100 without one). As the files have it, such a symbol's art (y down, as symbols are read) points right along a straight, level sample of the line: an open stroked path with no fill, which ends where the line stops under the head. The rest of the art that paints is the head, its tip its rightmost point, at one symbol unit a head weight (the stroke's weight at the scale). The head comes in as a custom arrowhead with that outline and that stop (a custom head now carries an optional stop, else its line ends halfway along it, as before). Its placement is the one of the two (tip on the end of the path, or Extend, the tip past it by the line's length under the head) that gives the object its drawn art's bounds; the user's file has every tip on its path's end. A stroke keeps its drawn look when neither placement gives those bounds (heads on other subpaths, say) or both do while a head moves 0.2 pt or more between them (a line whose end lies inside the bounds of its other segments), when its symbol isn't read whole or isn't read as a head (no sample or more than one, a sample that isn't 1 pt wide, as in art stored at a Large Canvas scale, art other than paths, compound paths and groups such as a clip group, a group with fills or strokes of its own, effects, brushes, partial opacity or an opacity mask), when its dictionary holds another `BSArrow` entry beside heads, when a scale is outside 1–1000 %, or when the head's weight would be under the 0.25 pt least one VectorCraft draws; a graphic style with such a stroke isn't read rather than read without its heads, and one with heads takes them on the end of the path, so an object whose heads are read past its ends isn't linked to its listed style. Measured on a user's file of ten arrows (used locally, never committed): every line gets its heads, and drawn at 4× its pixels match the file's own page but for 3 of 9,825 inked ones (0.24.1: 1,232 differ). Tests `a_strokes_arrowhead_symbols_are_its_arrowheads`, `a_strokes_start_arrowhead_points_back_and_keeps_its_side`, `a_stroke_takes_both_heads_at_their_own_scales`, `heads_drawn_past_the_path_extend_it`, `arrowheads_this_does_not_read_keep_the_drawn_look`, `an_arrowhead_entry_without_heads_leaves_the_stroke_read` in `crates/eps/src/import/ai/tests.rs`, `heads_whose_placement_the_drawn_bounds_leave_open_keep_the_drawn_look`, `a_head_that_stays_put_leaves_a_moving_heads_placement_open`, `a_style_library_reads_the_heads_of_symbols_defined_after_its_styles` in it, `a_symbol_entry_cut_short_leaves_the_next_style_read` and `a_comment_inside_a_symbol_entry_is_skipped` in `crates/eps/src/import/ai/style/tests.rs`, `partly_transparent_or_masked_art_makes_no_head` in `crates/eps/src/import/ai/arrowhead.rs`, fuzzed by `ai_arrowhead_strokes_never_panic`; scores unchanged |
|
||||
| 2026-11-19 | minor | PDF import (#8549 follow-up): type filled and stroked after a page of type filled only came in as a filled object and a stroked one: since #8549 lines filled only are kept for a stroke pass too, and the glyphs of the lines finished past the 64 kept were remembered until the next stroke, so `2 Tr (Title) Tj` after more than 64 lines of type filled only took its first stroke for the start of a stroke pass over them, always once more than 4,096 glyphs had been finished so. Those glyphs are now forgotten when anything else is drawn (a path, an image, a Type 3 glyph's art, a change of blend mode or soft mask: nothing is drawn between an operator's fill pass and its stroke pass), and past the first 4,096 glyphs none are remembered instead of every stroke matching. A `TJ` over more lines than are kept still comes in as a filled object and a stroked one for each part, also when it ends where it began, and when a glyph kept as an outline comes before that (the line it starts keeps the glyphs of the lines finished). Remaining: with nothing drawn between them, type filled and stroked at exactly the place, font, size and text of a glyph filled only on a line finished so still comes in as a filled object and a stroked one, as the device can't tell its stroke pass from the start of one over that glyph. Tests: `type_filled_and_stroked_after_a_dense_page_of_filled_type_is_filled_and_stroked`, `type_filled_and_stroked_over_a_finished_glyph_after_a_path_is_filled_and_stroked`, `an_outline_glyph_in_a_tj_over_more_lines_than_are_kept_leaves_fill_and_stroke_apart`; scores and estimates unchanged. |
|
||||
| 2026-11-18 | minor | PDF import (#8543): type filled and stroked (text rendering modes 2 and 6) by a `TJ` whose kerning starts a new line part way through came in as four type objects, each part filled only and each part stroked only over it: the reader fills every glyph of the operator before it strokes them, and the line the first part was gathered on was finished before the stroke pass came back to it. Lines an operator's fill pass finishes while a stroke may still be drawn over them are now kept (up to 64 besides the open line, so a `TJ` over up to 65 lines: one over more stays a filled object and a stroked one for each part, as before) until the stroke pass goes past them, and the pass's strokes are held (up to 4096: a longer pass is matched a part at a time, each part to glyphs filled one right after another, never to one an operator before it filled) until it ends, then matched to the glyphs filled last, in the order they were filled, so each stroke finds the glyph it was filled as, also where the `TJ` draws a glyph again where it drew one (`[(A) -3500 (B) 4834 (A)] TJ`). Each part comes in as one type object filled and stroked, in the order drawn; also a `TJ` that jumps back and one whose kerning starts two new lines. In an `ActualText` span (whose stroke was lost) the replacement text stays one type object on the first glyph's line and in its style, now filled and stroked, also where the `TJ` draws a glyph again: the span's strokes are matched the same way. A stroke over no filled glyph (stroked type of its own) and the start and end of an `ActualText` span end a stroke pass: no stroke after them goes over a glyph filled before them, so none is drawn under type drawn after it, and a later span keeps its own replacement text. Stroke rendering stays stroke only, and translucent type stays a filled object and a stroked one. Tests: `a_tj_whose_kerning_starts_a_new_line_is_filled_and_stroked`, `a_tj_that_draws_a_glyph_again_where_it_drew_one_strokes_each_copy`, `a_stroked_tj_whose_kerning_starts_a_new_line_stays_stroke_only`, `a_translucent_tj_whose_kerning_starts_a_new_line_stays_fill_and_stroke_apart`, `a_long_stroke_pass_strokes_its_own_glyphs_not_one_filled_before`, `a_stroke_after_stroked_type_of_its_own_does_not_join_a_glyph_filled_before`, `a_stroke_in_an_actual_text_span_does_not_take_an_earlier_spans_glyph`, `a_tj_that_draws_a_glyph_again_in_an_actual_text_span_strokes_the_replacement`, `a_tj_over_more_lines_than_are_kept_comes_in_as_fill_and_stroke_apart`, `a_tj_over_more_lines_than_are_kept_that_ends_where_it_began_stays_fill_and_stroke_apart`, `type_after_a_tj_over_more_lines_than_are_kept_is_filled_and_stroked`; scores and estimates unchanged. |
|
||||
| 2026-11-18 | minor | PDF export (#3644): the document language chosen in Document Setup is written as the catalog's `/Lang` (BCP 47, `en-US` by default) and as XMP `dc:language`; a language without a tag writes none. Scores and estimates unchanged. |
|
||||
|
||||
+60
-1
@@ -4736,6 +4736,21 @@ already walks Image Trace. Short agent entry points:
|
||||
dialog's OK) when every group already has the options and `closeGaps` finds no gap, and `livePaint.make` or
|
||||
`livePaint.merge` given one Live Paint group alone, which they select. Such a fill or stroke also leaves the recent
|
||||
colors and the last color as they are. `livePaint.gapOptions` makes a group's faces again, with new ids, only when it adds a path or when Gap Detection is turned on or off or given a new size while it is on.
|
||||
With a tool other than the Live Paint Bucket, a whole Live Paint group that is selected, given in `ids`, or inside a
|
||||
selected group takes a fill on its faces only and a stroke on its edges only, and its hidden source paths keep their
|
||||
paint. Without an `item`, `paint.setFill`, `paint.setStroke`, `paint.lastColor`, `paint.lastGradient` and
|
||||
`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.
|
||||
|
||||
`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
|
||||
@@ -6328,7 +6343,9 @@ Arrowheads… is not confined.
|
||||
|
||||
`stroke.set {endArrow: {"custom": name}}` puts a custom head on a stroke. The stroke keeps a copy of the head's art,
|
||||
so the document draws it, saves it and exports it to SVG and PDF the same way without the arrowheads file.
|
||||
`document.inspect` reports such a head as `{"Custom": {name, path}}`, which `stroke.set` takes back unchanged. It
|
||||
`document.inspect` reports such a head as `{"Custom": {name, path}}`, which `stroke.set` takes back unchanged. A head
|
||||
read from an Illustrator file also carries `stop`, where the stroke ends under it in head units back from the tip
|
||||
(0 to 64; without it, the stroke ends halfway along the head). It
|
||||
refuses a `path` that fills no area (non-zero rule; parts thinner than a millionth of a head unit count as none) or
|
||||
has more than 4,096 anchors, more than 4,096 subpaths or a point more than 64 head units from the tip. The help page
|
||||
[Apply stroke on an object](https://helpx.adobe.com/illustrator/using/stroke-object.html) describes defining custom
|
||||
@@ -6984,6 +7001,48 @@ toggles a point with `path.convertAnchor`; an Alt-click on an end of an open sub
|
||||
{"name":"run_command","arguments":{"command":"path.curvatureEdit","params":{"id":12,"op":"extend","x":650,"y":60,"from":"smooth"}}}
|
||||
```
|
||||
|
||||
## Drawing with the Quick Pen tool
|
||||
|
||||
The Quick Pen tool (`quickPen`, in the Pen tool's group, Alt+P or Option+P on macOS) draws paths of straight lines and
|
||||
circular arcs ([Draw with the Quick Pen tool](https://helpx.adobe.com/illustrator/web/add-and-edit-artwork/draw-and-edit-paths/draw-with-quick-pen-tool.html),
|
||||
[Quick Pen tool keyboard shortcuts](https://helpx.adobe.com/illustrator/web/add-and-edit-artwork/draw-and-edit-paths/quick-pen-tool-keyboard-shortcuts.html)).
|
||||
A click sets the start point. Each click after it, or a press dragged to where it is let go, adds a piece from the
|
||||
path's last point, drawn with the tool's `action` option:
|
||||
|
||||
- `"line"` (the default): a straight line.
|
||||
- `"continuousArc"`: an arc that leaves the last point in the direction the path arrives there, so the two join
|
||||
smoothly. The first piece of a path has no direction and is drawn as a sharp-corner arc; an end straight ahead of or
|
||||
straight behind the last point gives a line.
|
||||
- `"sharpArc"`: an arc that turns through the tool's `turn` option (degrees, 1 to 359, 180 by default: a half circle)
|
||||
and bulges to the left of the direction drawn, meeting the path before it at a corner.
|
||||
|
||||
Alt (Option on macOS) pressed and let go with no other key, click or wheel turn in between switches to the next action:
|
||||
Line, Continuous Arc, Sharp Corner Arc, and back to Line. C flips the last piece, while it is a sharp-corner arc, to
|
||||
the other side of its chord. `[` and `]` make the arc size 15° smaller or larger, for the last sharp-corner arc and the
|
||||
arcs after it. A click on the first point closes the path, and a click on an end of an open path goes on drawing from
|
||||
that end. Escape or Enter ends the path, and so does an edit made to it by another command. The path's points show as circles without handles, and a preview shows the
|
||||
piece the next click adds. Points snap to Smart Guides. Each piece, flip and size change is one undo step. The arc
|
||||
size of 180°, its 15° steps, the side an arc bulges to and Enter ending the path are VectorCraft's own rules. The
|
||||
tool keeps `action` and `turn` with the preferences (`tool.setOption {tool: "quickPen", key, value}`).
|
||||
|
||||
`path.quickPen {start?: [x, y], id?, subpath?, keep?, pieces?, closed?}` draws such a path and selects it, as one
|
||||
undo step, and answers `{id}`. With `start`, it makes a new path with the current paint (a black stroke when the paint
|
||||
has neither fill nor stroke). With `id`, it draws on the open subpath `subpath` (0 when left out) of that path: its
|
||||
first `keep` points stay (all of them when left out) and the pieces follow. Each piece is
|
||||
`{x, y, action?, turn?, flip?}`: it ends at `x`, `y`, `action` is `"line"` when left out, `turn` is 180 when left out,
|
||||
and `flip` puts a sharp-corner arc on the right of the direction drawn. A piece that ends where the path does adds
|
||||
nothing. With `closed: true`, a last piece that ends on the first point joins it; otherwise a straight segment closes
|
||||
the path. The command returns an error and changes nothing when both or neither of `start` and `id` are given
|
||||
(`` give either `start` for a new path or `id`, not both ``), when `subpath` or `keep` comes without `id`, when
|
||||
`pieces` is not a list of at most 10000 pieces, when a point's x or y is not a number or is 1e9 or more in size, for
|
||||
an unknown `action`, a `turn` outside 1 to 359, a `flip` or `closed` that is not true or false, a `keep` outside 1 to
|
||||
the subpath's points, and for a closed subpath, a locked or hidden path or an `id` that is not a path.
|
||||
|
||||
```json
|
||||
{"name":"run_command","arguments":{"command":"path.quickPen","params":{"start":[100,100],"pieces":[{"x":200,"y":100},{"x":300,"y":200,"action":"continuousArc"},{"x":300,"y":300,"action":"sharpArc","turn":90,"flip":true}]}}}
|
||||
{"name":"run_command","arguments":{"command":"tool.setOption","params":{"tool":"quickPen","key":"action","value":"sharpArc"}}}
|
||||
```
|
||||
|
||||
## Registration and trim marks
|
||||
|
||||
Every document has the built-in `[Registration]` swatch (listed after None by `swatch.list`): a colour that prints on
|
||||
|
||||
@@ -628,6 +628,7 @@ since 2026-10-01.
|
||||
- **Guide row highlight (#7344):** `guide_row_highlight_stays_selected_without_hover` in `crates/ui-egui/src/panels/layers/tests.rs` checks selected guide background after the pointer leaves, with unselected guide and ordinary row controls. Guide selection, dragging and deletion are unchanged. Scores and estimates unchanged.
|
||||
|
||||
- **Recolor picker follow-up (#8031/#4028):** native Lab numeric entry, document/loaded-library swatches in the Color Picker, and Assign-row Pick from Swatches / Limit to Library menus. #4090 provided the double-click picker and #5113 the Assign sliders. Regression tests `native_lab_entry_in_color_picker` and `row_context_menu_pick_from_swatches_and_limit_to_library` exercise the fields and menu callbacks rather than writing their result state. Area score and hours unchanged.
|
||||
- **Quick Pen tool (#2660, in part):** a tool in the Pen tool's group (Alt+P, Option+P on macOS) draws straight lines, continuous arcs and sharp-corner arcs, one undo step per piece; Alt pressed and let go on its own switches the action, C flips the last sharp-corner arc, `[` and `]` change the arc size by 15°, a click on the first point closes the path, a click on an open end continues it, and Escape or Enter ends it (`path.quickPen`), as [Draw with the Quick Pen tool](https://helpx.adobe.com/illustrator/web/add-and-edit-artwork/draw-and-edit-paths/draw-with-quick-pen-tool.html) and [Quick Pen tool keyboard shortcuts](https://helpx.adobe.com/illustrator/web/add-and-edit-artwork/draw-and-edit-paths/quick-pen-tool-keyboard-shortcuts.html) describe. The 180° default arc, its 15° steps and the side an arc bulges to are VectorCraft's own rules. Tests: tools `quickpen::tests`, engine `tests::quickpen`, ui-egui `shortcuts::alt_tap::tests` and `alt_p_chooses_the_quick_pen_and_an_alt_tap_switches_its_action`. Score and hours unchanged.
|
||||
|
||||
- **Optional compact Tools (#7234):** Window > Toolbars > Compact Tools reduces row and column spacing and the main panel's allocated width in one or two columns, docked or floating. The setting is saved with the UI state and applies to Basic, Advanced and edited main Tools layouts; the selected tool, icon size, footer controls and tool-flyout behavior are retained. Turning it off restores the existing layout, which remains the default. Named custom toolbars and flyout spacing are unchanged. Public regressions in `crates/ui-egui/tests/toolbar_compact.rs` cover the actual toolbar layout against the default control, the command and saved-state roundtrip, tool selection, flyouts, footer controls and short-window reachability. This is an optional layout choice, without a styling-parity or score claim; hours are unchanged.
|
||||
|
||||
@@ -1891,6 +1892,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, `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.
|
||||
|
||||
+5
-3
@@ -1,6 +1,6 @@
|
||||
# UI and interaction parity
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-18 · **Change:** minor (a tool drag held near an edge of the canvas scrolls the view, #8551; scores and estimates unchanged; previously: G12: Place: show progress window with Cancel for slow placed files exceeding 0.4 s, part of #5930; scores and estimates unchanged; previously: All Tools drawer: a tool the toolbar holds is dimmed in the readable dim text colour, not the disabled colour that was unreadable against the panel, and a hovered dimmed row takes the panel's darker fill so it stays readable, #8294; scores and estimates unchanged; previously: : selected guide rows stay highlighted after the pointer leaves (#7344); scores and estimates unchanged; previously: Layersselected Dimension extension-line color and weight in Properties (#7078; four focused UI regressions passed); scores and estimates unchanged; previously: Brush Options Key Color: restore canvas input for the existing one-shot pick, then resume the retained draft and previous tool (#8284; six full-app input regressions passed); scores and estimates unchanged; previously: Ellipse: Up/Down changes Anchors while drawing (#7840); scores and estimates unchanged; previously: Windows/Linux menu access keys and localized cues (#6596); previously: Backquote/~ arrow pattern nudges (#7717); scores and estimates unchanged; previously: Window > Toolbars > Compact Tools offers optional denser main Tools spacing (#7234); default layout, scores and estimates unchanged; previously: Direct Selection: Space during an ordinary path's handle drag repositions its anchor and handles, including a Pen loan (#7237, request 3 only; scores and estimates unchanged); previously: Floating panels keep their window level while focus moves between the app's windows, so a press on one panel's bar no longer hands the keyboard to another, #6986; scores and estimates unchanged; previously minor: Lock Guides: a selection marquee (Selection, Direct Selection, Group Selection, Enclosing Lasso) leaves out paths made into guides inside groups and compound paths too, as clicks do (#3074), so a group is no longer selected by a locked guide in it; an enclosing marquee measures a group without its locked or hidden guides, and Direct Selection takes no anchor or segment of a guide that can't be picked; a guide in a group still moves with its group (#8538); scores and estimates unchanged; previously: Production Preflight: output-aware fonts, text overflow, linked files and effective image resolution, clickable findings and automatic rechecking; scores and estimates unchanged; previously: Layers panel: an Alt-drag copies a row above or below itself, so the top layer dragged up, the bottom layer dragged down and a lone layer are copied, #8237; scores and estimates unchanged; previously: Layers panel: Alt over the list shows the copy cursor while rows or the selected-art square are dragged, #8217; scores and estimates unchanged; previously: Gradient panel: the add-stop strip under the ramp shows the white arrow with a plus on Windows and X11, #8241; scores and estimates unchanged; previously: Recolor Artwork follow-up (#8031, remaining #4028): native Lab input, picker swatch libraries and Assign-row menus; UI interaction regression coverage; scores and estimates unchanged; previously: Eraser review: hidden Rasterize and Along/Across stroke rows do not block preserving visible gradients; scores and estimates unchanged; previously: Eraser review: ordinary Group/Layer paints and reproducible evaluated gradient placements are preserved; other placements retain existing fitting; scores and estimates unchanged; previously: Eraser: shared fill-only area cutting for fixed and varied tips and the Alt-drag marquee, #6582; scores and estimates unchanged; previously: #8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: Pencil continuation, straight-line and closing cursors; scores and estimates unchanged; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: macOS: the canvas cursor stays after the pointer moves, #6362; scores and estimates unchanged; previously minor: Remove Background in the Contextual Task Bar, Properties › Quick Actions and the Control bar; previously minor: Ruler origin: the corner drag snaps as a drawn point does; previously minor: Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: Outline view: images and gradient meshes are picked on what Outline dLine truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (Canvas context menu: a right-click on a path offers Simplify… next to Smooth…, opening the Simplify slider, or the Simplify dialog kept for next time, as Object › Path › Simplify… does, #8344; scores and estimates unchanged; previously: a tool drag held near an edge of the canvas scrolls the view, #8551; scores and estimates unchanged; previously: G12: Place: show progress window with Cancel for slow placed files exceeding 0.4 s, part of #5930; scores and estimates unchanged; previously: All Tools drawer: a tool the toolbar holds is dimmed in the readable dim text colour, not the disabled colour that was unreadable against the panel, and a hovered dimmed row takes the panel's darker fill so it stays readable, #8294; scores and estimates unchanged; previously: : selected guide rows stay highlighted after the pointer leaves (#7344); scores and estimates unchanged; previously: Layersselected Dimension extension-line color and weight in Properties (#7078; four focused UI regressions passed); scores and estimates unchanged; previously: Brush Options Key Color: restore canvas input for the existing one-shot pick, then resume the retained draft and previous tool (#8284; six full-app input regressions passed); scores and estimates unchanged; previously: Ellipse: Up/Down changes Anchors while drawing (#7840); scores and estimates unchanged; previously: Windows/Linux menu access keys and localized cues (#6596); previously: Backquote/~ arrow pattern nudges (#7717); scores and estimates unchanged; previously: Window > Toolbars > Compact Tools offers optional denser main Tools spacing (#7234); default layout, scores and estimates unchanged; previously: Direct Selection: Space during an ordinary path's handle drag repositions its anchor and handles, including a Pen loan (#7237, request 3 only; scores and estimates unchanged); previously: Floating panels keep their window level while focus moves between the app's windows, so a press on one panel's bar no longer hands the keyboard to another, #6986; scores and estimates unchanged; previously minor: Lock Guides: a selection marquee (Selection, Direct Selection, Group Selection, Enclosing Lasso) leaves out paths made into guides inside groups and compound paths too, as clicks do (#3074), so a group is no longer selected by a locked guide in it; an enclosing marquee measures a group without its locked or hidden guides, and Direct Selection takes no anchor or segment of a guide that can't be picked; a guide in a group still moves with its group (#8538); scores and estimates unchanged; previously: Production Preflight: output-aware fonts, text overflow, linked files and effective image resolution, clickable findings and automatic rechecking; scores and estimates unchanged; previously: Layers panel: an Alt-drag copies a row above or below itself, so the top layer dragged up, the bottom layer dragged down and a lone layer are copied, #8237; scores and estimates unchanged; previously: Layers panel: Alt over the list shows the copy cursor while rows or the selected-art square are dragged, #8217; scores and estimates unchanged; previously: Gradient panel: the add-stop strip under the ramp shows the white arrow with a plus on Windows and X11, #8241; scores and estimates unchanged; previously: Recolor Artwork follow-up (#8031, remaining #4028): native Lab input, picker swatch libraries and Assign-row menus; UI interaction regression coverage; scores and estimates unchanged; previously: Eraser review: hidden Rasterize and Along/Across stroke rows do not block preserving visible gradients; scores and estimates unchanged; previously: Eraser review: ordinary Group/Layer paints and reproducible evaluated gradient placements are preserved; other placements retain existing fitting; scores and estimates unchanged; previously: Eraser: shared fill-only area cutting for fixed and varied tips and the Alt-drag marquee, #6582; scores and estimates unchanged; previously: #8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: Pencil continuation, straight-line and closing cursors; scores and estimates unchanged; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: macOS: the canvas cursor stays after the pointer moves, #6362; scores and estimates unchanged; previously minor: Remove Background in the Contextual Task Bar, Properties › Quick Actions and the Control bar; previously minor: Ruler origin: the corner drag snaps as a drawn point does; previousLine truncated
|
||||
>
|
||||
> Tech Circuit update (2026-11-14): three original procedural brushes; ten built-in brush libraries (G5).
|
||||
>
|
||||
@@ -201,6 +201,7 @@ tools, never checked side by side) isn't captured row by row.
|
||||
| Busy cursor during long operations | done | Background open, save and export show the system progress cursor (gap G1) |
|
||||
| Each anchor snaps to Smart Guides and construction angles | done | `DrawSnap` |
|
||||
| Curvature tool: click/drag points, double-click or Alt-click for a corner, temporary Direct Selection, point conversion | partial | circular point markers without direction handles or duplicate markers, Anchor Size and Hide Edges regression-tested (#1236, in part); curve geometry: each stretch of three points follows the circle through them (handles along its tangent, chord/(3·cos²(α/2)) long, shorter in a turn tighter than 30°), open ends curving in, the same rule for the rubber band, dragged, inserted and converted points (#1236, in part); neighbours of a point dragged on an existing path keep their tangents, and modifiers requested in #975 remain |
|
||||
| Quick Pen tool: straight lines, continuous arcs and sharp-corner arcs, Alt/Option to switch action, C to flip an arc, `[` / `]` for its size, Alt+P / Option+P, close on the first point, continue from an end, Escape to end ([help page](https://helpx.adobe.com/illustrator/web/add-and-edit-artwork/draw-and-edit-paths/draw-with-quick-pen-tool.html), [shortcuts](https://helpx.adobe.com/illustrator/web/add-and-edit-artwork/draw-and-edit-paths/quick-pen-tool-keyboard-shortcuts.html)) | partial | `path.quickPen` and the tool in `crates/tools/src/quickpen.rs`, in the Pen tool's group (#2660). Not yet: the on-canvas toolbar with its More menu, dragging a path's ends to change a line's or arc's length, Ctrl+scroll for the arc size, and editing and deleting with the tool |
|
||||
| Icon-strip flyout resizing (#5713) | done | Canvas-side edge and bottom; user size persists after reopening and workspace restore; Glyphs and Artboards pointer/cursor regression |
|
||||
| Icon-strip flyout resizing from the top (storytold/craft-libs#1094) | done | Top edge (a 4 pt band over the tab strip) and the canvas-side top corner; the bottom and the icon-column edge stay; the moved top persists after reopening and workspace restore; `an_icon_flyout_grows_upward_from_its_top_edge_and_free_corner` |
|
||||
| Graphic Styles list fills a taller panel (#2992) | done | Docked, floating or in a resized flyout, the list takes the height above the panel's footer, as the Artboards list does; outside a sized panel it stays 220 pt; `the_list_fills_a_tall_panel_above_its_footer` |
|
||||
@@ -222,7 +223,7 @@ tools, never checked side by side) isn't captured row by row.
|
||||
| Average and Join in one step, with a corner or smooth choice for the joined anchor | done | Object › Path › Average & Join… (`path.averageJoin`, Cmd+Alt+Shift+J, "Create corner or smooth join" in [Default keyboard shortcuts](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)): two open path ends meet at their midpoint and join, a corner or smooth point as the dialog's Points choice asks (Corner first, then the last choice), in one undo step |
|
||||
| Smooth tool smooths only the stretch of path under the drag | done | #1512 |
|
||||
| Drawing modes apply to pastes: Draw Inside takes Paste, Paste in Place and Paste on All Artboards inside the object; Draw Behind puts Paste in Place and Paste on All Artboards behind the selection; Shift+D cycles past Draw Behind with any selection ([drawing modes](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/learn-drawing-basics/drawing-modes-overview.html)) | done | #3705; `pasting_in_draw_inside_puts_the_copies_inside_the_object`, `paste_in_place_in_draw_behind_goes_behind_the_selection`, `shift_d_goes_past_draw_behind_whatever_is_selected` |
|
||||
| Simplify (slider, auto, corner angle threshold), of a whole path or of the part of it selected with Direct Selection ([manually simplify paths](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-paths/manually-simplify-paths.html)) | done | Tolerance, default-on Preview and original/new point counts (#1272); Corner Point Angle Threshold, Convert to Straight Lines and Show Original Path; the slider under the selection with Auto-Simplify and More Options, opening at the Auto-Simplify level for the selection with that result previewed, and the dialog's option to open it directly with its last settings. With anchors or segments direct-selected, the slider, Auto-Simplify and the dialog refit only each run of selected segments between its end anchors, a closed path's run across its start point included; the rest of the path stays exactly as it was (`tests/simplify_part.rs`, `simplify_slider_and_dialog_simplify_only_the_direct_selected_part_of_a_path`) |
|
||||
| Simplify (slider, auto, corner angle threshold), of a whole path or of the part of it selected with Direct Selection ([manually simplify paths](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-paths/manually-simplify-paths.html)) | done | Tolerance, default-on Preview and original/new point counts (#1272); Corner Point Angle Threshold, Convert to Straight Lines and Show Original Path; the slider under the selection with Auto-Simplify and More Options, opening at the Auto-Simplify level for the selection with that result previewed, and the dialog's option to open it directly with its last settings. The canvas context menu's Simplify…, listed with Smooth… while the selection holds a path, opens the same slider or dialog (#8344, `right_click_on_a_path_opens_simplify_as_the_menu_item_does`). With anchors or segments direct-selected, the slider, Auto-Simplify and the dialog refit only each run of selected segments between its end anchors, a closed path's run across its start point included; the rest of the path stays exactly as it was (`tests/simplify_part.rs`, `simplify_slider_and_dialog_simplify_only_the_direct_selected_part_of_a_path`) |
|
||||
| Smooth (Object › Path › Smooth…: slider from minimum to maximum smoothing, Auto-Smooth) ([smooth slider](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-paths/refine-path-segments-with-the-smooth-slider.html)) | done | #4115: the slider under the selection previews `object.path.smooth {level}`, Auto-Smooth picks level 50 and takes a shaky line to one smooth curve, direct-selected anchors smooth only their section, Enter or a click outside keeps one undo step and Escape restores; the smoothing rule beyond the two ends is VectorCraft's own (`tests/smooth_path.rs`, `smooth_slider_previews_auto_smooth_and_keeps_the_result`) |
|
||||
| Draw Inside in isolation mode: art drawn or pasted inside the isolated object takes isolation mode into its clip group, clickable and undimmed ([isolation mode](https://helpx.adobe.com/illustrator/desktop/manage-objects/select-objects/isolate-objects.html), [drawing modes](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/learn-drawing-basics/drawing-modes-overview.html)) | done | #3705; `drawing_inside_an_isolated_object_keeps_the_new_art_in_isolation_mode` |
|
||||
| Draw Inside marks the object it draws into: a dotted open rectangle round its corners, in its layer's colour, while the mode lasts, selected or not | done | #4319, `canvas::tests::draw_inside_marks_the_corners_of_its_object` ([drawing modes](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/learn-drawing-basics/drawing-modes-overview.html)) |
|
||||
@@ -499,7 +500,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po
|
||||
| Pathfinder panel › Pathfinder Options…: Precision, Remove Redundant Points, Divide and Outline Will Remove Unpainted Artwork | done | #3426; `object.pathfinder.options`, kept in the preferences; defaults (0.01 pt, both off) keep the earlier results; [spec](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/pathfinder-panel-overview.html) |
|
||||
| Cmd/Ctrl+4 repeats the last successful Shape Mode or Pathfinder operation on the selection | done | Panel operations, direct `object.pathfinder.*` commands and `command.batch` steps (Actions playback) set history; `action.batch`, Trap, compound-shape edits and live effects do not. Repeat uses current Pathfinder Options; [key spec](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html), [menu spec](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/pathfinder-panel-overview.html) |
|
||||
| Pathfinder panel: compound shapes (Make, Release and Expand Compound Shape in the panel menu, Alt-click a Shape Mode, a Shape Mode for selected members, the Expand button) | partial | #4522; `object.compoundShape.make`/`setMode`/`release`/`expand`; members stay editable, the area draws, exports and saves; the button of the members' shared mode is lit, and members in different modes put a question mark on each Shape Mode button; blends, envelopes and warped objects are members as they draw; [spec](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/create-compound-shapes-with-pathfinder.html); missing: hit-testing by the area |
|
||||
| Canvas context menu | done | Right-clicking type opens the canvas menu, with Bullets and Numbering and Spelling. Artboard rows, library groups and items, the rulers and floating toolbar grips have menus too. Gaps: other panels have none |
|
||||
| Canvas context menu | done | Right-clicking type opens the canvas menu, with Bullets and Numbering and Spelling. Right-clicking a path offers Object › Path › Simplify… and Smooth…, each opening what its menu item opens (#8344). Artboard rows, library groups and items, the rulers and floating toolbar grips have menus too. Gaps: other panels have none |
|
||||
| Layers panel row context menu | done | Right-clicking a layer/group/object row shows a context menu with Options…, Duplicate, Delete, Lock/Hide Others, Locate Object, and Collect for Export; right-clicking a ruler guide row shows Hide/Show, Lock/Unlock, Release Guides, Delete and Locate Object; right-clicking a blend spine row shows Select, Blend Options…, Reverse Spine, Reverse Front to Back, Expand, Release and Locate Object (#8592). |
|
||||
| Swatches item context menu (G12) | done | List and thumbnail items offer Swatch Options…, Duplicate Swatch and Delete Swatch for the clicked item. Right-click selects without applying paint; reserved/missing items disable actions. All 39 Swatches tests pass, including all five views and Undo; the regression fails with the menu hooks removed. Rendered headless menus inspected. Full workspace CI passed on Linux/WSL on the merged branch (all 13 gates), including the test-helper correction for the upstream compile error tracked in #7727; native Windows full CI has two unchanged engine-test failures. |
|
||||
| SVG Interactivity panel: JavaScript for each object's events and the document's linked JavaScript files, written to SVG and read back as text | done | `svgInteractivity.*`, `ui.javascriptFilesDialog` |
|
||||
@@ -616,6 +617,7 @@ before release (#6373). [Paint faces and edges](https://helpx.adobe.com/illustra
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-19 | minor | Canvas context menu: a right-click on a path, a group of paths or a compound path offers Simplify… between Average… and Smooth…, in the Path menu's order, opening the Simplify slider at the Auto-Simplify level, or the Simplify dialog on its kept settings, as Object › Path › Simplify… does (#8344). Scores and estimates unchanged. |
|
||||
| 2026-11-19 | minor | G12: Place: show progress window with Cancel for slow placed files exceeding 0.4 s (part of #5930, `file.cancelPlace`); indeterminate moving bar, Cancel (Esc) leaves the document unmodified without undo steps; scores and estimates unchanged. |
|
||||
| 2026-11-18 | minor | Lock Guides: a selection marquee (Selection, Direct Selection, Group Selection, Enclosing Lasso) leaves out paths made into guides inside groups and compound paths too, as clicks do (#3074), so a group is no longer selected by a locked guide in it; an enclosing marquee measures a group without its locked or hidden guides, and Direct Selection takes no anchor or segment of a guide that can't be picked; a guide in a group still moves with its group (#8538). Scores and estimates unchanged. |
|
||||
| 2026-11-18 | minor | Production Preflight: output-aware fonts, text overflow, linked files and effective image resolution, clickable findings and automatic rechecking; scores and estimates unchanged. See [production-preflight.md](production-preflight.md) for scope and limits. |
|
||||
|
||||
Reference in new issue
Block a user