Merge main after qualifying Image Trace sampler follow-up

This commit is contained in:
yoriswind committed 2026-11-17 04:29:44 -08:00
commit c990b8c3b0
45 files changed
+1431 -85

No files matched your search

+27 -7
View File
@@ -27,7 +27,11 @@ impl TextObject {
/// Character attributes as presented by controls (stored runs stay local for layout
/// and rich-text clipboard operations). Explicit vertical character scale stays separate.
pub fn effective_char_style(&self, style: &CharStyle) -> Option<CharStyle> {
let scale = self.style_scale()?;
Self::scaled_char_style(style, self.style_scale()?)
}
/// `style` with `scale` taken into its attributes ([`Self::effective_char_style`]).
fn scaled_char_style(style: &CharStyle, scale: TextStyleScale) -> Option<CharStyle> {
let mut style = style.clone();
style.size *= scale.points;
style.leading = style.leading.map(|v| v * scale.points);
@@ -57,19 +61,27 @@ impl TextObject {
/// scale from `xf`, so panels show document-point sizes without a separate transform factor.
/// Returns `false` when there is nothing to bake (identity scale or an unrepresentable
/// transform).
///
/// Type on a path bakes only the uniform part of the scale (the vertical one) and keeps any
/// stretch in `xf`: its brackets and glyphs sit at fractions of the path's length, which a
/// non-uniform scale of the path would move, and a uniform one keeps.
pub fn scale_text_attributes(&mut self) -> bool {
let Some(scale) = self.style_scale() else { return false };
if (scale.points - 1.0).abs() <= 1e-12 && (scale.horizontal - 1.0).abs() <= 1e-12 {
let Some(mut scale) = self.style_scale() else { return false };
let [a, b, c, d, _, _] = self.xf.as_coeffs();
let (mut sx, sy) = (a.hypot(b), c.hypot(d));
if sx <= 1e-12 || sy <= 1e-12 {
return false;
}
let [a, b, c, d, _, _] = self.xf.as_coeffs();
let (sx, sy) = (a.hypot(b), c.hypot(d));
if sx <= 1e-12 || sy <= 1e-12 {
if matches!(self.kind, TextKind::OnPath { .. }) {
scale.horizontal = 1.0;
sx = sy;
}
if (scale.points - 1.0).abs() <= 1e-12 && (scale.horizontal - 1.0).abs() <= 1e-12 {
return false;
}
let mut baked = Vec::with_capacity(self.runs.len());
for run in &self.runs {
let Some(eff) = self.effective_char_style(&run.style) else { return false };
let Some(eff) = Self::scaled_char_style(&run.style, scale) else { return false };
baked.push(eff);
}
for (run, style) in self.runs.iter_mut().zip(baked) {
@@ -78,6 +90,14 @@ impl TextObject {
// Character strokes are drawn in text space: widen them by the vertical scale we remove.
self.scale_char_strokes(1.0 / sy);
self.xf *= Affine::scale_non_uniform(1.0 / sx, 1.0 / sy);
// An area's frame and a path type's path are drawn through `xf` too: give them the scale
// `xf` loses, so the frame (and so the line breaks) and the path stay where they were.
let grow = Affine::scale_non_uniform(sx, sy);
match &mut self.kind {
TextKind::Area { frame } => frame.transform(grow),
TextKind::OnPath { path, .. } => path.transform(grow),
TextKind::Point => {}
}
self.cached_bounds = None;
self.cached_baselines.clear();
self.cached_ink = None;
+2 -2
View File
@@ -11,7 +11,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Pencil",
[],
None,
"{points: [[x,y]…] or [[x,y,pressure]…] or [[x,y,pressure,tiltX,tiltY,rotation]…] (pen pressure 0..1: the stroke keeps it, for Calligraphic and Scatter brushes with Pressure variation; a point without one presses fully. Pen tilt in degrees, each −90..90, x positive leaning right and y leaning down the page, and barrel rotation in degrees clockwise, 0..360: the stroke keeps how far the pen leaned, which way and how far its barrel turned, for brushes with Tilt, Bearing and Rotation variation; null for what a point lacks. A pressure, tilt or rotation outside its range, or a point array of more than six numbers, is an error), fidelity?: pt (1.5; from 0.000015625 (0.01 / 640) to 100 / 0.0313 (about 3194.89), the Pencil's and the Paintbrush's 0.01 to 100 px Fidelity at the highest and the lowest zoom; a value outside that range is an error. The tools send their Fidelity in pixels divided by the zoom, kept within the range), fit?: bool (true; false: the points are joined by straight segments, as the Pencil previews a stroke with Live curve fitting off), closed?, style?: \"pencil\"|\"brush\", fill?: bool, keepSelected?: bool (true: the drawn or continued path is selected; false: a new path leaves nothing selected, and a continued or redrawn one is deselected while the rest of the selection stays), extend?: {id, end: \"start\"|\"end\"}, connect?: {id, end: \"start\"|\"end\"}, redraw?: {id, within?: pt (12)}} fit a freehand stroke → {id}. extend continues the path from that end, and closes it when `closed` is true (left out, when the stroke ends within four Fidelities of the path's other end, 6 to 400 pt); with connect, the stroke ends on that end of another path's last open subpath and joins it on, in one path with the extended path's appearance (the other path is removed when nothing of it is left); redraw (Edit Selected Paths) replaces the section of the path between where the stroke starts and ends, each within `within` of one subpath (the shorter way round a closed one), and draws a new path when the stroke doesn't end on it",
"{points: [[x,y]…] or [[x,y,pressure]…] or [[x,y,pressure,tiltX,tiltY,rotation]…] (pen pressure 0..1: the stroke keeps it, for Calligraphic and Scatter brushes with Pressure variation; a point without one presses fully. Pen tilt in degrees, each −90..90, x positive leaning right and y leaning down the page, and barrel rotation in degrees clockwise, 0..360: the stroke keeps how far the pen leaned, which way and how far its barrel turned, for brushes with Tilt, Bearing and Rotation variation; null for what a point lacks. A pressure, tilt or rotation outside its range, or a point array of more than six numbers, is an error), fidelity?: pt (1.5; from 0.000015625 (0.01 / 640) to 100 / 0.0313 (about 3194.89), the Pencil's and the Paintbrush's 0.01 to 100 px Fidelity at the highest and the lowest zoom; a value outside that range is an error. The tools send their Fidelity in pixels divided by the zoom, kept within the range), fit?: bool (true; false: the points are joined by straight segments, as the Pencil previews a stroke with Live curve fitting off), closed?, style?: \"pencil\" (default) | \"brush\", fill?: bool, keepSelected?: bool (true: the drawn or continued path is selected; false: a new path leaves nothing selected, and a continued or redrawn one is deselected while the rest of the selection stays), extend?: {id, end?: \"end\" (default) | \"start\"}, connect?: {id, end: \"start\"|\"end\"}, redraw?: {id, within?: pt (12)}} fit a freehand stroke → {id}. extend continues the path from that end, and closes it when `closed` is true (left out, when the stroke ends within four Fidelities of the path's other end, 6 to 400 pt); with connect, the stroke ends on that end of another path's last open subpath and joins it on, in one path with the extended path's appearance (the other path is removed when nothing of it is left); redraw (Edit Selected Paths) replaces the section of the path between where the stroke starts and ends, each within `within` of one subpath (the shorter way round a closed one), and draws a new path when the stroke doesn't end on it. Any other style, extend end or connect end is an error, and nothing changes",
has_doc,
freehand
),
@@ -128,7 +128,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Blob Brush",
[],
None,
"{points: [[x,y]…] or [[x,y,pressure]…] (pen pressure 0..1; pen values are checked as path.freehand checks them), size?: pt (10; from 0.1 to 1000), sizeMode?: \"fixed\" (default) | \"pressure\" (Blob Brush Tool Options' Size set to Pressure: the brush is size − sizeVariation wide at the lightest pen pressure and size + sizeVariation at the heaviest, at least 0.1 pt; a stroke without pressure keeps the size), sizeVariation?: pt (0; from 0 to 1000, checked with Fixed too), angle?: ° (0, kept within −180–180: the tip's long axis counter-clockwise from horizontal, kept on the page along the stroke), roundness?: % (100, kept within 0–100: the tip's short axis in percent of its long one, 100 round; 0 is drawn as 0.1), fidelity?: pt (0.01–100; the brush follows the stroke fitted at this tolerance as path.freehand fits a Pencil stroke, and a higher value gives a smoother shape; without it the brush follows every point), merge?: true, mergeOnlySelection?: bool (false: merge with any touching same-color blob; true: only with selected ones), keepSelected?: bool (false: the drawn or merged path is not selected, and the rest of the selection stays; true: it is selected)} filled brush shape, merged with the topmost touching same-color blob and the touching ones next to it in stacking order in its group or layer → {id}",
"{points: [[x,y]…] or [[x,y,pressure]…] (pen pressure 0..1; pen values are checked as path.freehand checks them), size?: pt (10; from 0.1 to 1000), sizeMode?: \"fixed\" (default) | \"pressure\" (Blob Brush Tool Options' Size set to Pressure: the brush is size − sizeVariation wide at the lightest pen pressure and size + sizeVariation at the heaviest, at least 0.1 pt; a stroke without pressure keeps the size), sizeVariation?: pt (0; from 0 to 1000, checked with Fixed too), angle?: ° (0, −180–180: the tip's long axis counter-clockwise from horizontal, kept on the page along the stroke), roundness?: % (100, 0–100: the tip's short axis in percent of its long one, 100 round; 0 is drawn as 0.1), fidelity?: pt (0.01–100; the brush follows the stroke fitted at this tolerance as path.freehand fits a Pencil stroke, and a higher value gives a smoother shape; without it the brush follows every point), merge?: true, mergeOnlySelection?: bool (false: merge with any touching same-color blob; true: only with selected ones), keepSelected?: bool (false: the drawn or merged path is not selected, and the rest of the selection stays; true: it is selected)} filled brush shape, merged with the topmost touching same-color blob and the touching ones next to it in stacking order in its group or layer → {id}. An angle, roundness or fidelity outside its range is rejected with an error, and nothing changes",
has_doc,
blob
),
+25 -13
View File
@@ -200,14 +200,22 @@ pub(crate) fn freehand_brushed(s: &mut Session, p: &Value, brush_name: Option<&s
// The tolerance the stroke is fitted at; with `fit: false` it is not fitted.
let fit_tol = switch_or(p, "fit", true, C)?.then_some(tol);
let closed = switch_or(p, "closed", false, C)?;
let brush = str_param(p, "style") == Some("brush");
let brush = match p.get("style").filter(|v| !v.is_null()).map(Value::as_str) {
None | Some(Some("pencil")) => false,
Some(Some("brush")) => true,
Some(_) => return Err(bad(C, "style must be \"pencil\" or \"brush\"")),
};
// The undo step's name: a stroke painted with a brush is a Paintbrush stroke, whatever its style.
let label = if brush || brush_name.is_some() { "Paintbrush" } else { "Pencil" };
let keep_selected = switch_or(p, "keepSelected", true, C)?;
let filled = switch_or(p, "fill", false, C)?;
if let Some(ext) = p.get("extend").filter(|v| !v.is_null()) {
let id = object_param(ext, "id", C)?.ok_or_else(|| bad(C, "extend needs id"))?;
let at_start = str_param(ext, "end") == Some("start");
let at_start = match ext.get("end").filter(|v| !v.is_null()).map(Value::as_str) {
None | Some(Some("end")) => false,
Some(Some("start")) => true,
Some(_) => return Err(bad(C, "extend end must be \"start\" or \"end\"")),
};
let (pd, _) = path_of(&s.doc()?.doc, id)?;
let si = pd.subpaths.iter().rposition(|s| !s.closed && !s.anchors.is_empty()).ok_or_else(|| bad(C, "path has no open end"))?;
let target = brush_target(&s.doc()?.doc, id);
@@ -488,12 +496,23 @@ pub(super) fn blob(s: &mut Session, p: &Value) -> Result<Value> {
let samples = samples_param(p, "points", C)?;
let size = ranged(p, "size", 10.0, SIZES, C)?;
let angle = number_or(p, "angle", 0.0, C)?;
if !(-180.0..=180.0).contains(&angle) {
return Err(bad(C, "`angle` must be from -180 to 180 degrees"));
}
let roundness = number_or(p, "roundness", 100.0, C)?;
if !angle.is_finite() || !roundness.is_finite() {
return Err(bad(C, "angle and roundness must be finite"));
if !(0.0..=100.0).contains(&roundness) {
return Err(bad(C, "`roundness` must be from 0 to 100%"));
}
// With `fidelity` (pt), the brush follows the stroke fitted by [`fit_freehand`], as a Pencil
// stroke is fitted. Without it, or when the fitted stroke has no length (a short stroke back to
// its start), the brush follows every point.
let fidelity = match p.get("fidelity") {
None | Some(Value::Null) => None,
Some(_) => Some(number_or(p, "fidelity", 0.0, C)?),
};
if fidelity.is_some_and(|f| !(vectorcraft_tools::draw2::MIN_FIDELITY..=100.0).contains(&f)) {
return Err(bad(C, "`fidelity` must be from 0.01 to 100 pt"));
}
let angle = angle.clamp(-180.0, 180.0);
let roundness = roundness.clamp(0.0, 100.0);
let tip = vectorcraft_tools::draw2::blob_tip(angle, roundness);
let squash = tip.inverse();
// Width profiles use distance along the spine, so measure pressure on the same squashed
@@ -515,13 +534,6 @@ pub(super) fn blob(s: &mut Session, p: &Value) -> Result<Value> {
let mapped_pts: Vec<Point> = mapped_samples.into_iter().map(|s| s.pt).collect();
// The widest the brush gets: the area merges look in.
let reach = pressure.as_ref().map_or(size, |(_, v)| size + v);
// With `fidelity` (pt), the brush follows the stroke fitted by [`fit_freehand`], as a Pencil
// stroke is fitted. Without it, or when the fitted stroke has no length (a short stroke back to
// its start), the brush follows every point.
let fidelity = match p.get("fidelity") {
None | Some(Value::Null) => None,
Some(_) => Some(number_or(p, "fidelity", 0.0, C)?.clamp(vectorcraft_tools::draw2::MIN_FIDELITY, 100.0)),
};
let spine = |tol: Option<f64>| {
let path = match tol {
Some(tol) => PathData::single(fit_freehand(&pts, tol, false)),
+86 -2
View File
@@ -86,8 +86,57 @@ fn blob_tip_zero_and_invalid_values_are_safe() {
p[key] = value;
assert!(s.execute("path.blob", &p).is_err(), "{key}: {p}");
}
s.execute("path.blob", &json!({"points": [[100, 200], [300, 200]], "angle": 1e300, "roundness": -1e300, "merge": false})).unwrap();
assert!(paths(&s)[1].1.control_bounds().unwrap().height().is_finite());
let stroke = json!({"points": [[100, 200], [300, 200]], "merge": false});
refuses_with(&mut s, "path.blob", &with(&stroke, json!({"angle": 1e300})), "`angle` must be from -180 to 180 degrees");
refuses_with(&mut s, "path.blob", &with(&stroke, json!({"roundness": -1e300})), "`roundness` must be from 0 to 100%");
assert_eq!(paths(&s).len(), 1);
}
/// `path.blob` refuses an `angle`, `roundness` or `fidelity` outside its range and changes nothing;
/// each end of a range paints, and a key left out or null takes its default (0°, 100% and no fitting).
#[test]
fn blob_brush_rejects_out_of_range_tip_and_fidelity_without_edit() {
let mut s = session();
let stroke = json!({"points": [[100, 100], [300, 100]], "size": 20, "merge": false});
let angle = "`angle` must be from -180 to 180 degrees";
let roundness = "`roundness` must be from 0 to 100%";
let fidelity = "`fidelity` must be from 0.01 to 100 pt";
for (extra, want) in [
(json!({"angle": -180.5}), angle),
(json!({"angle": 181}), angle),
(json!({"angle": 1e300}), angle),
(json!({"roundness": -0.5}), roundness),
(json!({"roundness": 101}), roundness),
(json!({"fidelity": 0.005}), fidelity),
(json!({"fidelity": 0}), fidelity),
(json!({"fidelity": -1}), fidelity),
(json!({"fidelity": 101}), fidelity),
(json!({"fidelity": 1e300}), fidelity),
(json!({"angle": 45, "roundness": 50, "fidelity": 100.5}), fidelity),
] {
refuses_with(&mut s, "path.blob", &with(&stroke, extra), want);
}
assert!(paths(&s).is_empty());
let painted = |s: &mut Session, extra: serde_json::Value| {
let id = NodeId(s.execute("path.blob", &with(&stroke, extra)).unwrap()["id"].as_u64().unwrap());
path(s, id)
};
for extra in [
json!({"angle": -180}),
json!({"angle": 180}),
json!({"roundness": 0}),
json!({"roundness": 100}),
json!({"fidelity": 0.01}),
json!({"fidelity": 100}),
] {
let pd = painted(&mut s, extra.clone());
assert!(pd.control_bounds().is_some_and(|b| b.height().is_finite() && b.height() > 0.0), "{extra}: {pd:?}");
}
let defaults = painted(&mut s, json!({}));
let nulls = painted(&mut s, json!({"angle": null, "roundness": null, "fidelity": null}));
let given = painted(&mut s, json!({"angle": 0, "roundness": 100}));
assert_eq!(nulls, defaults);
assert_eq!(given, defaults);
}
#[test]
@@ -330,6 +379,41 @@ fn pencil_connect_keeps_the_rest_of_a_compound_path_and_refuses_the_extended_pat
assert!(s.execute("path.freehand", &json!({"points": points, "extend": {"id": a.0}, "connect": {"id": a.0}})).is_err());
}
/// `path.freehand` refuses a `style` other than "pencil" or "brush" and an `extend` end other than
/// "start" or "end" and changes nothing; left out or null, the style is "pencil" and the stroke
/// continues the path from its end.
#[test]
fn pencil_refuses_an_unknown_style_or_extend_end() {
let mut s = session();
let a = line(&mut s, 100.0, 100.0, 200.0, 100.0);
let stroke = json!({"points": [[100, 300], [200, 320], [300, 300]]});
for style in [json!("calligraphic"), json!("Brush"), json!(""), json!(1), json!(true)] {
refuses_with(&mut s, "path.freehand", &with(&stroke, json!({ "style": style })), "style must be \"pencil\" or \"brush\"");
}
let from_end = json!({"points": [[200, 100], [250, 150], [300, 100]]});
for end in [json!("middle"), json!("START"), json!(""), json!(0), json!(false)] {
let p = with(&from_end, json!({"extend": {"id": a.0, "end": end}}));
refuses_with(&mut s, "path.freehand", &p, "extend end must be \"start\" or \"end\"");
}
assert_eq!((paths(&s).len(), path(&s, a).anchor_count()), (1, 2), "refused: nothing changed");
for style in [json!("pencil"), json!("brush"), json!(null)] {
s.execute("path.freehand", &with(&stroke, json!({ "style": style }))).unwrap();
}
assert_eq!(paths(&s).len(), 4);
for end in [json!(null), json!("end")] {
let mut s = session();
let a = line(&mut s, 100.0, 100.0, 200.0, 100.0);
s.execute("path.freehand", &with(&from_end, json!({"extend": {"id": a.0, "end": end}}))).unwrap();
let sp = &path(&s, a).subpaths[0];
assert_eq!((sp.anchors[0].p, sp.anchors[sp.anchors.len() - 1].p), (Point::new(100.0, 100.0), Point::new(300.0, 100.0)), "{end}");
}
let mut s = session();
let a = line(&mut s, 100.0, 100.0, 200.0, 100.0);
s.execute("path.freehand", &json!({"points": [[100, 100], [50, 150], [0, 100]], "extend": {"id": a.0, "end": "start"}})).unwrap();
let ends: Vec<Point> = path(&s, a).subpaths[0].anchors.iter().map(|x| x.p).collect();
assert!(ends.contains(&Point::new(0.0, 100.0)) && ends.contains(&Point::new(200.0, 100.0)), "continued from its start: {ends:?}");
}
/// With Keep selected off, a compound path whose direct-selected anchors all lie on the subpath
/// that connect joins on is no longer selected, and Delete then has nothing to delete.
#[test]
+126
View File
@@ -369,3 +369,129 @@ fn scale_text_attributes_keeps_tracked_type_where_it_was() {
assert!((*a - *b).hypot() < 1e-6, "{before:?} {after:?}");
}
}
/// What Scale Text Attributes must leave as it was: the document-space bounds of an area's frame
/// or a path type's path, each line's text, whether the text overflows, and where each glyph
/// starts on the page.
struct Placed {
outline: Option<vectorcraft_geom::Rect>,
lines: Vec<(usize, usize)>,
overflow: bool,
pens: Vec<Point>,
}
fn placed(s: &Session, id: NodeId) -> Placed {
let t = text(s, id);
let lay = vectorcraft_text::layout(vectorcraft_text::FontDb::global(), &t);
let outline = match &t.kind {
vectorcraft_doc::TextKind::Area { frame } => Some(frame),
vectorcraft_doc::TextKind::OnPath { path, .. } => Some(path),
vectorcraft_doc::TextKind::Point => None,
};
Placed {
outline: outline.and_then(|p| p.transformed(t.xf).bounds()),
lines: lay.lines.iter().map(|l| (l.start, l.end)).collect(),
overflow: lay.overflow,
pens: lay.glyphs.iter().map(|g| t.xf * (g.xf * Point::ZERO)).collect(),
}
}
fn same_place(before: &Placed, after: &Placed) {
let (Some(b), Some(a)) = (before.outline, after.outline) else { panic!("no frame or path: {:?} {:?}", before.outline, after.outline) };
for (x, y) in [(b.x0, a.x0), (b.y0, a.y0), (b.x1, a.x1), (b.y1, a.y1)] {
assert!((x - y).abs() < 1e-6, "frame {b:?} became {a:?}");
}
assert_eq!(after.lines, before.lines, "line breaks");
assert_eq!(after.overflow, before.overflow, "overflow");
assert_eq!(before.pens.len(), after.pens.len());
for (b, a) in before.pens.iter().zip(&after.pens) {
assert!((*a - *b).hypot() < 1e-6, "{:?} {:?}", before.pens, after.pens);
}
}
/// #8297: Scale Text Attributes on scaled area type keeps the frame the scale gave it, so the
/// lines break where they did and no text becomes overset. It used to leave the frame at its
/// unscaled size, which then held two lines of the larger type and hid the rest.
#[test]
fn scale_text_attributes_keeps_an_area_frame_and_its_lines() {
for (sx, sy, size) in [(200, 200, 24.0), (200, 100, 12.0), (50, 50, 6.0)] {
let mut s = session();
let id = NodeId(
s.execute(
"text.create",
&json!({"x": 40, "y": 60, "size": 12, "area": {"width": 120, "height": 80}, "text": "Bright river stones mark a gentle path past old trees."}),
)
.unwrap()["id"]
.as_u64()
.unwrap(),
);
s.execute("object.scale", &json!({"sx": sx, "sy": sy, "origin": [0, 0]})).unwrap();
let before = placed(&s, id);
assert!(before.lines.len() >= 3 && !before.overflow, "{sx}x{sy}: {:?}", before.lines);
s.execute("type.scaleTextAttributes", &json!({})).unwrap();
near(text(&s, id).runs[0].style.size, size);
same_place(&before, &placed(&s, id));
if (sx, sy) == (200, 200) {
let f = before.outline.unwrap();
assert_eq!((f.x0.round(), f.y0.round(), f.x1.round(), f.y1.round()), (80.0, 120.0, 320.0, 280.0));
}
s.execute("edit.undo", &json!({})).unwrap();
near(text(&s, id).runs[0].style.size, 12.0);
same_place(&before, &placed(&s, id));
s.execute("edit.redo", &json!({})).unwrap();
same_place(&before, &placed(&s, id));
}
}
/// Type on a path keeps its path: it used to shrink with the scale removed, so the type ran past
/// its end.
#[test]
fn scale_text_attributes_keeps_a_path_types_path() {
let mut s = session();
let pid = s.execute("path.create", &json!({ "d": "M100 300 L300 300" })).unwrap()["id"].as_u64().unwrap();
let id = NodeId(
s.execute("text.createInPath", &json!({"path": pid, "mode": "onPath", "text": "Along the way", "size": 12, "at": [100, 300]})).unwrap()["id"]
.as_u64()
.unwrap(),
);
s.execute("select.set", &json!({"ids": [id.0]})).unwrap();
s.execute("object.scale", &json!({"sx": 200, "origin": [0, 0]})).unwrap();
let before = placed(&s, id);
assert!(!before.overflow);
s.execute("type.scaleTextAttributes", &json!({})).unwrap();
near(text(&s, id).runs[0].style.size, 24.0);
same_place(&before, &placed(&s, id));
}
/// A non-uniform scale on type on a path: only the uniform part is baked and the stretch stays in
/// the transform, so the brackets, which sit at fractions of the path's length, stay where they
/// were. Baking the stretch into the path would move them: on this path, scaled 3 × 2, the length
/// grows from 200 to 500 and not in proportion, so the same fraction lands elsewhere.
#[test]
fn scale_text_attributes_keeps_path_type_on_a_stretched_path_where_it_was() {
let mut s = session();
let pid = s.execute("path.create", &json!({ "d": "M0 0 L100 0 L100 100" })).unwrap()["id"].as_u64().unwrap();
let id = NodeId(
s.execute("text.createInPath", &json!({"path": pid, "mode": "onPath", "text": "Corner", "size": 12, "at": [60, 0]})).unwrap()["id"]
.as_u64()
.unwrap(),
);
s.execute("select.set", &json!({"ids": [id.0]})).unwrap();
s.execute("object.scale", &json!({"sx": 300, "sy": 200, "origin": [0, 0]})).unwrap();
let before = placed(&s, id);
let brackets = |s: &Session| match text(s, id).kind {
vectorcraft_doc::TextKind::OnPath { start, end, .. } => (start, end),
k => panic!("not path type: {k:?}"),
};
let before_brackets = brackets(&s);
s.execute("type.scaleTextAttributes", &json!({})).unwrap();
near(text(&s, id).runs[0].style.size, 24.0);
near(text(&s, id).runs[0].style.h_scale, 100.0);
let left = text(&s, id).style_scale().unwrap();
near(left.points, 1.0);
near(left.horizontal, 1.5);
assert_eq!(brackets(&s), before_brackets);
same_place(&before, &placed(&s, id));
// Only the stretch is left: there is nothing more to bake.
assert!(s.execute("type.scaleTextAttributes", &json!({})).is_err());
}
+167 -2
View File
@@ -9444,7 +9444,8 @@ fn brushes_document() -> Document {
}
/// Brush art `n` as a tree to compare with [`same_tree`]: each object's kind, its anchors and handles,
/// the fills and strokes that paint (a stroke with its width), and its members in order.
/// the fills and strokes that paint (a stroke with its width), its members in order, and its opacity
/// mask's art and options when it has one.
fn art_tree(n: &Node) -> serde_json::Value {
let kind = match &n.kind {
NodeKind::Path { .. } => "path",
@@ -9469,7 +9470,11 @@ fn art_tree(n: &Node) -> serde_json::Value {
})
.collect();
let members: Vec<serde_json::Value> = n.children().map(|c| c.iter().map(|m| art_tree(m)).collect()).unwrap_or_default();
serde_json::json!({"kind": kind, "anchors": anchors, "paints": paints, "members": members})
let mut tree = serde_json::json!({"kind": kind, "anchors": anchors, "paints": paints, "members": members});
if let Some(m) = &n.extras().mask {
tree["mask"] = serde_json::json!({"art": art_tree(&m.art), "options": [m.clip, m.invert, m.disabled, m.linked]});
}
tree
}
/// Are trees `a` and `b` ([`art_tree`]) the same but for numbers within the written numbers'
@@ -9667,6 +9672,166 @@ fn an_art_brush_whose_art_doesnt_bend_keeps_its_paths_look() {
assert!(same_tree(&art_tree(&got.art), &art_tree(&want.art)), "{:#?}", got.art);
}
/// An opacity mask whose art is rectangle `r` filled in `paint`, with the options given.
fn rect_mask(id: u64, r: Rect, paint: Paint, clip: bool, invert: bool, linked: bool) -> OpacityMask {
let art = Node::path(vectorcraft_doc::NodeId(id), shapes::rectangle(r), Appearance::basic(paint, Paint::None, 0.0));
OpacityMask { art: Arc::new(art), clip, invert, disabled: false, linked }
}
/// `levels` white rectangle masks that clip, each but the last holding the next in its art.
fn mask_chain(levels: u32) -> Option<Box<OpacityMask>> {
(0..levels).fold(None, |inner, i| {
let mut m = rect_mask(100 + u64::from(i), Rect::new(0.0, 0.0, 30.0 - f64::from(i), 8.0), solid(Color::WHITE), true, false, true);
Arc::make_mut(&mut m.art).extras_mut().mask = inner;
Some(Box::new(m))
})
}
/// [`brush_art_node`] with opacity masks: on the group, a mid-gray rectangle that clips; on the wide
/// block, a white rectangle inverted without clipping. Both masks are `linked` or not.
fn masked_brush_art(linked: bool) -> Node {
let mut art = brush_art_node();
if let Some(c) = art.children_mut() {
let wide = rect_mask(10, Rect::new(0.0, 0.0, 20.0, 4.0), solid(Color::WHITE), false, true, linked);
Arc::make_mut(&mut c[0]).extras_mut().mask = Some(Box::new(wide));
}
art.extras_mut().mask = Some(Box::new(rect_mask(11, Rect::new(0.0, 0.0, 30.0, 8.0), solid(Color::rgb(0.5, 0.5, 0.5)), true, false, linked)));
art
}
/// Scatter and Art brushes whose art holds opacity masks come back in the Brushes panel with their
/// settings, the masks' art in place with its paint, and the masks' options: masks on the art and on
/// a member, masks that don't move with their objects, and masks seven deep in one another's art. A
/// path with the masked Art brush comes back as its drawn look, with the stroke warning.
#[test]
fn scatter_and_art_brush_mask_art_round_trips() {
use vectorcraft_brush::{ArtBrush, Brush, BrushKind, Scatter};
let mut deep = brush_art_node();
deep.extras_mut().mask = mask_chain(7);
let lib = vec![
Brush { name: "Masked spray".into(), kind: BrushKind::Scatter(Scatter { art: masked_brush_art(true), ..Scatter::default() }) },
Brush { name: "Masked ribbon".into(), kind: BrushKind::Art(ArtBrush { art: masked_brush_art(true), ..ArtBrush::default() }) },
Brush { name: "Unlinked spray".into(), kind: BrushKind::Scatter(Scatter { art: masked_brush_art(false), ..Scatter::default() }) },
Brush { name: "Unlinked ribbon".into(), kind: BrushKind::Art(ArtBrush { art: masked_brush_art(false), ..ArtBrush::default() }) },
Brush { name: "Deep spray".into(), kind: BrushKind::Scatter(Scatter { art: deep.clone(), ..Scatter::default() }) },
Brush { name: "Deep ribbon".into(), kind: BrushKind::Art(ArtBrush { art: deep, ..ArtBrush::default() }) },
];
let mut doc = Document::new(300.0, 200.0);
vectorcraft_brush::store(&mut doc, &lib);
brushed(&mut doc, "Masked ribbon", (20.0, 120.0), (280.0, 150.0), 1.0);
let out = export_ai_editing(&doc, &opts()).unwrap();
assert!(!out.warnings.iter().any(|w| w == writer::BRUSHES || w == writer::DEEP_MASKS), "{:?}", out.warnings);
assert!(out.warnings.iter().any(|w| w == writer::STROKES), "{:?}", out.warnings);
assert_eq!(program(&doc).matches("%AI8_BeginBrushPattern").count(), lib.len());
let back = read_back(&doc);
assert!(matches!(back.layers[0].children().unwrap()[0].kind, NodeKind::Group { .. }), "the path's drawn look");
let got = vectorcraft_brush::library(&back);
assert_eq!(got.iter().map(|b| b.name.as_str()).collect::<Vec<_>>(), lib.iter().map(|b| b.name.as_str()).collect::<Vec<_>>());
let none = || Node::group(vectorcraft_doc::NodeId(0), vec![]);
for (g, w) in got.iter().zip(&lib) {
let name = &w.name;
let (ga, wa) = match (&g.kind, &w.kind) {
(BrushKind::Scatter(gs), BrushKind::Scatter(ws)) => {
let settings = |s: &Scatter| Scatter { art: none(), modes: Some(s.modes()), ..s.clone() };
assert_eq!(settings(gs), settings(ws), "{name}");
(&gs.art, &ws.art)
}
(BrushKind::Art(ga), BrushKind::Art(wa)) => {
assert_eq!(ArtBrushOptions::of(ga), ArtBrushOptions::of(wa), "{name}");
(&ga.art, &wa.art)
}
_ => panic!("{name}: {g:?}"),
};
let (gt, wt) = (art_tree(ga), art_tree(wa));
assert!(same_tree(&gt, &wt), "{name}: {gt:#} for {wt:#}");
}
}
/// Brushes whose mask art the reader wouldn't read back as it is are left out with a warning, beside
/// a brush that comes back: a Scatter brush whose art's mask is a gradient, one whose art holds
/// masks eight deep in one another's art (deeper than the editing data writes masks), one whose
/// mask's art is a compound path of 26,500 members of two squares each, which the reader reads as
/// 53,000 paths, more art than it copies into one file's brushes, and one whose art is a compound
/// path with a mask on a member (a compound path is written as one path, without its members' masks).
#[test]
fn brushes_whose_mask_art_isnt_read_back_are_left_out() {
use vectorcraft_brush::{Brush, BrushKind, Scatter};
let keep = Brush { name: "Masked spray".into(), kind: BrushKind::Scatter(Scatter { art: masked_brush_art(true), ..Scatter::default() }) };
let mut gradient = brush_art_node();
let ramp = gradient_paint(sunset(), None, None);
gradient.extras_mut().mask = Some(Box::new(rect_mask(11, Rect::new(0.0, 0.0, 30.0, 8.0), ramp, true, false, true)));
let mut deep = brush_art_node();
deep.extras_mut().mask = mask_chain(8);
let square = |i: u32| {
let (x, y) = (f64::from(i % 400) * 2.0, f64::from(i / 400) * 2.0);
shapes::rectangle(Rect::new(x, y, x + 1.0, y + 1.0)).subpaths
};
let members = (0..26_500)
.map(|m| {
let path = PathData::new((0..2).flat_map(|k| square(m * 2 + k)).collect());
Arc::new(Node::path(vectorcraft_doc::NodeId(21), path, Appearance::basic(solid(Color::WHITE), Paint::None, 0.0)))
})
.collect();
let mut squares = Node::path(vectorcraft_doc::NodeId(20), PathData::default(), Appearance::basic(solid(Color::WHITE), Paint::None, 0.0));
squares.kind = NodeKind::Compound { children: members, rule: FillRule::NonZero };
let mut heavy = brush_art_node();
heavy.extras_mut().mask = Some(Box::new(OpacityMask { art: Arc::new(squares), clip: true, invert: false, disabled: false, linked: true }));
let mut member = brush_art_node();
member.kind = match member.kind {
NodeKind::Group { mut children, .. } => {
let mask = rect_mask(10, Rect::new(0.0, 0.0, 20.0, 4.0), solid(Color::WHITE), true, false, true);
Arc::make_mut(&mut children[0]).extras_mut().mask = Some(Box::new(mask));
NodeKind::Compound { children, rule: FillRule::NonZero }
}
kind => kind,
};
member.appearance = Appearance::basic(black_fill(), Paint::None, 0.0).into();
let cases = [
("gradient mask", gradient),
("masks eight deep", deep),
("mask art past the reader's limit", heavy),
("mask on a compound path's member", member),
];
for (why, art) in cases {
let mut doc = Document::new(300.0, 200.0);
let lib = vec![keep.clone(), Brush { name: why.into(), kind: BrushKind::Scatter(Scatter { art, ..Scatter::default() }) }];
vectorcraft_brush::store(&mut doc, &lib);
let out = export_ai_editing(&doc, &opts()).unwrap();
assert!(out.warnings.iter().any(|w| w == writer::BRUSHES), "{why}: {:?}", out.warnings);
assert!(!out.warnings.iter().any(|w| w == writer::DEEP_MASKS), "{why}: {:?}", out.warnings);
let names: Vec<String> = vectorcraft_brush::library(&read_back(&doc)).into_iter().map(|b| b.name).collect();
assert_eq!(names, ["Masked spray"], "{why}");
assert_eq!(program(&doc).matches("%AI8_BeginBrushPattern").count(), 1, "{why}");
}
}
/// A brush's mask art is written as the brush holds it when an object of the layers' mask art with
/// the same id keeps a live effect as an art style: the brush's mask comes back as its own plain
/// rectangle, without the layers' object's effect or geometry.
#[test]
fn a_brushs_mask_art_isnt_written_as_a_styled_object_with_its_id() {
use vectorcraft_brush::{Brush, BrushKind, Scatter};
let offset = fx("path.offsetPath", serde_json::json!({"offset": 8.0, "joins": "miter", "miterLimit": 4.0}));
let mut id = None;
let mut doc = masked_image(|doc| {
let grown = styled_rect(doc, "Grown", Rect::new(60.0, 30.0, 110.0, 70.0), solid(Color::rgb(0.0, 0.0, 0.0)), Paint::None, vec![offset]);
id = Some(grown.id);
grown
});
let id = id.expect("the mask's art");
let mut art = brush_art_node();
art.extras_mut().mask = Some(Box::new(rect_mask(id.0, Rect::new(0.0, 0.0, 30.0, 8.0), solid(Color::WHITE), true, false, true)));
let lib = vec![Brush { name: "Masked spray".into(), kind: BrushKind::Scatter(Scatter { art, ..Scatter::default() }) }];
vectorcraft_brush::store(&mut doc, &lib);
let got = vectorcraft_brush::library(&read_back(&doc));
let [Brush { kind: BrushKind::Scatter(s), .. }] = got.as_slice() else { panic!("{got:?}") };
let BrushKind::Scatter(want) = &lib[0].kind else { panic!("a Scatter brush") };
let m = s.art.extras().mask.as_deref().unwrap_or_else(|| panic!("the mask is read: {:#?}", s.art));
assert!(m.art.appearance.effects.is_empty(), "{:?}", m.art.appearance.effects);
let (gt, wt) = (art_tree(&s.art), art_tree(&want.art));
assert!(same_tree(&gt, &wt), "{gt:#} for {wt:#}");
}
/// Settings the other tests don't use come back: a Calligraphic brush varying with tilt and bearing,
/// a Scatter brush keeping its art's colors whose rotation doesn't follow the path, and brushes whose
/// modes aren't given (the reader gives them, the same ones).
+38 -8
View File
@@ -23,7 +23,7 @@ use super::{Writer, Xy};
use crate::ai_ops;
use crate::ps;
pub(in crate::ai_editing) const BRUSHES: &str = "Pattern and Bristle brushes, Art brushes that don't run their art from left to right, that overlap or whose width follows the pen, Scatter and Art brushes in Tints and Shades or Hue Shift, brushes whose art holds an empty path or group or more than paths, compound paths and groups with one solid fill and one plain stroke each, brushes whose names hold a slash or repeat an earlier brush's name, brushes that would open with other settings, brushes past the number or the amount of art one file's brushes can hold, and every brush on a large canvas are left out of the Brushes panel in the editing data for other apps";
pub(in crate::ai_editing) const BRUSHES: &str = "Pattern and Bristle brushes, Art brushes that don't run their art from left to right, that overlap or whose width follows the pen, Scatter and Art brushes in Tints and Shades or Hue Shift, brushes whose art or its opacity masks' art holds an empty path or group or more than paths, compound paths and groups with one solid fill and one plain stroke each, or opacity masks on a compound path's members or more than seven deep in one another's art, brushes whose names hold a slash or repeat an earlier brush's name, brushes that would open with other settings, brushes past the number or the amount of art one file's brushes can hold, and every brush on a large canvas are left out of the Brushes panel in the editing data for other apps";
/// Most brushes written (the reader's limit).
const MAX_BRUSHES: usize = 4096;
@@ -213,17 +213,38 @@ fn art_params(a: &ArtBrush, art: &str) -> Option<String> {
Some(format!("2 / {art}/ / / / / 0 0/ 5 0 0 0 / {}", nums6(&numbers)))
}
/// Most opacity masks in one another's art in a brush's art: a brush's art section writes its art
/// one level inside, and masks at [`super::MAX_NEST`] levels are left out ([`super::DEEP_MASKS`]).
const MAX_MASK_NEST: u32 = super::MAX_NEST - 1;
/// Is `art` written as the reader reads it back, within a brush: paths and compound paths with
/// points and groups with members (not clipping, without paint of their own), each opaque in the
/// normal blending mode, without effects or opacity masks, with at most one fill and one plain
/// stroke (no brush, width profile, arrowheads, alignment off the path or dashes fitted to corners)
/// over it, each in a color or none? A path without points isn't written ([`Writer::plain_object`]).
/// normal blending mode, without effects, with at most one fill and one plain stroke (no brush,
/// width profile, arrowheads, alignment off the path or dashes fitted to corners) over it, each in a
/// color or none, and opacity masks whose art is such art too, at most [`MAX_MASK_NEST`] deep and
/// none on a compound path's members? A path without points isn't written
/// ([`Writer::plain_object`]).
fn plain_art(art: &Node) -> bool {
plain_within(art, MAX_MASK_NEST)
}
/// Does no object of `art` have an opacity mask?
fn unmasked(art: &Node) -> bool {
let mut unmasked = true;
art.walk(&mut |n| unmasked &= n.extras().mask.is_none());
unmasked
}
/// [`plain_art`] with at most `masks` opacity masks in one another's art.
fn plain_within(art: &Node, masks: u32) -> bool {
let mut plain = true;
art.walk(&mut |n| {
let kind = match &n.kind {
NodeKind::Path { path, guide: false, clipping: false, .. } => path.subpaths.iter().any(|sp| !sp.anchors.is_empty()),
NodeKind::Compound { .. } => super::compound_path(n).subpaths.iter().any(|sp| !sp.anchors.is_empty()),
// A compound path is written as one path of its members' subpaths, without their masks.
NodeKind::Compound { children, .. } => {
children.iter().all(|c| unmasked(c)) && super::compound_path(n).subpaths.iter().any(|sp| !sp.anchors.is_empty())
}
NodeKind::Group { children, clip: false } => !children.is_empty(),
_ => false,
};
@@ -247,7 +268,7 @@ fn plain_art(art: &Node) -> bool {
&& order
&& quiet
&& n.appearance.effects.is_empty()
&& n.extras().mask.is_none()
&& n.extras().mask.as_deref().is_none_or(|m| masks > 0 && plain_within(&m.art, masks - 1))
&& n.opacity >= 1.0
&& n.blend == BlendMode::Normal;
});
@@ -258,8 +279,13 @@ fn plain_art(art: &Node) -> bool {
/// compound path with the subpaths of all its members as one path ([`super::compound_path`]), is
/// written as one path when it has one subpath with points and as a compound path when it has more
/// ([`Writer::plain_object`]); the reader reads that compound path as one path for each subpath,
/// each with the object's paint.
/// each with the object's paint. An opacity mask's art is written shown ([`Writer::mask`]).
fn as_read(art: &mut Node) {
if let Some(m) = art.extras_if_any().and_then(|e| e.mask.as_mut()) {
let mask_art = Arc::make_mut(&mut m.art);
mask_art.visible = true;
as_read(mask_art);
}
let (subpaths, rule) = match &art.kind {
NodeKind::Path { path, rule, .. } => (path.subpaths.clone(), *rule),
NodeKind::Compound { rule, .. } => (super::compound_path(art).subpaths, *rule),
@@ -390,7 +416,7 @@ impl Writer<'_> {
}
let mut read = a.clone();
if *to_section == Affine::IDENTITY {
read.transform(Affine::FLIP_Y, false);
crate::import::turn_brush_art_over(&mut read);
}
as_read(&mut read);
Some(read)
@@ -427,6 +453,9 @@ impl Writer<'_> {
// The art is the brush's own: not on `%_` lines, in a drawn look or in a symbol that
// first uses the brush.
(std::mem::take(&mut self.hidden), std::mem::take(&mut self.in_look), std::mem::take(&mut self.in_symbol)),
// The layers' objects written with art styles, by id: none of them is the brush's art,
// which may hold objects with the same ids.
std::mem::take(&mut self.styled),
);
(self.to_art, self.grad_space, self.canvas, self.block_end) = (to_section, to_section, to_section, usize::MAX);
self.state(false, false);
@@ -462,6 +491,7 @@ impl Writer<'_> {
(self.clip, self.shown),
(self.block_start, self.block_end),
(self.hidden, self.in_look, self.in_symbol),
self.styled,
) = saved;
let text = std::mem::replace(&mut self.body, body);
if !std::mem::replace(&mut self.warnings, warnings).is_empty() {
+1 -1
View File
@@ -93,7 +93,7 @@ pub(crate) use ai::{
BLEND_BUDGET, BLEND_PLUGIN, BRUSH_MANAGER, BrushesRead, DEFORM_PLUGIN, EnvelopeGridPoint, MAX_BLEND_KEYS, MAX_BLEND_OBJECTS,
MAX_CHECKED as ENVELOPE_CHECKS, MAX_EDITING_OBJECTS, MAX_GRADIENT_STOPS, MAX_LISTED, MAX_LISTED_NAME, MAX_SYMBOLS, blend_reads,
brush_plugin_name, brushes_kept, envelope_outline, envelope_upright, read_art_style, read_brush_object, read_style_list, style_moves_with,
symbol_art_member, warp_number,
symbol_art_member, turn_brush_art_over, warp_number,
};
#[cfg(test)]
pub(crate) use ai::{ENVELOPE_DRAWN, ENVELOPE_TYPE_DRAWN};
+3 -1
View File
@@ -35,7 +35,9 @@ use super::lex::find;
use crate::ps;
pub(crate) use blend::{MAX_BLEND_OBJECTS, MAX_KEYS as MAX_BLEND_KEYS, PLUGIN as BLEND_PLUGIN, blend_reads};
pub(crate) use brush::{BrushesRead, MANAGER_NAME as BRUSH_MANAGER, brushes_kept, plugin_name as brush_plugin_name, read_brush_object};
pub(crate) use brush::{
BrushesRead, MANAGER_NAME as BRUSH_MANAGER, brushes_kept, plugin_name as brush_plugin_name, read_brush_object, turn_over as turn_brush_art_over,
};
pub(crate) use envelope::DRAWN as ENVELOPE_DRAWN;
pub(crate) use envelope::MAX_CHECKED;
pub(crate) use envelope::TYPE_DRAWN as ENVELOPE_TYPE_DRAWN;
+26 -1
View File
@@ -58,6 +58,7 @@
//! at None so the art keeps its own colors.
use std::collections::{HashMap, HashSet};
use std::sync::Arc;
use kurbo::Affine;
use vectorcraft_brush::{ArtBrush, ArtScale, Bristle, Brush, BrushKind, Calligraphic, Colorization, Scatter, Variation};
@@ -474,6 +475,30 @@ pub(super) fn parse_tool_object(kind: Tool, name: &str, params: &str) -> Result<
Ok(BrushDraft { name: name.to_string(), kind })
}
/// Turn `art` over (y for -y) with the art of all its opacity masks, those that don't move with
/// their objects too: the art changes the space it is in, and no object moves over its mask.
pub(crate) fn turn_over(art: &mut Node) {
art.transform(Affine::scale_non_uniform(1.0, -1.0), false);
turn_unlinked_masks(art);
}
/// Turn over the art of the opacity masks in `n` that a transform of `n` leaves in place (the masks
/// that don't move with their objects), in members and in other masks' art too.
fn turn_unlinked_masks(n: &mut Node) {
if let Some(m) = n.extras_if_any().and_then(|e| e.mask.as_mut()) {
let linked = m.linked;
let art = Arc::make_mut(&mut m.art);
if linked {
turn_unlinked_masks(art);
} else {
turn_over(art);
}
}
for c in n.children_mut().into_iter().flatten() {
turn_unlinked_masks(Arc::make_mut(c));
}
}
/// The brushes of `drafts`, their art from the sections `art` (by name), in the brush manager's
/// `order` (brushes it doesn't list after those it does, in the order of their objects), each
/// kept within its ranges → the brushes and how many were left out: those whose art isn't read,
@@ -553,7 +578,7 @@ pub(super) fn finish_brushes_within(
DraftKind::Art { mut brush, art: name, settings } => copy(&name).map(|mut a| {
// The side of the section with y up draws on the right of the path, and a brush
// draws art's y (down here) on the left of the path.
a.transform(Affine::scale_non_uniform(1.0, -1.0), false);
turn_over(&mut a);
if let ArtScale::BetweenGuides { start, end } = &mut brush.scale {
// Guides that leave no art between them stretch the whole art.
let length = a.geometric_bounds().map_or(0.0, |b| b.width());
+24
View File
@@ -6462,6 +6462,30 @@ fn a_brushs_opacity_mask_art_takes_ids_of_the_document() {
assert_eq!(unique.len(), all.len(), "{all:?}");
}
/// An Art brush's art is turned over with the art of its opacity mask, whether the mask moves with
/// its object or not: the mask's art stays over the part of the object it is over in the section.
#[test]
fn an_art_brushs_opacity_mask_art_turns_over_with_its_object() {
let mut read = vec![];
for linked in [true, false] {
let mask_art: String = format!("1 g\n{}f\n", rect_path(0.0, 0.0, 40.0, 3.0)).lines().map(|l| format!("%_{l}\n")).collect();
let options = format!("%_1 /Bool (Clipping) ,\n%_{} /Bool (Linked) ,\n", u8::from(linked));
let mask = format!("%_/ArtDictionary :\n%_/Mask :\n%_X=\n{mask_art}%_X+\n%_(Art) ,\n{options}%_; (AI9_Mask) ,\n%_;\n");
let section = format!("%AI8_BeginBrushPattern\n(Ribbon art)\n0 A\n0 g\n{}f\n{mask}%AI8_EndBrushPattern\n", rect_path(0.0, 0.0, 40.0, 8.0));
let shape = format!("{RED}{}f\n", rect_path(0.0, 0.0, 10.0, 10.0));
let r = read_ok(&format!("{section}{}{}", plugin_object(ART_BRUSH, "Ribbon", RIBBON), layer(&shape)));
let lib = vectorcraft_brush::library(&r.doc);
let vectorcraft_brush::BrushKind::Art(brush) = brush_named(&lib, "Ribbon") else { panic!("art: {:?}", r.warnings) };
let m = brush.art.extras().mask.as_deref().unwrap_or_else(|| panic!("the mask is read: {:#?}", brush.art));
assert_eq!(m.linked, linked);
let (object, over) = (brush.art.geometric_bounds().unwrap(), m.art.geometric_bounds().unwrap());
assert!((object.height() - 8.0).abs() < 1e-6 && (over.height() - 3.0).abs() < 1e-6, "linked {linked}: {over:?} over {object:?}");
assert!(over.y0 > object.y0 - 1e-6 && over.y1 < object.y1 + 1e-6, "linked {linked}: {over:?} over {object:?}");
read.push((object, over));
}
assert_eq!(read[0], read[1], "a mask is in the same place whether it moves with its object or not");
}
/// An art styles section inside a symbol's, a pattern's or a brush's art is skipped: the file's own
/// art styles still style the layers' objects read after the definition.
#[test]
+20 -3
View File
@@ -6,7 +6,7 @@
//! transparency (the app flattens it before writing), no layers, PDF 1.3.
//! - PDF/X-3:2002: colours are ICC-based (always tagged), no transparency, no layers, PDF 1.3.
//! - PDF/X-4:2010: transparency and layers are kept, colours are tagged, PDF 1.6 at most, and the
//! XMP metadata names the standard too.
//! XMP metadata names the standard too and carries `xmp:MetadataDate`.
//! - All of them: a `/GTS_PDFX` output intent (blank, the CMYK profile in effect, embedded), a
//! TrimBox on every page (the artboard), `/Trapped` True or False, `/GTS_PDFXVersion` in the
//! document information, a title and dates, embedded fonts (or text as outlines), no editing
@@ -120,8 +120,9 @@ pub(crate) fn info_entries(standard: Standard) -> String {
}
/// Edit the XMP metadata of a PDF/X file (the catalog's `/Metadata` stream; `root` is the
/// catalog dictionary's contents) into `patch`: PDF/X-4 adds the standard, Trapped and a version
/// id (PDF 1.3 files say so in [`finish`]). Files without metadata are left as they are.
/// catalog dictionary's contents) into `patch`: PDF/X-4 adds the standard, Trapped, a version id
/// and the metadata date (PDF 1.3 files say so in [`finish`]). Files without metadata are left as
/// they are.
pub(crate) fn xmp(pdf: &[u8], xref: &Xref, root: (usize, usize), patch: &mut Patch, standard: Standard, trapped: bool) -> Result<(), PdfError> {
if !standard.is_pdfx() {
return Ok(());
@@ -145,6 +146,22 @@ pub(crate) fn xmp(pdf: &[u8], xref: &Xref, root: (usize, usize), patch: &mut Pat
"<pdfxid:GTS_PDFXVersion xmlns:pdfxid=\"http://www.npes.org/pdfx/ns/id/\">{version}</pdfxid:GTS_PDFXVersion><pdf:Trapped>{trapped}</pdf:Trapped><xmpMM:VersionID>1</xmpMM:VersionID>"
);
edits.push((close, close, props.into_bytes()));
// When the packet has no `<xmp:MetadataDate>` element, this adds one after the writer's
// `<xmp:ModifyDate>` element with the same value. The search expects the writer's form:
// properties written as elements with the `xmp` prefix, and `<` in text written as `&lt;`.
// The writer's description declares the `xmp` prefix there, and
// [`crate::post::modification_date`] keeps the two dates equal.
if find(xml, b"<xmp:MetadataDate>", 0).is_none()
&& let Some(at) = find(xml, b"<xmp:ModifyDate>", 0).map(|i| i + b"<xmp:ModifyDate>".len())
&& let Some(to) = find(xml, b"</xmp:ModifyDate>", at)
{
let date = xml.get(at..to).ok_or_else(bad)?;
let mut prop = b"<xmp:MetadataDate>".to_vec();
prop.extend_from_slice(date);
prop.extend_from_slice(b"</xmp:MetadataDate>");
let after = to + b"</xmp:ModifyDate>".len();
edits.push((after, after, prop));
}
}
// Every edit grows the stream (or keeps its length).
let grown: usize = edits.iter().map(|(s, e, new)| new.len().saturating_sub(e - s)).sum();
+3 -2
View File
@@ -84,8 +84,9 @@ pub(crate) fn user_units(pdf: Vec<u8>, units: &[f64]) -> Result<Vec<u8>, PdfErro
/// `pdf` dated as modified at `modified` (Unix seconds, UTC), its creation dates kept: the
/// document information's `/ModDate` (a PDF date, ISO 32000-1 §7.9.4) and every `xmp:ModifyDate`,
/// `xmp:MetadataDate` and `stEvt:when` of the catalog's XMP metadata (ISO 8601 dates), in UTC as
/// the PDF writer writes the creation date. The writer gives `/ModDate`, `xmp:ModifyDate` and
/// `stEvt:when` the creation date.
/// the PDF writer writes the creation date. The writer gives `/ModDate`, `xmp:ModifyDate`,
/// `stEvt:when` and, in a PDF/X-4 file, `xmp:MetadataDate` ([`crate::pdfx::xmp`]) the creation
/// date.
pub(crate) fn modification_date(pdf: Vec<u8>, modified: i64) -> Result<Vec<u8>, PdfError> {
let failed = |why: &str| PdfError::Write(format!("can't write the file's modification date: {why}"));
let Parsed { xref, objects, trailer, root, .. } = linearize::parse(&pdf).map_err(failed)?;
+45
View File
@@ -42,6 +42,51 @@ fn text(pdf: &[u8]) -> String {
String::from_utf8_lossy(pdf).into_owned()
}
/// The XMP packet of `pdf`, read as its stream's `/Length` says: the packet's end must be inside
/// those bytes and nothing but the end of line may follow them before `endstream`.
fn xmp_packet(pdf: &[u8]) -> String {
use crate::lab_spot::{find, rfind};
let begin = find(pdf, b"<?xpacket begin", 0).expect("an XMP packet");
let head = &pdf[..begin];
let obj = rfind(head, b" obj").expect("the packet's object");
let dict = &head[obj..];
let at = find(dict, b"/Length ", 0).expect("its length") + b"/Length ".len();
let digits: Vec<u8> = dict[at..].iter().copied().take_while(u8::is_ascii_digit).collect();
let length: usize = String::from_utf8(digits).unwrap().parse().unwrap();
let mut data = obj + rfind(dict, b"stream").unwrap() + b"stream".len();
data += pdf[data..].iter().take(2).take_while(|b| matches!(b, b'\r' | b'\n')).count();
let stream = &pdf[data..data + length];
let close = find(stream, b"<?xpacket end=", 0).expect("the packet ends inside the stream's length");
assert!(find(stream, b"?>", close).is_some(), "the packet ends inside the stream's length");
let rest = String::from_utf8_lossy(&pdf[data + length..]);
assert!(rest.trim_start_matches(['\r', '\n']).starts_with("endstream"), "the stream ends at its length");
String::from_utf8(stream.to_vec()).unwrap()
}
/// The value of the XMP element `tag` in `xmp`.
fn xmp_value<'a>(xmp: &'a str, tag: &str) -> Option<&'a str> {
let open = format!("<{tag}>");
let rest = &xmp[xmp.find(&open)? + open.len()..];
Some(&rest[..rest.find(&format!("</{tag}>"))?])
}
#[test]
fn pdfx4_metadata_has_a_metadata_date_equal_to_the_modification_date() {
let d = doc(&[Color::cmyk(0.0, 1.0, 1.0, 0.0)]);
// Dated by the writer (created), then dated again after writing (modified later).
for modified in [None, Some(1_800_000_000)] {
let mut o = opts(Standard::PdfX4, |_| {});
o.modified = modified;
let xmp = xmp_packet(&export(&d, &o).unwrap());
let modify = xmp_value(&xmp, "xmp:ModifyDate").expect("xmp:ModifyDate");
assert_eq!(xmp_value(&xmp, "xmp:MetadataDate"), Some(modify), "{modified:?}: {xmp}");
assert_eq!(xmp.matches("<xmp:MetadataDate>").count(), 1, "{modified:?}");
if modified.is_some() {
assert!(modify.starts_with("2027-01-15T"), "the later date: {modify}");
}
}
}
#[test]
fn each_standard_writes_its_header_output_intent_boxes_and_identification() {
let mut d = doc(&[Color::cmyk(0.0, 1.0, 1.0, 0.0), Color::rgb(0.2, 0.4, 0.9)]);
+3 -6
View File
@@ -236,6 +236,7 @@ impl VectorcraftApp {
let ime_target = crate::ime::target(&mut self.session, ime_view);
let ime_before = crate::ime::stamp(&mut self.session, ime_view);
let cursor_settings = (self.session.caps_lock, self.session.prefs.use_precise_cursors);
let spot_base = panels::color_guide::before_command(self);
let r = self.session.execute(id, &params).map_err(|e| e.to_string());
let r = panels::actions::after_recorded_command(self, r);
if r.is_ok() && cursor_settings != (self.session.caps_lock, self.session.prefs.use_precise_cursors) {
@@ -267,12 +268,8 @@ impl VectorcraftApp {
{
self.ui.status = w.to_string();
}
// A renamed spot color swatch stays the Color Guide's base.
if id == "swatch.edit"
&& let (Some(from), Some(to)) = (params["name"].as_str(), v["name"].as_str())
{
crate::panels::color_guide::swatch_renamed(self, from, to);
}
// A renamed spot color swatch stays the Color Guide's base; a deleted one ends the link.
panels::color_guide::after_command(self, id, &params, v, spot_base);
if id == "file.new" {
self.ui.status.clear();
// New Document's Pixel preview mode (Overprint Preview is the engine's).
+5
View File
@@ -7937,6 +7937,11 @@ breakText Glyphs Glifs
@msg Some islands could not be joined to the area around the art Algunes illes no s’han pogut unir a l’àrea que envolta la il·lustració
@msg `width` must be from {lo} to {hi} pt `width` ha d’estar entre {lo} i {hi} pt
@msg `angle` must be from -180 to 180 degrees `angle` ha d’estar entre -180 i 180 graus
@msg `roundness` must be from 0 to 100% `roundness` ha d’estar entre 0 i 100%
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` ha d’estar entre 0.01 i 100 pt
@msg style must be "pencil" or "brush" style ha de ser "pencil" o "brush"
@msg extend end must be "start" or "end" l’extrem d’extend ha de ser "start" o "end"
@msg connect end must be "start" or "end" l’extrem de connect ha de ser "start" o "end"
@msg `roundness` must be from 1 to 100% `roundness` ha d’estar entre 1 i 100%
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` ha de ser un nombre enter d’1 a {MAX_BRIDGES_PER_ISLAND}
Weed Box and Lines… Caixa i línies de pelat…
Can't render this file because it contains an unexpected character in line 2 and column 73.
+5 -1
View File
@@ -8031,6 +8031,11 @@ breakText Glyphs Glyfy
@msg Some islands could not be joined to the area around the art Některé ostrůvky nebylo možné připojit k oblasti kolem kresby
@msg `width` must be from {lo} to {hi} pt `width` musí být od {lo} do {hi} pt
@msg `angle` must be from -180 to 180 degrees `angle` musí být od -180 do 180 stupňů
@msg `roundness` must be from 0 to 100% `roundness` musí být od 0 do 100 %
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` musí být od 0.01 do 100 pt
@msg style must be "pencil" or "brush" style musí být "pencil" nebo "brush"
@msg extend end must be "start" or "end" konec extend musí být "start" nebo "end"
@msg connect end must be "start" or "end" konec connect musí být "start" nebo "end"
@msg `roundness` must be from 1 to 100% `roundness` musí být od 1 do 100 %
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` musí být celé číslo od 1 do {MAX_BRIDGES_PER_ISLAND}
Weed Box and Lines… Rámeček a linie pro vybírání…
@@ -8552,7 +8557,6 @@ breakText Glyphs Glyfy
@msg anchor `smooth` must be true or false `smooth` kotevního bodu musí být true nebo false
@msg anchor `{key}` must be [x, y] `{key}` kotevního bodu musí být [x, y]
@msg anchor `{key}` must be a number `{key}` kotevního bodu musí být číslo
@msg angle and roundness must be finite úhel a zaoblení musí být konečné
@msg angles must be a list as long as pins (degrees or null) angles musí být seznam stejně dlouhý jako pins (stupně nebo null)
@msg appearance must be flat|center|edge appearance musí být flat|center|edge
@msg apply is "fill" or "stroke", not `{other}` apply je "fill" nebo "stroke", ne `{other}`
Can't render this file because it is too large.
+5
View File
@@ -726,6 +726,11 @@ liquify-list-end {0}, {1} {0} og {1}
@msg Some islands could not be joined to the area around the art Nogle øer kunne ikke forbindes med området omkring grafikken
@msg `width` must be from {lo} to {hi} pt `width` skal være fra {lo} til {hi} pt
@msg `angle` must be from -180 to 180 degrees `angle` skal være fra -180 til 180 grader
@msg `roundness` must be from 0 to 100% `roundness` skal være fra 0 til 100 %
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` skal være fra 0.01 til 100 pt
@msg style must be "pencil" or "brush" style skal være "pencil" eller "brush"
@msg extend end must be "start" or "end" enden for extend skal være "start" eller "end"
@msg connect end must be "start" or "end" enden for connect skal være "start" eller "end"
@msg `roundness` must be from 1 to 100% `roundness` skal være fra 1 til 100 %
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` skal være et heltal fra 1 til {MAX_BRIDGES_PER_ISLAND}
Can't render this file because it is too large.
+4 -1
View File
@@ -7507,6 +7507,10 @@ breakText Glyphs Glyphen
@msg Some islands could not be joined to the area around the art Einige Inseln konnten nicht mit der Fläche um das Bildmaterial verbunden werden
@msg `width` must be from {lo} to {hi} pt `width` muss zwischen {lo} und {hi} pt liegen
@msg `angle` must be from -180 to 180 degrees `angle` muss zwischen -180 und 180 Grad liegen
@msg `roundness` must be from 0 to 100% `roundness` muss zwischen 0 und 100 % liegen
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` muss zwischen 0.01 und 100 pt liegen
@msg style must be "pencil" or "brush" style muss "pencil" oder "brush" sein
@msg extend end must be "start" or "end" Das Ende von extend muss "start" oder "end" sein
@msg `roundness` must be from 1 to 100% `roundness` muss zwischen 1 und 100 % liegen
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` muss eine ganze Zahl von 1 bis {MAX_BRIDGES_PER_ISLAND} sein
Weed Box and Lines… Entgitterrahmen und -linien…
@@ -8247,7 +8251,6 @@ breakText Glyphs Glyphen
@msg anchor `smooth` must be true or false Ankerpunkt-`smooth` muss true oder false sein
@msg anchor `{key}` must be [x, y] Ankerpunkt-`{key}` muss [x, y] sein
@msg anchor `{key}` must be a number Ankerpunkt-`{key}` muss eine Zahl sein
@msg angle and roundness must be finite angle und roundness müssen endlich sein
@msg angles must be a list as long as pins (degrees or null) angles muss eine Liste so lang wie pins sein (Grad oder null)
@msg appearance must be flat|center|edge appearance muss flat|center|edge sein
@msg apply is "fill" or "stroke", not `{other}` apply ist „fill“ oder „stroke“, nicht `{other}`
Can't render this file because it is too large.
+5
View File
@@ -7910,6 +7910,11 @@ breakText Glyphs Γλύφοι
@msg Some islands could not be joined to the area around the art Ορισμένες νησίδες δεν ήταν δυνατό να συνδεθούν με την περιοχή γύρω από το γραφικό
@msg `width` must be from {lo} to {hi} pt Το `width` πρέπει να είναι από {lo} έως {hi} pt
@msg `angle` must be from -180 to 180 degrees Το `angle` πρέπει να είναι από -180 έως 180 μοίρες
@msg `roundness` must be from 0 to 100% Το `roundness` πρέπει να είναι από 0 έως 100%
@msg `fidelity` must be from 0.01 to 100 pt Το `fidelity` πρέπει να είναι από 0.01 έως 100 pt
@msg style must be "pencil" or "brush" Το style πρέπει να είναι "pencil" ή "brush"
@msg extend end must be "start" or "end" Το άκρο του extend πρέπει να είναι "start" ή "end"
@msg connect end must be "start" or "end" Το άκρο του connect πρέπει να είναι "start" ή "end"
@msg `roundness` must be from 1 to 100% Το `roundness` πρέπει να είναι από 1 έως 100%
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} Το `count` πρέπει να είναι ακέραιος από 1 έως {MAX_BRIDGES_PER_ISLAND}
Weed Box and Lines… Πλαίσιο και γραμμές αφαίρεσης περισσευμάτων…
Can't render this file because it is too large.
+5
View File
@@ -8015,6 +8015,11 @@ breakText Glyphs Glifos
@msg Some islands could not be joined to the area around the art Algunas islas no se pudieron unir al área que rodea la ilustración
@msg `width` must be from {lo} to {hi} pt `width` debe estar entre {lo} y {hi} pt
@msg `angle` must be from -180 to 180 degrees `angle` debe estar entre -180 y 180 grados
@msg `roundness` must be from 0 to 100% `roundness` debe estar entre 0 y 100 %
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` debe estar entre 0.01 y 100 pt
@msg style must be "pencil" or "brush" style debe ser "pencil" o "brush"
@msg extend end must be "start" or "end" el extremo de extend debe ser "start" o "end"
@msg connect end must be "start" or "end" el extremo de connect debe ser "start" o "end"
@msg `roundness` must be from 1 to 100% `roundness` debe estar entre 1 y 100 %
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` debe ser un número entero entre 1 y {MAX_BRIDGES_PER_ISLAND}
Weed Box and Lines… Caja y líneas de pelado…
Can't render this file because it contains an unexpected character in line 2 and column 73.
+5
View File
@@ -7991,6 +7991,11 @@ breakText Glyphs Merkit
@msg Some islands could not be joined to the area around the art Joitakin saarekkeita ei voitu yhdistää grafiikkaa ympäröivään alueeseen
@msg `width` must be from {lo} to {hi} pt `width`-arvon on oltava {lo}–{hi} pt
@msg `angle` must be from -180 to 180 degrees `angle`-arvon on oltava -180–180 astetta
@msg `roundness` must be from 0 to 100% `roundness`-arvon on oltava 0–100 %
@msg `fidelity` must be from 0.01 to 100 pt `fidelity`-arvon on oltava 0.01–100 pt
@msg style must be "pencil" or "brush" style-arvon on oltava "pencil" tai "brush"
@msg extend end must be "start" or "end" extend-pään on oltava "start" tai "end"
@msg connect end must be "start" or "end" connect-pään on oltava "start" tai "end"
@msg `roundness` must be from 1 to 100% `roundness`-arvon on oltava 1–100 %
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` on oltava kokonaisluku 1–{MAX_BRIDGES_PER_ISLAND}
Weed Box and Lines… Karsintakehys ja -viivat…
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4 -1
View File
@@ -7909,6 +7909,10 @@ breakText Glyphs Glyphes
@msg Some islands could not be joined to the area around the art Certains îlots n’ont pas pu être reliés à la zone autour de l’illustration
@msg `width` must be from {lo} to {hi} pt `width` doit être compris entre {lo} et {hi} pt
@msg `angle` must be from -180 to 180 degrees `angle` doit être compris entre -180 et 180 degrés
@msg `roundness` must be from 0 to 100% `roundness` doit être compris entre 0 et 100 %
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` doit être compris entre 0.01 et 100 pt
@msg style must be "pencil" or "brush" style doit être "pencil" ou "brush"
@msg extend end must be "start" or "end" l’extrémité de extend doit être "start" ou "end"
@msg `roundness` must be from 1 to 100% `roundness` doit être compris entre 1 et 100 %
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` doit être un nombre entier compris entre 1 et {MAX_BRIDGES_PER_ISLAND}
Weed Box and Lines… Cadre et lignes d’échenillage…
@@ -8413,7 +8417,6 @@ breakText Glyphs Glyphes
@msg anchor `smooth` must be true or false `smooth` d’un point d’ancrage doit valoir true ou false
@msg anchor `{key}` must be [x, y] `{key}` d’un point d’ancrage doit être [x, y]
@msg anchor `{key}` must be a number `{key}` d’un point d’ancrage doit être un nombre
@msg angle and roundness must be finite l’angle et l’arrondi doivent être finis
@msg angles must be a list as long as pins (degrees or null) angles doit être une liste aussi longue que pins (degrés ou null)
@msg appearance must be flat|center|edge appearance doit valoir flat|center|edge
@msg apply is "fill" or "stroke", not `{other}` apply vaut "fill" ou "stroke", pas `{other}`
Can't render this file because it is too large.
+4 -1
View File
@@ -6696,7 +6696,6 @@ antiAlias Sharp शार्प
@msg anchor `{key}` must be a number एंकर `{key}` को एक नंबर होना चाहिए
@msg anchor `smooth` must be true or false एंकर का `smooth` true या false होना चाहिए
@msg anchor must name a registered panel anchor किसी पंजीकृत पैनल का नाम होना चाहिए
@msg angle and roundness must be finite कोण और गोलाई परिमित होना चाहिए
@msg angles must be a list as long as pins (degrees or null) angles पिन जितनी लंबी सूची होनी चाहिए (डिग्री या null)
@msg Angles require two straight segments कोणों को दो सीधे खंडों की आवश्यकता होती है
@msg antiAlias `{id}`: none, art or type antiAlias `{id}`: none, art या type
@@ -9337,6 +9336,10 @@ theme Appearance अपीयरेंस
@msg Some islands could not be joined to the area around the art कुछ आइलैंड आर्टवर्क के आसपास के क्षेत्र से नहीं जोड़े जा सके
@msg `width` must be from {lo} to {hi} pt `width` {lo} से {hi} pt तक होना चाहिए
@msg `angle` must be from -180 to 180 degrees `angle` -180 से 180 डिग्री तक होना चाहिए
@msg `roundness` must be from 0 to 100% `roundness` 0 से 100% तक होना चाहिए
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` 0.01 से 100 pt तक होना चाहिए
@msg style must be "pencil" or "brush" style "pencil" या "brush" होना चाहिए
@msg extend end must be "start" or "end" extend अंत "start" या "end" होना चाहिए
@msg `roundness` must be from 1 to 100% `roundness` 1 से 100% तक होना चाहिए
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` 1 से {MAX_BRIDGES_PER_ISLAND} तक पूरी संख्या होना चाहिए
Weed Box and Lines… वीड बॉक्स और लाइनें…
Can't render this file because it is too large.
+5 -1
View File
@@ -7899,6 +7899,11 @@ breakText Glyphs Glifák
@msg Some islands could not be joined to the area around the art Egyes szigeteket nem sikerült összekötni a grafikát körülvevő területtel
@msg `width` must be from {lo} to {hi} pt A `width` értéke {lo} és {hi} pt között lehet
@msg `angle` must be from -180 to 180 degrees Az `angle` értéke -180 és 180 fok között lehet
@msg `roundness` must be from 0 to 100% A `roundness` értéke 0 és 100% között lehet
@msg `fidelity` must be from 0.01 to 100 pt A `fidelity` értéke 0.01 és 100 pt között lehet
@msg style must be "pencil" or "brush" A style értéke "pencil" vagy "brush" lehet
@msg extend end must be "start" or "end" Az extend vége "start" vagy "end" lehet
@msg connect end must be "start" or "end" A connect vége "start" vagy "end" lehet
@msg `roundness` must be from 1 to 100% A `roundness` értéke 1 és 100% között lehet
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count`: 1 és {MAX_BRIDGES_PER_ISLAND} közötti egész szám kell
Weed Box and Lines… Gyomláló keret és vonalak…
@@ -8422,7 +8427,6 @@ breakText Glyphs Glifák
@msg anchor `smooth` must be true or false horgonypont, `smooth`: true vagy false kell
@msg anchor `{key}` must be [x, y] horgonypont, `{key}`: [x, y] kell
@msg anchor `{key}` must be a number horgonypont, `{key}`: szám kell
@msg angle and roundness must be finite angle és roundness: véges érték kell
@msg angles must be a list as long as pins (degrees or null) angles: a pins listával azonos hosszúságú lista kell (fok vagy null)
@msg appearance must be flat|center|edge appearance: flat|center|edge kell
@msg apply is "fill" or "stroke", not `{other}` apply: "fill" vagy "stroke", ez nem az: `{other}`
Can't render this file because it is too large.
+4 -1
View File
@@ -7543,6 +7543,10 @@ breakText Glyphs Glifi
@msg Some islands could not be joined to the area around the art Non è stato possibile collegare alcune isole all’area intorno alla grafica
@msg `width` must be from {lo} to {hi} pt `width` deve essere compreso tra {lo} e {hi} pt
@msg `angle` must be from -180 to 180 degrees `angle` deve essere compreso tra -180 e 180 gradi
@msg `roundness` must be from 0 to 100% `roundness` deve essere compreso tra 0 e 100%
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` deve essere compreso tra 0.01 e 100 pt
@msg style must be "pencil" or "brush" style deve essere "pencil" o "brush"
@msg extend end must be "start" or "end" l’estremità di extend deve essere "start" o "end"
@msg `roundness` must be from 1 to 100% `roundness` deve essere compreso tra 1 e 100%
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` deve essere un numero intero compreso tra 1 e {MAX_BRIDGES_PER_ISLAND}
Weed Box and Lines… Riquadro e linee di spellicolatura…
@@ -8297,7 +8301,6 @@ breakText Glyphs Glifi
@msg anchor `smooth` must be true or false `smooth` del punto di ancoraggio deve essere true o false
@msg anchor `{key}` must be [x, y] `{key}` del punto di ancoraggio deve essere [x, y]
@msg anchor `{key}` must be a number `{key}` del punto di ancoraggio deve essere un numero
@msg angle and roundness must be finite angle e roundness devono essere finiti
@msg angles must be a list as long as pins (degrees or null) angles deve essere un elenco lungo quanto pins (gradi o null)
@msg appearance must be flat|center|edge appearance deve essere flat|center|edge
@msg apply is "fill" or "stroke", not `{other}` apply è "fill" o "stroke", non `{other}`
Can't render this file because it is too large.
+4 -1
View File
@@ -7456,7 +7456,6 @@ axis Y Axis Y 軸
@msg anchor `smooth` must be true or false アンカーの `smooth` には true または false を指定してください
@msg anchor `{key}` must be [x, y] アンカーの `{key}` には [x, y] を指定してください
@msg anchor `{key}` must be a number アンカーの `{key}` には数値を指定してください
@msg angle and roundness must be finite angle と roundness には有限の値を指定してください
@msg angles must be a list as long as pins (degrees or null) angles には pins と同じ長さのリスト (度数または null) を指定してください
@msg appearance must be flat|center|edge appearance には flat|center|edge のいずれかを指定してください
@msg apply is "fill" or "stroke", not `{other}` apply には "fill" または "stroke" を指定してください (`{other}` は指定できません)
@@ -9422,6 +9421,10 @@ breakText Glyphs 字形
@msg Some islands could not be joined to the area around the art 一部のアイランドをアートワークの周囲の領域につなげられませんでした
@msg `width` must be from {lo} to {hi} pt `width` は {lo}~{hi} pt の範囲で指定してください
@msg `angle` must be from -180 to 180 degrees `angle` は -180~180 度の範囲で指定してください
@msg `roundness` must be from 0 to 100% `roundness` は 0~100% の範囲で指定してください
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` は 0.01~100 pt の範囲で指定してください
@msg style must be "pencil" or "brush" style は "pencil" または "brush" を指定してください
@msg extend end must be "start" or "end" extend の端は "start" または "end" を指定してください
@msg `roundness` must be from 1 to 100% `roundness` は 1~100% の範囲で指定してください
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` には 1 から {MAX_BRIDGES_PER_ISLAND} の整数を指定してください
Weed Box and Lines… カス取り枠とライン…
Can't render this file because it is too large.
+4
View File
@@ -10217,6 +10217,10 @@ font-script Japanese იაპონური
@msg Some islands could not be joined to the area around the art ზოგიერთი კუნძული ვერ დაუკავშირდა ნახატის გარშემო არეს
@msg `width` must be from {lo} to {hi} pt `width` უნდა იყოს {lo}-დან {hi} pt-მდე
@msg `angle` must be from -180 to 180 degrees `angle` უნდა იყოს -180-დან 180 გრადუსამდე
@msg `roundness` must be from 0 to 100% `roundness` უნდა იყოს 0-დან 100%-მდე
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` უნდა იყოს 0.01-დან 100 pt-მდე
@msg style must be "pencil" or "brush" style უნდა იყოს "pencil" ან "brush"
@msg extend end must be "start" or "end" extend-ის ბოლო უნდა იყოს "start" ან "end"
@msg `roundness` must be from 1 to 100% `roundness` უნდა იყოს 1-დან 100%-მდე
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` უნდა იყოს მთელი რიცხვი 1-დან {MAX_BRIDGES_PER_ISLAND}-მდე
Weed Box and Lines… ნარჩენის მოსაცილებელი ჩარჩო და ხაზები…
Can't render this file because it is too large.
+5 -1
View File
@@ -7507,6 +7507,11 @@ breakText Glyphs 글리프
@msg Some islands could not be joined to the area around the art 일부 섬을 아트워크 주변 영역에 연결할 수 없습니다
@msg `width` must be from {lo} to {hi} pt `width`는 {lo}에서 {hi}pt 사이여야 합니다
@msg `angle` must be from -180 to 180 degrees `angle`는 -180도에서 180도 사이여야 합니다
@msg `roundness` must be from 0 to 100% `roundness`는 0%에서 100% 사이여야 합니다
@msg `fidelity` must be from 0.01 to 100 pt `fidelity`는 0.01에서 100pt 사이여야 합니다
@msg style must be "pencil" or "brush" style은 "pencil" 또는 "brush"여야 합니다
@msg extend end must be "start" or "end" extend 끝은 "start" 또는 "end"여야 합니다
@msg connect end must be "start" or "end" connect 끝은 "start" 또는 "end"여야 합니다
@msg `roundness` must be from 1 to 100% `roundness`는 1%에서 100% 사이여야 합니다
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count`는 1에서 {MAX_BRIDGES_PER_ISLAND} 사이의 정수여야 합니다
Weed Box and Lines… 위딩 상자 및 선…
@@ -8150,7 +8155,6 @@ breakText Glyphs 글리프
@msg anchor `smooth` must be true or false 앵커의 `smooth`은(는) true 또는 false여야 합니다
@msg anchor `{key}` must be [x, y] 앵커의 `{key}`은(는) [x, y]여야 합니다
@msg anchor `{key}` must be a number 앵커의 `{key}`은(는) 숫자여야 합니다
@msg angle and roundness must be finite 각도와 원형률은 유한해야 합니다
@msg angles must be a list as long as pins (degrees or null) angles는 pins와 길이가 같은 목록이어야 합니다(도 또는 null)
@msg appearance must be flat|center|edge appearance는 flat|center|edge여야 합니다
@msg apply is "fill" or "stroke", not `{other}` apply는 "fill" 또는 "stroke"입니다: `{other}`
Can't render this file because it is too large.
+5 -1
View File
@@ -576,6 +576,11 @@ liquify-list-end {0}, {1} {0} en {1}
@msg Some islands could not be joined to the area around the art Sommige eilanden konden niet worden verbonden met het gebied rond de illustratie
@msg `width` must be from {lo} to {hi} pt `width` moet van {lo} tot {hi} pt zijn
@msg `angle` must be from -180 to 180 degrees `angle` moet van -180 tot 180 graden zijn
@msg `roundness` must be from 0 to 100% `roundness` moet van 0 tot 100% zijn
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` moet van 0.01 tot 100 pt zijn
@msg style must be "pencil" or "brush" style moet "pencil" of "brush" zijn
@msg extend end must be "start" or "end" het einde van extend moet "start" of "end" zijn
@msg connect end must be "start" or "end" het einde van connect moet "start" of "end" zijn
@msg `roundness` must be from 1 to 100% `roundness` moet van 1 tot 100% zijn
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` moet een geheel getal van 1 tot {MAX_BRIDGES_PER_ISLAND} zijn
@@ -6409,7 +6414,6 @@ imageTrace Outline Contour
@msg anchor `smooth` must be true or false `smooth` van het anker moet true of false zijn
@msg anchor `{key}` must be [x, y] `{key}` van het anker moet [x, y] zijn
@msg anchor `{key}` must be a number `{key}` van het anker moet een getal zijn
@msg angle and roundness must be finite hoek en ronding moeten eindig zijn
@msg angles must be a list as long as pins (degrees or null) angles moet een lijst zijn die even lang is als pins (graden of null)
@msg appearance must be flat|center|edge appearance moet flat|center|edge zijn
@msg apply is "fill" or "stroke", not `{other}` apply is "fill" of "stroke", niet `{other}`
Can't render this file because it is too large.
+5 -1
View File
@@ -7770,6 +7770,11 @@ breakText Glyphs Glify
@msg Some islands could not be joined to the area around the art Niektórych wysp nie udało się połączyć z obszarem wokół grafiki
@msg `width` must be from {lo} to {hi} pt `width` musi mieścić się w zakresie od {lo} do {hi} pt
@msg `angle` must be from -180 to 180 degrees `angle` musi mieścić się w zakresie od -180 do 180 stopni
@msg `roundness` must be from 0 to 100% `roundness` musi mieścić się w zakresie od 0 do 100%
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` musi mieścić się w zakresie od 0.01 do 100 pt
@msg style must be "pencil" or "brush" style musi mieć wartość "pencil" lub "brush"
@msg extend end must be "start" or "end" koniec extend musi mieć wartość "start" lub "end"
@msg connect end must be "start" or "end" koniec connect musi mieć wartość "start" lub "end"
@msg `roundness` must be from 1 to 100% `roundness` musi mieścić się w zakresie od 1 do 100%
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` musi być liczbą całkowitą od 1 do {MAX_BRIDGES_PER_ISLAND}
Weed Box and Lines… Ramka i linie do wybierania…
@@ -8536,7 +8541,6 @@ breakText Glyphs Glify
@msg anchor `smooth` must be true or false `smooth` punktu kontrolnego musi mieć wartość true lub false
@msg anchor `{key}` must be [x, y] `{key}` punktu kontrolnego musi mieć postać [x, y]
@msg anchor `{key}` must be a number `{key}` punktu kontrolnego musi być liczbą
@msg angle and roundness must be finite kąt i okrągłość muszą być skończone
@msg angles must be a list as long as pins (degrees or null) angles musi być listą tej samej długości co pins (stopnie lub null)
@msg appearance must be flat|center|edge appearance musi mieć wartość flat|center|edge
@msg apply is "fill" or "stroke", not `{other}` apply ma wartość "fill" lub "stroke", a nie `{other}`
Can't render this file because it is too large.
+5 -1
View File
@@ -8101,6 +8101,11 @@ swatch Yellow Green Verde-amarelado
@msg Some islands could not be joined to the area around the art Algumas ilhas não puderam ser unidas à área ao redor da arte
@msg `width` must be from {lo} to {hi} pt `width` deve estar entre {lo} e {hi} pt
@msg `angle` must be from -180 to 180 degrees `angle` deve estar entre -180 e 180 graus
@msg `roundness` must be from 0 to 100% `roundness` deve estar entre 0 e 100%
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` deve estar entre 0.01 e 100 pt
@msg style must be "pencil" or "brush" style deve ser "pencil" ou "brush"
@msg extend end must be "start" or "end" a extremidade de extend deve ser "start" ou "end"
@msg connect end must be "start" or "end" a extremidade de connect deve ser "start" ou "end"
@msg `roundness` must be from 1 to 100% `roundness` deve estar entre 1 e 100%
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` deve ser um número inteiro de 1 a {MAX_BRIDGES_PER_ISLAND}
Weed Box and Lines… Caixa e Linhas de Descasque…
@@ -8614,7 +8619,6 @@ swatch Yellow Green Verde-amarelado
@msg anchor `smooth` must be true or false `smooth` do ponto de ancoragem deve ser true ou false
@msg anchor `{key}` must be [x, y] `{key}` do ponto de ancoragem deve ser [x, y]
@msg anchor `{key}` must be a number `{key}` do ponto de ancoragem deve ser um número
@msg angle and roundness must be finite angle e roundness devem ser finitos
@msg angles must be a list as long as pins (degrees or null) angles deve ser uma lista do mesmo tamanho que pins (graus ou null)
@msg appearance must be flat|center|edge appearance deve ser flat|center|edge
@msg apply is "fill" or "stroke", not `{other}` apply é "fill" ou "stroke", não `{other}`
Can't render this file because it is too large.
+4
View File
@@ -8016,6 +8016,10 @@ shape Open Открытый
@msg Some islands could not be joined to the area around the art Некоторые островки не удалось соединить с областью вокруг графики
@msg `width` must be from {lo} to {hi} pt `width` должно быть от {lo} до {hi} pt
@msg `angle` must be from -180 to 180 degrees `angle` должно быть от -180 до 180 градусов
@msg `roundness` must be from 0 to 100% `roundness` должно быть от 0 до 100%
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` должно быть от 0.01 до 100 pt
@msg style must be "pencil" or "brush" style должен быть "pencil" или "brush"
@msg extend end must be "start" or "end" конец extend должен быть "start" или "end"
@msg `roundness` must be from 1 to 100% `roundness` должно быть от 1 до 100%
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` должно быть целым числом от 1 до {MAX_BRIDGES_PER_ISLAND}
Weed Box and Lines… Рамка и линии выборки…
Can't render this file because it is too large.
+4 -1
View File
@@ -8213,7 +8213,6 @@ digits Hindi Hindi
@msg anchor `{key}` must be [x, y] ankarpunktens `{key}` måste vara [x, y]
@msg anchor `{key}` must be a number ankarpunktens `{key}` måste vara ett tal
@msg anchor `smooth` must be true or false ankarpunktens `smooth` måste vara true eller false
@msg angle and roundness must be finite vinkel och rundhet måste vara ändliga
@msg angles must be a list as long as pins (degrees or null) angles måste vara en lista lika lång som pins (grader eller null)
@msg appearance must be flat|center|edge appearance måste vara flat|center|edge
@msg apply is "fill" or "stroke", not `{other}` apply är "fill" eller "stroke", inte `{other}`
@@ -9379,6 +9378,10 @@ digits Hindi Hindi
@msg Some islands could not be joined to the area around the art Vissa öar kunde inte förbindas med området runt teckningen
@msg `width` must be from {lo} to {hi} pt `width` måste vara från {lo} till {hi} pt
@msg `angle` must be from -180 to 180 degrees `angle` måste vara från -180 till 180 grader
@msg `roundness` must be from 0 to 100% `roundness` måste vara från 0 till 100 %
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` måste vara från 0.01 till 100 pt
@msg style must be "pencil" or "brush" style måste vara "pencil" eller "brush"
@msg extend end must be "start" or "end" extend end måste vara "start" eller "end"
@msg `roundness` must be from 1 to 100% `roundness` måste vara från 1 till 100 %
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` måste vara ett heltal från 1 till {MAX_BRIDGES_PER_ISLAND}
Weed Box and Lines… Rensningsram och rensningslinjer…
Can't render this file because it is too large.
+61
View File
@@ -3090,6 +3090,67 @@ fn three_d_refusals_translate_with_their_values() {
assert_eq!(message(de(), &errors[1].0), "ungültige Parameter für `effect.apply`: Licht: intensity muss eine Zahl von 0 bis 100 sein");
}
/// The Blob Brush's range refusals (`path.blob` `angle`, `roundness` and `fidelity`) show in every
/// complete-message language with the key and the range numbers as given; the error the command
/// returns stays English.
#[test]
fn blob_brush_range_refusals_translate_with_their_values() {
use serde_json::json;
let mut s = vectorcraft_engine::Session::new();
s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
let refusals = [
(json!({"angle": 200}), "`angle`", ["-180", "180"]),
(json!({"roundness": 101}), "`roundness`", ["0", "100"]),
(json!({"fidelity": 0}), "`fidelity`", ["0.01", "100"]),
];
for (extra, key, numbers) in &refusals {
let mut p = json!({"points": [[10, 10], [60, 10]]});
p.as_object_mut().unwrap().extend(extra.as_object().unwrap().clone());
let e = s.execute("path.blob", &p).unwrap_err().to_string();
assert!(e.starts_with("invalid parameters for `path.blob`: ") && e.contains(key) && e.contains(" must be from "), "{e}");
assert_eq!(message(Lang::EN, &e), e);
for code in COMPLETE_MESSAGES {
let shown = message(Lang::from_code(code).expect("registered"), &e);
assert!(!shown.contains(" must be from ") && shown.contains("`path.blob`") && shown.contains(key), "{code}: {e} -> {shown}");
assert!(numbers.iter().all(|n| shown.contains(n)), "{code}: {e} -> {shown}");
}
}
assert_eq!(
message(de(), &s.execute("path.blob", &json!({"points": [[10, 10], [60, 10]], "angle": -181})).unwrap_err().to_string()),
"ungültige Parameter für `path.blob`: `angle` muss zwischen -180 und 180 Grad liegen"
);
}
/// `path.freehand`'s refusals of an unknown `style`, `extend` end or `connect` end show in every
/// complete-message language with the accepted values as given.
#[test]
fn freehand_choice_refusals_translate_with_their_values() {
use serde_json::json;
let mut s = vectorcraft_engine::Session::new();
s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
let a = s.execute("path.create", &json!({"d": "M10 10 L20 10"})).unwrap()["id"].clone();
let b = s.execute("path.create", &json!({"d": "M10 50 L20 50"})).unwrap()["id"].clone();
let points = json!([[20, 10], [30, 30], [20, 50]]);
let refusals = [
(json!({"points": points, "style": "ink"}), ["pencil", "brush"]),
(json!({"points": points, "extend": {"id": a, "end": "middle"}}), ["start", "end"]),
(json!({"points": points, "extend": {"id": a}, "connect": {"id": b, "end": "middle"}}), ["start", "end"]),
];
// A catalog may translate the parameter's name (Hindi कनेक्ट) and put the accepted values in its
// own quotation marks (German „start“); the values themselves stay as written.
let quotes = [("\"", "\""), ("„", "“"), ("“", "”"), ("«", "»"), ("« ", " »"), ("「", "」"), ("‘", "’")];
for (p, values) in &refusals {
let e = s.execute("path.freehand", p).unwrap_err().to_string();
assert!(e.starts_with("invalid parameters for `path.freehand`: ") && e.contains(" must be "), "{e}");
for code in COMPLETE_MESSAGES {
let shown = message(Lang::from_code(code).expect("registered"), &e);
assert!(!shown.contains(" must be ") && shown.contains("`path.freehand`"), "{code}: {e} -> {shown}");
let quoted = |v: &str| quotes.iter().any(|(open, close)| shown.contains(&format!("{open}{v}{close}")));
assert!(values.iter().all(|v| quoted(v)), "{code}: {e} -> {shown}");
}
}
}
/// The values SVG filter refusals put in `{what}` that are messages of their own: the attributes
/// over their limit, named with their element. `kernelUnitLength` is an attribute's name as written.
const SVG_FILTER_PARTS: &[&str] = &["feConvolveMatrix's order", "feMorphology's radius", "a blur's stdDeviation"];
+5
View File
@@ -9795,6 +9795,11 @@ breakText Glyphs Glifler
@msg Some islands could not be joined to the area around the art Bazı adalar çizimin çevresindeki alana bağlanamadı
@msg `width` must be from {lo} to {hi} pt `width` {lo} ile {hi} pt arasında olmalıdır
@msg `angle` must be from -180 to 180 degrees `angle` -180 ile 180 derece arasında olmalıdır
@msg `roundness` must be from 0 to 100% `roundness` %0 ile %100 arasında olmalıdır
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` 0.01 ile 100 pt arasında olmalıdır
@msg style must be "pencil" or "brush" style "pencil" veya "brush" olmalıdır
@msg extend end must be "start" or "end" extend ucu "start" veya "end" olmalıdır
@msg connect end must be "start" or "end" connect ucu "start" veya "end" olmalıdır
@msg `roundness` must be from 1 to 100% `roundness` %1 ile %100 arasında olmalıdır
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` 1 ile {MAX_BRIDGES_PER_ISLAND} arasında bir tam sayı olmalıdır
Weed Box and Lines… Ayıklama Kutusu ve Çizgileri…
Can't render this file because it is too large.
+5 -1
View File
@@ -7642,6 +7642,11 @@ breakText Glyphs Гліфи
@msg Some islands could not be joined to the area around the art Деякі острівці не вдалося з’єднати з областю навколо графіки
@msg `width` must be from {lo} to {hi} pt `width` має бути від {lo} до {hi} pt
@msg `angle` must be from -180 to 180 degrees `angle` має бути від -180 до 180 градусів
@msg `roundness` must be from 0 to 100% `roundness` має бути від 0 до 100%
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` має бути від 0.01 до 100 pt
@msg style must be "pencil" or "brush" style має бути "pencil" або "brush"
@msg extend end must be "start" or "end" кінець extend має бути "start" або "end"
@msg connect end must be "start" or "end" кінець connect має бути "start" або "end"
@msg `roundness` must be from 1 to 100% `roundness` має бути від 1 до 100%
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` має бути цілим числом від 1 до {MAX_BRIDGES_PER_ISLAND}
Weed Box and Lines… Рамка й лінії вибірки…
@@ -8153,7 +8158,6 @@ breakText Glyphs Гліфи
@msg anchor `smooth` must be true or false `smooth` опорної точки має бути true або false
@msg anchor `{key}` must be [x, y] `{key}` опорної точки має бути [x, y]
@msg anchor `{key}` must be a number `{key}` опорної точки має бути числом
@msg angle and roundness must be finite angle і roundness мають бути скінченними
@msg angles must be a list as long as pins (degrees or null) angles має бути списком такої самої довжини, як pins (градуси або null)
@msg appearance must be flat|center|edge appearance має бути flat|center|edge
@msg apply is "fill" or "stroke", not `{other}` apply — це "fill" або "stroke", а не `{other}`
Can't render this file because it is too large.
+5
View File
@@ -7569,6 +7569,11 @@ breakText Glyphs Glyph
@msg Some islands could not be joined to the area around the art Không thể nối một số đảo với vùng xung quanh hình vẽ
@msg `width` must be from {lo} to {hi} pt `width` phải từ {lo} đến {hi} pt
@msg `angle` must be from -180 to 180 degrees `angle` phải từ -180 đến 180 độ
@msg `roundness` must be from 0 to 100% `roundness` phải từ 0 đến 100%
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` phải từ 0.01 đến 100 pt
@msg style must be "pencil" or "brush" style phải là "pencil" hoặc "brush"
@msg extend end must be "start" or "end" đầu extend phải là "start" hoặc "end"
@msg connect end must be "start" or "end" đầu connect phải là "start" hoặc "end"
@msg `roundness` must be from 1 to 100% `roundness` phải từ 1 đến 100%
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` phải là số nguyên từ 1 đến {MAX_BRIDGES_PER_ISLAND}
Weed Box and Lines… Khung và đường bóc phần thừa…
Can't render this file because it contains an unexpected character in line 205 and column 5.
+5 -1
View File
@@ -7754,6 +7754,11 @@ breakText Glyphs 字形
@msg Some islands could not be joined to the area around the art 部分孤岛无法连接到图稿周围的区域
@msg `width` must be from {lo} to {hi} pt `width` 必须介于 {lo} 到 {hi} pt 之间
@msg `angle` must be from -180 to 180 degrees `angle` 必须介于 -180 到 180 度之间
@msg `roundness` must be from 0 to 100% `roundness` 必须介于 0 到 100% 之间
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` 必须介于 0.01 到 100 pt 之间
@msg style must be "pencil" or "brush" style 必须为 "pencil" 或 "brush"
@msg extend end must be "start" or "end" extend 的端点必须为 "start" 或 "end"
@msg connect end must be "start" or "end" connect 的端点必须为 "start" 或 "end"
@msg `roundness` must be from 1 to 100% `roundness` 必须介于 1 到 100% 之间
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` 必须是 1 到 {MAX_BRIDGES_PER_ISLAND} 之间的整数
Weed Box and Lines… 除废框和除废线…
@@ -8524,7 +8529,6 @@ breakText Glyphs 字形
@msg anchor `smooth` must be true or false 锚点的 `smooth` 必须为 true 或 false
@msg anchor `{key}` must be [x, y] 锚点的 `{key}` 必须是 [x, y]
@msg anchor `{key}` must be a number 锚点的 `{key}` 必须是数字
@msg angle and roundness must be finite angle 和 roundness 必须是有限值
@msg angles must be a list as long as pins (degrees or null) angles 必须是与 pins 等长的列表 (度数或 null)
@msg appearance must be flat|center|edge appearance 必须是 flat|center|edge
@msg apply is "fill" or "stroke", not `{other}` apply 为 "fill" 或 "stroke",不能是 `{other}`
Can't render this file because it is too large.
+5 -1
View File
@@ -7563,6 +7563,11 @@ breakText Glyphs 字符
@msg Some islands could not be joined to the area around the art 部分孤島無法連接到圖稿周圍的區域
@msg `width` must be from {lo} to {hi} pt `width` 必須介於 {lo} 到 {hi} pt 之間
@msg `angle` must be from -180 to 180 degrees `angle` 必須介於 -180 到 180 度之間
@msg `roundness` must be from 0 to 100% `roundness` 必須介於 0 到 100% 之間
@msg `fidelity` must be from 0.01 to 100 pt `fidelity` 必須介於 0.01 到 100 pt 之間
@msg style must be "pencil" or "brush" style 必須為 "pencil" 或 "brush"
@msg extend end must be "start" or "end" extend 的端點必須為 "start" 或 "end"
@msg connect end must be "start" or "end" connect 的端點必須為 "start" 或 "end"
@msg `roundness` must be from 1 to 100% `roundness` 必須介於 1 到 100% 之間
@msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` 必須是介於 1 到 {MAX_BRIDGES_PER_ISLAND} 的整數
Weed Box and Lines… 除廢框與除廢線…
@@ -8453,7 +8458,6 @@ breakText Glyphs 字符
@msg anchor `smooth` must be true or false 錨點的 `smooth` 必須是 true 或 false
@msg anchor `{key}` must be [x, y] 錨點的 `{key}` 必須是 [x, y]
@msg anchor `{key}` must be a number 錨點的 `{key}` 必須是數字
@msg angle and roundness must be finite angle 和 roundness 必須是有限值
@msg angles must be a list as long as pins (degrees or null) angles 必須是與 pins 等長的清單 (度數或 null)
@msg appearance must be flat|center|edge appearance 必須是 flat|center|edge
@msg apply is "fill" or "stroke", not `{other}` apply 是 "fill" 或 "stroke",而非 `{other}`
Can't render this file because it is too large.
+636 -12
View File
@@ -41,6 +41,17 @@ pub struct SpotBase {
pub swatch: String,
/// The base's tint of it, 0..1.
pub tint: f32,
/// The names it had before renames, oldest first (at most as many as the History panel keeps
/// states), for an Undo or Redo that gives it one of them back.
pub earlier: Vec<String>,
/// Its swatch went without a command the panel followed: the link waits for an Undo or Redo
/// ([`check_spot`]).
pub resting: bool,
}
/// Whether `name` is a spot color of `doc`.
fn is_spot(doc: &vectorcraft_doc::Document, name: &str) -> bool {
doc.swatch(name).is_some_and(|w| w.spot) && doc.global_color(name).is_some()
}
/// The spot color the base is a tint of, while its swatch is still a spot color of the active
@@ -48,8 +59,7 @@ pub struct SpotBase {
fn live_spot(app: &VectorcraftApp) -> Option<&SpotBase> {
let s = app.ui.color_guide_spot.as_ref()?;
let st = app.session.active()?;
let spot = st.doc.swatch(&s.swatch).is_some_and(|w| w.spot) && st.doc.global_color(&s.swatch).is_some();
(st.uid == s.doc && spot).then_some(s)
(st.uid == s.doc && !s.resting && is_spot(&st.doc, &s.swatch)).then_some(s)
}
/// The color of tint `tint` (0..1) of global swatch `name` in the active document.
@@ -79,20 +89,324 @@ pub(crate) fn choose_linked_base(app: &mut VectorcraftApp, c: Color, link: Optio
app.ui.color_guide_spot = link.and_then(|(swatch, tint)| {
let st = app.session.active()?;
st.doc.swatch(&swatch).filter(|w| w.spot)?;
Some(SpotBase { doc: st.uid, swatch, tint: tint.clamp(0.0, 1.0) })
Some(SpotBase { doc: st.uid, swatch, tint: tint.clamp(0.0, 1.0), earlier: Vec::new(), resting: false })
});
}
/// `swatch.edit` renamed swatch `from` of the active document to `to`: a spot color base linked to
/// it links to `to`.
pub(crate) fn swatch_renamed(app: &mut VectorcraftApp, from: &str, to: &str) {
let uid = app.session.active().map(|st| st.uid);
if let Some(s) = app.ui.color_guide_spot.as_mut()
&& Some(s.doc) == uid
&& s.swatch == from
{
s.swatch = to.to_string();
/// The spot color base before a command runs ([`before_command`]).
pub(crate) struct LinkBefore {
/// Its document is the active one.
active: bool,
/// The color group that holds its swatch.
group: Option<String>,
/// The color the guide shows as the base.
color: Option<Color>,
/// The open documents' `uid`s in order, while there is a spot color base.
docs: Vec<u64>,
/// The active document's index.
active_index: Option<usize>,
}
/// The spot color base before a command runs, for [`after_command`].
pub(crate) fn before_command(app: &VectorcraftApp) -> LinkBefore {
let s = app.ui.color_guide_spot.as_ref();
let active = app.session.active().is_some_and(|st| s.is_some_and(|s| s.doc == st.uid));
// Its document, active or not.
let st = s.and_then(|s| app.session.documents().iter().find(|d| d.uid == s.doc));
let group =
st.zip(s).and_then(|(st, s)| st.doc.swatch_groups.iter().find(|g| g.swatches.iter().any(|w| w.name == s.swatch)).map(|g| g.name.clone()));
let docs = if s.is_some() { app.session.documents().iter().map(|d| d.uid).collect() } else { Vec::new() };
// The color it shows: its swatch's tint in its document, while that is a spot color there.
let shown = st
.zip(s)
.filter(|(st, s)| st.doc.swatch(&s.swatch).is_some_and(|w| w.spot))
.and_then(|(st, s)| st.doc.tint_paint(&s.swatch, s.tint)?.color());
let color = s.map(|_| shown.unwrap_or_else(|| base_color(app)));
LinkBefore { active, group, color, docs, active_index: app.session.active_index() }
}
/// Where the steps of a `command.batch` run, as far as the steps before each one show: new
/// documents open after the others and become the active one, and Close and Move Document shift
/// the documents after them.
struct BatchDocs {
/// The tab index of the base's document, when known.
base: Option<usize>,
/// The base's document was closed.
closed: bool,
/// The tab index of the active document, when known.
active: Option<usize>,
/// The number of open documents, when known.
len: Option<usize>,
}
impl BatchDocs {
/// Whether the next step runs in the base's document, when that is known.
fn in_base(&self) -> Option<bool> {
if self.closed {
return Some(false);
}
Some(self.active? == self.base?)
}
/// Follow step `id`, which ran with params `p` and replied `r`.
fn step(&mut self, id: &str, p: &Value, r: &Value) {
let index = |key: &str| p[key].as_u64().and_then(|i| usize::try_from(i).ok());
// The tab index a step that opens a document replies with: a new one after the others, or
// one already open made active.
let opened = r["index"].as_u64().and_then(|i| usize::try_from(i).ok());
match id {
"document.activate" => self.active = index("index"),
"file.new" | "file.newFromTemplate" | "edit.newDocumentFromState" => {
self.len = self.len.map(|n| n + 1);
self.active = opened.or(self.len.map(|n| n - 1));
}
"file.close" | "document.close" => {
let i = index("index").or(self.active);
let len = self.len.map(|n| n.saturating_sub(1));
match (i, self.base) {
(Some(i), Some(b)) if i == b => (self.closed, self.base) = (true, None),
(Some(i), Some(b)) if i < b => self.base = Some(b - 1),
(Some(_), Some(_)) => {}
_ => self.base = None,
}
// Closing another document keeps the active one; closing the active one makes the
// one at its index active (the last one when it was last).
self.active = match (i, self.active) {
(Some(i), Some(a)) if i != a => Some(if i < a { a - 1 } else { a }),
(Some(i), Some(_)) => len.and_then(|n| n.checked_sub(1)).map(|last| i.min(last)),
_ => None,
};
self.len = len;
}
"file.closeAll" => self.closed = true,
"document.move" => {
let moved = |x: usize, from: usize, to: usize| {
if x == from {
return to;
}
let x = if from < x { x - 1 } else { x };
if to <= x { x + 1 } else { x }
};
match (index("from").or(self.active), index("to"), self.len) {
(Some(from), Some(to), Some(n)) if n > 0 => {
let to = to.min(n - 1);
self.base = self.base.map(|b| moved(b, from, to));
self.active = self.active.map(|a| moved(a, from, to));
}
_ => (self.base, self.active) = (None, None),
}
}
_ if id.starts_with("file.open")
|| id.starts_with("recovery.")
|| matches!(id, "document.open" | "document.compare" | "stroke.arrowheads.edit") =>
{
match (opened, self.len) {
(Some(i), Some(n)) if i <= n => (self.active, self.len) = (Some(i), Some(n.max(i + 1))),
_ => (self.active, self.len) = (None, None),
}
}
_ => {}
}
}
}
/// The name the spot color base's swatch `name` of document `base` has after a `command.batch`
/// ran `steps` and replied `results`, or `None` when a step may have
/// removed it or made it a process color ([`follow_step`]). Steps in the base's document are
/// followed and steps in another document are skipped. A step in a document that is not known
/// keeps the name, and a rename there adds a second name to choose from once the batch is done:
/// the one that is a spot color of the base's document. Scripts and plug-ins may do anything, so
/// they end the link.
fn follow_batch(app: &VectorcraftApp, base: u64, name: String, steps: &[Value], results: &[Value], before: &LinkBefore) -> Option<String> {
let mut group = before.group.clone();
let at = before.docs.iter().position(|&u| u == base);
let mut docs = BatchDocs { base: at, closed: at.is_none(), active: before.active_index, len: Some(before.docs.len()) };
let mut names = vec![name];
for (i, step) in steps.iter().enumerate() {
let sid = step["command"].as_str().unwrap_or_default();
let (p, r) = (&step["params"], results.get(i).unwrap_or(&Value::Null));
if sid.starts_with("script.") || sid.starts_with("plugin.") {
return None;
}
match docs.in_base() {
Some(true) => {
let one = names.len() == 1;
let mut next = Vec::with_capacity(names.len());
for n in names {
let mut scratch = group.clone();
next.push(follow_step(sid, p, r, n, if one { &mut group } else { &mut scratch })?);
}
names = next;
}
Some(false) => {}
None => {
// The step may have run elsewhere, so the name stays a candidate whatever the step
// did; a rename adds the new name.
let mut next = Vec::with_capacity(names.len() + 1);
for n in names {
if let Some(m) = follow_step(sid, p, r, n.clone(), &mut group.clone())
&& m != n
{
next.push(m);
}
next.push(n);
}
next.sort();
next.dedup();
names = next;
}
}
docs.step(sid, p, r);
}
if names.len() == 1 {
return names.pop();
}
// The one name that is a spot color of the base's document.
let st = app.session.documents().iter().find(|d| d.uid == base)?;
let mut spots = names.into_iter().filter(|n| is_spot(&st.doc, n));
let first = spots.next()?;
spots.next().is_none().then_some(first)
}
/// Command `id` ran with `params` and replied `reply`: a spot color base linked to a swatch that
/// Swatch Options renamed links to the new name, and one whose swatch a command deleted or made a
/// process color is no longer linked to it, so a later spot color of the same name does not
/// become the base; the base keeps the color it showed. A `command.batch`'s steps are followed in
/// order ([`follow_batch`]).
pub(crate) fn after_command(app: &mut VectorcraftApp, id: &str, params: &Value, reply: &Value, before: LinkBefore) {
let Some(s) = app.ui.color_guide_spot.as_ref() else { return };
let (base, n) = (s.doc, s.swatch.clone());
let name = if id == "command.batch" {
let steps = params["commands"].as_array().map(Vec::as_slice).unwrap_or_default();
let results = reply["results"].as_array().map(Vec::as_slice).unwrap_or_default();
follow_batch(app, base, n, steps, results, &before)
} else if before.active {
follow_step(id, params, reply, n, &mut before.group.clone())
} else {
Some(n)
};
let keep = usize::try_from(app.session.prefs.history_states).unwrap_or(usize::MAX).max(1);
let Some(s) = app.ui.color_guide_spot.as_mut() else { return };
match name {
Some(n) => {
if n != s.swatch {
let old = std::mem::replace(&mut s.swatch, n);
s.earlier.retain(|e| *e != old && *e != s.swatch);
s.earlier.push(old);
if s.earlier.len() > keep {
s.earlier.drain(..s.earlier.len() - keep);
}
}
}
None => app.ui.color_guide_spot = None,
}
let undo = |id: &str| matches!(id, "edit.undo" | "edit.redo");
let undone = undo(id)
|| (id == "command.batch"
&& params["commands"].as_array().is_some_and(|a| a.iter().any(|st| undo(st["command"].as_str().unwrap_or_default()))));
check_spot(app, if undone { Ran::UndoRedo } else { Ran::Command });
if app.ui.color_guide_spot.is_none()
&& let Some(c) = before.color
{
app.ui.color_guide_base = Some(c);
}
}
/// The name swatch `name` (in color group `group`) has after command `id` ran with `params` and
/// replied `reply` in its document, or `None` when the command may have removed it or made it a
/// process color: Swatch Options making it a process color, Delete Swatch naming it or its group,
/// Merge Swatches merging it into another and Edit Color Group leaving it out of its group.
/// `group` follows the step: New Color Group, Move Swatch, Edit Color Group and Ungroup Color
/// Group.
fn follow_step(id: &str, p: &Value, reply: &Value, name: String, group: &mut Option<String>) -> Option<String> {
let ours = |v: &Value| v == name.as_str();
let in_group = |key: &str| group.as_deref().is_some_and(|g| p[key] == g);
let named = |key: &str| p[key].as_array().is_some_and(|a| a.iter().any(|n| ours(n) || group.as_deref().is_some_and(|g| n == g)));
let members = |key: &str| reply[key].as_array().is_some_and(|a| a.iter().any(ours));
let removed = match id {
"swatch.edit" => ours(&p["name"]) && p["spot"] == false,
"swatch.delete" => ours(&p["name"]) || in_group("name") || named("names"),
"swatch.merge" => named("names") && !ours(&p["names"][0]),
"swatch.editGroup" => in_group("group") && !members("swatches"),
_ => false,
};
if removed {
return None;
}
// The color group that holds it after the step.
let moved = match id {
"swatch.newGroup" | "swatch.editGroup" if members("swatches") => Some(reply["name"].as_str().map(str::to_string)),
"swatch.ungroup" if in_group("name") => Some(None),
"swatch.move" if ours(&p["name"]) || p["names"].as_array().is_some_and(|a| a.iter().any(ours)) => {
Some(p["group"].as_str().map(str::to_string))
}
_ => None,
};
if let Some(m) = moved {
*group = m;
}
// A rename by Swatch Options, or of the swatch Merge Swatches keeps.
let renamed = match id {
"swatch.edit" if p["name"] == name.as_str() => reply["name"].as_str(),
"swatch.merge" if p["names"][0] == name.as_str() => reply["name"].as_str(),
_ => None,
};
Some(renamed.map_or(name, str::to_string))
}
/// What ran before the spot color base's link is checked ([`check_spot`]).
#[derive(Clone, Copy, PartialEq)]
pub(crate) enum Ran {
/// Nothing the panel followed: a frame of the panel (a script's commands, for example).
Frame,
/// A command other than Undo and Redo.
Command,
/// Undo or Redo, or a batch with one of them.
UndoRedo,
}
/// Check the spot color base's link after `ran`. A closed document ends it. When its swatch is no
/// longer a spot color of its document (deleted, renamed or made a process color by something the
/// panel did not follow), after an Undo or Redo a name it had before that is one again takes its
/// place (an Undo or Redo of a rename); otherwise the link rests until an Undo or Redo makes it a spot color again, and
/// the next other command ends it. The base keeps the color it last showed.
pub(crate) fn check_spot(app: &mut VectorcraftApp, ran: Ran) {
let Some(s) = app.ui.color_guide_spot.as_mut() else { return };
if !app.session.documents().iter().any(|d| d.uid == s.doc) {
app.ui.color_guide_spot = None;
return;
}
let Some(st) = app.session.active().filter(|st| st.uid == s.doc) else { return };
if s.resting && ran != Ran::UndoRedo {
if ran == Ran::Command {
app.ui.color_guide_spot = None;
}
return;
}
if ran == Ran::UndoRedo && !is_spot(&st.doc, &s.swatch) {
// An Undo or Redo of a rename gave it a name it had before.
if let Some(i) = s.earlier.iter().rposition(|n| is_spot(&st.doc, n)) {
let name = s.earlier.remove(i);
let gone = std::mem::replace(&mut s.swatch, name);
s.earlier.push(gone);
}
}
if is_spot(&st.doc, &s.swatch) {
s.resting = false;
// Kept for when the link ends where the color can no longer be read (a closed document).
if let Some(c) = st.doc.tint_paint(&s.swatch, s.tint).and_then(|p| p.color()) {
app.ui.color_guide_base = Some(c);
}
return;
}
if ran != Ran::Command {
s.resting = true;
return;
}
if let Some(c) = st.doc.tint_paint(&s.swatch, s.tint).and_then(|p| p.color()) {
app.ui.color_guide_base = Some(c);
}
app.ui.color_guide_spot = None;
}
/// The global swatch and tint (0..1) a solid paint links to.
@@ -295,6 +609,7 @@ fn save_group(app: &mut VectorcraftApp, ctx: &egui::Context) {
pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
let t = crate::theme::Tokens::get(ui.ctx());
let ctx = ui.ctx().clone();
check_spot(app, Ran::Frame);
// The current color becomes the base when the panel first shows; selecting artwork later
// leaves it as it is.
if app.ui.color_guide_base.is_none() {
@@ -938,6 +1253,315 @@ mod tests {
app.run("swatch.edit", json!({"name": "Deep Ink", "color": "#cc0000"})).unwrap();
let red = app.session.active().unwrap().doc.global_color("Deep Ink").unwrap();
assert_eq!(base_color(&app), red, "the base follows the renamed spot color");
// Renames in a batch, in step order.
let steps = json!([
{"command": "swatch.edit", "params": {"name": "Deep Ink", "newName": "Ink A"}},
{"command": "swatch.edit", "params": {"name": "Ink A", "newName": "Ink B"}},
]);
app.run("command.batch", json!({"commands": steps})).unwrap();
let Paint::Solid { swatch, .. } = cell_paint(&app, &guide(&app, &ctx), 0, c + 1).unwrap() else { panic!("a solid") };
assert_eq!(swatch.as_deref(), Some("Ink B"), "renamed in a batch");
}
/// Deleting the spot color, or making it a process color, ends the base's link: a new spot color
/// of the same name, or the swatch made a spot color again, gives process colors until it is
/// chosen again.
#[test]
fn a_deleted_spot_color_ends_the_link() {
let mut app = spot_app(1.0);
let ctx = egui::Context::default();
frame(&mut app, &ctx);
let c = guide(&app, &ctx).centre();
let linked = |app: &VectorcraftApp, ctx: &egui::Context| {
matches!(cell_paint(app, &guide(app, ctx), 0, c + 1).unwrap(), Paint::Solid { swatch: Some(_), .. })
};
assert!(linked(&app, &ctx));
app.run("swatch.delete", json!({"name": "Ink"})).unwrap();
app.run("swatch.new", json!({"name": "Ink", "color": "#00cc66", "spot": true})).unwrap();
assert!(!linked(&app, &ctx), "a new spot color of the same name");
assert!(app.ui.color_guide_spot.is_none());
let ink = app.session.active().unwrap().doc.global_color("Ink").unwrap();
choose_linked_base(&mut app, ink, Some(("Ink".to_string(), 1.0)));
assert!(linked(&app, &ctx));
app.run("swatch.edit", json!({"name": "Ink", "spot": false, "global": false})).unwrap();
app.run("swatch.edit", json!({"name": "Ink", "spot": true})).unwrap();
assert!(!linked(&app, &ctx), "a spot color again");
// The same in a batch: a step that deletes the swatch, or one that makes it a process color.
let relink = |app: &mut VectorcraftApp| {
let ink = app.session.active().unwrap().doc.global_color("Ink").unwrap();
choose_linked_base(app, ink, Some(("Ink".to_string(), 1.0)));
};
for steps in [
json!([
{"command": "swatch.edit", "params": {"name": "Ink", "newName": "Ink 2"}},
{"command": "swatch.delete", "params": {"name": "Ink 2"}},
{"command": "swatch.new", "params": {"name": "Ink 2", "color": "#cc6600", "spot": true}},
{"command": "swatch.edit", "params": {"name": "Ink 2", "newName": "Ink"}},
]),
json!([
{"command": "swatch.edit", "params": {"name": "Ink", "spot": false, "global": false}},
{"command": "swatch.edit", "params": {"name": "Ink", "spot": true}},
]),
] {
relink(&mut app);
assert!(linked(&app, &ctx));
app.run("command.batch", json!({"commands": steps})).unwrap();
assert!(!linked(&app, &ctx), "{steps}");
}
// A batch that edits the spot color's values and deletes another swatch keeps the link.
relink(&mut app);
app.run("swatch.new", json!({"name": "Spare", "color": "#999999"})).unwrap();
let steps = json!([
{"command": "swatch.edit", "params": {"name": "Ink", "color": "#cc0000"}},
{"command": "swatch.delete", "params": {"name": "Spare"}},
]);
app.run("command.batch", json!({"commands": steps})).unwrap();
assert!(linked(&app, &ctx), "an unrelated batch");
// `global: false` leaves a spot color global, so the link stays.
let steps = json!([{"command": "swatch.edit", "params": {"name": "Ink", "global": false}}, {"command": "swatch.sortByName"}]);
app.run("command.batch", json!({"commands": steps})).unwrap();
assert!(linked(&app, &ctx), "global: false on a spot color");
// Closing its document ends the link, and the base keeps the color it showed.
app.run("swatch.edit", json!({"name": "Ink", "color": "#00aa00"})).unwrap();
let shown = base_color(&app);
// Closed the way the tab's close button closes it, outside `app.run`.
app.session.execute("file.new", &json!({})).unwrap();
app.session.execute("file.close", &json!({"index": 0})).unwrap();
frame(&mut app, &ctx);
assert_eq!(app.session.documents().len(), 1);
assert!(app.ui.color_guide_spot.is_none(), "its document closed");
assert_eq!(base_color(&app), shown, "the color it showed before the close");
}
/// An Undo or a Redo of a rename keeps the spot color base's link under the name the swatch has
/// again, also after more renames than a short list would hold and after a rename the panel did
/// not follow (a script's); another command after such a rename ends the link.
#[test]
fn an_undone_rename_keeps_the_link() {
let mut app = spot_app(1.0);
let ctx = egui::Context::default();
frame(&mut app, &ctx);
let c = guide(&app, &ctx).centre();
let linked = |app: &VectorcraftApp, ctx: &egui::Context| {
matches!(cell_paint(app, &guide(app, ctx), 0, c + 1).unwrap(), Paint::Solid { swatch: Some(_), .. })
};
let spot_name = |app: &VectorcraftApp| app.ui.color_guide_spot.as_ref().map(|s| s.swatch.clone());
app.run("swatch.edit", json!({"name": "Ink", "newName": "Ink U"})).unwrap();
app.run("edit.undo", json!({})).unwrap();
assert!(linked(&app, &ctx), "a rename undone");
assert_eq!(spot_name(&app).as_deref(), Some("Ink"));
app.run("edit.redo", json!({})).unwrap();
assert!(linked(&app, &ctx), "a rename redone");
assert_eq!(spot_name(&app).as_deref(), Some("Ink U"));
app.run("edit.undo", json!({})).unwrap();
// Forty renames undone one by one.
for i in 0..40 {
let from = if i == 0 { "Ink".to_string() } else { format!("Ink {i}") };
app.run("swatch.edit", json!({"name": from, "newName": format!("Ink {}", i + 1)})).unwrap();
}
for _ in 0..40 {
app.run("edit.undo", json!({})).unwrap();
}
assert_eq!(spot_name(&app).as_deref(), Some("Ink"), "forty renames undone");
assert!(linked(&app, &ctx));
// A rename the panel did not follow: the link rests, and the Undo brings it back.
app.session.execute("swatch.edit", &json!({"name": "Ink", "newName": "Ink S"})).unwrap();
frame(&mut app, &ctx);
assert!(!linked(&app, &ctx), "resting");
app.run("edit.undo", json!({})).unwrap();
assert!(linked(&app, &ctx), "an unfollowed rename undone");
assert_eq!(spot_name(&app).as_deref(), Some("Ink"));
// Another command while it rests ends it.
app.session.execute("swatch.edit", &json!({"name": "Ink", "newName": "Ink S"})).unwrap();
frame(&mut app, &ctx);
app.run("swatch.new", json!({"name": "Spare", "color": "#999999"})).unwrap();
assert!(app.ui.color_guide_spot.is_none(), "another command while it rests");
// Outside an Undo or Redo, a new spot color with an earlier name does not take its place.
app.run("swatch.edit", json!({"name": "Ink S", "newName": "Ink"})).unwrap();
let ink = app.session.active().unwrap().doc.global_color("Ink").unwrap();
choose_linked_base(&mut app, ink, Some(("Ink".to_string(), 1.0)));
app.run("swatch.edit", json!({"name": "Ink", "newName": "Ink U"})).unwrap();
app.run("swatch.new", json!({"name": "Ink", "color": "#00cc66", "spot": true})).unwrap();
app.session.execute("swatch.edit", &json!({"name": "Ink U", "newName": "Ink V"})).unwrap();
frame(&mut app, &ctx);
assert!(!linked(&app, &ctx), "a new spot color with an earlier name");
assert_eq!(spot_name(&app).as_deref(), Some("Ink U"));
}
/// A `command.batch` that switches, opens, closes or moves documents follows the spot color
/// base's swatch in its own document and leaves the link alone for steps in the others.
#[test]
fn a_batch_follows_the_spot_color_across_documents() {
let mut app = spot_app(1.0);
let ctx = egui::Context::default();
frame(&mut app, &ctx);
let c = guide(&app, &ctx).centre();
let linked = |app: &VectorcraftApp, ctx: &egui::Context| {
matches!(cell_paint(app, &guide(app, ctx), 0, c + 1).unwrap(), Paint::Solid { swatch: Some(_), .. })
};
let relink = |app: &mut VectorcraftApp| {
let ink = app.session.active().unwrap().doc.global_color("Ink").unwrap();
choose_linked_base(app, ink, Some(("Ink".to_string(), 1.0)));
};
assert!(linked(&app, &ctx));
// Undo, Activate Document and New in a batch keep the link while the swatch is a spot color,
// and the steps in the base's document are still followed.
app.run("swatch.new", json!({"name": "Spare 2", "color": "#777777"})).unwrap();
let steps = json!([
{"command": "edit.undo"},
{"command": "document.activate", "params": {"index": 0}},
{"command": "swatch.sortByName"},
]);
app.run("command.batch", json!({"commands": steps})).unwrap();
assert!(linked(&app, &ctx), "an undo, an activate and a sort");
let steps = json!([
{"command": "file.new"},
{"command": "swatch.new", "params": {"name": "Other", "color": "#123456", "spot": true}},
{"command": "swatch.delete", "params": {"name": "Other"}},
{"command": "document.activate", "params": {"index": 0}},
]);
app.run("command.batch", json!({"commands": steps})).unwrap();
assert!(linked(&app, &ctx), "steps in a new document");
let spot_name = |app: &VectorcraftApp| app.ui.color_guide_spot.as_ref().map(|s| s.swatch.clone());
let steps = json!([
{"command": "file.new"},
{"command": "document.activate", "params": {"index": 0}},
{"command": "swatch.edit", "params": {"name": "Ink", "newName": "Ink C"}},
]);
app.run("command.batch", json!({"commands": steps})).unwrap();
assert!(linked(&app, &ctx), "renamed after a new document");
assert_eq!(spot_name(&app).as_deref(), Some("Ink C"));
// Moves and closes shift the tabs: [base, 1, 2] becomes [1, 2, base], then [2, base], then
// [base, 2]; the steps in tab 2 leave the link alone.
let steps = json!([
{"command": "document.move", "params": {"from": 0, "to": 2}},
{"command": "document.activate", "params": {"index": 2}},
{"command": "swatch.edit", "params": {"name": "Ink C", "newName": "Ink M"}},
{"command": "file.close", "params": {"index": 0}},
{"command": "document.activate", "params": {"index": 0}},
{"command": "swatch.new", "params": {"name": "Ink M", "color": "#123456", "spot": true}},
{"command": "swatch.delete", "params": {"name": "Ink M"}},
{"command": "document.activate", "params": {"index": 1}},
{"command": "document.move", "params": {"from": 1, "to": 0}},
]);
app.run("command.batch", json!({"commands": steps})).unwrap();
assert_eq!(app.session.active_index(), Some(0));
assert!(linked(&app, &ctx), "moved and closed tabs");
assert_eq!(spot_name(&app).as_deref(), Some("Ink M"));
app.run("swatch.edit", json!({"name": "Ink M", "newName": "Ink"})).unwrap();
assert!(linked(&app, &ctx), "renamed back");
// A batch that starts in another document follows the base's color group too.
app.run("swatch.newGroup", json!({"name": "Held", "swatches": ["Ink"]})).unwrap();
app.run("document.activate", json!({"index": 1})).unwrap();
let steps = json!([
{"command": "document.activate", "params": {"index": 0}},
{"command": "swatch.delete", "params": {"names": ["Held"]}},
{"command": "swatch.new", "params": {"name": "Ink", "color": "#cc6600", "spot": true}},
{"command": "document.activate", "params": {"index": 1}},
]);
app.run("command.batch", json!({"commands": steps})).unwrap();
app.run("document.activate", json!({"index": 0})).unwrap();
assert!(!linked(&app, &ctx), "its group deleted in a batch that started elsewhere");
relink(&mut app);
// Where an opened document's steps run is not known: deleting a swatch of the same name
// there keeps the link.
let svg = r#"<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"/>"#;
let steps = json!([
{"command": "document.open", "params": {"name": "a.svg", "dataBase64": vectorcraft_format::base64_encode(svg.as_bytes())}},
{"command": "swatch.new", "params": {"name": "Ink", "color": "#123456", "spot": true}},
{"command": "swatch.delete", "params": {"name": "Ink"}},
{"command": "document.activate", "params": {"index": 0}},
]);
app.run("command.batch", json!({"commands": steps})).unwrap();
assert!(linked(&app, &ctx), "deleted in an opened document");
// The opened document's tab is known from its reply: a rename there is not the base's,
// even when the base's document has spot colors of both names.
app.run("swatch.new", json!({"name": "Ink Alt", "color": "#654321", "spot": true})).unwrap();
let steps = json!([
{"command": "document.open", "params": {"name": "b.svg", "dataBase64": vectorcraft_format::base64_encode(svg.as_bytes())}},
{"command": "swatch.new", "params": {"name": "Ink", "color": "#123456", "spot": true}},
{"command": "swatch.edit", "params": {"name": "Ink", "newName": "Ink Alt"}},
{"command": "document.activate", "params": {"index": 0}},
]);
app.run("command.batch", json!({"commands": steps})).unwrap();
assert!(linked(&app, &ctx), "renamed in an opened document");
assert_eq!(spot_name(&app).as_deref(), Some("Ink"));
// Deleted by a batch that starts in another tab: the base keeps the color it showed.
app.run("swatch.edit", json!({"name": "Ink", "color": "#00aa00"})).unwrap();
let shown = base_color(&app);
app.run("document.activate", json!({"index": 1})).unwrap();
let steps = json!([
{"command": "document.activate", "params": {"index": 0}},
{"command": "swatch.delete", "params": {"name": "Ink"}},
]);
app.run("command.batch", json!({"commands": steps})).unwrap();
assert!(app.ui.color_guide_spot.is_none());
assert_eq!(base_color(&app), shown, "the edited color");
app.run("swatch.new", json!({"name": "Ink", "color": "#cc0000", "spot": true})).unwrap();
relink(&mut app);
let steps = json!([
{"command": "document.activate", "params": {"index": 1}},
{"command": "swatch.new", "params": {"name": "Ink", "color": "#123456", "spot": true}},
{"command": "swatch.delete", "params": {"name": "Ink"}},
{"command": "document.activate", "params": {"index": 0}},
]);
app.run("command.batch", json!({"commands": steps})).unwrap();
assert!(linked(&app, &ctx), "a swatch of the same name deleted in another document");
let steps = json!([
{"command": "document.activate", "params": {"index": 0}},
{"command": "swatch.delete", "params": {"name": "Ink"}},
{"command": "swatch.new", "params": {"name": "Ink", "color": "#123456", "spot": true}},
]);
app.run("command.batch", json!({"commands": steps})).unwrap();
assert!(!linked(&app, &ctx), "deleted after an activate");
relink(&mut app);
assert!(linked(&app, &ctx));
}
/// Deleting the color group that holds the spot color base's swatch ends the link; an Edit
/// Color Group that keeps it does not.
#[test]
fn a_deleted_color_group_ends_the_link() {
let mut app = spot_app(1.0);
let ctx = egui::Context::default();
frame(&mut app, &ctx);
let c = guide(&app, &ctx).centre();
let linked = |app: &VectorcraftApp, ctx: &egui::Context| {
matches!(cell_paint(app, &guide(app, ctx), 0, c + 1).unwrap(), Paint::Solid { swatch: Some(_), .. })
};
let relink = |app: &mut VectorcraftApp| {
let ink = app.session.active().unwrap().doc.global_color("Ink").unwrap();
choose_linked_base(app, ink, Some(("Ink".to_string(), 1.0)));
};
// Deleting the color group that holds it, then a new spot color of the same name.
app.run("swatch.newGroup", json!({"name": "Inks", "swatches": ["Ink"]})).unwrap();
assert!(linked(&app, &ctx), "moved into a group");
let steps = json!([
{"command": "swatch.delete", "params": {"names": ["Inks"]}},
{"command": "swatch.new", "params": {"name": "Ink", "color": "#cc6600", "spot": true}},
]);
app.run("command.batch", json!({"commands": steps})).unwrap();
assert!(!linked(&app, &ctx), "its group deleted");
// Moved into a group and the group deleted in the same batch.
relink(&mut app);
let steps = json!([
{"command": "swatch.newGroup", "params": {"name": "Spots", "swatches": ["Ink"]}},
{"command": "swatch.delete", "params": {"names": ["Spots"]}},
{"command": "swatch.new", "params": {"name": "Ink", "color": "#336699", "spot": true}},
]);
app.run("command.batch", json!({"commands": steps})).unwrap();
assert!(!linked(&app, &ctx), "moved into a group that was deleted");
// Edit Color Group that keeps it, with a new group name, keeps the link.
relink(&mut app);
app.run("swatch.newGroup", json!({"name": "Spots", "swatches": ["Ink"]})).unwrap();
let ink = app.session.active().unwrap().doc.global_color("Ink").unwrap();
app.run("swatch.editGroup", json!({"group": "Spots", "colors": [ink.to_hex()], "rename": "Spot Inks"})).unwrap();
assert!(linked(&app, &ctx), "a group edit that keeps it");
// A deleted base keeps the color it showed after an edit.
app.run("swatch.edit", json!({"name": "Ink", "color": "#cc0000"})).unwrap();
let shown = base_color(&app);
app.run("swatch.delete", json!({"name": "Ink"})).unwrap();
assert_eq!(base_color(&app), shown, "the color it showed");
}
/// Save Colors as Swatches and Save Color Group save a spot color base's tints as tint swatches
+9 -6
View File
@@ -1045,17 +1045,20 @@ fn open_menu_with(id: &str, left: f32, width: f32, screen: egui::Vec2, look: Men
}
// egui places the menu by the size it had the frame before. When a name measured late (a face
// added for its script, a font found in the background) widens it on that frame, the menu sits
// where the narrower one fit until the next: draw until it stays put.
let filter_at = |shapes: &[egui::epaint::ClippedShape]| {
shapes.iter().find_map(|s| match &s.shape {
// where the narrower one fit until the next: draw until it stays put. The filter alone can stay
// put on the frame that widens the menu, so the menu's own rect must stay put too.
let placed = |shapes: &[egui::epaint::ClippedShape]| {
let filter = shapes.iter().find_map(|s| match &s.shape {
egui::Shape::Text(t) if t.galley.text() == crate::i18n::t("Any Kind") => Some(t.pos),
_ => None,
})
});
let menu = filter.and_then(|p| ctx.layer_id_at(p)).and_then(|l| ctx.memory(|m| m.area_rect(l.id)));
(filter, menu)
};
for _ in 0..100 {
let before = filter_at(&shapes);
let before = placed(&shapes);
shapes = frame(vec![]);
if filter_at(&shapes) == before && !crate::font_menu::wait_for_samples(&ctx) {
if placed(&shapes) == before && !crate::font_menu::wait_for_samples(&ctx) {
break;
}
}
+4 -1
View File
@@ -120,7 +120,10 @@ private editing data. VectorCraft:
Scatter and Art brushes with their art, are written in its order: Scatter and Art brushes in Tints or keeping their
art's colors, Art brushes that run their art from left to right without overlap at a fixed width, with their
width, flips and scale (Stretch Between Guides with guides that leave art between them), and art of paths and
compound paths with points and groups with members, with one solid fill and one plain stroke each. Other brushes,
compound paths with points and groups with members, with one solid fill and one plain stroke each. Such art may
hold opacity masks whose art is of the same kinds, up to seven deep in one another's art; the masks are written
with their options, and an Art brush whose art holds one is written with its strokes as their drawn look. Other
brushes,
Pattern and Bristle brushes among them, and brushes past the number or the art VectorCraft's reader reads are left
out with a warning; no brush is written on a large canvas. A path or compound path with a Calligraphic brush, or
with an Art brush whose art bends along the path and that doesn't scale its art proportionately, keeps the brush
+10 -2
View File
@@ -3618,7 +3618,10 @@ already walks Image Trace. Short agent entry points:
a straight Pencil line too, or with Alt held at the release. The stroke's end then joins the other end when it is
within four times the Fidelity of it (at least 6 pt and at most 400 pt), and a straight segment closes the path from
farther away. Without `closed`, the stroke closes the path when it ends within that four-times-Fidelity distance. The
Blob Brush's `path.blob` Fidelity stays in points, 0.01 to 100 pt.
Blob Brush's `path.blob` Fidelity stays in points, 0.01 to 100 pt, and is
not used when left out or null. `path.blob` rejects a `fidelity` outside 0.01 to 100 pt, an `angle` outside -180° to
180° and a `roundness` outside 0% to 100% with an error such as `` `angle` must be from -180 to 180 degrees ``; the
document does not change and no undo step is recorded. These ranges are VectorCraft's own values.
- Variables: `variable.list`, `variable.define {name, kind: text|visibility|image|graph}`, `variable.bind {variable, ids?}`,
`variable.makeTextDynamic`, `variable.makeVisibilityDynamic`, `variable.makeImageDynamic`, `variable.makeGraphDynamic`
(`variable.bind` and `variable.makeTextDynamic` refuse type that already has another text variable and name it),
@@ -6057,6 +6060,11 @@ These commands refuse a string, a number or another value that is not true or fa
in `path.curvatureEdit`; `perpendicular` in `path.reshapeSegment`; and `keepSelected`, `mergeOnlySelection` and
`merge` in `path.blob`. A null is read as a key left out.
`path.freehand` (and `brush.freehand`, which runs it) refuses a `style` other than "pencil" or "brush" with
`style must be "pencil" or "brush"`, and an `end` of `extend` other than "start" or "end" with
`extend end must be "start" or "end"`; the document does not change and no undo step is recorded. Left out or null,
`style` is "pencil" and the `end` of `extend` is "end".
A `pointer_gesture` with `mods: {cmd: true}` held at the press, with any tool but the selection tools (Command on
macOS, Ctrl elsewhere), drags with the selection tool chosen last (`select_tool`), or Direct Selection with the Pen,
Curvature and anchor tools until one is chosen; the release gives the tool back as it was, so the Pen goes on drawing
@@ -9393,7 +9401,7 @@ layers are refused.
destination or output intent is refused. Transparency is flattened before writing.
- **pdfX3** (PDF/X-3:2002, written as PDF 1.3): colours are tagged with ICC profiles; transparency is flattened.
- **pdfX4** (PDF/X-4:2010, PDF 1.6 at most): transparency and layers are kept, colours are tagged, and the XMP metadata
names the standard.
names the standard and has an `xmp:MetadataDate` equal to its `xmp:ModifyDate`.
Flattening uses `flattenerPreset` (default High Resolution, see PDF 1.3 above) on a copy (the document is untouched; a
warning says so), and images with see-through pixels count as transparency. The written file is checked against
+3 -1
View File
@@ -1357,6 +1357,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
The Blob Brush Tool Options also have Angle and Roundness, as the reference app's [Blob Brush options](https://web.archive.org/web/20261012042029/https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/blob-brush-options-and-best-practices.html) list them: Angle from −180° to 180° (0° by default) and Roundness from 0% to 100% (100%, a round tip, by default). The elliptical tip keeps its angle on the page along a stroke, a 0% tip is drawn 0.1% as wide as it is long, and the dialog shows the tip and three dabs of it. The values are kept with the tool's options (`path.blob` `angle` and `roundness`). Not done: the Random and pen-driven variations of Angle and Roundness.
The Blob Brush Tool Options' tip preview is the Angle slider for screen readers, with the Angle in degrees as its value: a click or a drag in it points the Angle at the pointer and gives it the keyboard focus, Tab reaches it after the Roundness field, and the arrow keys step the Angle by 1° (10° with Shift, Home and End to −180° and 180°).
The Blob Brush Tool Options also have Fidelity, which the reference app's [Blob Brush options](https://web.archive.org/web/20261012042029/https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/blob-brush-options-and-best-practices.html) list as setting how far the pointer moves before the path gets a new anchor point. The range and default are VectorCraft's own values: the Pencil's logarithmic slider from Accurate (0.01 pt) to Smooth (20 pt) and its field (up to 100 pt), 1.5 pt by default and kept with the tool's options. The brush follows the stroke fitted at the Fidelity, as a Pencil stroke is fitted: a low value follows the drag closely, jitter included, and a higher one gives smoother curves (`path.blob` `fidelity`).
`path.blob` rejects an Angle outside −180° to 180°, a Roundness outside 0% to 100% and a Fidelity outside 0.01 to 100 pt with an error and leaves the document unchanged; a key left out or null takes its default (0°, 100% and no fitting).
A Blob Brush stroke merges with the topmost path of its fill color and no stroke that it touches, and with the other such paths it touches in the same group or layer that are next to that path in stacking order with no other kind of object between them; matching paths in other groups or layers are left alone, as the Blob Brush tool guidelines in [Paint with fills and strokes](https://web.archive.org/web/20241219085603/https://helpx.adobe.com/illustrator/using/painting-fills-strokes.html) describe (`path.blob`).
- **Ruler guides as layer objects:** a guide goes on the current layer, shows, hides, locks and is deleted with it, is listed in the Layers panel (its row selects it) and moves to another layer (`guide.setLayer`, or its row dragged onto that layer's rows); guides on a hidden or locked layer can't be selected, moved or deleted, Duplicate copies a layer's guides and Merge Selected and Flatten Artwork keep them on the merged layer; guides from files saved before guides had layers go on the top visible, unlocked layer when the document opens. A guide's row has its own eye and lock, which hide or lock that guide alone in one undo step and take part in a drag down either column ([help page](https://helpx.adobe.com/in_hi/tutorial-builder/user-guide/illustrator-tutorial-builder/-ai--examples-of-common-coach-marks.html) lists a Guide among the Layers panel's items); a hidden guide is not drawn and does not snap, a locked one is drawn and snaps but can't be selected, moved or deleted, and its own state is kept through save and reopen and while its layer is hidden or locked (`layer.setProps` on its `guide.list` id). Object › Lock › Selection and Object › Hide › Selection lock or hide a selected guide with the selected art, and Unlock All and Show All unlock or show such guides and select them ([help page](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf) for Lock and Hide Selection). A guide row dropped on the panel's trash deletes its guide, the trash deletes a guide its row selected, and after a click on a guide row Delete deletes the guide rather than the rows highlighted before ([help page](https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/align-graphic-objects-with-guides.html) for deleting a selected guide). A plain click on another row lets go of a guide its row selected, keeping the selected art, as a plain click on a row picks that row alone; a Ctrl/Cmd or Shift click keeps it (#7340, `panels::layers` test `a_plain_row_click_lets_go_of_the_selected_guide`). Not done: guides stacked among the art of their layer (they are listed above it). Lock Guides also locks the objects made into guides: they can't be selected, moved or deleted (#1543); they are drawn in the guide colour and style of Preferences, and a dragged selection snaps to ruler guides with Smart Guides on (#1583, fixes #1534). Preferences › Guides & Grid › Lock Guides by Default locks guides when the app starts; it is off by default, and new guides can still be dragged out of a ruler while guides are locked. The Transform panel shows a selected ruler guide's X or Y, and typing a value moves it (#1659, part of #1597). This is not established by the documentation we could find: the public help pages on guides, rulers and the Transform, Control and Properties panels (read again on 2026-10-14) describe selecting and dragging unlocked guides and the panels' X and Y for a selection, not a guide's position in a panel, and the one public statement of it is a user's [community answer](https://community.adobe.com/questions-652/adding-a-new-custom-guide-785586), which is not documentation. It is kept as a convenience pending the owner's decision, with no parity claim and nothing counted towards a score.
- **Releasing ruler guides:** View › Guides › Release Guides turns the selected ruler guides into paths with no fill or stroke. An artboard guide becomes a line across its artboard, and a canvas guide becomes a line across the artboards (`view.guides.release {index?, ids?}`). A Cmd/Ctrl+Shift double-click with the Selection, Direct Selection or Group Selection tool releases the ruler guide or guide path under the pointer.
@@ -1763,7 +1764,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- **Sample Color from Screen:** an eyedropper button in the Color Picker and `ui.sampleScreenColor` (which can be given a key in Keyboard Shortcuts) pick a color anywhere on the screen with the system's sampler: `NSColorSampler` on macOS, the XDG desktop portal's [PickColor](https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Screenshot.html) on Linux, a still copy of every monitor under a crosshair on Windows, and the EyeDropper API in browsers that have it. The color becomes the fill or the stroke as one undo step, or the Color Picker's color, converted from display sRGB into the working RGB space. On Linux, a session without a portal that has PickColor, a portal that does not return from the call within 25 seconds (VectorCraft's own limit) or leaves the bus before it answers, and a portal that ends the request another way each show a status message and end the wait. On Windows, the copy is read as sRGB, so the colors of HDR and wide-gamut displays are not converted; Escape, a click of another mouse button or switching to another window cancels (VectorCraft's own rules). The BSDs and other browsers have no sampler yet; the button is gray there.
- **Color Guide color groups:** with variation cells selected, the Color Guide's Save Color Group to Swatches button saves those cells as one swatch group, and with none selected it saves the harmony colors, as the [help page](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf) describes saving several selected variations together (printed page 135). The group takes the cells in grid order (row by row, left to right, each cell once), is named after the harmony rule and is one undo step; these are VectorCraft's own rules. A selection lasts until the base, the Color Guide Options, the variation mode, the harmony rule, the library limit or the colors the grid shows (for example after a new swatch while the guide is limited to the document's swatches) change.
- **Color Guide colors dragged to Swatches:** a variation cell dragged from the Color Guide onto the Swatches panel's list becomes a swatch of that color, as the [help page](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf) describes for saving variations as individual swatches (printed page 135). In VectorCraft a harmony strip color drags the same way, a drag carries only the grabbed color (the selected cells stay selected and the selection is not saved), it carries the color the cell shows (snapped to the Limit to Library colors), keeps the color's model and does not paint the selected art; the swatch follows the panel's rules for a dropped color (`swatch.new`, one undo step, a color that is already a swatch is added again under another name, a drop on a color group joins it). These are VectorCraft's own rules. Tests: `a_dragged_guide_color_carries_its_color_and_applies_nothing` and `a_guide_color_dragged_onto_the_swatches_panel_becomes_a_swatch` in `crates/ui-egui/src/panels/color_guide.rs`.
- **Color Guide tints of a spot color:** when the Color Guide's base is a spot color, or a tint of one, chosen in the Swatches panel, with the Color panel's tint slider or with the base chip, the cells right of the center in the base row of Tints/Shades are tints of that spot color: a click paints the art with the tint, a drag carries it, and Save Colors as Swatches and Save Color Group to Swatches make tint swatches ("Ink 60%") linked to the spot color, so they follow an edit of it. The [help page](https://helpx.adobe.com/illustrator/desktop/manage-colors/learn-color-basics/color-guide-panel-overview.html) says spot colors are kept only on the right side of Tints/Shades and every other variation gives process colors. The tint percentages (the base's tint reduced by the share each cell goes toward white), the shades on the left staying process colors, a Limit to Library giving process colors, and a global process base keeping plain colors are VectorCraft's own rules. `swatch.new {colors}` and `swatch.newGroup {colors}` take `{swatch, tint}` entries. Tests: `a_spot_color_base_gives_tints_of_that_spot_color`, `a_tinted_spot_base_gives_lighter_tints_and_a_lost_link_gives_process_colors`, `a_renamed_spot_color_stays_the_base`, `saved_spot_tints_are_tint_swatches_of_the_spot_color`, `a_dragged_spot_tint_becomes_a_tint_swatch`, `a_clicked_spot_color_swatch_becomes_a_linked_color_guide_base`, `colors_entries_naming_a_spot_color_save_tint_swatches`.
- **Color Guide tints of a spot color:** when the Color Guide's base is a spot color, or a tint of one, chosen in the Swatches panel, with the Color panel's tint slider or with the base chip, the cells right of the center in the base row of Tints/Shades are tints of that spot color: a click paints the art with the tint, a drag carries it, and Save Colors as Swatches and Save Color Group to Swatches make tint swatches ("Ink 60%") linked to the spot color, so they follow an edit of it. The [help page](https://helpx.adobe.com/illustrator/desktop/manage-colors/learn-color-basics/color-guide-panel-overview.html) says spot colors are kept only on the right side of Tints/Shades and every other variation gives process colors. The tint percentages (the base's tint reduced by the share each cell goes toward white), the shades on the left staying process colors, a Limit to Library giving process colors, and a global process base keeping plain colors are VectorCraft's own rules. So are these: renaming the spot color in Swatch Options, also as a `command.batch` step, keeps it the base, and so do an Undo and a Redo of the rename; deleting it (or its color group), making it a process color or closing its document ends the link, so a later spot color of the same name does not become the base until it is chosen, and the base keeps the color it showed. A batch's steps in other documents leave the link alone. `swatch.new {colors}` and `swatch.newGroup {colors}` take `{swatch, tint}` entries. Tests: `a_spot_color_base_gives_tints_of_that_spot_color`, `a_tinted_spot_base_gives_lighter_tints_and_a_lost_link_gives_process_colors`, `a_renamed_spot_color_stays_the_base`, `a_deleted_spot_color_ends_the_link`, `an_undone_rename_keeps_the_link`, `a_batch_follows_the_spot_color_across_documents`, `a_deleted_color_group_ends_the_link`, `saved_spot_tints_are_tint_swatches_of_the_spot_color`, `a_dragged_spot_tint_becomes_a_tint_swatch`, `a_clicked_spot_color_swatch_becomes_a_linked_color_guide_base`, `colors_entries_naming_a_spot_color_save_tint_swatches`.
- **Stroke visibility (#1253):** adding paint to a previously unpainted zero-width stroke restores the existing 1 pt default (`PaintDefaults::default`, `Appearance::set_stroke`), for the selected appearance item, the new-art defaults and Swap Fill/Stroke. Positive widths are kept; recoloring a painted zero-width stroke keeps its explicit zero. A real Eyedropper-to-new-shape sequence reproduces the zero-width inheritance. Five engine regressions cover creation, defaults, targeted items, preserved widths and one-step Undo/Redo (`crates/engine/tests/it/stroke_visibility.rs`).
- **Gradients:** lossless, validated gradient params; gradients follow rotate, reflect, shear, non-uniform scale and distortions; the Gradient tool edits the fill or stroke of the active proxy, type included; an interactive on-canvas annotator (move, length/angle, rotate, add/move/delete/duplicate stops, midpoints, a stop popover, Delete and arrow keys). The Gradient panel has the Fill/Stroke proxy, a gradient-swatch dropdown with Save to Swatches, midpoint locations, Alt-drag to copy or swap stops, swatch drops on the ramp and a stop eyedropper; copied appearances and graphic styles place gradients on each target's own bounds; gradient handles, both ends of a vector drawn on the art and the start of a clicked one snap as other drawn points do (path segments, construction guides and View › Snap to Glyph's guides included) and honour Constrain Angle. Gradient stops stay linked to global and spot swatches. Freeform gradients (points and lines) are edited on the canvas; radial gradients have an extent ellipse, an aspect handle and an off-centre focal point (SVG `fx`/`fy`, PDF two-point radials). A stroke's gradient runs within, along or across it. Object ▸ Expand turns gradients into N objects or a gradient mesh.
A gradient stop that loses its link to a spot swatch (the swatch deleted, a recolor or adjustment that unlinks it, a library gradient, or a library character style linked to a swatch the document lacks) keeps the color it shows at full tint and drops the process plates it printed with that ink, as a stop given a plain color does; this is VectorCraft's own rule. Evidence: `tests::mapping_links_drops_the_process_plates_of_unlinked_stops` in `crates/color`, `tests::linked_stops::deleting_a_spot_swatch_takes_the_process_plates_of_the_stops_it_unlinks` and `tests::library::library_stops_unlinked_from_their_swatch_keep_no_process_plates` in `crates/engine`.
@@ -1974,6 +1975,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
A `.ai` or EPS whose editing data has brushes opens with the file's Calligraphic, Scatter, Art and Bristle brushes in the Brushes panel in place of the default ones, in the file's order: the Calligraphic size, roundness and angle with their variation, the Scatter size, spacing, scatter and rotation, the Bristle settings, and the Scatter and Art brushes' art (Art brushes in the older and newer forms of their objects). A brush library `.ai` (brushes and no layers) opens from its PDF part with its brushes, so Other Library lists them. An Art brush in None or Tints keeps that colorization, and one in the newer form also keeps its fixed width, Flip Along and Flip Across, and Scale Proportionately, Stretch to Fit Stroke Length or Stretch Between Guides with its guides ([Art brush options](https://web.archive.org/web/20220911143322/https://helpx.adobe.com/pdf/cs6/illustrator_reference.pdf), printed page 193). Pattern brushes and brushes that can't be read are left out with a note. Paths with a Calligraphic brush, and paths with an Art brush in the newer form that bends art of solid-filled paths with those options, open as the path with the brush on its stroke, except paths whose brush scales its art proportionately. Paths with an Art brush in the older form, and other brushed paths, still come in as their drawn look (part of #372 and #637; `crates/eps/src/import/ai/tests.rs`, `crates/eps/src/import/tests_native.rs`).
In a `.ai` opened from its editing data, a path or type object with Offset Path, Outline Object or Outline Stroke on the whole object opens as itself with those effects live, in their order and shown or hidden; on a fill or stroke of type they stay on that fill or stroke. Offset Path keeps its Offset, Joins and Miter Limit, and Outline Stroke takes its width from the stroke. An Offset Path with a setting missing, out of range or not read keeps the drawn art, as does a path with a Path effect on one fill or stroke (`crates/eps/src/import/ai/style/tests.rs`, `crates/eps/src/import/ai/tests.rs`, `crates/eps/src/import/tests_native.rs`).
In a `.ai` or EPS opened from its editing data, a Scatter brush whose last 15 numbers start with 1 comes into the Brushes panel in Tints, and each brush art section is read without its frame, an unnamed, unpainted rectangle with no settings of its own at the art's bounds (within 1/1000 pt). A wider frame stays in the art, and an art group with a state or look of its own (hidden, locked, isolated, knockout, an opacity, a blend mode, a name, a mask, a note or an appearance) stays a group (`crates/eps/src/import/ai/tests.rs`).
A PDF-compatible `.ai` saved with Include Editing Data for Other Apps writes a Scatter or Art brush whose art holds opacity masks to the Brushes panel of its editing copy. This is VectorCraft's own rule for brushes a document already holds. Each mask's art is written in the brush's art section in the form VectorCraft's `.ai` reader reads (`define_brush_art` in `crates/eps/src/import/ai/read/directives.rs`), with the mask's Clip and Invert Mask options, whether it is disabled and whether it moves with its object, for masks up to seven deep in one another's art. A brush whose mask art holds more than paths, compound paths and groups with one solid fill and one plain stroke each is left out with a warning, and a path with an Art brush whose art holds a mask is written as its drawn look. When the reader turns an Art brush's art over, it turns the art of a mask that doesn't move with its object over too (`scatter_and_art_brush_mask_art_round_trips` and `brushes_whose_mask_art_isnt_read_back_are_left_out` in `crates/eps/src/ai_editing/tests.rs`, `an_art_brushs_opacity_mask_art_turns_over_with_its_object` in `crates/eps/src/import/ai/tests.rs`).
In a `.ai` opened from its editing data, type with Warp on the object or on one of its fills or strokes opens as type with the effect live when the live warp draws as the art saved with it. When it draws differently, or when the file's limit of checks has no check left for it, it opens as that art, and one note says how many did. Type stays live without a comparison when the saved art paints nothing or draws type of its own, in frames of threaded type, when a text variable binds it, and when its text object doesn't come in as one text object (`crates/eps/src/import/ai/envelope.rs`, `crates/eps/src/import/tests_native.rs`).
In a `.ai` opened from its editing data, an object with a Tweak that moves nothing or Pucker & Bloat at 0 opens as itself with the effect live. A path, compound path or group whose only effect is Transform without copies, or a Free Distort whose corners make a parallelogram, opens as itself with it live, and so does an object with nothing stroked whose only effect is Twist: a path or compound path with straight segments at up to 180° either way, unless it is a compound path with a guide member that reaches past its other members and the angle is not 0°, and another path, compound path or group with no guide in it at up to 90° either way (limits VectorCraft sets); one twisted further keeps the drawn art. A gradient or pattern, an image, type, a clipping group, an opacity mask or effects inside the object, or a stroke with a Transform that scales, rotates or reflects, keep the drawn art (`crates/eps/src/import/ai/style/tests.rs`, `crates/eps/src/import/ai/tests.rs`, `crates/eps/src/import/ai/read/ops.rs`).
A PDF page whose `UserUnit` (PDF 1.6) is above 1 opens at its size in points, its numbers times the `UserUnit` (one above 75,000 counts as 75,000), and `document.pdfInfo` gives its size and boxes in points too. A `.ai` whose editing data has its artboards in the units of such a page opens from that data at the page's size, with its layers, and when the layers can't be read its pages still take the artboard layout of the data, scaled the same way (part of #1482).