mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-03 15:21:17 -05:00
Merge main into fix/window-panels-stay-shown
This commit is contained in:
@@ -86,7 +86,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Make",
|
||||
["Object", "Live Paint"],
|
||||
Some("Cmd+Alt+X"),
|
||||
"{ids?|id?} build a Live Paint group from the selected paths (paths, compound paths and groups of them; type, images and other objects are refused, nothing changes); each covered face starts with the fill rows that draw (shown, with paint and an opacity above 0) of its front-most covering source that has one and an opacity above 0, and each edge with the stroke rows that draw (also a weight above 0) of its source, in order with their settings and with that source's opacity and blending mode (on a path cut into several edges, dashes go on along the path with the lengths set, without the fit of dashes aligned to corners and path ends, arrowheads stay at its own ends, and a width profile or brush stays only on an edge that runs the whole path); a face or edge given no such row has one unpainted row; with a Live Paint group among them, add the others to it as livePaint.merge does; a Live Paint group alone has nothing to add, so it is selected and nothing changes (no undo step) → {id, faces, edges}",
|
||||
"{ids?|id?} build a Live Paint group from the selected paths (paths, compound paths and groups of them; type, images and other objects are refused, nothing changes); each covered face starts with the fill rows that draw (shown, with paint and an opacity above 0) of its front-most covering source that has one and an opacity above 0, and each edge with the stroke rows that draw (also a weight above 0) of its source, in order with their settings and with that source's opacity and blending mode (on a path cut into several edges, dashes go on along the path with the lengths set, without the fit of dashes aligned to corners and path ends, arrowheads stay at its own ends, and a width profile or brush stays only on an edge that runs the whole path); a face or edge given no such row has one unpainted row; with a Live Paint group among them, add the others to it as livePaint.merge does; a Live Paint group alone has nothing to add, so it is selected and nothing changes (no undo step). The command stops with an error and leaves the art unchanged when the paths are too many or too complex to map. This happens when the paths have more than 131,072 pieces once cut where they meet, or exceed the sweep's work budget, which counts pairs of segments with overlapping bounds. → {id, faces, edges}",
|
||||
has_selection_or_ids,
|
||||
lp_make
|
||||
),
|
||||
@@ -95,7 +95,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Merge",
|
||||
["Object", "Live Paint"],
|
||||
None,
|
||||
"{ids?|id?} add the other selected paths (compound paths, groups of paths and Live Paint groups too; type, images and other objects are refused, nothing changes) to the bottom-most Live Paint group, keeping its id, its paint and its own properties (name, lock, visibility, transparency, appearance, opacity mask, graphic style link); a Live Paint group alone has nothing to add, so it is selected and nothing changes (no undo step) → {id, faces, edges}",
|
||||
"{ids?|id?} add the other selected paths (compound paths, groups of paths and Live Paint groups too; type, images and other objects are refused, nothing changes) to the bottom-most Live Paint group, keeping its id, its paint and its own properties (name, lock, visibility, transparency, appearance, opacity mask, graphic style link); a Live Paint group alone has nothing to add, so it is selected and nothing changes (no undo step). The command stops with an error and leaves the art unchanged when the paths are too many or too complex to map. This happens when the paths have more than 131,072 pieces once cut where they meet, or exceed the sweep's work budget, which counts pairs of segments with overlapping bounds. → {id, faces, edges}",
|
||||
has_multi_or_ids,
|
||||
lp_merge
|
||||
),
|
||||
@@ -122,7 +122,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Gap Options",
|
||||
[],
|
||||
None,
|
||||
"{id?, ids?: [id…] (instead of id; default: the selected Live Paint groups), detect?: bool (Gap Detection: paint stops at gaps up to size wide), size?: \"small\" (3 pt) | \"medium\" (6 pt) | \"large\" (12 pt) | pt (custom, over 0 up to 72) (Paint Stops At), color?: #rrggbb or a layer color's name such as \"Red\" (Gap Preview Color; a hex color with an alpha part, #rrggbbaa or #rgba, is an error), closeGaps?: bool (add an unpainted path across each gap up to size wide to the group's paths)} set the Gap Options of Live Paint groups (what is not given stays as it was; a group starts with detect false, small and Red) and make their faces again, keeping their paint; when every group already has the options and closeGaps finds no gap, nothing changes (no undo step) → {ids, faces, gaps: [[x0,y0,x1,y1]…] (the gaps up to size wide that no path closes, from a loose end of a path to where it closes to; detect closes them for paint), closed (paths added)}",
|
||||
"{id?, ids?: [id…] (instead of id; default: the selected Live Paint groups), detect?: bool (Gap Detection: paint stops at gaps up to size wide), size?: \"small\" (3 pt) | \"medium\" (6 pt) | \"large\" (12 pt) | pt (custom, over 0 up to 72) (Paint Stops At), color?: #rrggbb or a layer color's name such as \"Red\" (Gap Preview Color; a hex color with an alpha part, #rrggbbaa or #rgba, is an error), closeGaps?: bool (add an unpainted path across each gap up to size wide to the group's paths)} set the Gap Options of Live Paint groups (what is not given stays as it was; a group starts with detect false, small and Red) and make their faces again, keeping their paint; when every group already has the options and closeGaps finds no gap, nothing changes (no undo step). The command stops with an error and leaves the art unchanged when a group's paths are too many or too complex to map. This happens when the paths have more than 131,072 pieces once cut where they meet, or exceed the sweep's work budget, which counts pairs of segments with overlapping bounds. The paths include lines across the gaps when detect is on. → {ids, faces, gaps: [[x0,y0,x1,y1]…] (the gaps up to size wide that no path closes, from a loose end of a path to where it closes to; detect closes them for paint), closed (paths added)}",
|
||||
has_selection_or_ids,
|
||||
lp_gap_options
|
||||
),
|
||||
@@ -740,12 +740,13 @@ fn build_children(d: &mut Document, sources: Vec<Arc<Node>>, max_gap: Option<f64
|
||||
src_group.visible = false;
|
||||
children.push(Arc::new(src_group));
|
||||
// Every path is an edge, open ones included; faces are the areas they enclose.
|
||||
let too_many = |e: po::TooManyPieces| EngineError::Other(format!("Live Paint: {e} to paint"));
|
||||
let (regs, edges) = match max_gap {
|
||||
Some(gap) => {
|
||||
let (regs, edges, _) = po::live_paint_with_gaps(&shapes, gap);
|
||||
let (regs, edges, _) = po::try_live_paint_with_gaps(&shapes, gap).map_err(too_many)?;
|
||||
(regs, edges)
|
||||
}
|
||||
None => po::live_paint(&shapes),
|
||||
None => po::try_live_paint(&shapes).map_err(too_many)?,
|
||||
};
|
||||
if regs.is_empty() && edges.is_empty() {
|
||||
return Err(EngineError::Other("Live Paint: these paths are too degenerate to paint".into()));
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -50,6 +50,12 @@ pub const OPTIONS: &[FormatOption] = &[
|
||||
FormatOption { name: "decimals", ty: "integer", default: "3", description: "coordinate precision, 1–7 decimal places" },
|
||||
FormatOption { name: "minify", ty: "boolean", default: "false", description: "no XML declaration, indentation or line breaks" },
|
||||
FormatOption { name: "responsive", ty: "boolean", default: "false", description: "no width/height: the SVG scales to its container" },
|
||||
FormatOption {
|
||||
name: "units",
|
||||
ty: "string",
|
||||
default: "null",
|
||||
description: "override the document unit for width and height: px (bare numbers, one per point) | pt | mm | cm | in; omit to follow the document unit, not null (the viewBox stays in points; not with responsive)",
|
||||
},
|
||||
FormatOption {
|
||||
name: "preserveEditing",
|
||||
ty: "boolean",
|
||||
@@ -121,7 +127,7 @@ pub fn options_map(p: &Value) -> Result<Map<String, Value>, String> {
|
||||
let mut m = Map::new();
|
||||
let Some(o) = p.as_object() else { return Ok(m) };
|
||||
for opt in OPTIONS.iter().filter(|opt| opt.name != "svg") {
|
||||
if let Some(v) = o.get(opt.name).filter(|v| !v.is_null()) {
|
||||
if let Some(v) = o.get(opt.name).filter(|v| opt.name == "units" || !v.is_null()) {
|
||||
m.insert(opt.name.into(), v.clone());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,10 @@ fn junk_options_are_rejected() {
|
||||
json!({"svg": "css"}),
|
||||
json!({"images": "inline"}),
|
||||
json!({"useArtboards": "yes"}),
|
||||
json!({"units": "furlong"}),
|
||||
json!({"units": 7}),
|
||||
json!({"units": null}),
|
||||
json!({"svg": {"units": null}}),
|
||||
] {
|
||||
let mut q = p.clone();
|
||||
q["format"] = json!("svg");
|
||||
@@ -124,6 +128,39 @@ fn junk_options_are_rejected() {
|
||||
assert!(s.execute("document.export", &json!({"format": "png", "styling": "fancy"})).is_ok());
|
||||
}
|
||||
|
||||
/// #4462: width and height carry the chosen unit (the document is 200 × 100 pt, the viewBox stays
|
||||
/// in points), px is today's bare numbers, and Responsive leaves the size out whatever the unit.
|
||||
#[test]
|
||||
fn svg_export_writes_width_height_with_the_requested_unit() {
|
||||
let mut s = session(1);
|
||||
let plain = svg(&mut s, json!({}));
|
||||
assert!(plain.contains(" width=\"200\" height=\"100\" viewBox=\"0 0 200 100\""), "{plain}");
|
||||
assert_eq!(svg(&mut s, json!({"units": "px"})), plain, "px keeps bare point coordinates");
|
||||
for unit in ["mm", "cm", "in", "pt"] {
|
||||
for decimals in [1, 3] {
|
||||
for p in [json!({"units": unit, "decimals": decimals}), json!({"svg": {"units": unit, "decimals": decimals}})] {
|
||||
let out = svg(&mut s, p);
|
||||
assert!(out.contains(&format!("{unit}\"")) && out.contains("viewBox=\"0 0 200 100\""), "{unit}:\n{out}");
|
||||
let back = vectorcraft_svg::import(&out).unwrap();
|
||||
let rect = back.artboards[0].rect;
|
||||
assert!((rect.width() - 200.0).abs() < 0.001 && (rect.height() - 100.0).abs() < 0.001, "{unit}: {rect:?}\n{out}");
|
||||
}
|
||||
}
|
||||
}
|
||||
let out = svg(&mut s, json!({"units": "mm", "responsive": true}));
|
||||
assert!(!out.contains("mm\"") && !out.contains("height=\"100\" viewBox") && out.contains("viewBox=\"0 0 200 100\""), "{out}");
|
||||
assert!(svg(&mut s, json!({"units": "mm", "decimals": 1})).contains("x=\"10.1\""), "coordinate precision is unchanged");
|
||||
// Omitted units retain main's document-unit save behavior, including serialized defaults.
|
||||
s.execute("document.setUnits", &json!({"units": "millimeters"})).unwrap();
|
||||
let defaults = serde_json::to_value(vectorcraft_svg::ExportOptions::default()).unwrap();
|
||||
assert!(svg(&mut s, json!({"svg": defaults})).contains("mm\""));
|
||||
for p in [json!({"units": "px"}), json!({"svg": {"units": "px"}})] {
|
||||
assert_eq!(svg(&mut s, p), plain, "explicit pixels override physical document units");
|
||||
}
|
||||
assert_eq!(svg(&mut s, json!({"units": "mm", "svg": {"units": "px"}})), plain, "nested units override flat units");
|
||||
assert_eq!(svg(&mut s, json!({"units": null, "svg": {"units": "px"}})), plain, "nested units override flat null");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn several_artboards_write_one_file_each() {
|
||||
let mut s = session(3);
|
||||
|
||||
@@ -956,11 +956,10 @@ fn option_trees() -> Value {
|
||||
let mut trees = pdf_option_tree();
|
||||
if let Some(tree) = trees.as_object_mut() {
|
||||
tree.insert("flattener".into(), serde_json::to_value(super::flatten::FlattenOptions::default()).unwrap_or_default());
|
||||
let mut svg = serde_json::to_value(vectorcraft_svg::ExportOptions::default()).unwrap_or_default();
|
||||
if let Some(svg) = svg.as_object_mut() {
|
||||
svg.extend(super::fileio::ARTBOARD_PARAMS.iter().chain(&["useArtboards"]).map(|k| (k.to_string(), Value::Null)));
|
||||
}
|
||||
tree.insert("svg".into(), svg);
|
||||
// Serialized defaults omit optional overrides such as units; the registry lists every key.
|
||||
let svg = super::fileio::FORMATS.iter().find(|f| f.id == "svg").into_iter().flat_map(|f| f.options);
|
||||
let svg = svg.filter(|o| o.name != "svg").map(|o| (o.name.to_string(), Value::Null)).collect();
|
||||
tree.insert("svg".into(), Value::Object(svg));
|
||||
}
|
||||
trees
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Divide",
|
||||
["Window", "Pathfinder"],
|
||||
None,
|
||||
"{ids?: [id…] (selected first; default: the selection), precision?: pt 0.001..10, removeRedundantPoints?: bool, removeUnpainted?: bool (default: the Pathfinder Options, see object.pathfinder.options; the values used join the journal entry)} operate on the selected objects (back → front) → {ids}",
|
||||
"{ids?: [id…] (selected first; default: the selection), precision?: pt 0.001..10, removeRedundantPoints?: bool, removeUnpainted?: bool (default: the Pathfinder Options, see object.pathfinder.options; the values used join the journal entry)} operate on the selected objects (back → front). When open paths are among them, the command stops with an error and leaves the art unchanged if the paths are too many or too complex to map. This happens when the paths it maps, as it prepares them from the selection, have more than 65,536 segments, have more than 131,072 pieces once cut where they meet, or exceed the sweep's work budget, which counts pairs of segments with overlapping bounds. → {ids}",
|
||||
has_selection,
|
||||
|s, p| run_pf(s, p, PathfinderOp::Divide)
|
||||
),
|
||||
@@ -823,7 +823,8 @@ fn run_pf(s: &mut Session, p: &Value, op: PathfinderOp) -> Result<Value> {
|
||||
if shapes.iter().any(|s| s.path.subpaths.iter().any(|sp| sp.anchors.iter().any(|a| !(a.p.x.is_finite() && a.p.y.is_finite())))) {
|
||||
return Err(EngineError::Other("paths contain invalid coordinates".into()));
|
||||
}
|
||||
let mut results = po::pathfinder_with(op, &shapes, options.precision);
|
||||
let mut results = po::try_pathfinder_with(op, &shapes, options.precision)
|
||||
.map_err(|e| EngineError::Other(format!("{label}: {e} to cut with the open paths; select fewer paths")))?;
|
||||
if options.remove_unpainted && matches!(op, PathfinderOp::Divide | PathfinderOp::Outline) {
|
||||
// Pathfinder Options › Divide and Outline Will Remove Unpainted Artwork: the pieces
|
||||
// of objects with no fill (or only hidden ones) go.
|
||||
|
||||
@@ -1160,9 +1160,10 @@ fn a_blend_mode_over_art_of_several_colors_has_no_one_answer() {
|
||||
assert!((ratio(&r) - 21.0).abs() < 1e-3, "white minus white is black: {r}");
|
||||
}
|
||||
|
||||
/// A Difference square over a white square in a 50 % group that isolates its blending, over the
|
||||
/// edge between black and white art: the square blends only with the white inside the group, so
|
||||
/// A Difference square over a 50 % white square in a 50 % group that isolates its blending, over
|
||||
/// the edge between black and white art: the square blends only with the white inside the group, so
|
||||
/// the art of two colors outside it, which the group draws over in Normal mode, leaves one answer.
|
||||
/// Without isolation the blend also reaches that art, and there is no one answer.
|
||||
#[test]
|
||||
fn a_blend_mode_inside_an_isolating_group_answers_over_art_of_several_colors() {
|
||||
let mut s = session();
|
||||
@@ -1177,14 +1178,33 @@ fn a_blend_mode_inside_an_isolating_group_answers_over_art_of_several_colors() {
|
||||
let back = id(s.execute("shape.rectangle", &json!({"x": 60, "y": 60, "width": 80, "height": 80})).unwrap());
|
||||
s.execute("paint.setFill", &json!({"color": "#ffffff"})).unwrap();
|
||||
s.execute("paint.setStroke", &json!({"none": true})).unwrap();
|
||||
// Translucent, so that a blend that is not isolated also reaches the art behind the group.
|
||||
s.execute("transparency.set", &json!({"opacity": 50})).unwrap();
|
||||
let square = id(s.execute("shape.rectangle", &json!({"x": 70, "y": 70, "width": 60, "height": 60})).unwrap());
|
||||
s.execute("paint.setStroke", &json!({"none": true})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#ffffff"})).unwrap();
|
||||
s.execute("transparency.set", &json!({"blend": "difference"})).unwrap();
|
||||
s.execute("object.group", &json!({"ids": [back, square]})).unwrap();
|
||||
let group = id(s.execute("object.group", &json!({"ids": [back, square]})).unwrap());
|
||||
s.execute("transparency.set", &json!({"opacity": 50, "isolate": true})).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [square]})).unwrap();
|
||||
s.execute("color.contrast", &json!({})).unwrap();
|
||||
let r = s.execute("color.contrast", &json!({})).unwrap();
|
||||
let isolated = ratio(&r);
|
||||
assert!(isolated > 1.0, "{r}");
|
||||
assert!(r["against"].as_str().is_some_and(|h| vectorcraft_color::Color::from_hex(h).is_some()), "{r}");
|
||||
// Without isolation the square also blends with the black and white art, so there is no one answer.
|
||||
let set_isolate = |s: &mut Session, on: bool| {
|
||||
s.execute("select.set", &json!({"ids": [group]})).unwrap();
|
||||
s.execute("transparency.set", &json!({"isolate": on})).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [square]})).unwrap();
|
||||
};
|
||||
set_isolate(&mut s, false);
|
||||
let e = s.execute("color.contrast", &json!({})).unwrap_err().to_string();
|
||||
assert!(e.contains("is not one color where it is read"), "{e}");
|
||||
set_isolate(&mut s, true);
|
||||
// The Difference mode is applied: in Normal mode the same square gives another answer.
|
||||
s.execute("transparency.set", &json!({"blend": "normal"})).unwrap();
|
||||
let normal = ratio(&s.execute("color.contrast", &json!({})).unwrap());
|
||||
assert!((isolated - normal).abs() > 0.1, "difference {isolated} against normal {normal}");
|
||||
}
|
||||
|
||||
/// With a fill of None, what a pick would be measured against is still read: the Color Wheel's
|
||||
|
||||
@@ -2214,7 +2214,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.livePaintGapOptions",
|
||||
"Gap Options…",
|
||||
"",
|
||||
"{} open Gap Options (Object › Live Paint › Gap Options…; dialog `livePaintGapOptions`: detect, size small|medium|large|custom, custom (pt), color (#rrggbb or a layer color's name), closeGaps, preview) on the selected Live Paint groups, filled in from the first; with preview on, the options apply live and the gaps found draw on the canvas in the preview color: OK runs livePaint.gapOptions as one undo step; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing, and with preview on a #rrggbbaa color is not previewed: the groups keep their own color and the gaps draw in black",
|
||||
"{} open Gap Options (Object › Live Paint › Gap Options…; dialog `livePaintGapOptions`: detect, size small|medium|large|custom, custom (pt), color (#rrggbb or a layer color's name), closeGaps, preview) on the selected Live Paint groups, filled in from the first; with preview on, the options apply live and the gaps found draw on the canvas in the preview color: OK runs livePaint.gapOptions as one undo step; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing, and with preview on a #rrggbbaa color is not previewed: the groups keep their own color and the gaps draw in black; a preview that fails shows its error in the status bar, puts the groups back as they were and stops drawing the dialog's preview of the gaps (View › Show Live Paint Gaps still draws the restored groups' own gaps)",
|
||||
),
|
||||
(
|
||||
"ui.perspectivePlane",
|
||||
|
||||
@@ -31,11 +31,12 @@ pub use fit::{fit_cubics, fit_cubics_through};
|
||||
pub use offset::{Cap, Join, MAX_OFFSET_SEGMENT_PAIRS, offset_path, outline_stroke, stroke_region, try_offset_path};
|
||||
pub use pathfinder::{
|
||||
FaceMerger, PathfinderOp, Region, Shape, merge_regions, pathfinder, pathfinder_with, region_at, regions, regions_with, regions_within,
|
||||
try_pathfinder_with,
|
||||
};
|
||||
pub use planar::{
|
||||
Adjacency, BuilderArrangement, MapEdge, MapFace, MapOutline, SHAPE_BUILDER_MAX_GAP, SHAPE_BUILDER_MAX_MAP_EDGES, SHAPE_BUILDER_MAX_SEGMENTS,
|
||||
adjacency, cut_out, encloses_area, find_gaps, has_open_path, interior_point, live_paint, live_paint_with_gaps, run_around, shape_builder,
|
||||
shape_builder_with_gap,
|
||||
TooManyPieces, adjacency, cut_out, encloses_area, find_gaps, has_open_path, interior_point, live_paint, live_paint_with_gaps, run_around,
|
||||
shape_builder, shape_builder_with_gap, try_live_paint, try_live_paint_with_gaps,
|
||||
};
|
||||
pub use thickness::{MAX_DOCUMENT_THICKNESS_WORK, MAX_THICKNESS_PIECES, ThicknessBudget, thinner_than, thinner_than_within};
|
||||
pub use trap::{TRAP_HEIGHT_WIDTH_RANGE, TRAP_MAX_WIDTH, TRAP_MIN_WIDTH, trap_band};
|
||||
|
||||
@@ -109,6 +109,36 @@ pub fn pathfinder(op: PathfinderOp, shapes: &[Shape]) -> Vec<Shape> {
|
||||
pathfinder_with(op, shapes, DEFAULT_PRECISION)
|
||||
}
|
||||
|
||||
/// [`pathfinder_with`], or [`TooManyPieces`](crate::TooManyPieces) when Divide's open paths and the
|
||||
/// shapes they cut have more than [`SHAPE_BUILDER_MAX_SEGMENTS`](crate::SHAPE_BUILDER_MAX_SEGMENTS)
|
||||
/// segments, or the sweep cuts them into more than
|
||||
/// [`SHAPE_BUILDER_MAX_MAP_EDGES`](crate::SHAPE_BUILDER_MAX_MAP_EDGES) pieces, or they exceed the
|
||||
/// sweep's work budget. [`pathfinder_with`] then divides only the filled areas and leaves the open
|
||||
/// paths out.
|
||||
pub fn try_pathfinder_with(op: PathfinderOp, shapes: &[Shape], precision: f64) -> Result<Vec<Shape>, crate::TooManyPieces> {
|
||||
if op == PathfinderOp::Divide && crate::has_open_path(shapes) {
|
||||
let precision = if precision.is_finite() && precision > 0.0 { precision } else { DEFAULT_PRECISION };
|
||||
let (faces, capped) = divide_with_open_paths(shapes, precision, false);
|
||||
return if capped { Err(crate::TooManyPieces) } else { Ok(faces) };
|
||||
}
|
||||
Ok(pathfinder_with(op, shapes, precision))
|
||||
}
|
||||
|
||||
/// Divide with open paths as cutting edges, through the Shape Builder's bounded planar map (and,
|
||||
/// with `fallback`, its filled-area fallback), and whether that map was skipped for its size.
|
||||
fn divide_with_open_paths(shapes: &[Shape], precision: f64, fallback: bool) -> (Vec<Shape>, bool) {
|
||||
let (arrangement, capped) = crate::planar::builder_capped(shapes, false, 0.0, precision, fallback);
|
||||
let faces = arrangement
|
||||
.regions
|
||||
.into_iter()
|
||||
.filter_map(|r| {
|
||||
let key = shapes.get(r.top()?)?.key;
|
||||
Some(Shape::new(r.path, FillRule::NonZero, key))
|
||||
})
|
||||
.collect();
|
||||
(faces, capped)
|
||||
}
|
||||
|
||||
/// [`pathfinder`] at Pathfinder Options › Precision: results are refit to within `precision`
|
||||
/// (document units) and pieces thinner than it are dropped. A smaller value follows the inputs more
|
||||
/// closely. A value that isn't positive and finite is [`DEFAULT_PRECISION`].
|
||||
@@ -130,14 +160,7 @@ pub fn pathfinder_with(op: PathfinderOp, shapes: &[Shape], precision: f64) -> Ve
|
||||
// Open paths are cutting edges for Divide; the filled-only operations keep their
|
||||
// implicit closure. Reuse Shape Builder's bounded planar map and its fallback.
|
||||
if op == PathfinderOp::Divide && crate::has_open_path(shapes) {
|
||||
return crate::planar::builder(shapes, false, 0.0, precision)
|
||||
.regions
|
||||
.into_iter()
|
||||
.filter_map(|r| {
|
||||
let key = shapes.get(r.top()?)?.key;
|
||||
Some(Shape::new(r.path, FillRule::NonZero, key))
|
||||
})
|
||||
.collect();
|
||||
return divide_with_open_paths(shapes, precision, true).0;
|
||||
}
|
||||
let Some(arr) = arrangement(shapes, precision) else { return Vec::new() };
|
||||
let p = &arr.tidy;
|
||||
@@ -1645,6 +1668,8 @@ mod tests {
|
||||
assert_eq!(faces.len(), 1, "a segment past the cap falls back to filled areas");
|
||||
assert_eq!(faces[0].key, 7);
|
||||
assert!((crate::area(&faces[0].path, faces[0].rule) - 10000.0).abs() < 1e-6);
|
||||
// The checked Divide reports that it left the lines out.
|
||||
assert_eq!(try_pathfinder_with(PathfinderOp::Divide, &inputs, DEFAULT_PRECISION), Err(crate::TooManyPieces));
|
||||
}
|
||||
|
||||
fn old_trim(shapes: &[Shape], precision: f64) -> Vec<Shape> {
|
||||
|
||||
@@ -37,14 +37,14 @@ pub use adjacency::{Adjacency, MapEdge, MapFace, MapOutline, adjacency};
|
||||
pub(crate) use graph::pin_ends;
|
||||
#[cfg(test)]
|
||||
use index::{Crossings, RectIndex, reference_budget, segment_footprint, work_done};
|
||||
pub use live_paint::{find_gaps, live_paint, live_paint_with_gaps};
|
||||
pub use live_paint::{find_gaps, live_paint, live_paint_with_gaps, try_live_paint, try_live_paint_with_gaps};
|
||||
pub use map::interior_point;
|
||||
pub(crate) use map::{Map, Rest, map};
|
||||
pub use shape_builder::{
|
||||
BuilderArrangement, SHAPE_BUILDER_MAX_GAP, SHAPE_BUILDER_MAX_MAP_EDGES, SHAPE_BUILDER_MAX_SEGMENTS, cut_out, encloses_area, has_open_path,
|
||||
run_around, shape_builder, shape_builder_with_gap,
|
||||
BuilderArrangement, SHAPE_BUILDER_MAX_GAP, SHAPE_BUILDER_MAX_MAP_EDGES, SHAPE_BUILDER_MAX_SEGMENTS, TooManyPieces, cut_out, encloses_area,
|
||||
has_open_path, run_around, shape_builder, shape_builder_with_gap,
|
||||
};
|
||||
pub(crate) use shape_builder::{builder, gap_inputs};
|
||||
pub(crate) use shape_builder::{builder_capped, gap_inputs};
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
@@ -6,26 +6,72 @@ use super::*;
|
||||
/// Faces are the bounded areas the paths enclose, holes included, each with the inputs whose fill
|
||||
/// covers it (ascending; empty for an area only enclosed by paths). Edges are the paths split
|
||||
/// wherever they meet another path, keyed by the input they came from (the front-most where
|
||||
/// inputs share one). Empty when the paths can't be swept (non-finite or too degenerate).
|
||||
/// inputs share one). Empty when the paths can't be swept (non-finite or too degenerate), or when
|
||||
/// the sweep cuts them into more than [`SHAPE_BUILDER_MAX_MAP_EDGES`] pieces or the inputs exceed
|
||||
/// the sweep's work budget ([`try_live_paint`] reports either limit).
|
||||
pub fn live_paint(shapes: &[Shape]) -> (Vec<Region>, Vec<Shape>) {
|
||||
build(shapes, DEFAULT_PRECISION).map(|(faces, edges, _)| (faces, edges)).unwrap_or_default()
|
||||
try_live_paint(shapes).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// [`live_paint`], or [`TooManyPieces`] when the sweep cuts the paths into more than
|
||||
/// [`SHAPE_BUILDER_MAX_MAP_EDGES`] pieces or the inputs exceed the sweep's work budget.
|
||||
/// No faces or edges are built in either case.
|
||||
pub fn try_live_paint(shapes: &[Shape]) -> Result<(Vec<Region>, Vec<Shape>), TooManyPieces> {
|
||||
Ok(build(shapes, DEFAULT_PRECISION)?.map(|(faces, edges, _)| (faces, edges)).unwrap_or_default())
|
||||
}
|
||||
|
||||
/// Faces, edges and gaps, as [`live_paint_with_gaps`] gives them.
|
||||
type WithGaps = (Vec<Region>, Vec<Shape>, Vec<[Point; 2]>);
|
||||
|
||||
type Capped<T> = Result<T, TooManyPieces>;
|
||||
|
||||
type CappedWithGaps = (Capped<Vec<Region>>, Capped<Vec<Shape>>, Vec<[Point; 2]>);
|
||||
|
||||
/// [`live_paint`] with Gap Detection: the faces are those of `shapes` with a line across each gap
|
||||
/// [`find_gaps`] finds up to `max_gap`, so paint stops at the gaps, and the edges are those of
|
||||
/// `shapes` alone (the lines add none). Also returns the gaps.
|
||||
pub fn live_paint_with_gaps(shapes: &[Shape], max_gap: f64) -> (Vec<Region>, Vec<Shape>, Vec<[Point; 2]>) {
|
||||
let (faces, edges, gaps) = faces_and_edges_with_gaps(shapes, max_gap);
|
||||
(faces.unwrap_or_default(), edges.unwrap_or_default(), gaps)
|
||||
}
|
||||
|
||||
/// [`live_paint_with_gaps`], or [`TooManyPieces`] when the sweep cuts the paths, or the paths with
|
||||
/// the lines across their gaps, into more than [`SHAPE_BUILDER_MAX_MAP_EDGES`] pieces, or either
|
||||
/// set of paths exceeds the sweep's work budget.
|
||||
pub fn try_live_paint_with_gaps(shapes: &[Shape], max_gap: f64) -> Result<WithGaps, TooManyPieces> {
|
||||
let gaps = find_gaps(shapes, max_gap);
|
||||
let Some(closed) = with_gap_lines(shapes, &gaps) else {
|
||||
let (faces, edges) = try_live_paint(shapes)?;
|
||||
return Ok((faces, edges, gaps));
|
||||
};
|
||||
let (faces, _) = try_live_paint(&closed)?;
|
||||
let (_, edges) = try_live_paint(shapes)?;
|
||||
Ok((faces, edges, gaps))
|
||||
}
|
||||
|
||||
/// The faces and the edges of [`live_paint_with_gaps`], each built on its own, and the gaps.
|
||||
fn faces_and_edges_with_gaps(shapes: &[Shape], max_gap: f64) -> CappedWithGaps {
|
||||
let gaps = find_gaps(shapes, max_gap);
|
||||
let Some(closed) = with_gap_lines(shapes, &gaps) else {
|
||||
return match try_live_paint(shapes) {
|
||||
Ok((faces, edges)) => (Ok(faces), Ok(edges), gaps),
|
||||
Err(e) => (Err(e), Err(e), gaps),
|
||||
};
|
||||
};
|
||||
let faces = try_live_paint(&closed).map(|(faces, _)| faces);
|
||||
let edges = try_live_paint(shapes).map(|(_, edges)| edges);
|
||||
(faces, edges, gaps)
|
||||
}
|
||||
|
||||
/// `shapes` with a line across each of `gaps`, or `None` when there are none.
|
||||
fn with_gap_lines(shapes: &[Shape], gaps: &[[Point; 2]]) -> Option<Vec<Shape>> {
|
||||
if gaps.is_empty() {
|
||||
let (faces, edges) = live_paint(shapes);
|
||||
return (faces, edges, gaps);
|
||||
return None;
|
||||
}
|
||||
let mut closed = shapes.to_vec();
|
||||
let lines = PathData::new(gaps.iter().map(|g| SubPath::polyline(g, false)).collect());
|
||||
closed.push(Shape::new(lines, FillRule::NonZero, u64::MAX));
|
||||
let (faces, _) = live_paint(&closed);
|
||||
let (_, edges) = live_paint(shapes);
|
||||
(faces, edges, gaps)
|
||||
Some(closed)
|
||||
}
|
||||
|
||||
/// How many times longer than a gap the way between its two ends along the paths must be for it to
|
||||
|
||||
@@ -42,11 +42,18 @@ pub(crate) fn map(shapes: &[Shape], cover: bool) -> Option<Map> {
|
||||
|
||||
/// [`map`] whose faces and pieces are refit to `precision`, and whose slivers thinner than it are dropped.
|
||||
pub(super) fn map_with(shapes: &[Shape], cover: bool, precision: f64) -> Option<Map> {
|
||||
map_within(shapes, cover, precision, usize::MAX)
|
||||
map_within(shapes, cover, precision, usize::MAX).ok().flatten()
|
||||
}
|
||||
|
||||
/// [`map_with`], or `None` when the sweep cuts the paths into more than `max_edges` pieces.
|
||||
pub(super) fn map_within(shapes: &[Shape], cover: bool, precision: f64, max_edges: usize) -> Option<Map> {
|
||||
/// [`map_with`], or [`TooManyPieces`] when the sweep cuts the paths into more than `max_edges` pieces
|
||||
/// or the inputs exceed the sweep's work budget.
|
||||
pub(super) fn map_within(shapes: &[Shape], cover: bool, precision: f64, max_edges: usize) -> Result<Option<Map>, TooManyPieces> {
|
||||
let mut capped = false;
|
||||
let map = map_capped(shapes, cover, precision, max_edges, &mut capped);
|
||||
if capped { Err(TooManyPieces) } else { Ok(map) }
|
||||
}
|
||||
|
||||
fn map_capped(shapes: &[Shape], cover: bool, precision: f64, max_edges: usize, capped: &mut bool) -> Option<Map> {
|
||||
let mut inputs: Vec<(BezPath, usize)> = Vec::new();
|
||||
for (i, s) in shapes.iter().enumerate() {
|
||||
let mut bp = BezPath::new();
|
||||
@@ -71,10 +78,11 @@ pub(super) fn map_within(shapes: &[Shape], cover: bool, precision: f64, max_edge
|
||||
snap_horizontals(&mut inputs.iter_mut().map(|p| &mut p.0).collect::<Vec<_>>(), eps);
|
||||
// Counted on the snapped geometry, which is what the sweep sees: snapping can bring boxes into contact.
|
||||
if !crate::budget::sweep_fits(inputs.iter().map(|p| &p.0)) {
|
||||
*capped = true;
|
||||
return None;
|
||||
}
|
||||
let tidy = Tidy::keeping(precision, inputs.iter().map(|p| &p.0));
|
||||
let (points, edges) = sweep_graph(&inputs, eps, precision, max_edges)?;
|
||||
let (points, edges) = sweep_graph(&inputs, eps, precision, max_edges, capped)?;
|
||||
let nv = points.len();
|
||||
|
||||
// Half-edges leaving each vertex, sorted by direction; walking a face, the next half-edge is
|
||||
@@ -193,7 +201,7 @@ pub(super) fn map_within(shapes: &[Shape], cover: bool, precision: f64, max_edge
|
||||
Some(Map { edges, around, slot_of, faces, face_index, slivers, holes, face_holes, tidy, anchors, snap })
|
||||
}
|
||||
|
||||
fn sweep_graph(inputs: &[(BezPath, usize)], eps: f64, precision: f64, max_edges: usize) -> Option<(Vec<Point>, Vec<Edge>)> {
|
||||
fn sweep_graph(inputs: &[(BezPath, usize)], eps: f64, precision: f64, max_edges: usize, capped: &mut bool) -> Option<(Vec<Point>, Vec<Edge>)> {
|
||||
// The sweep can panic on rare near-degenerate input; that must never take the app down.
|
||||
let sweep =
|
||||
std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| Topology::<Crossings>::from_paths(inputs.iter().map(|(p, i)| (p, *i)), eps)));
|
||||
@@ -202,6 +210,7 @@ fn sweep_graph(inputs: &[(BezPath, usize)], eps: f64, precision: f64, max_edges:
|
||||
// the paths into, and paths that cross many times are cut into far more pieces than they have
|
||||
// segments.
|
||||
if top.segment_indices().nth(max_edges).is_some() {
|
||||
*capped = true;
|
||||
return None;
|
||||
}
|
||||
// The planar graph: vertices are the sweep's points, edges its segments. Points closer than
|
||||
@@ -437,10 +446,17 @@ impl Map {
|
||||
/// Faces and edges of `shapes`, and the pieces of the open paths (those with no closed subpath)
|
||||
/// that lie under another path in front of them, whose edges are that path's: under a closed
|
||||
/// path's outline, or along an open path in front.
|
||||
/// `None` when the sweep cuts the paths into more than [`SHAPE_BUILDER_MAX_MAP_EDGES`] pieces.
|
||||
pub(super) fn build(shapes: &[Shape], precision: f64) -> Option<(Vec<Region>, Vec<Shape>, Vec<Shape>)> {
|
||||
let m = map_within(shapes, false, precision, SHAPE_BUILDER_MAX_MAP_EDGES)?;
|
||||
let Map { edges, around, faces, holes, face_holes, tidy, anchors, snap, .. } = &m;
|
||||
/// This returns [`TooManyPieces`] when the sweep cuts the paths into more than
|
||||
/// [`SHAPE_BUILDER_MAX_MAP_EDGES`] pieces or the inputs exceed the sweep's work budget.
|
||||
pub(super) fn build(shapes: &[Shape], precision: f64) -> Result<Option<Built>, TooManyPieces> {
|
||||
Ok(map_within(shapes, false, precision, SHAPE_BUILDER_MAX_MAP_EDGES)?.and_then(|m| build_from(&m, shapes, precision)))
|
||||
}
|
||||
|
||||
/// Faces, edges and the open paths' pieces under another path, as [`build`] gives them.
|
||||
pub(super) type Built = (Vec<Region>, Vec<Shape>, Vec<Shape>);
|
||||
|
||||
fn build_from(m: &Map, shapes: &[Shape], precision: f64) -> Option<Built> {
|
||||
let Map { edges, around, faces, holes, face_holes, tidy, anchors, snap, .. } = m;
|
||||
let snap = *snap;
|
||||
let fills: Vec<Fill> = shapes.iter().map(Fill::new).collect();
|
||||
let subpath = |cycle: &[usize]| {
|
||||
|
||||
@@ -19,6 +19,20 @@ pub const SHAPE_BUILDER_MAX_SEGMENTS: usize = 65_536;
|
||||
/// from them still has its region.
|
||||
pub const SHAPE_BUILDER_MAX_MAP_EDGES: usize = 2 * SHAPE_BUILDER_MAX_SEGMENTS;
|
||||
|
||||
/// The paths have more than [`SHAPE_BUILDER_MAX_SEGMENTS`] segments, or the sweep cut them into
|
||||
/// more than [`SHAPE_BUILDER_MAX_MAP_EDGES`] pieces, or they exceed the sweep's work budget.
|
||||
/// Their planar map was not built.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct TooManyPieces;
|
||||
|
||||
impl std::fmt::Display for TooManyPieces {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str("the paths have too many segments or pieces")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for TooManyPieces {}
|
||||
|
||||
/// The Shape Builder's arrangement: see [`shape_builder`].
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct BuilderArrangement {
|
||||
@@ -86,23 +100,43 @@ pub fn shape_builder_with_gap(shapes: &[Shape], edges: bool, gap: f64) -> Builde
|
||||
|
||||
/// [`shape_builder_with_gap`] refitting its results to `precision` (Pathfinder Options › Precision).
|
||||
pub(crate) fn builder(shapes: &[Shape], edges: bool, gap: f64, precision: f64) -> BuilderArrangement {
|
||||
builder_capped(shapes, edges, gap, precision, true).0
|
||||
}
|
||||
|
||||
/// [`builder`], and whether its full map was skipped because the paths have more than
|
||||
/// [`SHAPE_BUILDER_MAX_SEGMENTS`] segments or the sweep cut them into more than
|
||||
/// [`SHAPE_BUILDER_MAX_MAP_EDGES`] pieces, or the inputs exceed the sweep's work budget.
|
||||
/// The regions are then the filled areas', or, without `fallback`, there are none and the filled
|
||||
/// areas are not swept.
|
||||
pub(crate) fn builder_capped(shapes: &[Shape], edges: bool, gap: f64, precision: f64, fallback: bool) -> (BuilderArrangement, bool) {
|
||||
let has_open = has_open_path(shapes);
|
||||
let segments: usize = shapes.iter().flat_map(|s| &s.path.subpaths).map(|sp| sp.segment_count()).sum();
|
||||
let mut capped = segments > SHAPE_BUILDER_MAX_SEGMENTS;
|
||||
let mut built = |shapes: &[Shape]| match build(shapes, precision) {
|
||||
Ok(b) => b.unwrap_or_default(),
|
||||
Err(TooManyPieces) => {
|
||||
capped = true;
|
||||
Default::default()
|
||||
}
|
||||
};
|
||||
let planar = (segments <= SHAPE_BUILDER_MAX_SEGMENTS)
|
||||
.then(|| {
|
||||
let keyed: Vec<Shape> = shapes.iter().enumerate().map(|(i, s)| Shape::new(s.path.clone(), s.rule, i as u64)).collect();
|
||||
if has_open && gap.is_finite() && gap > 0.0 {
|
||||
let (faces, pieces, under) = build(&gap_inputs(&keyed, gap), precision).unwrap_or_default();
|
||||
let (faces, pieces, under) = built(&gap_inputs(&keyed, gap));
|
||||
// Gap targets split original outlines too, but the bridges themselves aren't art.
|
||||
let art = |p: &Shape| p.key < shapes.len() as u64;
|
||||
(faces, pieces.into_iter().filter(art).collect(), under.into_iter().filter(art).collect())
|
||||
} else {
|
||||
build(&keyed, precision).unwrap_or_default()
|
||||
built(&keyed)
|
||||
}
|
||||
})
|
||||
.filter(|(faces, pieces, _)| !faces.is_empty() || !pieces.is_empty());
|
||||
let Some((faces, pieces, under)) = planar else {
|
||||
return BuilderArrangement { regions: filled_regions(shapes, precision), ..Default::default() };
|
||||
if capped && !fallback {
|
||||
return (BuilderArrangement::default(), true);
|
||||
}
|
||||
return (BuilderArrangement { regions: filled_regions(shapes, precision), ..Default::default() }, capped);
|
||||
};
|
||||
let is_line = |i: u64| shapes.get(i as usize).is_some_and(|s| !s.path.subpaths.iter().any(|sp| sp.closed));
|
||||
let (lines, outline): (Vec<Shape>, Vec<Shape>) = pieces.into_iter().partition(|e| is_line(e.key));
|
||||
@@ -114,12 +148,13 @@ pub(crate) fn builder(shapes: &[Shape], edges: bool, gap: f64, precision: f64) -
|
||||
regions.extend(faces.into_iter().filter(|f| f.sources.is_empty()));
|
||||
regions
|
||||
};
|
||||
BuilderArrangement {
|
||||
let arrangement = BuilderArrangement {
|
||||
regions,
|
||||
lines: if has_open { lines } else { Vec::new() },
|
||||
edges: if edges { outline } else { Vec::new() },
|
||||
lines_under: if has_open { under } else { Vec::new() },
|
||||
}
|
||||
};
|
||||
(arrangement, false)
|
||||
}
|
||||
|
||||
/// The regions of the shapes' filled areas. A shape that fills nothing (open paths that enclose no
|
||||
|
||||
@@ -623,13 +623,39 @@ fn bar_grid(n: usize) -> Vec<Shape> {
|
||||
fn a_map_past_its_edge_cap_is_not_built() {
|
||||
// 20 lines each way: each line is cut into 21 pieces, 840 in all.
|
||||
let s = line_grid(20);
|
||||
assert!(map::map_within(&s, false, DEFAULT_PRECISION, 1000).is_some());
|
||||
assert!(map::map_within(&s, false, DEFAULT_PRECISION, 500).is_none());
|
||||
assert!(map::map_within(&s, false, DEFAULT_PRECISION, 1000).is_ok_and(|m| m.is_some()));
|
||||
assert!(map::map_within(&s, false, DEFAULT_PRECISION, 500).is_err());
|
||||
let bars = bar_grid(20);
|
||||
assert!(crate::pathfinder::regions_capped(&bars, DEFAULT_PRECISION, 100_000).is_some_and(|r| r.len() > 400));
|
||||
assert!(crate::pathfinder::regions_capped(&bars, DEFAULT_PRECISION, 1000).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn divide_and_live_paint_report_the_edge_cap() {
|
||||
// A filled square under 300 lines each way: the lines cross past the cap.
|
||||
let mut s = vec![rect(100.0, 100.0, 900.0, 900.0, 7)];
|
||||
s.extend(line_grid(300).into_iter().map(|l| Shape::new(l.path, l.rule, l.key + 1)));
|
||||
assert_eq!(crate::try_pathfinder_with(crate::PathfinderOp::Divide, &s, DEFAULT_PRECISION), Err(TooManyPieces));
|
||||
// Without the report, Divide gives back the square alone, uncut.
|
||||
assert_eq!(crate::pathfinder_with(crate::PathfinderOp::Divide, &s, DEFAULT_PRECISION).len(), 1);
|
||||
assert_eq!(try_live_paint(&s), Err(TooManyPieces));
|
||||
assert_eq!(try_live_paint_with_gaps(&s, 10.0), Err(TooManyPieces));
|
||||
// Overlapping lines exceed the sweep's work budget before any pieces are cut.
|
||||
let mut overlapping = vec![rect(100.0, 100.0, 900.0, 900.0, 7)];
|
||||
overlapping.extend((0..1500).map(|i| line((0.0, 0.0), (1000.0, 1000.0), i + 8)));
|
||||
assert_eq!(crate::try_pathfinder_with(crate::PathfinderOp::Divide, &overlapping, DEFAULT_PRECISION), Err(TooManyPieces));
|
||||
assert_eq!(crate::pathfinder_with(crate::PathfinderOp::Divide, &overlapping, DEFAULT_PRECISION).len(), 1);
|
||||
assert_eq!(try_live_paint(&overlapping), Err(TooManyPieces));
|
||||
assert_eq!(try_live_paint_with_gaps(&overlapping, 10.0), Err(TooManyPieces));
|
||||
let (faces, edges) = live_paint(&overlapping);
|
||||
assert!(faces.is_empty() && edges.is_empty());
|
||||
// Under the cap, both build as before.
|
||||
let mut small = vec![rect(100.0, 100.0, 900.0, 900.0, 7)];
|
||||
small.extend(line_grid(20).into_iter().map(|l| Shape::new(l.path, l.rule, l.key + 1)));
|
||||
assert!(crate::try_pathfinder_with(crate::PathfinderOp::Divide, &small, DEFAULT_PRECISION).is_ok_and(|f| f.len() > 1));
|
||||
assert!(try_live_paint(&small).is_ok_and(|(faces, _)| faces.len() > 1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shape_builder_builds_no_regions_past_its_edge_cap() {
|
||||
// 300 lines each way cross 90,000 times with 600 segments: the sweep cuts them into about
|
||||
|
||||
@@ -195,7 +195,11 @@ fn write(doc: &Document, opts: &ExportOptions, native: Option<&[u8]>, id_prefix:
|
||||
root = root.attr("version", "1.2").attr("baseProfile", "tiny");
|
||||
}
|
||||
if !opts.responsive {
|
||||
if let Some((unit, suffix)) = doc.units.svg_unit().and_then(|u| Some((u, u.svg_suffix()?))) {
|
||||
// Explicit SVG Options override the document unit; absence keeps its native save behavior.
|
||||
if let Some(unit) = opts.units {
|
||||
let (width, height) = (unit.length(rect.width(), opts.decimals), unit.length(rect.height(), opts.decimals));
|
||||
root = root.attr("width", &width).attr("height", &height);
|
||||
} else if let Some((unit, suffix)) = doc.units.svg_unit().and_then(|u| Some((u, u.svg_suffix()?))) {
|
||||
let w_val = physical_num(unit.from_pt(rect.width()));
|
||||
let h_val = physical_num(unit.from_pt(rect.height()));
|
||||
root = root.attr("width", format_args!("{w_val}{suffix}")).attr("height", format_args!("{h_val}{suffix}"));
|
||||
|
||||
@@ -185,6 +185,53 @@ impl Encoding {
|
||||
}
|
||||
}
|
||||
|
||||
/// The unit of the `width` and `height` an export writes (SVG Options → Units, off Responsive).
|
||||
/// The `viewBox` stays in user units (points) whatever is chosen.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum SizeUnit {
|
||||
/// Legacy bare numbers, unchanged: one per document point. CSS pixels are 96 per inch;
|
||||
/// choose an explicit physical unit to preserve the document's physical size.
|
||||
#[default]
|
||||
#[serde(rename = "px")]
|
||||
Px,
|
||||
#[serde(rename = "pt")]
|
||||
Pt,
|
||||
#[serde(rename = "mm")]
|
||||
Mm,
|
||||
#[serde(rename = "cm")]
|
||||
Cm,
|
||||
#[serde(rename = "in")]
|
||||
In,
|
||||
}
|
||||
|
||||
impl SizeUnit {
|
||||
/// This unit's size in points, and the suffix a length in it carries (`px` is written bare).
|
||||
fn per_point(self) -> (f64, &'static str) {
|
||||
match self {
|
||||
Self::Px => (1.0, ""),
|
||||
Self::Pt => (1.0, "pt"),
|
||||
Self::Mm => (25.4 / 72.0, "mm"),
|
||||
Self::Cm => (2.54 / 72.0, "cm"),
|
||||
Self::In => (1.0 / 72.0, "in"),
|
||||
}
|
||||
}
|
||||
|
||||
/// `points` as a length in this unit. Physical sizes use at least six decimal places and
|
||||
/// six significant digits, independent of coordinate precision, so rounding does not change
|
||||
/// the viewBox's rendered scale. `px` keeps [`fmt_num`]'s selected `decimals`.
|
||||
pub fn length(self, points: f64, decimals: u8) -> String {
|
||||
let (scale, suffix) = self.per_point();
|
||||
let v = points * scale;
|
||||
let places =
|
||||
if !suffix.is_empty() && v.is_finite() && v != 0.0 { decimals.max(6).max((5.0 - v.abs().log10().floor()) as u8) } else { decimals };
|
||||
format!("{}{suffix}", fmt_num(v, places))
|
||||
}
|
||||
}
|
||||
|
||||
fn explicit_size_unit<'de, D: serde::Deserializer<'de>>(d: D) -> Result<Option<SizeUnit>, D::Error> {
|
||||
SizeUnit::deserialize(d).map(Some)
|
||||
}
|
||||
|
||||
/// The SVG profile written (SVG Options → SVG Profile).
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum Profile {
|
||||
@@ -231,6 +278,10 @@ pub struct ExportOptions {
|
||||
pub minify: bool,
|
||||
/// Omit `width`/`height` so the SVG scales to its container.
|
||||
pub responsive: bool,
|
||||
/// Override the document's unit for `width` and `height` (ignored when `responsive`).
|
||||
/// Absent follows the document; explicit `px` writes bare numbers. Null is invalid.
|
||||
#[serde(skip_serializing_if = "Option::is_none", deserialize_with = "explicit_size_unit")]
|
||||
pub units: Option<SizeUnit>,
|
||||
/// Fonts → Convert to Outlines: text becomes paths (portable, no font needed to view it).
|
||||
pub outline_text: bool,
|
||||
/// Embed the native document (passed to [`export_full`]) in `<metadata>` so VectorCraft
|
||||
@@ -268,6 +319,7 @@ impl Default for ExportOptions {
|
||||
images: ImageMode::Embed,
|
||||
minify: false,
|
||||
responsive: false,
|
||||
units: None,
|
||||
outline_text: false,
|
||||
preserve_editing: false,
|
||||
metadata: false,
|
||||
@@ -721,6 +773,22 @@ mod tests {
|
||||
assert_eq!(fmt_num(100.0, 0), "100");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tiny_physical_sizes_keep_their_scale() {
|
||||
for unit in [SizeUnit::Pt, SizeUnit::Mm, SizeUnit::Cm, SizeUnit::In] {
|
||||
let (scale, suffix) = unit.per_point();
|
||||
for points in [200.0, 10.0, 3.0, 0.001, 1e-14, 1e-30] {
|
||||
let written = unit.length(points, 1);
|
||||
let value: f64 = written.strip_suffix(suffix).unwrap().parse().unwrap();
|
||||
assert!((value / scale / points - 1.0).abs() < 1e-5, "{points}pt: {written}");
|
||||
}
|
||||
}
|
||||
assert_eq!(SizeUnit::In.length(0.0, 1), "0in");
|
||||
// `px` is written exactly as `fmt_num` does.
|
||||
assert_eq!(SizeUnit::Px.length(3.0, 1), "3");
|
||||
assert_eq!(SizeUnit::Px.length(0.01, 1), "0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn escaping() {
|
||||
assert_eq!(xml_escape("a<b>&\"'"), "a<b>&"'");
|
||||
|
||||
@@ -6,7 +6,7 @@ use vectorcraft_doc::{
|
||||
StrokeLayer, TextKind, TextObject,
|
||||
};
|
||||
use vectorcraft_geom::{Affine, FillRule, PathData, Point, Rect, shapes};
|
||||
use vectorcraft_svg::{ExportOptions, ObjectIds, Styling, export, import, import_with_report};
|
||||
use vectorcraft_svg::{ExportOptions, ObjectIds, SizeUnit, Styling, export, import, import_with_report};
|
||||
|
||||
fn doc_with(nodes: Vec<Node>) -> Document {
|
||||
let mut d = Document::new(200.0, 200.0);
|
||||
@@ -698,6 +698,48 @@ fn options_decimals_minify_responsive_artboard() {
|
||||
assert!(!s.contains("id=\"Layer_1\""));
|
||||
}
|
||||
|
||||
/// An SVG written with a physical width and height (#4462) reopens at the artboard it was written from.
|
||||
#[test]
|
||||
fn svg_in_physical_units_reopens_at_the_same_size() {
|
||||
let mut d = Document::new(200.0, 100.0);
|
||||
d.units = vectorcraft_doc::Unit::Millimeters;
|
||||
let n = rect_node(&mut d, Rect::new(10.0, 10.0, 60.0, 50.0), Appearance::default_art());
|
||||
let l = d.layers[0].id;
|
||||
d.insert(Some(l), usize::MAX, n).unwrap();
|
||||
for units in [SizeUnit::Mm, SizeUnit::Cm, SizeUnit::In, SizeUnit::Pt] {
|
||||
let s = export(&d, &ExportOptions { units: Some(units), ..Default::default() });
|
||||
let back = import(&s).unwrap_or_else(|e| panic!("{units:?}: {e}\n{s}"));
|
||||
let r = back.artboards[0].rect;
|
||||
assert!((r.width() - 200.0).abs() < 0.1 && (r.height() - 100.0).abs() < 0.1, "{units:?}: {r:?}\n{s}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A viewer's default `meet` scaling must preserve the artwork's physical extent, not just
|
||||
/// reopen an artboard with roughly the right width and height.
|
||||
#[test]
|
||||
fn physical_units_preserve_rendered_extent_at_low_coordinate_precision() {
|
||||
for (width, height, decimals) in [(200.0, 10.0, 1), (10.0, 200.0, 1), (0.2, 0.1, 1), (0.002, 0.001, 3)] {
|
||||
let mut d = Document::new(width, height);
|
||||
let n = rect_node(&mut d, Rect::new(0.0, 0.0, width, height), Appearance::basic(solid("#000000"), Paint::None, 0.0));
|
||||
let layer = d.layers[0].id;
|
||||
d.insert(Some(layer), usize::MAX, n).unwrap();
|
||||
for units in [SizeUnit::Mm, SizeUnit::Cm, SizeUnit::In, SizeUnit::Pt] {
|
||||
let svg = export(&d, &ExportOptions { units: Some(units), decimals, ..Default::default() });
|
||||
let tree = usvg::Tree::from_str(&svg, &usvg::Options::default()).unwrap();
|
||||
let extent = tree.root().abs_bounding_box();
|
||||
// CSS consumers render physical lengths at 96 px/in, document geometry is 72 pt/in.
|
||||
for (actual, expected) in [
|
||||
(tree.size().width(), width * 96.0 / 72.0),
|
||||
(tree.size().height(), height * 96.0 / 72.0),
|
||||
(extent.width(), width * 96.0 / 72.0),
|
||||
(extent.height(), height * 96.0 / 72.0),
|
||||
] {
|
||||
assert!((f64::from(actual) / expected - 1.0).abs() < 2e-5, "{units:?}: {actual} != {expected}\n{svg}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unique_sanitized_ids() {
|
||||
let mut d = Document::new(200.0, 200.0);
|
||||
|
||||
@@ -198,7 +198,8 @@ pub(crate) fn pump(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
Some(Ok(done)) => Some(done["gaps"].clone()),
|
||||
Some(Err(e)) => {
|
||||
app.status(e);
|
||||
None
|
||||
// The failed preview rolled the groups back, so the gaps an earlier one found are gone too.
|
||||
Some(Value::Null)
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
@@ -519,6 +520,23 @@ mod tests {
|
||||
assert!(!drawn(&mut app), "no preview, no gap");
|
||||
}
|
||||
|
||||
/// A preview that fails after one that found gaps leaves no gaps drawn from the earlier one.
|
||||
#[test]
|
||||
fn a_failed_preview_draws_no_earlier_gaps() {
|
||||
let mut app = app();
|
||||
gapped_group(&mut app);
|
||||
app.run("ui.livePaintGapOptions", json!({})).unwrap();
|
||||
set(&app, "detect", json!(true)).unwrap();
|
||||
set(&app, "preview", json!(true)).unwrap();
|
||||
pump_all(&mut app);
|
||||
assert_eq!(overlays(&app).len(), 1, "the gap is previewed");
|
||||
// A custom size past 72 pt is refused, and the preview with it fails.
|
||||
set(&app, "size", json!("custom")).unwrap();
|
||||
set(&app, "custom", json!(100.0)).unwrap();
|
||||
pump_all(&mut app);
|
||||
assert!(overlays(&app).is_empty(), "{:?}", overlays(&app));
|
||||
}
|
||||
|
||||
/// With Preview on, a Gap Preview Color with an alpha part is not previewed: the group keeps
|
||||
/// its own color, the gaps draw in black, OK refuses the color and Cancel rolls the preview back.
|
||||
#[test]
|
||||
|
||||
@@ -497,7 +497,7 @@ pub(crate) fn settings(ui: &mut Ui, fields: &mut Map<String, Value>, presets: &[
|
||||
let mine = fields.get("settings").and_then(|all| all.get(id)).and_then(Value::as_object).cloned().unwrap_or_default();
|
||||
let tiny = mine.get("profile").and_then(Value::as_str) == Some("tiny12");
|
||||
let params = match id {
|
||||
"svg" => svg_options::svg_params(true, tiny),
|
||||
"svg" => svg_options::svg_params(svg_options::Mode::Export, true, tiny),
|
||||
"pdf" => Vec::new(),
|
||||
_ => png_options::raster_params(id, true, None),
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! SVG Options (Export As SVG, Save As / Save a Copy to .svg): profile, styling, fonts, images,
|
||||
//! object ids, decimals, encoding, minify, responsive, embedded fonts, artboards (export) or
|
||||
//! object ids, decimals, encoding, units, minify, responsive, embedded fonts, artboards (export) or
|
||||
//! editing data (save), and a read-only view of the code. OK remembers the choices for next time and runs the export or save command with
|
||||
//! them as `svg: {…}`. Show in Browser (`file.export.svg.browser`) writes the SVG the choices give
|
||||
//! to a temporary folder and opens it in the default browser, leaving the dialog open.
|
||||
@@ -56,6 +56,8 @@ const IMAGES: [(&str, &str); 2] = [("embed", "Embed"), ("link", "Link")];
|
||||
const OBJECT_IDS: [(&str, &str); 3] = [("layerNames", "Layer Names"), ("minimal", "Minimal"), ("unique", "Unique")];
|
||||
const PROFILES: [(&str, &str); 2] = [("svg11", "SVG 1.1"), ("tiny12", "SVG Tiny 1.2")];
|
||||
const ENCODINGS: [(&str, &str); 3] = [("utf8", "Unicode (UTF-8)"), ("utf16", "Unicode (UTF-16)"), ("latin1", "ISO 8859-1")];
|
||||
const UNITS: [(&str, &str); 6] =
|
||||
[("document", "Document"), ("px", "Pixels"), ("pt", "Points"), ("mm", "Millimeters"), ("cm", "Centimeters"), ("in", "Inches")];
|
||||
|
||||
/// Dialog fields that are not SVG options.
|
||||
const UI_KEYS: [&str; 5] = ["mode", "path", "showCode", "allArtboards", "range"];
|
||||
@@ -72,11 +74,12 @@ pub(crate) struct SvgCodeKey {
|
||||
selected: Option<Vec<vectorcraft_doc::NodeId>>,
|
||||
}
|
||||
|
||||
/// The options a first SVG Options dialog starts from: the engine's defaults with Internal CSS
|
||||
/// and Responsive on (as the reference app's Export As starts). Hidden layers are left to the
|
||||
/// command (Save keeps them, Export leaves them out).
|
||||
/// The options a first SVG export starts from: the engine's defaults with Pixels,
|
||||
/// Internal CSS and Responsive on. Saves choose Document unless a remembered unit overrides it.
|
||||
/// Hidden layers are left to the command (Save keeps them, Export leaves them out).
|
||||
pub(super) fn first_use() -> Map<String, Value> {
|
||||
let mut m = serde_json::to_value(vectorcraft_svg::ExportOptions::default()).ok().and_then(|v| v.as_object().cloned()).unwrap_or_default();
|
||||
let opts = vectorcraft_svg::ExportOptions { units: Some(vectorcraft_svg::SizeUnit::Px), ..Default::default() };
|
||||
let mut m = serde_json::to_value(opts).ok().and_then(|v| v.as_object().cloned()).unwrap_or_default();
|
||||
m.remove("hiddenLayers");
|
||||
m.insert("styling".into(), json!("css"));
|
||||
m.insert("responsive".into(), json!(true));
|
||||
@@ -109,6 +112,10 @@ pub(crate) fn open_with(app: &mut VectorcraftApp, mode: Mode, path: Option<&str>
|
||||
fields.extend(o.iter().map(|(k, v)| (k.clone(), v.clone())));
|
||||
}
|
||||
}
|
||||
if mode != Mode::Export && saved.as_ref().unwrap_or(&app.ui.svg_options).get("units").is_none() {
|
||||
// A document's legacy SVG options must not inherit Pixels from the last export.
|
||||
fields.insert("units".into(), json!("document"));
|
||||
}
|
||||
fields.insert("allArtboards".into(), json!(true));
|
||||
fields.insert("range".into(), json!(""));
|
||||
if let Some(p) = path {
|
||||
@@ -146,7 +153,7 @@ fn pairs(key: &str, label: &'static str, choices: &[(&str, &'static str)]) -> Pa
|
||||
/// responsive, `<tspan>`s and metadata. `screens` (Export for Screens' Format Settings) leaves out
|
||||
/// Images and Variable Data: a linked image is another file. `tiny`: SVG Tiny has presentation
|
||||
/// attributes alone and no web fonts.
|
||||
pub(crate) fn svg_params(screens: bool, tiny: bool) -> Vec<Param> {
|
||||
pub(crate) fn svg_params(mode: Mode, screens: bool, tiny: bool) -> Vec<Param> {
|
||||
let styling = pairs("styling", tl!("Styling:"), &STYLING);
|
||||
let fonts = ParamKind::radio(FONTS.iter().map(|(v, l)| ((*v).to_string(), tl!(*l).into())).collect(), Some("false".into()));
|
||||
let (lo, hi) = (*vectorcraft_svg::DECIMALS.start() as f64, *vectorcraft_svg::DECIMALS.end() as f64);
|
||||
@@ -161,6 +168,9 @@ pub(crate) fn svg_params(screens: bool, tiny: bool) -> Vec<Param> {
|
||||
rows.push(pairs("objectIds", tl!("Object IDs:"), &OBJECT_IDS));
|
||||
rows.push(Param::number("decimals", tl!("Decimal:"), 3.0, 1.0, 0).bounds(Some(lo), Some(hi)));
|
||||
rows.push(pairs("encoding", tl!("Encoding:"), &ENCODINGS));
|
||||
// Responsive omits width and height, so the unit has nothing to act on.
|
||||
let units = if mode == Mode::Export { &UNITS[1..] } else { &UNITS[..] };
|
||||
rows.push(pairs("units", tl!("Units:"), units).enabled_when("responsive", false));
|
||||
rows.push(check("minify", tl!("Minify"), false));
|
||||
rows.push(check("responsive", tl!("Responsive"), true));
|
||||
// Embedded fonts need SVG 1.1 and text that stays text.
|
||||
@@ -189,7 +199,7 @@ fn artboard_rows(count: usize) -> Vec<Param> {
|
||||
/// Every row of the dialog for `mode`. Export Selection writes the selection's crop, without
|
||||
/// artboards to choose.
|
||||
fn dialog_params(mode: Mode, selection: bool, count: usize, tiny: bool) -> Vec<Param> {
|
||||
let mut rows = svg_params(false, tiny);
|
||||
let mut rows = svg_params(mode, false, tiny);
|
||||
match mode {
|
||||
Mode::Export if !selection => rows.extend(artboard_rows(count)),
|
||||
Mode::Export => {}
|
||||
@@ -211,6 +221,9 @@ fn options(mode: Mode, f: &DialogFields) -> Value {
|
||||
let tiny = f.text("profile") == Some("tiny12");
|
||||
let mut o = json_of(&dialog_params(mode, false, 1, tiny), f);
|
||||
o.retain(|k, _| !UI_KEYS.contains(&k.as_str()) && !k.starts_with("__"));
|
||||
if o.get("units").and_then(Value::as_str) == Some("document") {
|
||||
o.remove("units");
|
||||
}
|
||||
if mode == Mode::Export {
|
||||
o.remove("preserveEditing");
|
||||
if f.bool("useArtboards").unwrap_or(false) {
|
||||
@@ -663,6 +676,77 @@ mod tests {
|
||||
assert_eq!(fields(&app).number("decimals"), Some(1.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn svg_options_write_and_remember_units_and_decimals() {
|
||||
let (mut app, written) = app();
|
||||
start(&mut app, Mode::Export, "/tmp/out.svg", false);
|
||||
set(&mut app, "responsive", json!(false));
|
||||
set(&mut app, "units", json!("mm"));
|
||||
set(&mut app, "decimals", json!(1));
|
||||
confirm(&mut app);
|
||||
let svg = text(&written, 0);
|
||||
assert!(svg.contains("mm\"") && svg.contains("viewBox=\"0 0 120 80\""), "{svg}");
|
||||
assert_eq!(app.ui.svg_options["decimals"], 1);
|
||||
start(&mut app, Mode::Export, "/tmp/out.svg", false);
|
||||
assert_eq!(fields(&app).text("units"), Some("mm"));
|
||||
set(&mut app, "responsive", json!(true));
|
||||
confirm(&mut app);
|
||||
let svg = text(&written, 2);
|
||||
assert!(!svg.contains("mm\"") && svg.contains("viewBox=\"0 0 120 80\""), "{svg}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_svg_saves_keep_document_units() {
|
||||
for mode in [Mode::Save, Mode::SaveCopy] {
|
||||
for last in [json!({"responsive": false}), json!({"responsive": false, "units": "px"})] {
|
||||
let (mut app, written) = app();
|
||||
let original = std::env::temp_dir().join("vc-original.svg").to_string_lossy().replace('\\', "/");
|
||||
let path = std::env::temp_dir().join("vc-saved.svg").to_string_lossy().replace('\\', "/");
|
||||
app.run("document.setUnits", json!({"units": "millimeters"})).unwrap();
|
||||
app.run("file.saveAs", json!({"path": original, "svg": {"responsive": false}})).unwrap();
|
||||
let before = vectorcraft_svg::import(&text(&written, 0)).unwrap();
|
||||
app.ui.svg_options = last;
|
||||
start(&mut app, mode, &path, false);
|
||||
confirm(&mut app);
|
||||
let after = vectorcraft_svg::import(&text(&written, 1)).unwrap();
|
||||
assert_eq!(after.units, vectorcraft_doc::Unit::Millimeters, "{mode:?}: {}", text(&written, 1));
|
||||
let (a, b) = (before.artboards[0].rect, after.artboards[0].rect);
|
||||
assert!((a.width() - b.width()).abs() < 1e-6 && (a.height() - b.height()).abs() < 1e-6, "{mode:?}: {a:?} -> {b:?}");
|
||||
let expected = if mode == Mode::SaveCopy { &original } else { &path };
|
||||
assert_eq!(app.session.active().unwrap().path.as_deref(), Some(expected.as_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn svg_saves_keep_explicit_units_and_allow_pixel_overrides() {
|
||||
for mode in [Mode::Save, Mode::SaveCopy] {
|
||||
let (mut app, written) = app();
|
||||
let path = std::env::temp_dir().join("vc-explicit.svg").to_string_lossy().replace('\\', "/");
|
||||
app.run("document.setUnits", json!({"units": "millimeters"})).unwrap();
|
||||
app.run("file.saveAs", json!({"path": path, "svg": {"responsive": false, "units": "in"}})).unwrap();
|
||||
app.ui.svg_options = json!({"responsive": false, "units": "px"});
|
||||
start(&mut app, mode, &path, false);
|
||||
confirm(&mut app);
|
||||
assert_eq!(vectorcraft_svg::import(&text(&written, 1)).unwrap().units, vectorcraft_doc::Unit::Inches);
|
||||
start(&mut app, mode, &path, false);
|
||||
set(&mut app, "units", json!("px"));
|
||||
confirm(&mut app);
|
||||
assert_eq!(vectorcraft_svg::import(&text(&written, 2)).unwrap().units, vectorcraft_doc::Unit::Pixels);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn svg_export_keeps_pixels_when_legacy_options_omit_units() {
|
||||
let (mut app, written) = app();
|
||||
let path = std::env::temp_dir().join("vc-export.svg").to_string_lossy().replace('\\', "/");
|
||||
app.run("document.setUnits", json!({"units": "millimeters"})).unwrap();
|
||||
app.ui.svg_options = json!({"responsive": false});
|
||||
start(&mut app, Mode::Export, &path, false);
|
||||
confirm(&mut app);
|
||||
assert_eq!(vectorcraft_svg::import(&text(&written, 0)).unwrap().units, vectorcraft_doc::Unit::Pixels);
|
||||
}
|
||||
|
||||
/// OK with a range the document lacks keeps the dialog open with the reason, writes nothing and
|
||||
/// remembers nothing.
|
||||
#[test]
|
||||
|
||||
@@ -2215,7 +2215,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.livePaintGapOptions",
|
||||
"Gap Options…",
|
||||
"",
|
||||
"{} open Gap Options (Object › Live Paint › Gap Options…; dialog `livePaintGapOptions`: detect, size small|medium|large|custom, custom (pt), color (#rrggbb or a layer color's name), closeGaps, preview) on the selected Live Paint groups, filled in from the first; with preview on, the options apply live and the gaps found draw on the canvas in the preview color: OK runs livePaint.gapOptions as one undo step; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing, and with preview on a #rrggbbaa color is not previewed: the groups keep their own color and the gaps draw in black",
|
||||
"{} open Gap Options (Object › Live Paint › Gap Options…; dialog `livePaintGapOptions`: detect, size small|medium|large|custom, custom (pt), color (#rrggbb or a layer color's name), closeGaps, preview) on the selected Live Paint groups, filled in from the first; with preview on, the options apply live and the gaps found draw on the canvas in the preview color: OK runs livePaint.gapOptions as one undo step; a color with an alpha part (#rrggbbaa or #rgba) is an error and OK changes nothing, and with preview on a #rrggbbaa color is not previewed: the groups keep their own color and the gaps draw in black; a preview that fails shows its error in the status bar, puts the groups back as they were and stops drawing the dialog's preview of the gaps (View › Show Live Paint Gaps still draws the restored groups' own gaps)",
|
||||
),
|
||||
(
|
||||
"ui.perspectivePlane",
|
||||
|
||||
@@ -293,6 +293,7 @@ fn a_touchpad_steps_once_per_wheel_line() {
|
||||
// test-lint: allow never-run touchpad gesture phases reach the app only on macOS
|
||||
#[cfg(target_os = "macos")]
|
||||
#[test]
|
||||
// test-lint: allow never-run egui reports touchpad gesture phases only on macOS
|
||||
fn keys_held_during_a_touchpad_gesture_count_until_it_ends() {
|
||||
let mut app = app();
|
||||
on_canvas(&mut app, |rig| {
|
||||
|
||||
File diff suppressed because one or more lines are too long
+8
-1
@@ -37,6 +37,8 @@ Actions panel item context menus (2026-11-20): Right-clicking an Action Set row
|
||||
|
||||
Appearance panel row context menus (part of G12): right-clicking stroke and fill rows offers Duplicate Stroke / Duplicate Fill, Delete Stroke / Delete Fill, and Hide Stroke/Show Stroke / Hide Fill/Show Fill; effect rows offer Edit Effect…, Duplicate Effect, Delete Effect, and Hide Effect / Show Effect; the root object row offers Clear Appearance and Reduce to Basic Appearance. Right-clicking an unselected row targets that row before presenting the menu. Item actions run in one undo step. Evidence: `panels::tests_appearance::right_clicking_a_stroke_row_selects_it_and_exposes_context_menu`, `panels::tests_appearance::clicking_duplicate_stroke_duplicates_the_stroke_with_one_undo_step`, `panels::tests_appearance::clicking_delete_effect_removes_the_effect_from_appearance`, and `panels::tests_appearance::right_clicking_root_object_row_exposes_clear_and_reduce_appearance` in `crates/ui-egui/src/panels/tests_appearance.rs`. Scores and estimates unchanged.
|
||||
|
||||
> SVG Options can write physical dimensions with Responsive off and a physical unit selected (#4462); pixel output remains bare numbers.
|
||||
|
||||
Draft enhancement #5804: Preferences › File Handling can select a raster editor through the native picker, with a private draft outside engine preferences and generic dialog fields. OK saves it, Cancel discards it, and Reset restores PhotoCraft. With Use System Defaults off, a missing chosen editor falls back to PhotoCraft, then the system default; validation and launch failures are reported. Control/MCP and synthetic input cannot choose an application or run external Edit Original. Web behavior, parity scores and estimates are unchanged; macOS/Linux smoke tests remain pending.
|
||||
|
||||
**2026-11-19 revision:** merged main while preserving the private raster-editor choice; no parity rescore.
|
||||
@@ -469,6 +471,10 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi
|
||||
such stubs into one vertex (within 4× the sweep's tolerance up and down its frame and 1/16 of the 0.01 pt precision
|
||||
along it, bounded by each cluster's extent so a run of tiny level segments keeps its length); regression tests
|
||||
in `crates/pathops/src/planar.rs`. Estimate unchanged.
|
||||
- **Done (2026-11-03):** SVG Options › Units (`units`) explicitly overrides `width` and `height` with `px`
|
||||
(bare numbers; CSS pixels are 96 per inch), `pt`, `mm`, `cm` or `in`, with the `viewBox` in points (#4462).
|
||||
Responsive omits both dimensions; unknown units and explicit null are errors. Without an override, export
|
||||
retains the document's physical units as below. Estimate unchanged.
|
||||
- **Done (#864):** SVG export writes physical unit suffixes on the root `<svg width="..." height="...">` for documents with physical units (`mm`, `cm`, `in`, `pc`; documents in feet and yards are written in `in`, in meters in `cm`, and in Q or Ha in `mm`, since SVG has no unit for them: `every_physical_document_unit_exports_its_printed_size`), so external vector tools (Inkscape, LightBurn) and browsers render drawings at their intended physical scale rather than scaling to 75% under point-based user-unit assumptions; unitless user coordinates in `viewBox` and path geometry remain in 1:1 internal points per SVG 1.1 coords §7.10. A round trip keeps `mm`, `cm`, `in` and `pc` documents in their unit (`export_physical_units_writes_unit_suffixes`, `svg_round_trip_preserves_document_units`); documents in feet, yards, meters, Q or Ha keep their printed size and open again in the SVG unit they were written in. General document unit preferences across restarts remain tracked under #864.
|
||||
- **Missing:** general document unit preference on restart (#864; SVG export physical units done). Shape Builder regions (#937, closed), PDF text placement
|
||||
(#722, above), the bezier drag preview (#834, #3065, #3729) and deleting an interior anchor of an open path (above)
|
||||
@@ -1116,6 +1122,7 @@ trap, and the defaults (0.25 pt, 100%, 40%) are VectorCraft's own, the pages giv
|
||||
| 2026-11-05 | minor | G15: a document's first frame renders on the render worker (#4155); the longest UI-thread stall opening that file went from 8.7 s to 64 ms. Estimate unchanged. |
|
||||
| 2026-11-05 | minor | G15: a reduced image is shrunk before it is separated into ink planes (#4155); first frame 9.2 s → 1.6 s, sharp frame after a pan 3.9 s → 8 ms on that file. Estimate unchanged. |
|
||||
| 2026-11-05 | minor | G7: document tabs are dragged along the tab strip to reorder them (`document.move`, #5663). Estimate unchanged. |
|
||||
| 2026-11-03 | minor | SVG Options has a Units choice (Pixels, Points, Millimeters, Centimeters, Inches) for the `width` and `height` an export writes, so laser and plotter software read the physical size (#4462; the `units` option, Pixels still bare numbers as before; to export physical dimensions turn Responsive off and choose Points, Millimeters, Centimeters or Inches, since Responsive omits `width` and `height`); scores and estimates unchanged |
|
||||
| 2026-11-03 | minor | Symbol editing shows draggable 9-slice guides within the artwork (#5280). Guides outside the artwork remain unsupported. The G5 estimate remains 14–24 h. |
|
||||
| 2026-11-02 | minor | G15: the renderer keeps a compound path's assembled path between frames and drops unused geometry entries after a few frames however few there are. Estimate unchanged. |
|
||||
| 2026-11-02 | minor | G15: hit testing culls paths and compound paths by their control points' box and tests a compound path's outline and fill against only its members near the click; the same objects are hit. Estimate unchanged. |
|
||||
@@ -1326,4 +1333,4 @@ trap, and the defaults (0.25 pt, 100%, 40%) are VectorCraft's own, the pages giv
|
||||
## EPS Save evidence (2026-10-26)
|
||||
Ordinary Save and Save As keep EPS as EPS, with the chosen page frame, transparent margins and the complete editable VectorCraft document. Existing import-loss confirmation and transparency warnings remain; the Save TIFF preview is capped at 1024 pixels, while Export retains 2048. See [file-format-parity.md](file-format-parity.md#eps-save-and-source-protection) for limits and regression evidence. This narrows G9 save-back workflow coverage; native Illustrator editing-data fidelity, parity scores and hour estimates are unchanged. Since 2026-11-12 the EPS Options of Save As show Use Artboards, unchecked by default: unchecked, the bounding box fits the visible art; checked, Save keeps the chosen page frame and margins described here.
|
||||
|
||||
> **Swatches status (2026-11-15):** Item context menus are implemented and covered by headless tests; full CI passed on the latest-main integration (all 13 gates), including the updated panel-view harness; parity scores and estimates are unchanged.
|
||||
> **Historical Swatches proof (2026-11-15):** Item context menus were implemented and covered by headless tests; all 13 CI gates passed on the integration tested then, including the updated panel-view harness. This is not validation of the current merge; parity scores and estimates are unchanged.
|
||||
|
||||
+11
-5
@@ -1355,7 +1355,7 @@ a script does the same with those commands.
|
||||
SVG Options: `export` to SVG takes them in `options`, flat or as `{"svg": {…}}`: `styling` (`presentation`,
|
||||
`style`, `entities`, `css`), `outlineText`, `images` (`embed`, or `link`: embedded images are written next to the
|
||||
SVG, or returned as `linked`), `objectIds` (`layerNames`, `minimal`, `unique`), `decimals` (1–7), `minify`,
|
||||
`responsive`, `useArtboards`, `range: "all"` (one SVG per artboard, listed in `files`, each holding only the art over its artboard), `preserveEditing` (the SVG
|
||||
`responsive`, `units` (`px`, `pt`, `mm`, `cm` or `in`: overrides the document unit for `width` and `height`; omit to retain the document unit, explicit null is rejected; `px` means bare numbers, the `viewBox` stays in points; ignored with `responsive`), `useArtboards`, `range: "all"` (one SVG per artboard, listed in `files`, each holding only the art over its artboard), `preserveEditing` (the SVG
|
||||
reopens as the full document), `metadata` and `fewerTspans` (one `<tspan>` per line of type). Unknown keys inside `svg` are rejected; `run_command document.formats`
|
||||
lists every option with its default. `encoding` is `utf8`, `utf16` (big-endian after a byte order mark) or `latin1`
|
||||
(ISO 8859-1, other characters as `&#x…;` references); `document.serialize` still answers `text`, plus `dataBase64`
|
||||
@@ -6162,7 +6162,9 @@ already walks Image Trace. Short agent entry points:
|
||||
When `livePaint.gapOptions` or `livePaint.merge` cuts an edge into pieces, each piece takes the edge's paint, with
|
||||
its rows fitted to its part of the edge in the same way. A face or edge given no such row has one unpainted row. Rows that do not draw stay with the stored sources, which
|
||||
`livePaint.release` returns unchanged. The source's object effects and the strokes' pen pressure are not carried.
|
||||
Expand keeps those face fills.
|
||||
Expand keeps those face fills. Make, Merge and Gap Options stop with an error and leave the art unchanged when the
|
||||
paths are too many or too complex to map. This happens when the paths have more than 131,072 pieces once cut where
|
||||
they meet, or exceed the sweep's work budget, which counts pairs of segments with overlapping bounds. The paths include lines across the gaps when Gap Detection is on.
|
||||
`livePaint.expand` keeps each face and edge that draws, with all its fill and stroke rows: it is shown, its opacity
|
||||
is above 0, and a fill or stroke row is shown, has paint and an opacity above 0 (a stroke also a weight above 0),
|
||||
whichever row is on top. A painted lower row under an unpainted top row keeps the part; a part whose only painted
|
||||
@@ -6186,7 +6188,9 @@ already walks Image Trace. Short agent entry points:
|
||||
when another merged group has it on. When Gap Detection is off in every merged group, it stays off.
|
||||
The Gap Options dialog (`ui.livePaintGapOptions`) takes `color` as `#rrggbb` or a layer color's name; its OK gives
|
||||
an error for a `color` with an alpha part (`#rrggbbaa` or `#rgba`) and changes nothing. With Preview on, a
|
||||
`#rrggbbaa` color is not previewed: the groups keep their own color, and the previewed gaps draw in black.
|
||||
`#rrggbbaa` color is not previewed: the groups keep their own color, and the previewed gaps draw in black. When a
|
||||
preview fails, the status bar shows the error, the groups go back to how they were, and the dialog stops drawing its preview of the gaps. View › Show Live Paint Gaps still draws the restored
|
||||
groups' own gaps.
|
||||
`view.livePaintGaps` (View › Show Live Paint Gaps, or Hide Live Paint Gaps while it is on) turns the drawing of
|
||||
those gaps on or off. While it is on and edges show, the canvas draws the gaps of each selected Live Paint group in
|
||||
that group's Gap Preview Color. The reply is the new state (`true` when on).
|
||||
@@ -7763,8 +7767,10 @@ Pathfinder command (`object.pathfinder.unite` … `minusBack`) also takes `preci
|
||||
whatever the options are then. Unite, Minus Front, Intersect, Exclude and Minus Back close open paths, so a straight
|
||||
line encloses no area and does not change the result's shape. When a selected object is or holds such a path, the reply's
|
||||
`warning` says so and names Object › Path › Outline Stroke. When such a path leaves the result empty (Intersect, a line
|
||||
at the back in Minus Front, or a line in front in Minus Back), the error says so too.
|
||||
|
||||
at the back in Minus Front, or a line in front in Minus Back), the error says so too. Divide with open paths among
|
||||
the objects stops with an error and leaves the art unchanged when the paths are too many or too complex to map.
|
||||
This happens when the paths Divide maps, as it prepares them from the selection, have more than 65,536 segments, have more than 131,072 pieces once cut where
|
||||
they meet, or exceed the sweep's work budget, which counts pairs of segments with overlapping bounds.
|
||||
```json
|
||||
{"name":"run_command","arguments":{"command":"object.pathfinder.options","params":{"precision":0.1,"removeUnpainted":true}}}
|
||||
```
|
||||
|
||||
@@ -15,6 +15,8 @@ Native saves on Unix flush the destination directory after writing or replacing
|
||||
>
|
||||
> Glyphs update (#5514): Alternates for Current Selection applies a variant's OpenType feature to that letter alone (`salt=2`) so an Arabic word stays joined; Entire Font lists unencoded glyphs. A positional variant no supported feature draws can be applied as a glyph choice (#6084). Entire Font uses the selection's font version and variable axes, and the default cell remains available after an unlisted choice even without GSUB alternates. Only Arabic presentation-form characters insert their joining base letter. Scores and estimates unchanged.
|
||||
>
|
||||
> SVG physical dimensions update (#5450): explicit SVG Options write width and height in mm, cm, in or pt (#4462), retaining scale independently of coordinate precision, including tiny sizes. Commands accept flat `units` or nested `svg.units`; nested values win and explicit null is rejected. Without an override, export retains the document's units (#864). Responsive omits dimensions; explicit Pixels keeps bare numbers and CSS pixels are 96/in. Scores and estimates unchanged.
|
||||
>
|
||||
> **File-font integration status (2026-11-19, #4569):** 56 focused integration tests passed, including wrapped carried-font paragraphs and conflicting glyphs through native reopen. Full workspace CI and other hardening paths remain pending. Type core and file-format scores and estimates unchanged. See [file-font ownership evidence](file-format-parity.md#file-font-ownership-hardening-4569).
|
||||
>
|
||||
> Live Paint Bucket update (2026-11-12): one drag fills the faces crossed in the same group (#6373).
|
||||
@@ -1828,7 +1830,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
Outline Stroke, Expand's Stroke option and Flatten Transparency's Convert All Strokes to Outlines apply the object's visible geometry effects (Offset Path, Zig Zag and the others) to the path, and then apply each stroke's own geometry effects before outlining that stroke, as the canvas draws it. The filled outline of a stroke without a brush keeps the stroke's other effects, such as a drop shadow.
|
||||
Outline Stroke and Unite remove the overlaps of a long, low path with the sweep turned along it: when the estimated number of segments the sweep holds at once is under two thirds as large for the path turned a quarter turn (paths of 2,048 segments or more), the overlaps are removed on the turned path and the result is turned back, which moves no point by rounding. The lookups of the input curve that a piece of the result lies on, and of the input anchors that are kept, can search along y instead of x: once lookups with more than 64 candidates along x have counted 16 for each input curve or anchor, a lookup searches along y when it finds fewer candidates there (under a quarter as many for curves), and where that has rarely happened it measures along y in only one lookup of 32. On one open path of 200,000 anchors in rows of 1,000, Outline Stroke takes 17.3 s of processor time instead of 31.3 s and Unite 2.9 s instead of 6.5 s in a release build. A turned result has as many subpaths as the result without the turn, and the area where the two differ is no larger than the refit precision times the outline's length (`crates/pathops/src/sweep_axis.rs` tests).
|
||||
Offset Path turns the sweep the same way: when the estimate for its fill, the ring stroked around the fill and the outline of its open subpaths is under two thirds as large turned a quarter turn, the faces are found on the turned parts, the faces that lie within the offset distance of the path are dropped by testing their points turned back, and the result is turned back. On an open path of 10,000 anchors in rows of 1,000, offsetting by 2 pt takes 1.0 s of processor time instead of 1.8 s in a release build. The offset of a long, low path has as many subpaths as the offset of the same path stood on end, and the area where the two differ is no larger than the refit precision times the outline's length (`offset_path_sweeps_a_long_low_path_turned_with_the_result_of_the_path_on_end`).
|
||||
- Divide uses open lines, bent paths and curves as cutting edges (#1307), preserving the frontmost filled face's appearance and holes. Engine tests cover implicit closure of filled open contours and unrelated objects; native automation confirms independent piece movement, one Undo/Redo, canvas/window captures and an exact saved-document read by a separate CLI process. The shared planar map keeps a segment cap (65,536 since #937, was 4,096) and its filled-area fallback; other Pathfinder operations are unchanged.
|
||||
- Divide uses open lines, bent paths and curves as cutting edges (#1307), preserving the frontmost filled face's appearance and holes. Engine tests cover implicit closure of filled open contours and unrelated objects; native automation confirms independent piece movement, one Undo/Redo, canvas/window captures and an exact saved-document read by a separate CLI process. Divide with open paths stops with an error and leaves the art unchanged when the paths are too many or too complex to map. This happens when the paths it maps, as it prepares them from the selection, have more than 65,536 segments (since #937, the cap was 4,096), have more than 131,072 pieces once cut where they meet, or exceed the sweep's work budget, which counts pairs of segments with overlapping bounds. Other Pathfinder operations are unchanged.
|
||||
- Type that Transform effects only move and copy (no scale, rotation, reflection or Random) exports as type in each place, and PDF export writes every copy as selectable, searchable text, when its characters are in solid colors without underline or strikethrough, the type object has no fills or strokes of its own, no inline graphics and no perspective, its transform does not scale or shear stroked characters, and the copies do not overlap. When the effect is on the type itself, the type can also have transparency, an opacity mask and raster effects. When the effect is on the group or layer holding the type, the type has no transparency or effects of its own and is not in a clipping path, the group or layer has no fill, stroke or Pathfinder effect of its own, and no group between them has a fill, stroke, Pathfinder or geometry effect. Type still exports as outlines when the effect stops its copies early, or when the copies would number more than 10,000 or take more than 20,000,000 bytes of document data, and so does other type under a geometry effect.
|
||||
- Extrude & Bevel and Inflate treat strokes as outlined: each visible stroke builds a solid from its outline in its own paint beside the top fill's ([three-d.md](three-d.md#fills-and-strokes)).
|
||||
- A 3D effect on one fill or stroke ([the help page](https://helpx.adobe.com/illustrator/using/effects.html)) leaves the object's other fills and strokes drawn with the path's or compound path's fill rule, so an even-odd compound path keeps its holes in them; this holds for Extrude & Bevel, Inflate, Rotate and Revolve, and for the Classic Extrude & Bevel, Rotate and Revolve. Tests: `solids::tests::a_fill_or_stroke_without_the_effect_keeps_the_even_odd_hole`, `revolve::tests::a_fill_without_the_revolve_keeps_the_even_odd_hole`.
|
||||
@@ -2108,7 +2110,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
Live Paint Make preserves the front-most covering source's fill when compound paths share a curved boundary, and Expand keeps the face fills. Regression evidence: `planar::tests::coincident_curves_keep_their_source_faces` checks source order, winding, fill rules and nearby boundaries; `tests::build::live_paint_make_and_expand_keep_abutting_compound_colors` checks native compound paths, Make, Expand and Undo/Redo. This preserves VectorCraft's source-fill rule without changing arrangement precision.
|
||||
Object › Live Paint › Expand keeps the faces and edges that draw on the canvas, with all their fill and stroke rows, so the expanded paths look as the painted group did ([Create Live Paint groups](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/create-live-paint-groups.html)). As VectorCraft's own rule, a face or edge draws when it is shown, its opacity is above 0, and any of its fill or stroke rows is shown, has paint and an opacity above 0 (a stroke also needs a weight above 0), whichever row is on top: a painted lower row under an unpainted top row is kept, and a part whose only painted row is hidden is removed. Merge copies the fill and stroke rows, visibility, opacity and blending mode of each face that draws by this rule, and of each edge, to the rebuilt parts, with their gradients kept at their fit on the old outline and without the strokes' pen pressure, tilt, bearing and rotation. Evidence: `tests::build::{live_paint_expand_keeps_the_faces_and_edges_that_draw, live_paint_merge_carries_the_faces_that_draw, live_paint_merge_leaves_pen_pressure_behind, live_paint_merge_keeps_the_fit_of_carried_gradients, live_paint_merge_keeps_the_visibility_opacity_and_blending_of_carried_parts}`.
|
||||
`livePaint.info` lists every fill and stroke row of each face and edge, bottom first, with its paint, opacity, visibility, weight for a stroke, and whether it draws by the rule above, beside the top fill, stroke and weight it already reported. Evidence: `tests::build::live_paint_info_lists_every_appearance_row`.
|
||||
Live Paint Gap Options (Object › Live Paint › Gap Options…, `livePaint.gapOptions`): with Gap Detection on, paint stops at the gaps that run from a loose end of a path to the nearest path, up to Small (3 pt), Medium (6 pt), Large (12 pt) or a custom size; Close Gaps With Paths adds an unpainted path across each gap; Preview applies the options live and draws the gaps in the Gap Preview Color. The options are saved, copied and undone with the group, and Merge keeps the bottom group's options when its Gap Detection is on, or else turns Gap Detection on with Small when another merged group has it on. When Gap Detection is off in every merged group, it stays off.
|
||||
Live Paint Gap Options (Object › Live Paint › Gap Options…, `livePaint.gapOptions`): with Gap Detection on, paint stops at the gaps that run from a loose end of a path to the nearest path, up to Small (3 pt), Medium (6 pt), Large (12 pt) or a custom size; Close Gaps With Paths adds an unpainted path across each gap; Preview applies the options live and draws the gaps in the Gap Preview Color, and a preview that fails puts the groups back and stops drawing the dialog's preview of the gaps. The options are saved, copied and undone with the group, and Merge keeps the bottom group's options when its Gap Detection is on, or else turns Gap Detection on with Small when another merged group has it on. When Gap Detection is off in every merged group, it stays off.
|
||||
View › Show Live Paint Gaps (`view.livePaintGaps`) draws the gaps of the selected Live Paint groups up to their Paint Stops At size, each in its group's Gap Preview Color, until Hide Live Paint Gaps or Hide Edges hides them ([Live Paint gaps](https://web.archive.org/web/20260105111201/https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/find-and-close-gaps-in-live-paint-groups.html)).
|
||||
Double-clicking the Live Paint Selection tool opens its Tool Options ([Live Paint Selection tool options](https://web.archive.org/web/20250904012025/https://helpx.adobe.com/illustrator/using/selecting-objects.html)): with Select Fills off, a click selects an edge instead of a face; with Select Strokes off, Alt-click selects a face instead of an edge; Color and Width set the color and width of the highlight on the face or edge under the pointer (red and 4 px by default). The options last across tool switches and are saved with the preferences (`tool.setOption {tool: "livePaintSelection"}`).
|
||||
As VectorCraft's own rule, OK in Live Paint Selection Tool Options, Live Paint Bucket Options, Gap Options and Tile Edge Color gives an error for a color with an alpha part (`#rrggbbaa` or `#rgba`) and changes nothing.
|
||||
@@ -2387,6 +2389,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
Save as Template always writes a file named with its template type's extension: `file.saveAsTemplate` saves a path ending in another format's extension (`card.png`) as `card.vctemplate` (or `card.ait`), the desktop save panel does the same with a Save As format's extension typed in it (`card.pdf` is saved as `card.vctemplate`), and `file.saveAs` and `document.save` refuse `ait` with an error that names `file.saveAsTemplate`. A `.ait` is PDF-compatible only: `aiVersion: "7"` is an error for it, and the web build's dialog shows no Version row for it.
|
||||
Exports refuse a `.ait` with an error that names `file.saveAsTemplate`, and `vectorcraft-cli convert in.pdf out.ait` and `run --export out.ait` write the template as `file.saveAsTemplate` does.
|
||||
- SVG/SVGZ in and out with SVG Options, Preserve Editing, symbols, filters, rich text and physical units (SVG type under a transform or `viewBox` scale opens at the size it draws at, the scale moved into its size, leading, baseline shift and strokes, a stretch, skew or rotation kept as its transform: #396; a top-level group with a clip path, such as a clipped Inkscape layer, opens as a layer with a clipping mask, its name kept: #420; hidden objects written hidden on Save and `convert`, and `data-*` attributes kept as the objects' own data: #522; top-level groups open as layers named from `data-name`, else the id, also when one more group (a transform on all the art, a `<switch>`) wraps them, hidden ones hidden, and a file whose art sits loose under a root `<svg>` with an id (or `data-name`), as one-layer exports write it, opens with its one layer named from it; nested groups stay groups, except the sublayers VectorCraft writes, marked `data-vc-layer`, and Inkscape sublayers, which open as sublayers in their layer's colour: #372); PDF and PDF-compatible `.ai` in and out (layers, with hidden ones kept hidden with their art and nested ones as sublayers, on pages of up to 64 million operators, art whose layer can't be told going to a hidden, non-printing layer rather than showing or printing: #419; strokes kept live, a fill and a stroke of one outline as one object; a type object's stroke written as each glyph's outline stroked back on the type, so it stays one editable object; lines wrapped in a frame (each wrapped line ending in a space, one left edge, leading and font) back as one area type object, left aligned or justified with its paragraph spacing, where laying it out breaks the lines where the file does; glyphs set apart by gaps wider than a space (a barcode's digit groups) keeping their places; layers stacked as the pages mark them even when one first paints on a later page, art ending a layer's marked content or a clip closing in a later layer kept in its own layer, and layers with no art kept empty: #508; art reaching past a plain PDF's page clipped to its crop box, as PDF viewers show it, each such object in a clip group of its own (a PDF-compatible `.ai` opens whole: #675); a `.ai` on its trim boxes with the bleed boxes round them as the document's bleed, as Crop To › Trim opens a PDF (#1266); masks, editable text with type set along a curve coming back as type on a path, each artboard's art on its own page only, an `.ai`'s white page under its layers left out rather than coming in as art, spot colours, presets, security, marks and bleed, ICC output intents, raster effects, subset fonts, PDF/X, PDF layers, overprint, page thumbnails, fast web view, PDF 1.3). CMYK images keep their ink amounts from PDF import (and from placed CMYK TIFFs and the images in an `.ai` or EPS file's editing data, an alpha channel coming in as a grayscale opacity mask) to PDF export: a CMYK JPEG passes through with its compressed samples unchanged (its `ICC_PROFILE` segments are removed when `output.profiles` is `none` (except in PDF/A, and in PDF/X-3 and PDF/X-4 files that do not write CMYK colors as DeviceCMYK) and in PDF/X-3 and PDF/X-4 when they are the CMYK output intent's profile and CMYK colors are DeviceCMYK), others stay CMYK (DeviceCMYK, or ICC-based CMYK in PDF/X-3/X-4 when not in the output intent's profile) unless the Output settings convert them; the canvas shows them through the working CMYK profile (#320). Overprint is kept from PDF import (opened, the PDF part of an `.ai`, placed) to PDF export: the graphics state's `/OP` and `/op` become the overprint of fills, strokes and type, so a spot colour over a process colour still overprints; a page whose overprint can't be read for certain knocks out with a note, as does `/OPM 0` being read as nonzero overprint (#1388; hand-written fixtures, `pdf/src/tests/import_overprint.rs`). A masked CMYK image (`/SMask`, `/Mask` or a colour key) keeps its inks too, its alpha coming in as a greyscale opacity mask.
|
||||
- SVG Options › Units writes export `width` and `height` in px (bare numbers, the default), pt, mm, cm or in, with the `viewBox` in points (#4462). Physical dimensions require Responsive off and a physical unit; Responsive omits both dimensions.
|
||||
In imported PDF type, a space glyph the file draws between two words also keeps the next word where the file has it when the gap beside the space is wide, as VectorCraft's own export draws a tracked space: the space gets tracking of its own, and the wrapped lines of a justified paragraph still come back as one area type object when the word gaps on each line are alike (part of #2384).
|
||||
Letter-spaced PDF type, whether set with character spacing (`Tc`) or glyph by glyph, keeps its word spaces and gains none between its letters: the spacing a line's letters share is taken off each gap before a gap reads as a space. That holds on a line that also shows where its words break, with spaces the file draws or gaps wider than the rest; evenly spaced glyphs alone, which could be words of one letter, keep every gap as a space, as do glyphs set more than half an em apart, such as figures in columns.
|
||||
A function-based PDF shading (type 1) whose colour changes along one axis only, as a browser writes a repeating linear gradient, comes in as a linear gradient over its domain, each hard colour change two stops at one offset; one whose colour changes in two directions comes in as its average colour, with a warning. Either paints only over the shading's domain. Both came in as a flat grey that wasn't in the file (#3621). Each such shading is read once per import, and all of them within one budget of 200,000 function evaluations, so a file filling thousands of paths with long functions still opens in about a second (it took minutes); past the budget they come in as their average colour, then grey, with a warning.
|
||||
@@ -2401,6 +2404,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
A `.svgz` file copied in a file manager pastes as its art, as a copied `.svg` file does.
|
||||
SVG export (Save As, Export As, Export for Screens, Asset Export and the clipboard share the writer) writes simple shapes as SVG basic shapes, as the reference app does (an ellipse is an `ellipse` tag until an anchor is added, [forum](https://community.adobe.com/t5/illustrator-discussions/trouble-exporting-shape-with-points-to-svg/td-p/10720325); rectangles come out as `<rect>` and `<polygon>`, [forum](https://community.adobe.com/t5/illustrator-discussions/force-svg-export-using-all-lt-rect-gt/td-p/11282378)): an axis-aligned rectangle as `<rect>`, a circle or ellipse drawn with four standard arcs as `<circle>`/`<ellipse>`, a straight line as `<line>`, and other straight-segment paths as `<polygon>`/`<polyline>`, at the written precision (#4652). A rectangle or ellipse with a dashed stroke, whose dashes would start elsewhere, a turned ellipse, curves and compound paths stay `<path>`. `crates/svg/tests/it/basic_shapes.rs` checks each element, that the picture renders as the canvas does and that the geometry reimports.
|
||||
At a precision of 9 decimals or fewer, SVG export writes each number from an integer when the integer rounds it as the decimal formatter does; the formatter still writes values halfway between two written numbers and values too large for the integer. Exporting one path of 200,000 anchors takes a median of 43.4 ms instead of 167.0 ms on Windows 11, and 20,000 rectangles 81.4 ms instead of 141.4 ms, with the same SVG (`crates/svg/src/lib.rs`).
|
||||
Physical SVG sizes require both disabling SVG Options › Responsive and selecting Points, Millimeters, Centimeters or Inches under Units; Responsive omits `width` and `height`, so selecting a unit alone does not set physical size. Physical dimensions retain at least six decimal places and six significant digits independently of coordinate precision. Legacy Pixels output remains bare numbers, one per document point, rather than a physical-size guarantee: CSS pixels are 96 per inch. Regression coverage: `physical_units_preserve_rendered_extent_at_low_coordinate_precision` checks a consumer's viewport and drawn extent under default aspect-ratio scaling, including narrow and tiny artboards; `tiny_physical_sizes_keep_their_scale` covers smaller converted lengths.
|
||||
SVG import reads each `<circle>` and `<ellipse>` as the ellipse VectorCraft draws: four smooth anchors on the axes, starting at the right, with handles of the standard length, so an ellipse exported as `<ellipse>` comes back with the anchors it was written from and draws the same (`circles_and_ellipses_import_as_the_ellipse_drawn` in `crates/svg/tests/it/basic_shapes.rs`, `filled_ellipse_on_the_artboard_edge_survives_visually` in `prop_svg.rs`).
|
||||
SVG import keeps attributes in other applications' XML namespaces (`plotter:pen="2"`) on the objects and layers they belong to, as it keeps their `data-*` attributes: copies, duplicates and `.vectorcraft` files keep them, and SVG export writes them back with each namespace declared once on the root (the rest of #522; `crates/svg/tests/it/foreign_attributes.rs`, `tests/attributes.rs`).
|
||||
A PDF-compatible `.ai` saved with Include Editing Data for Other Apps defines every symbol in its editing copy with its art, registration point and place in the Symbols panel's order, and writes its instances as symbol instances, which VectorCraft's `.ai` reader opens as symbols and instances again (`symbols_and_their_instances_are_read_back` in `crates/eps/src/ai_editing/tests.rs`; [file-format-parity.md](file-format-parity.md) lists the instances written as their art).
|
||||
@@ -3475,6 +3479,7 @@ Edit › Copy and Cut put the selected ruler guides on the clipboard, with the s
|
||||
| 2026-11-12 | minor | Type: kerning at the Type tool's caret at the start of a line (the text's, a paragraph's, or after a forced line break) sets the space before the character after it (`kerningBefore`), which moves it and the rest of its line; it did nothing at the text's start and kerned the invisible line break at a paragraph's (#5111). Scores and estimates unchanged. |
|
||||
| 2026-11-12 | minor | Live Paint Bucket fills faces crossed in one drag (#6373). Scores and estimates unchanged. |
|
||||
| 2026-11-12 | minor | Save refusal follow-up (#6146): changed format opens its Save options; unchanged format retains original options. Focused UI regressions passed, including the format-change case that failed before the fix; native panel acceptance pending. Scores and estimates unchanged. |
|
||||
| 2026-11-11 | minor | SVG physical dimensions retain scale independently of coordinate precision, including tiny sizes (#5450 review); consumer-rendered extent regression added. Clarify that physical output requires Responsive off and a physical unit; legacy bare numeric output is unchanged and CSS pixels are 96/in. Scores and estimates unchanged. |
|
||||
| 2026-11-11 | minor | Rulers: the zero point dragged out of the rulers' corner snaps as a drawn point does (Smart Guides, Snap to Point and the ruler guides, pixels, the grid); evidence updated; scores unchanged. |
|
||||
| 2026-11-11 | minor | Interim macOS canvas cursor delivery (#2292): the tool's cursor stays after the pointer moves (#6362); tool cursors evidence updated; scores and hours unchanged. |
|
||||
| 2026-11-11 | minor | Eyedropper copies effective character dimensions between transformed text objects (#6404); scores and estimates unchanged. |
|
||||
@@ -3537,6 +3542,7 @@ Edit › Copy and Cut put the selected ruler guides on the clipboard, with the s
|
||||
| 2026-11-04 | minor | Contour add-on (beyond Illustrator): drag away from a selected shape's edge to grow a live copy of it, or toward the inside to shrink it; the copy carries a live Offset Path effect, so it stays editable until Bake (Expand Appearance), a second drag changes the same Contour instead of nesting one, and a floating bar sets the distance and the Sharp, Round or Square corners. `addon.contour.set` is the command behind it. It is a built-in add-on: Object › Plug-ins › Contour, and its own heading in All Tools, with no default shortcut or toolbar slot. A VectorCraft design built on Offset Path; no other application was inspected. Scores and estimates unchanged. |
|
||||
| 2026-11-04 | minor | Contour tool (beyond Illustrator): drag away from a selected shape's edge to grow a live copy of it, or toward the inside to shrink it; the copy carries a live Offset Path effect, so it stays editable until Bake (Expand Appearance), a second drag changes the same Contour instead of nesting one, and a floating bar sets the distance and the Sharp, Round or Square corners. `object.contour` is the command behind it. A VectorCraft design built on Offset Path; no other application was inspected. Scores and estimates unchanged. |
|
||||
| 2026-11-04 | minor | Area type vertical alignment buttons in the Properties panel's Paragraph section and the Control panel, off for columns, rows and threaded frames (#3759); evidence added; scores unchanged. |
|
||||
| 2026-11-03 | minor | SVG Options has a Units choice (Pixels, Points, Millimeters, Centimeters, Inches) for exported `width` and `height`. For physical size in laser and plotter software, disable Responsive and select a physical unit; Responsive omits both dimensions, so selecting a unit alone does not help (#4462; Pixels still bare numbers as before). Scores and estimates unchanged. |
|
||||
| 2026-11-03 | minor | Enclosing Lasso is an add-on with no default shortcut or Basic toolbar slot. Scores and estimates remain unchanged. |
|
||||
| 2026-11-03 | minor | The canvas context menu offers Outline Stroke for a stroked selection (#5267); scores and estimates unchanged. |
|
||||
| 2026-11-03 | minor | Find Font's replacement-source chooser offers Document, Recent and System (#5217); scores and estimates unchanged. |
|
||||
@@ -3878,4 +3884,4 @@ Edit › Copy and Cut put the selected ruler guides on the clipboard, with the s
|
||||
## EPS Save evidence (2026-10-26)
|
||||
Ordinary Save and Save As keep EPS as EPS, with the chosen page frame, transparent margins and the complete editable VectorCraft document. Existing import-loss confirmation and transparency warnings remain; the Save TIFF preview is capped at 1024 pixels, while Export retains 2048. See [file-format-parity.md](file-format-parity.md#eps-save-and-source-protection) for limits and regression evidence. This narrows G9 save-back workflow coverage; native Illustrator editing-data fidelity, parity scores and hour estimates are unchanged. Since 2026-11-12 the EPS Options of Save As show Use Artboards, unchecked by default: unchecked, the bounding box fits the visible art; checked, Save keeps the chosen page frame and margins described here.
|
||||
|
||||
> **Swatches status (2026-11-15):** Item context menus are implemented and covered by headless tests; full CI passed on the latest-main integration (all 13 gates), including the updated panel-view harness; parity scores and estimates are unchanged.
|
||||
> **Historical Swatches proof (2026-11-15):** Item context menus were implemented and covered by headless tests; all 13 CI gates passed on the integration tested then, including the updated panel-view harness. This is not validation of the current merge; parity scores and estimates are unchanged.
|
||||
|
||||
+4
-1
@@ -7,6 +7,8 @@
|
||||
>
|
||||
> Outline Stroke is available in the canvas context menu when the selection has an outlinable stroke (#5267). A linked dimension selected with its source keeps its lines; those protected lines do not make a fill-only source eligible, including inside a group. Coincident-point paths with a plain butt-capped stroke do not make the selection eligible either; round and square caps still paint and can be outlined. Scores and estimates unchanged.
|
||||
>
|
||||
> SVG Options can write physical dimensions with Responsive off and a physical unit selected (#4462); pixel output remains bare numbers. Save As and Save a Copy offer Document units and preserve an existing SVG's physical units when legacy saved options omit a unit; Export keeps its Pixels default.
|
||||
>
|
||||
> Tech Circuit update (2026-11-14): three original procedural brushes; ten built-in brush libraries (G5).
|
||||
>
|
||||
> Selection update (2026-11-11): path and compound-path interiors follow enabled non-None fill rows, including lower fills beneath a top None row (#6625). Hidden-only interiors miss; zero-opacity fills remain selectable. Cap/join follow-up (2026-11-12): hidden-fill and no-fill stroke hits must respect cap and join geometry; focused cap/join CPU regressions passed. Scores and estimates unchanged.
|
||||
@@ -750,6 +752,7 @@ before release (#6373). [Paint faces and edges](https://helpx.adobe.com/illustra
|
||||
| 2026-11-03 | minor | The canvas context menu offers Outline Stroke when the selection has a stroke to outline (#5267); scores and estimates unchanged. |
|
||||
| 2026-11-03 | minor | Enclosing Lasso selects fully enclosed objects with a freehand loop under Object › Plug-ins; scores and estimates unchanged. |
|
||||
| 2026-11-03 | minor | Type on a Path Options has a Preview checkbox (#5360, as public tutorials of the dialog show); scores and estimates unchanged |
|
||||
| 2026-11-03 | minor | SVG Options has a Units choice (Pixels, Points, Millimeters, Centimeters, Inches) for the `width` and `height` an export writes, so laser and plotter software read the physical size (#4462; the `units` option, Pixels still bare numbers as before); scores and estimates unchanged |
|
||||
| 2026-11-03 | minor | Symbol editing draws and drags 9-slice guides on the canvas (#5280). Guides outside the artwork remain unsupported. Scores and hours remain unchanged. |
|
||||
| 2026-11-02 | minor | Font-family fields in Character, Properties and Control accept the wheel without opening the menu (#5253); scores and estimates unchanged. |
|
||||
| 2026-11-01 | minor | Object › Image Trace › Batch Trace Folder asks for a source and a destination folder and traces each image into it (#4921); scores and estimates unchanged |
|
||||
@@ -957,6 +960,6 @@ before release (#6373). [Paint faces and edges](https://helpx.adobe.com/illustra
|
||||
| 2026-10-22 | minor | Tab-drag follow-up: reconcile upstream progress updates and document drag lifecycle, insertion behavior and regression contracts; behavior, scores and estimates unchanged. |
|
||||
| 2026-10-22 | minor | Artwork dragged with Selection switches visible document tabs after a 400 ms hover, then copies editable artwork on canvas release; source and clipboard stay intact; scores and hours unchanged |
|
||||
|
||||
> **Swatches status (2026-11-15):** Item context menus are implemented and covered by headless tests; full CI passed on the latest-main integration (all 13 gates), including the updated panel-view harness; parity scores and estimates are unchanged.
|
||||
> **Historical Swatches proof (2026-11-15):** Item context menus were implemented and covered by headless tests; all 13 CI gates passed on the integration tested then, including the updated panel-view harness. This is not validation of the current merge; parity scores and estimates are unchanged.
|
||||
|
||||
> **Text styles status (2026-11-19):** Character Styles and Paragraph Styles panels item context menus (Options…, Duplicate, Delete, Redefine, Clear Overrides) are implemented and covered by headless tests; parity scores and estimates are unchanged.
|
||||
|
||||
Reference in New Issue
Block a user