mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-28 01:10:54 +01:00
Merge pull request #7068 from ruchirguitar/feat/docinfo-path-area
feat(docinfo): add path area to Document Info (#6965)
This commit is contained in:
8 files changed
+272
-18
No files matched your search
@@ -291,3 +291,15 @@ fn q_and_ha_suffixes_do_not_take_other_units_suffixes() {
|
||||
// A suffix after math covers the whole expression, as for the other units.
|
||||
assert!((Unit::Points.parse("26/2 q").unwrap() - Unit::Q.to_pt(13.0)).abs() < 1e-9);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_area_formats_and_trims_cleanly() {
|
||||
assert_eq!(Unit::Points.format_area(100.0), "100 pt²");
|
||||
assert_eq!(Unit::Inches.format_area(4.5 * 72.0 * 72.0), "4.5 in²");
|
||||
let mm_side = Unit::Millimeters.to_pt(1.0);
|
||||
assert_eq!(Unit::Millimeters.format_area(12.5 * mm_side * mm_side), "12.5 mm²");
|
||||
assert_eq!(Unit::Points.format_area(0.0), "0 pt²");
|
||||
assert_eq!(Unit::Points.format_area(-10.0), "0 pt²");
|
||||
assert_eq!(Unit::Points.format_area(f64::NAN), "0 pt²");
|
||||
assert_eq!(Unit::Points.format_area(f64::INFINITY), "0 pt²");
|
||||
}
|
||||
@@ -166,6 +166,19 @@ impl Unit {
|
||||
pub fn format(self, pt: f64) -> String {
|
||||
format!("{} {}", self.number(pt), self.suffix())
|
||||
}
|
||||
/// Format an area in square points into this unit (e.g. `12.5 mm²`, `4.5 in²`, `100 pt²`).
|
||||
pub fn format_area(self, pt2: f64) -> String {
|
||||
if !pt2.is_finite() || pt2 <= 0.0 {
|
||||
return format!("0 {}²", self.suffix());
|
||||
}
|
||||
let side = self.from_pt(1.0);
|
||||
let val = pt2 * side * side;
|
||||
let decimals = if matches!(self, Unit::Points | Unit::Pixels | Unit::Picas | Unit::Q | Unit::Ha) { 3 } else { 4 };
|
||||
let s = format!("{:.*}", decimals, val);
|
||||
let s = s.trim_end_matches('0').trim_end_matches('.');
|
||||
let s = if s == "-0" || s.is_empty() { "0" } else { s };
|
||||
format!("{s} {}²", self.suffix())
|
||||
}
|
||||
/// [`Unit::format`] without the suffix (`12.5`), for narrow fields.
|
||||
pub fn number(self, pt: f64) -> String {
|
||||
// Three decimals for the small units (`595.276 pt`), four for the large ones (`8.2677 in`,
|
||||
|
||||
@@ -18,7 +18,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Document Info",
|
||||
["Window", "Document Info"],
|
||||
None,
|
||||
"{selectionOnly?, category?: document|objects|graphicStyles|brushes|spotColors|patterns|gradients|symbols|fonts|fontDetails|linkedImages|embeddedImages|repeats (only that one in sections and the text), format?: \"text\" (→ {text}: the report Document Info › Save… and Package write)} → {document: {…, units (English), unitId: the units' Preferences › Units id (points, millimeters, feetInches, …), rasterEffectsPpi, transparency: {gridSize: small|medium|large, gridColors: [#rrggbb, #rrggbb], gridColorsName (a preset's name or Custom), simulatePaper, flattenerPreset} (File › Document Setup's transparency settings, which the document category lists), selectedArtboards: [{index, name, width, height, x, y}] (while the Artboard tool is the current tool, the artboards it has selected, in the document's units, x and y those of the top-left corner from the ruler origin of its active artboard, which the document category lists after the artboards; else empty)}, objects: {paths, compoundPaths, groups, …}, pathLength: pt (the paths' total length, compound paths' included, guides left out), fonts (the type in opacity masks and in the art of symbols and patterns included; with selectionOnly: the selected type's), fontUses: [{font, type: truetype|opentype|unknown, uses}] (each font of fonts, in order: truetype or opentype by the outlines (glyf, or CFF or CFF2) of the face its type is drawn in, unknown for a font not installed in the family and style it names; uses: the text objects set in it, each once however many of its runs use the font, the type in a mask or in a symbol's or pattern's art once however many objects show it; the fonts category's rows give them as `TrueType; 2 uses`), fontDetails: [{font, match: exact|style|missingWithFallback|missing, family, style, file, embedding: allowed|editing|previewPrint|forbidden|null}] (each font of fonts, in order: how it was found, the face shown (null when none), that face's file name (null for a built-in face) and what its license allows), images, imageObjects: [{name, width, height, linked, file, format, effectivePpi, memoryBytes, storedBytes}] (the image objects in the order Linked Images and Embedded Images list them; file: what a linked image's row shows, null for an embedded one; format: a linked image's file format by its extension, else the format of the pixels the document holds, null when unknown; effectivePpi: [x, y] pixels per inch at the size it is placed at, a distorted image measured at its middle, null when it has no area; memoryBytes: for an embedded image width × height × 4, the bytes of the 8-bit RGBA pixels it is drawn from, else null; storedBytes: for an embedded image the bytes of the encoded image the document holds, else null; a Linked Images row gives the format, the size, the resolution and the file (`PNG; 1200 × 800 px; 150 ppi — /art/photo.png`), an Embedded Images row the format, the size and the memory (`PNG; 1200 × 800 px; estimated memory 3.7 MiB`)), swatches, graphicStyleNames (with selectionOnly: the styles the selected objects are linked to), brushNames (the brushes the art's drawn strokes use, each once; with selectionOnly: those the selected objects' strokes use), brushes: [{name, type: calligraphic|scatter|art|pattern|bristle|null}] (those brushes with their types; null: not in the Brushes panel), panelBrushNames (the Brushes panel's brushes), repeatObjects: [{id, name, type: radial|grid|mirror, instances, rows?, cols?}] (the Repeat objects, those in groups and other repeats included; with selectionOnly: those in the selection), spotObjects: [{id, name, spotColors}] (the objects filled or stroked with a spot color swatch, as a solid color or in the stops of a gradient that color a part of it above opacity 0 (a stop at opacity 0 counts only where it mixes with a stop above opacity 0 over a stretch of some width), at a tint above 0, and grayscale images colorized with one, each once, by the rules patternObjects follows, with the spot colors they use; Registration and process colors are not spot colors; objects.spots counts them), spotColorNames and spotColors (the spot colors those objects use), patternObjects: [{id, name, patterns}] (the objects filled or stroked with a pattern, each once, those in groups and type whose drawn characters use one included, hidden fills and strokes, fills and strokes at an opacity of 0, strokes with no width, guides, compound path members' own fills and strokes, images' fills and strokes without a shape and characters that draw nothing left out, with the patterns they use, which objects.patterns counts; with selectionOnly: those in the selection), patternNames (the patterns those objects use), gradientObjects: [{id, name, gradients, kinds}] (the objects filled or stroked with a gradient, by the same rules, with the gradients they use: a linked gradient swatch's name, else its kind's name, such as Linear gradient; kinds gives each one's kind, linear|radial|conic|diamond|freef
Line truncated
|
||||
"{selectionOnly?, category?: document|objects|graphicStyles|brushes|spotColors|patterns|gradients|symbols|fonts|fontDetails|linkedImages|embeddedImages|repeats (only that one in sections and the text), pathArea?: bool (default true; false skips the paths' area pass, as a category other than objects does), format?: \"text\" (→ {text}: the report Document Info › Save… and Package write)} → {document: {…, units (English), unitId: the units' Preferences › Units id (points, millimeters, feetInches, …), rasterEffectsPpi, transparency: {gridSize: small|medium|large, gridColors: [#rrggbb, #rrggbb], gridColorsName (a preset's name or Custom), simulatePaper, flattenerPreset} (File › Document Setup's transparency settings, which the document category lists), selectedArtboards: [{index, name, width, height, x, y}] (while the Artboard tool is the current tool, the artboards it has selected, in the document's units, x and y those of the top-left corner from the ruler origin of its active artboard, which the document category lists after the artboards; else empty)}, objects: {paths, compoundPaths, groups, …}, pathLength: pt (the paths' total length, compound paths' included, guides left out), pathArea: pt² (the paths' total area, compound paths' included, guides left out; null unless the request covers the Objects category (no category, or objects) and pathArea? is not false: the area pass normalizes every closed path's geometry, so a caller showing another category can skip it), fonts (the type in opacity masks and in the art of symbols and patterns included; with selectionOnly: the selected type's), fontUses: [{font, type: truetype|opentype|unknown, uses}] (each font of fonts, in order: truetype or opentype by the outlines (glyf, or CFF or CFF2) of the face its type is drawn in, unknown for a font not installed in the family and style it names; uses: the text objects set in it, each once however many of its runs use the font, the type in a mask or in a symbol's or pattern's art once however many objects show it; the fonts category's rows give them as `TrueType; 2 uses`), fontDetails: [{font, match: exact|style|missingWithFallback|missing, family, style, file, embedding: allowed|editing|previewPrint|forbidden|null}] (each font of fonts, in order: how it was found, the face shown (null when none), that face's file name (null for a built-in face) and what its license allows), images, imageObjects: [{name, width, height, linked, file, format, effectivePpi, memoryBytes, storedBytes}] (the image objects in the order Linked Images and Embedded Images list them; file: what a linked image's row shows, null for an embedded one; format: a linked image's file format by its extension, else the format of the pixels the document holds, null when unknown; effectivePpi: [x, y] pixels per inch at the size it is placed at, a distorted image measured at its middle, null when it has no area; memoryBytes: for an embedded image width × height × 4, the bytes of the 8-bit RGBA pixels it is drawn from, else null; storedBytes: for an embedded image the bytes of the encoded image the document holds, else null; a Linked Images row gives the format, the size, the resolution and the file (`PNG; 1200 × 800 px; 150 ppi — /art/photo.png`), an Embedded Images row the format, the size and the memory (`PNG; 1200 × 800 px; estimated memory 3.7 MiB`)), swatches, graphicStyleNames (with selectionOnly: the styles the selected objects are linked to), brushNames (the brushes the art's drawn strokes use, each once; with selectionOnly: those the selected objects' strokes use), brushes: [{name, type: calligraphic|scatter|art|pattern|bristle|null}] (those brushes with their types; null: not in the Brushes panel), panelBrushNames (the Brushes panel's brushes), repeatObjects: [{id, name, type: radial|grid|mirror, instances, rows?, cols?}] (the Repeat objects, those in groups and other repeats included; with selectionOnly: those in the selection), spotObjects: [{id, name, spotColors}] (the objects filled or stroked with a spot color swatch, as a solid color or in the stops of a gradient that color a part of it above opacity 0 (a stop at opacity 0 counts only where it mixes with a stop above opacity 0 over a stretch of some width), at a tint above 0, and grayscale images colorized with one, each once, by the rules patternObjects follows, with the spot colors they use; Registration and process colors are not spot colors; objects.spots counts them), spotColorNames and spotColors (the spot colors those objects use), patternObjects: [{id, name, patterns}] (the objects filled or stroked with a pattern, each once, those in groups and type whose drawn characters use one included, hidden fills and strokes, fills and strokes at an opacity of 0, strokes with no width, guides, compound path members' own fills and strokes, images' fills and strokes without a shape and characters that draw nothing left out, with the patterns they use, which obje
Line truncated
|
||||
has_doc,
|
||||
info
|
||||
),
|
||||
@@ -445,6 +445,12 @@ fn sections(
|
||||
if let Some(at) = rows.iter().position(|(label, _)| label == "Paths") {
|
||||
rows.insert(at + 1, ("Path Length".into(), u.format(info["pathLength"].as_f64().unwrap_or(0.0))));
|
||||
}
|
||||
let area = info["pathArea"].as_f64().unwrap_or(0.0);
|
||||
if area > 0.0
|
||||
&& let Some(at) = rows.iter().position(|(label, _)| label == "Path Length")
|
||||
{
|
||||
rows.insert(at + 1, ("Path Area".into(), u.format_area(area)));
|
||||
}
|
||||
rows
|
||||
}
|
||||
"graphicStyles" => names("graphicStyleNames"),
|
||||
@@ -755,6 +761,38 @@ fn object_paints(d: &Document, spots: &HashSet<&str>, members: &HashSet<*const N
|
||||
used
|
||||
}
|
||||
|
||||
/// Filled area of a path's closed subpaths under its fill rule (holes subtracted; open subpaths left out).
|
||||
fn closed_path_area(path: &vectorcraft_geom::PathData, rule: vectorcraft_geom::FillRule) -> f64 {
|
||||
let closed = vectorcraft_geom::PathData { subpaths: path.subpaths.iter().filter(|s| s.closed).cloned().collect() };
|
||||
if closed.subpaths.is_empty() {
|
||||
return 0.0;
|
||||
}
|
||||
let a = vectorcraft_pathops::area(&closed, rule);
|
||||
if a.is_finite() && a > 0.0 { a } else { 0.0 }
|
||||
}
|
||||
|
||||
/// Recursively collects non-guide subpaths from a node and its descendants for compound path area calculation.
|
||||
fn collect_compound_subpaths(n: &Node, subs: &mut Vec<vectorcraft_geom::SubPath>) {
|
||||
if n.is_guide() {
|
||||
return;
|
||||
}
|
||||
match &n.kind {
|
||||
NodeKind::Path { path, guide: false, .. } => {
|
||||
subs.extend(path.subpaths.clone());
|
||||
}
|
||||
NodeKind::Compound { children, .. } => {
|
||||
for c in children {
|
||||
collect_compound_subpaths(c, subs);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
if let Some((pd, _)) = super::pathops::node_path(n) {
|
||||
subs.extend(pd.subpaths);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn info(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
const C: &str = "document.info";
|
||||
let category = str_param(p, "category");
|
||||
@@ -782,6 +820,10 @@ fn info(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
// The paths' total length, as Document Info › Objects shows it (the length of a cut line, a
|
||||
// strip of LEDs along the letters, #1958).
|
||||
let mut path_length = 0.0;
|
||||
let mut path_area = 0.0;
|
||||
// The area normalizes every closed path's geometry, so it is worked out only for a request
|
||||
// that covers the Objects category and does not turn it off with `pathArea: false`.
|
||||
let want_area = bool_or(p, "pathArea", true) && category.is_none_or(|c| c == "objects");
|
||||
// Each font with the number of text objects set in it.
|
||||
let mut fonts: BTreeMap<super::fonts::UsedFont, usize> = BTreeMap::new();
|
||||
let mut images: BTreeMap<String, Value> = BTreeMap::new();
|
||||
@@ -830,6 +872,19 @@ fn info(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
members.extend(children.iter().map(|c| std::ptr::from_ref(&**c)));
|
||||
}
|
||||
});
|
||||
// The members of the compound paths that the roots contain. Only these leave their area to the compound.
|
||||
let mut compound_members: HashSet<*const Node> = HashSet::new();
|
||||
for (r, _) in roots.iter().filter(|_| want_area) {
|
||||
r.walk(&mut |n| {
|
||||
if let NodeKind::Compound { children, .. } = &n.kind {
|
||||
for c in children {
|
||||
c.walk(&mut |descendant| {
|
||||
compound_members.insert(std::ptr::from_ref(descendant));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// Depth first, in paint order, as `Node::walk` visits: each object with whether it and the groups and layers around it
|
||||
// draw. An object that does not draw is still counted, and its members are visited.
|
||||
let mut stack: Vec<(&Node, bool)> = vec![];
|
||||
@@ -849,14 +904,26 @@ fn info(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
NodeKind::Group { clip: true, .. } => Some("clipGroups"),
|
||||
NodeKind::Group { .. } => Some("groups"),
|
||||
NodeKind::Path { guide: true, .. } => Some("guides"),
|
||||
NodeKind::Path { path, .. } => {
|
||||
NodeKind::Path { path, rule, .. } => {
|
||||
let l = path.length();
|
||||
if l.is_finite() {
|
||||
path_length += l;
|
||||
}
|
||||
if want_area && !compound_members.contains(&std::ptr::from_ref(n)) {
|
||||
path_area += closed_path_area(path, *rule);
|
||||
}
|
||||
Some("paths")
|
||||
}
|
||||
NodeKind::Compound { .. } => Some("compoundPaths"),
|
||||
NodeKind::Compound { children, rule } => {
|
||||
if want_area && !compound_members.contains(&std::ptr::from_ref(n)) {
|
||||
let mut subs = Vec::new();
|
||||
for c in children {
|
||||
collect_compound_subpaths(c, &mut subs);
|
||||
}
|
||||
path_area += closed_path_area(&vectorcraft_geom::PathData::new(subs), *rule);
|
||||
}
|
||||
Some("compoundPaths")
|
||||
}
|
||||
NodeKind::Text(t) => {
|
||||
count_fonts(&mut fonts, t);
|
||||
Some("textObjects")
|
||||
@@ -972,6 +1039,7 @@ fn info(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
"document": document_summary(d),
|
||||
"objects": counts,
|
||||
"pathLength": path_length,
|
||||
"pathArea": want_area.then_some(path_area),
|
||||
"fonts": font_names,
|
||||
"fontUses": font_uses,
|
||||
"fontDetails": font_entries,
|
||||
@@ -1347,6 +1415,115 @@ mod tests {
|
||||
assert_eq!(length(&mut s, json!({"selectionOnly": true})), 0.0);
|
||||
}
|
||||
|
||||
/// Document Info › Objects gives the paths' total area in the document's units: an open line
|
||||
/// counts 0, a closed rectangle encloses its area, and a compound path's holes are subtracted.
|
||||
#[test]
|
||||
fn info_gives_the_paths_total_area() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 400, "height": 400, "units": "Points"})).unwrap();
|
||||
let line = s.execute("shape.line", &json!({"x1": 0, "y1": 0, "x2": 72, "y2": 0})).unwrap()["id"].clone();
|
||||
let rect = s.execute("shape.rectangle", &json!({"x": 100, "y": 100, "width": 10, "height": 20})).unwrap()["id"].clone();
|
||||
let area = |s: &mut Session, p: Value| s.execute("document.info", &p).unwrap()["pathArea"].as_f64().unwrap();
|
||||
// The rectangle encloses 200 pt²; the open line encloses 0.
|
||||
assert!((area(&mut s, json!({})) - 200.0).abs() < 1e-6);
|
||||
// An open line selected: pathArea is 0, so no "Path Area" row is inserted.
|
||||
s.execute("select.set", &json!({"ids": [line]})).unwrap();
|
||||
assert_eq!(area(&mut s, json!({"selectionOnly": true})), 0.0);
|
||||
let rows = s.execute("document.info", &json!({"selectionOnly": true, "category": "objects"})).unwrap()["sections"][0]["rows"].clone();
|
||||
assert_eq!(rows, json!([["Paths", "1"], ["Path Length", "72 pt"]]));
|
||||
// The rectangle selected: "Path Area" row follows "Path Length".
|
||||
s.execute("select.set", &json!({"ids": [rect]})).unwrap();
|
||||
assert!((area(&mut s, json!({"selectionOnly": true})) - 200.0).abs() < 1e-6);
|
||||
let rows = s.execute("document.info", &json!({"selectionOnly": true, "category": "objects"})).unwrap()["sections"][0]["rows"].clone();
|
||||
assert_eq!(rows, json!([["Paths", "1"], ["Path Length", "60 pt"], ["Path Area", "200 pt²"]]));
|
||||
// A compound path's pieces are paths: their areas count.
|
||||
let other = s.execute("shape.rectangle", &json!({"x": 200, "y": 200, "width": 5, "height": 5})).unwrap()["id"].clone();
|
||||
s.execute("select.set", &json!({"ids": [rect, other]})).unwrap();
|
||||
s.execute("object.compoundPath.make", &json!({})).unwrap();
|
||||
assert!((area(&mut s, json!({"selectionOnly": true})) - 225.0).abs() < 1e-6);
|
||||
// A compound path (a 10x10 outer contour with a 6x6 inner hole) subtracts the hole:
|
||||
let mut s2 = Session::new();
|
||||
s2.execute("file.new", &json!({"width": 100, "height": 100, "units": "Points"})).unwrap();
|
||||
let outer = s2.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 10, "height": 10})).unwrap()["id"].clone();
|
||||
let inner = s2.execute("shape.rectangle", &json!({"x": 12, "y": 12, "width": 6, "height": 6})).unwrap()["id"].clone();
|
||||
s2.execute("select.set", &json!({"ids": [outer, inner]})).unwrap();
|
||||
let cp1 = s2.execute("object.compoundPath.make", &json!({})).unwrap()["id"].clone();
|
||||
assert!((area(&mut s2, json!({"selectionOnly": true})) - 64.0).abs() < 1e-6);
|
||||
// A nested compound path (cp1 compounded with another disjoint 5x5 rectangle) does not double-count cp1:
|
||||
let extra = s2.execute("shape.rectangle", &json!({"x": 50, "y": 50, "width": 5, "height": 5})).unwrap()["id"].clone();
|
||||
s2.execute("select.set", &json!({"ids": [cp1, extra]})).unwrap();
|
||||
s2.execute("object.compoundPath.make", &json!({})).unwrap();
|
||||
assert!((area(&mut s2, json!({"selectionOnly": true})) - 89.0).abs() < 1e-6);
|
||||
// A guide path is left out.
|
||||
let guide = s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 50, "height": 50})).unwrap()["id"].as_u64().unwrap();
|
||||
let d = std::sync::Arc::make_mut(&mut s.doc_mut().unwrap().doc);
|
||||
if let NodeKind::Path { guide: g, .. } = &mut d.node_mut(NodeId(guide)).unwrap().kind {
|
||||
*g = true;
|
||||
}
|
||||
s.execute("select.set", &json!({"ids": [guide]})).unwrap();
|
||||
assert_eq!(area(&mut s, json!({"selectionOnly": true})), 0.0);
|
||||
// A compound path whose members are guides is left out.
|
||||
let g1 = s.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap();
|
||||
let g2 = s.execute("shape.rectangle", &json!({"x": 20, "y": 20, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap();
|
||||
let d = std::sync::Arc::make_mut(&mut s.doc_mut().unwrap().doc);
|
||||
if let NodeKind::Path { guide: g, .. } = &mut d.node_mut(NodeId(g1)).unwrap().kind {
|
||||
*g = true;
|
||||
}
|
||||
if let NodeKind::Path { guide: g, .. } = &mut d.node_mut(NodeId(g2)).unwrap().kind {
|
||||
*g = true;
|
||||
}
|
||||
s.execute("select.set", &json!({"ids": [g1, g2]})).unwrap();
|
||||
s.execute("object.compoundPath.make", &json!({})).unwrap();
|
||||
assert_eq!(area(&mut s, json!({"selectionOnly": true})), 0.0);
|
||||
// Nothing with no paths, and no area row.
|
||||
s.execute("select.none", &json!({})).unwrap();
|
||||
assert_eq!(area(&mut s, json!({"selectionOnly": true})), 0.0);
|
||||
}
|
||||
|
||||
/// The area pass normalizes every closed path, so `document.info` leaves it out (`pathArea`
|
||||
/// null) for a request that does not cover the Objects category or turns it off, and still
|
||||
/// gives it for Objects and for every category.
|
||||
#[test]
|
||||
fn info_works_out_the_path_area_only_for_the_objects_category() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
|
||||
s.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 10, "height": 20})).unwrap();
|
||||
let area = |s: &mut Session, p: Value| s.execute("document.info", &p).unwrap()["pathArea"].as_f64();
|
||||
assert!(area(&mut s, json!({})).is_some_and(|a| a > 0.0));
|
||||
assert!(area(&mut s, json!({"category": "objects"})).is_some_and(|a| a > 0.0));
|
||||
assert_eq!(area(&mut s, json!({"category": "fonts"})), None);
|
||||
assert_eq!(area(&mut s, json!({"pathArea": false})), None);
|
||||
// Without the area, Objects has no Path Area row and keeps its other rows.
|
||||
let rows = |s: &mut Session, p: Value| s.execute("document.info", &p).unwrap()["sections"][0]["rows"].clone();
|
||||
let without = rows(&mut s, json!({"category": "objects", "pathArea": false}));
|
||||
let with = rows(&mut s, json!({"category": "objects"}));
|
||||
assert!(without.as_array().unwrap().iter().all(|r| r[0] != "Path Area"), "{without}");
|
||||
assert!(with.as_array().unwrap().iter().any(|r| r[0] == "Path Area"), "{with}");
|
||||
assert_eq!(with.as_array().unwrap().len(), without.as_array().unwrap().len() + 1);
|
||||
}
|
||||
|
||||
/// A selection containing both a compound and its member counts the member once; selecting
|
||||
/// only the member still reports that path's area.
|
||||
#[test]
|
||||
fn info_path_area_counts_selected_compound_members_once() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
|
||||
let p = s.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap();
|
||||
let q = s.execute("shape.rectangle", &json!({"x": 30, "y": 30, "width": 5, "height": 5})).unwrap()["id"].clone();
|
||||
s.execute("select.set", &json!({"ids": [p, q]})).unwrap();
|
||||
let compound = s.execute("object.compoundPath.make", &json!({})).unwrap()["id"].as_u64().unwrap();
|
||||
let st = s.doc_mut().unwrap();
|
||||
let NodeKind::Compound { children, .. } = &st.doc.node(NodeId(compound)).unwrap().kind else { panic!("not a compound path") };
|
||||
let member = children.iter().find(|child| child.id.0 == p).unwrap().id;
|
||||
let area = |s: &mut Session| s.execute("document.info", &json!({"selectionOnly": true})).unwrap()["pathArea"].as_f64().unwrap();
|
||||
let picked = s.execute("select.set", &json!({"ids": [member.0]})).unwrap();
|
||||
assert_eq!(picked["count"], 1);
|
||||
assert!((area(&mut s) - 100.0).abs() < 1e-6);
|
||||
let picked = s.execute("select.set", &json!({"ids": [member.0, compound]})).unwrap();
|
||||
assert_eq!(picked["count"], 2);
|
||||
assert!((area(&mut s) - 125.0).abs() < 1e-6);
|
||||
}
|
||||
|
||||
/// Document Info › Brushes lists the brushes the art's strokes use, each once with its type, and
|
||||
/// leaves out the Brushes panel's brushes no art uses (`panelBrushNames` lists those). With
|
||||
/// Selection Only it lists the brushes the selected objects' strokes use.
|
||||
|
||||
@@ -189,9 +189,10 @@ pub struct CanvasCache {
|
||||
pub(crate) palette: Option<(crate::palette::BuildKey, Arc<crate::palette::Built>)>,
|
||||
}
|
||||
|
||||
/// [`CanvasCache::doc_info`]: (document uid, revision, selection only, the Artboard tool's options)
|
||||
/// and the `document.info` result fetched for them.
|
||||
pub type DocInfoCache = ((u64, u64, bool, Value), Arc<Value>);
|
||||
/// [`CanvasCache::doc_info`]: (document uid, revision, selection only, whether Objects is shown
|
||||
/// (and so the paths' area asked for), the Artboard tool's options) and the `document.info` result
|
||||
/// fetched for them.
|
||||
pub type DocInfoCache = ((u64, u64, bool, bool, Value), Arc<Value>);
|
||||
|
||||
/// [`CanvasCache::map_surfaces`]: the surfaces and what they were computed for.
|
||||
pub type MapSurfacesCache = (MapSurfacesKey, Arc<Vec<vectorcraft_effects::MapSurface>>);
|
||||
|
||||
@@ -68,20 +68,28 @@ fn no_artwork_selected(app: &VectorcraftApp) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
/// `document.info` with its categories, fetched again only when the document, the scope or the
|
||||
/// artboards the Artboard tool has selected change. A frame that fetches nothing returns the stored
|
||||
/// result without copying it and stores nothing; a failed fetch leaves the stored result as it was.
|
||||
/// Whether the panel shows Objects, where Path Area is: only then does it ask `document.info`
|
||||
/// for the paths' area, whose pass normalizes every closed path again after each edit.
|
||||
fn shows_path_area(view: &DocInfoView) -> bool {
|
||||
view.category.is_empty() || view.category == "objects"
|
||||
}
|
||||
|
||||
/// `document.info` with its categories, fetched again only when the document, the scope, the
|
||||
/// artboards the Artboard tool has selected or whether Objects is shown change. A frame that
|
||||
/// fetches nothing returns the stored result without copying it and stores nothing; a failed fetch
|
||||
/// leaves the stored result as it was.
|
||||
pub(crate) fn info(app: &mut VectorcraftApp) -> Option<Arc<Value>> {
|
||||
let selection_only = app.ui.doc_info.selection_only;
|
||||
let path_area = shows_path_area(&app.ui.doc_info);
|
||||
let artboard_tool = if app.session.tool_id() == "artboard" { app.session.tool_options_of("artboard") } else { Value::Null };
|
||||
let st = app.session.active()?;
|
||||
let key = (st.uid, st.revision, selection_only, artboard_tool);
|
||||
let key = (st.uid, st.revision, selection_only, path_area, artboard_tool);
|
||||
if let Some((cached, info)) = &app.canvas.doc_info
|
||||
&& *cached == key
|
||||
{
|
||||
return Some(Arc::clone(info));
|
||||
}
|
||||
let info = Arc::new(app.session.execute("document.info", &json!({ "selectionOnly": selection_only })).ok()?);
|
||||
let info = Arc::new(app.session.execute("document.info", &json!({ "selectionOnly": selection_only, "pathArea": path_area })).ok()?);
|
||||
app.canvas.doc_info = Some((key, Arc::clone(&info)));
|
||||
Some(info)
|
||||
}
|
||||
@@ -757,28 +765,30 @@ mod tests {
|
||||
}
|
||||
|
||||
/// The by-value cache the panel kept before its result was shared, with the same key.
|
||||
type CopiedCache = Option<((u64, u64, bool, Value), Value)>;
|
||||
type CopiedCache = Option<((u64, u64, bool, bool, Value), Value)>;
|
||||
|
||||
/// `document.info` read as the panel read it before its result was shared: the stored result
|
||||
/// copied out by value on every call, kept in `cache` so it does not touch the panel's.
|
||||
fn copied_info(app: &mut VectorcraftApp, cache: &mut CopiedCache) -> Option<Value> {
|
||||
let selection_only = app.ui.doc_info.selection_only;
|
||||
let path_area = shows_path_area(&app.ui.doc_info);
|
||||
let artboard_tool = if app.session.tool_id() == "artboard" { app.session.tool_options_of("artboard") } else { Value::Null };
|
||||
let st = app.session.active()?;
|
||||
let key = (st.uid, st.revision, selection_only, artboard_tool);
|
||||
let key = (st.uid, st.revision, selection_only, path_area, artboard_tool);
|
||||
if let Some((cached, info)) = cache.as_ref()
|
||||
&& *cached == key
|
||||
{
|
||||
return Some(info.clone());
|
||||
}
|
||||
let info = app.session.execute("document.info", &json!({ "selectionOnly": selection_only })).ok()?;
|
||||
let info = app.session.execute("document.info", &json!({ "selectionOnly": selection_only, "pathArea": path_area })).ok()?;
|
||||
*cache = Some((key, info.clone()));
|
||||
Some(info)
|
||||
}
|
||||
|
||||
/// A frame that fetches nothing keeps the stored `document.info` result without a copy and
|
||||
/// shows the same rows; another document (at the same revision), an edit, Selection Only and
|
||||
/// the Artboard tool's options each store a new one, and a category does not. With no
|
||||
/// the Artboard tool's options each store a new one, and a category that keeps Objects shown or
|
||||
/// hidden does not. With no
|
||||
/// document nothing is fetched and the stored result stays as it was.
|
||||
#[test]
|
||||
fn frames_that_fetch_nothing_reuse_the_cached_rows() {
|
||||
@@ -841,7 +851,7 @@ mod tests {
|
||||
app.select_tool("selection");
|
||||
let (key, away, _) = frame(&mut app);
|
||||
assert!(!Arc::ptr_eq(&kept, &away), "another tool stores a new result");
|
||||
assert_eq!(key.3, Value::Null);
|
||||
assert_eq!(key.4, Value::Null);
|
||||
// With no document the panel shows its empty state and keeps the stored result.
|
||||
app.session.execute("file.close", &json!({})).unwrap();
|
||||
app.session.execute("file.close", &json!({})).unwrap();
|
||||
@@ -850,6 +860,37 @@ mod tests {
|
||||
assert!(text.contains("No document"), "{text}");
|
||||
}
|
||||
|
||||
/// The paths' area pass normalizes every closed path, so while the panel shows a category other
|
||||
/// than Objects its `document.info` leaves the area out, and edits there do not work it out
|
||||
/// again. Objects and All Categories ask for it and share one result.
|
||||
#[test]
|
||||
fn the_path_area_is_worked_out_only_while_objects_is_shown() {
|
||||
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
|
||||
app.session.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
|
||||
app.session.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 10, "height": 20})).unwrap();
|
||||
let shown = |app: &mut VectorcraftApp, category: &str| {
|
||||
run(app, "ui.docInfo.category", &json!({ "category": category })).unwrap().unwrap();
|
||||
let _ = crate::tests_labels::painted_text(app, show);
|
||||
app.canvas.doc_info.clone().unwrap().1
|
||||
};
|
||||
let all = shown(&mut app, "");
|
||||
assert!(all["pathArea"].as_f64().is_some_and(|a| a > 0.0), "{}", all["pathArea"]);
|
||||
assert!(Arc::ptr_eq(&all, &shown(&mut app, "objects")), "Objects reuses All Categories' result");
|
||||
for category in ["document", "fonts"] {
|
||||
let other = shown(&mut app, category);
|
||||
assert!(other["pathArea"].is_null(), "{category}: {}", other["pathArea"]);
|
||||
// An edit while another category is shown fetches again, still without the area.
|
||||
app.session.execute("shape.ellipse", &json!({"x": 40, "y": 40, "width": 20, "height": 20})).unwrap();
|
||||
let edited = shown(&mut app, category);
|
||||
assert!(!Arc::ptr_eq(&other, &edited));
|
||||
assert!(edited["pathArea"].is_null(), "{category}: {}", edited["pathArea"]);
|
||||
}
|
||||
// Back on Objects, the area covers the paths drawn meanwhile.
|
||||
let objects = shown(&mut app, "objects");
|
||||
assert!(objects["pathArea"].as_f64().unwrap() > all["pathArea"].as_f64().unwrap());
|
||||
assert!(shown_rows(&objects, "objects").iter().any(|(l, _)| l == "Path Area"));
|
||||
}
|
||||
|
||||
/// Time a frame's read of Document Info's result for a document with 5,000 objects painted
|
||||
/// with a gradient (a row each): by the by-value read before the result was shared
|
||||
/// ([`copied_info`]) and by [`info`]. Per run each side reads 2,000 times; the two sides
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
## Feature submission evidence
|
||||
|
||||
Document Info › Objects reports total enclosed area (`pathArea` in square points) for eligible closed paths and compound paths according to their fill rule, subtracting holes and excluding guides and open paths, with duplicate nested compound geometry avoided; this is a VectorCraft addition beyond the reference panel. The Document Info panel inserts a formatted `Path Area` row in the document's active units (`Unit::format_area`) right after `Path Length` whenever the total area is positive. The area pass runs only for a request that covers the Objects category: `document.info` with another `category`, or with `pathArea: false`, skips it and gives `pathArea` as null, and the panel asks for the area only while it shows Objects or All Categories, so edits made with another category shown do not work it out again. Focused tests: `cmd::docinfo::tests::info_gives_the_paths_total_area`, `info_path_area_counts_selected_compound_members_once` and `info_works_out_the_path_area_only_for_the_objects_category` (vectorcraft-engine), `panels::doc_info::tests::the_path_area_is_worked_out_only_while_objects_is_shown` (vectorcraft-ui-egui) and `units::tests::format_area_formats_and_trims_cleanly` (vectorcraft-doc). Scores and estimates unchanged.
|
||||
|
||||
Properties panel Quick Actions follow the whole selection (G12). Ungroup (`object.ungroup`) is offered when any selected object is a group, including several groups, a group selected after other objects, and a group that holds another group. Isolate Group (`object.isolate`) is offered only when that group is the whole selection. Unite (`object.pathfinder.unite`) appears only for selections of at least two objects, each a non-guide path or a compound path. It appears alongside Group and Make Clipping Mask. Unite joins those objects in one undo step. Evidence: `panels::properties::tests::two_groups_offer_ungroup_without_isolate_group`, `one_group_offers_ungroup_and_isolate_group` and `several_paths_offer_group_clipping_mask_and_unite` in `crates/ui-egui/src/panels/properties/tests.rs`. Scores and estimates unchanged.
|
||||
|
||||
History panel row context menus (2026-11-20, G12): Right-clicking any state offers New Document from State, Step to This State, and Clear History. Creating a document uses the clicked snapshot without stepping the source document; Step to This State uses undo/redo and is disabled on the current row; Clear History removes undo and redo steps without changing artwork and is disabled when history is empty. Headless tests in `crates/ui-egui/src/panels/history.rs` cover opening an earlier row menu, snapshot creation, backward/forward jumps, and clearing history. The snapshot chosen when the menu opens is retained while it stays open; pending tool edits are settled before resolving that snapshot to its new row; a discarded snapshot reports that it is unavailable instead of acting on a neighboring row. Jumps settle pending typing before counting undo/redo steps. Shift+F10 opens the focused row menu; Escape dismisses it and restores row focus. Switching documents dismisses the menu before it can act on another document. Headless tests cover these keyboard and document-switch paths. The list and menu use shared Craft UI controls. Scores and estimates unchanged.
|
||||
@@ -68,6 +70,7 @@ Artboard Options forwards the active Artboard tool's Scale Artwork with Artboard
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-25 | minor | Document Info › Objects: total enclosed area (`pathArea` in pt²) for closed and compound paths (holes subtracted per fill rule; guides and open paths left out) and formatted Path Area in document units, beyond reference panel (#6965). Worked out only when the request covers Objects (`pathArea` null otherwise or with `pathArea: false`); the panel asks for it only while Objects or All Categories is shown. Tests: `info_gives_the_paths_total_area`, `info_works_out_the_path_area_only_for_the_objects_category`, `the_path_area_is_worked_out_only_while_objects_is_shown`, `format_area_formats_and_trims_cleanly`. Scores and estimates unchanged. |
|
||||
| 2026-11-24 | minor | G12: History row context menus use shared Craft List and Menu controls after rebasing onto the panel migration. App-specific actions retain the chosen snapshot across pending edits and dismiss on document switches; keyboard context requests and focus restoration use the shared runtime. Regression cases retained (#8845); scores and estimates unchanged. |
|
||||
| 2026-11-21 | minor | G12: Document Info › Selection Only (`ui.docInfo.selectionOnly`) counts objects in the selection through `document.info`; with no artwork selected it shows (No artwork selected) and artboards the Artboard tool has selected still show. Headless regressions: `panels::doc_info::tests::test_doc_info_counts_entire_document`, `test_doc_info_selection_only_toggles_and_filters_counts`, `test_doc_info_selection_only_keeps_selected_artboard`, `test_doc_info_panel_menu_toggles_state`. Scores and estimates unchanged. |
|
||||
| 2026-11-21 | minor | G12/M14: History row context menus retain the chosen snapshot while the menu is open and pending edits settle; jumps settle typing before counting undo/redo, and discarded states report that they are unavailable. Shift+F10 opens the focused row menu, Escape restores row focus, and switching documents dismisses the popup. History checklist, area and milestone evidence updated (#8845); scores and estimates unchanged. |
|
||||
|
||||
+4
-1
@@ -10913,7 +10913,10 @@ the same rules as `patternObjects`, with the spot colors it uses; a process
|
||||
color, even one of the same color, and Registration are not spot colors; the spotColors category lists them as Spot
|
||||
Color Objects and `objects.spots` counts them; spot swatches no art uses are not listed; with `selectionOnly`, those
|
||||
in the selection), `spotColorNames` and `spotColors` (the spot colors those objects use) and `pathLength` (pt: the total length of the paths, compound paths' pieces included and guides left
|
||||
out, which objects lists as Path Length in the document's units, say for a cut line or an LED strip along the letters);
|
||||
out, which objects lists as Path Length in the document's units, say for a cut line or an LED strip along the letters),
|
||||
`pathArea` (pt²: the area the closed paths and compound paths enclose under their fill rules, holes subtracted, open
|
||||
paths and guides left out, which objects lists as Path Area in the document's units after Path Length when above 0;
|
||||
null for a request with a category other than `objects` or with `pathArea: false`, which skips that pass);
|
||||
`brushNames`, `brushes`, `spotObjects`, `patternObjects` and `gradientObjects` leave out hidden objects, objects at an
|
||||
opacity of 0 and the objects inside a hidden group or layer or one at an opacity of 0, their characters' paints and
|
||||
colorized images included, and so does `selectionOnly` for an object selected inside such a group or layer, while
|
||||
|
||||
@@ -34,6 +34,8 @@ Native saves on Unix flush the destination directory after writing or replacing
|
||||
|
||||
## Feature submission evidence
|
||||
|
||||
Document Info › Objects reports total enclosed area (`pathArea` in square points) for eligible closed paths and compound paths according to their fill rule, subtracting holes and excluding guides and open paths, with duplicate nested compound geometry avoided. The Document Info panel inserts a formatted `Path Area` row in the document's active units (`Unit::format_area`) right after `Path Length` whenever the total area is positive. The area pass runs only for a request that covers the Objects category: `document.info` with another `category`, or with `pathArea: false`, skips it and gives `pathArea` as null, and the panel asks for the area only while it shows Objects or All Categories, so edits made with another category shown do not work it out again. Focused tests: `cmd::docinfo::tests::info_gives_the_paths_total_area`, `info_path_area_counts_selected_compound_members_once` and `info_works_out_the_path_area_only_for_the_objects_category` (vectorcraft-engine), `panels::doc_info::tests::the_path_area_is_worked_out_only_while_objects_is_shown` (vectorcraft-ui-egui) and `units::tests::format_area_formats_and_trims_cleanly` (vectorcraft-doc). Scores and estimates unchanged.
|
||||
|
||||
When startup scripts precede a chosen script, its source must compile before startup scripts run. Invalid chosen source is rejected before startup scripts execute in synchronous and sliced sessions, and a compilation failure clears the previous script report. The chosen script runs the source read before startup scripts, including when a startup script removes its installed file. Included files are read again when the chosen run starts. Each app queue pump processes at most one startup entry and preserves the remaining order after a failure. `crates/engine/tests/script_startup.rs` covers both modes.
|
||||
|
||||
XMP array insertion with `XMPConst.ARRAY_LAST_ITEM` precedes the last existing item and rejects an empty array. Array insertion and replacement store `null` as an empty item value. `crates/js/src/xmp_tests.rs` covers ordering, empty arrays, and null values.
|
||||
@@ -105,6 +107,7 @@ Artboard Options forwards the active Artboard tool's Scale Artwork with Artboard
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-25 | minor | Document Info › Objects: total enclosed area (`pathArea` in pt²) for closed and compound paths (holes subtracted per fill rule; guides and open paths left out) and formatted Path Area in document units (#6965). Worked out only when the request covers Objects (`pathArea` null otherwise or with `pathArea: false`); the panel asks for it only while Objects or All Categories is shown. Tests: `info_gives_the_paths_total_area`, `info_works_out_the_path_area_only_for_the_objects_category`, `the_path_area_is_worked_out_only_while_objects_is_shown`, `format_area_formats_and_trims_cleanly`. Scores and estimates unchanged. |
|
||||
| 2026-11-24 | minor | G12: History row context menus use shared Craft List and Menu controls after rebasing onto the panel migration. App-specific actions retain the chosen snapshot across pending edits and dismiss on document switches; keyboard context requests and focus restoration use the shared runtime. Regression cases retained (#8845); scores and estimates unchanged. |
|
||||
| 2026-11-21 | minor | G12/M14: History row context menus retain the chosen snapshot while the menu is open and pending edits settle; jumps settle typing before counting undo/redo, and discarded states report that they are unavailable. Shift+F10 opens the focused row menu, Escape restores row focus, and switching documents dismisses the popup. History checklist, area and milestone evidence updated (#8845); scores and estimates unchanged. |
|
||||
| 2026-11-20 | minor | G12: History panel row context menus: New Document from State uses the clicked snapshot; Step to This State runs undo/redo; Clear History clears both stacks. Current-state stepping and empty-history clearing are disabled. Headless tests in `crates/ui-egui/src/panels/history.rs`; scores and estimates unchanged. |
|
||||
@@ -2183,6 +2186,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
In the Brushes panel, Shift-click selects a range of brushes and Ctrl/Cmd-click adds or removes one. Delete Brush and Duplicate Brush then act on all of them (`brush.delete {names}`, `brush.duplicate {names}`).
|
||||
The Brushes panel's Delete Brush button and panel menu item ask "Delete the selected brushes?" with Yes and No when none of the brushes is in use. Alt-click (Option-click on macOS) on the button deletes them without asking, as the [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) page lists for panel deletion outside the Layers panel (archived copy). When a stroke uses one of the brushes, the button, Alt-click and the menu item all ask with Remove Strokes and Cancel; Remove Strokes deletes the brushes and the strokes that used them become plain strokes. Tests: `panels::brushes::tests`, `dialogs::brush_delete::tests`.
|
||||
Document Info has a Brushes category after Graphic Styles. It lists the names and types of the brushes applied to the artwork, as the [Document Info panel](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/document-info-panel.html) page describes, or with Selection Only the brushes that the selected objects' strokes use. The Document Info report and Package's report list them too (`document.info {category: "brushes"}`, `brushNames`, `brushes`). Listing each brush once, leaving out the Brushes panel's brushes no art uses (`panelBrushNames` lists the panel's brushes), hidden strokes, strokes at an opacity of 0, strokes with no paint or width, guides, paths with no segment, type that draws no characters, a group's or layer's own strokes, a compound path member's own strokes and an image's strokes without a shape, and listing a brush the panel does not hold as missing, are VectorCraft's own rules. Tests: `cmd::docinfo::tests::info_lists_the_brushes` and `info_brushes_skip_undrawn_strokes_and_name_missing_brushes` (vectorcraft-engine).
|
||||
Document Info's Objects category calculates the total enclosed area of closed paths and compound paths (`pathArea` in pt²), a VectorCraft addition beyond the reference panel, and displays it as Path Area in the document's active units right after Path Length whenever the total area is positive. With Selection Only it covers the selected paths and compound paths. Open paths, paths with no segments, and guides (standalone or inside compound paths) contribute zero to the area, and compound paths calculate net enclosed area according to their fill rule (Non-Zero or Even-Odd) with inner holes subtracted rather than summing member areas, avoiding double-counting on nested compound paths. The square-point API value is returned in `document.info`'s `pathArea`. The area pass runs only for a request that covers the Objects category: `document.info` with another `category`, or with `pathArea: false`, skips it and gives `pathArea` as null, and the panel asks for the area only while it shows Objects or All Categories, so edits made with another category shown do not work it out again. Tests: `cmd::docinfo::tests::info_gives_the_paths_total_area`, `info_path_area_counts_selected_compound_members_once` and `info_works_out_the_path_area_only_for_the_objects_category` (vectorcraft-engine), `panels::doc_info::tests::the_path_area_is_worked_out_only_while_objects_is_shown` (vectorcraft-ui-egui) and `units::tests::format_area_formats_and_trims_cleanly` (vectorcraft-doc).
|
||||
Document Info's Fonts category gives each font's type and number of uses beside its name, as the [help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/document-info-panel.html) describes, for the whole document or with Selection Only for the selected type. The Document Info report and Package's report give them too (`document.info {category: "fonts"}`, `fontUses`), and the panel shows the type and count in the interface language. Counting a use as a text object set in the font (once however many of its runs use it, and the type in a mask or in a symbol's or pattern's art once however many objects show it), naming the type by the face's outlines (TrueType for `glyf`, OpenType for `CFF` or `CFF2`) and showing an unknown type for a font that is not installed in the family and style the type names are VectorCraft's own rules. Tests: `cmd::docinfo::tests::info_fonts_give_each_font_s_type_and_uses` (vectorcraft-engine), `panels::doc_info::tests::font_types_and_uses_show_in_the_interface_language` (vectorcraft-ui-egui), `fontdb::face::tests::outline_format_follows_the_outline_tables` (vectorcraft-text).
|
||||
Document Info's Linked Images category gives each linked image's format, size in pixels, resolution and file, and its Embedded Images category gives each embedded image's format, size in pixels and memory size, as the [help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/document-info-panel.html) describes, for the whole document or with Selection Only for the selected images. The Document Info report and Package's report give them too (`document.info {category: "linkedImages"}`, `imageObjects`' `format`, `effectivePpi`, `memoryBytes` and `storedBytes`), and the panel shows them in the interface language. Taking the format from a linked file's extension or else from the pixels the document holds, measuring the resolution at the size the image is placed at, counting the memory as the 8-bit RGBA pixels the image is drawn from (width × height × 4), and showing `Unknown format` or `resolution unavailable` when those are not known are VectorCraft's own rules. Tests: `cmd::docinfo::tests::image_rows_give_format_resolution_and_memory` and `byte_sizes_and_resolutions_read_to_a_tenth` (vectorcraft-engine), `panels::doc_info::tests::image_details_show_in_the_interface_language` (vectorcraft-ui-egui).
|
||||
Document Info has a Repeat Objects category after Embedded Images. It lists each radial, grid and mirror Repeat object by name with its kind and the number of instances it makes. For a grid it gives the rows and columns instead, followed by the number of instances it draws when that is fewer. With Selection Only it lists the Repeat objects in the selection. The Document Info report and Package's report list them too (`document.info {category: "repeats"}`, `repeatObjects`).
|
||||
@@ -2641,7 +2645,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
The same 2,000-anchor limit counts each glyph of type as 4 anchors, each point of a gradient mesh as 1 and every 100 pixels of an image as 1, and a symbol instance or a placed document counts the objects and anchors of the art it shows. A placed document whose file has not been read yet, or a symbol nested more than 8 deep (one that holds an instance of itself, for example), gets its first thumbnail on the thumbnail thread, and so does a row whose art takes more than 20,000 steps to count (each object, subpath, text run and symbol looked at is one step). The first frame after the panel opens takes 2.4 ms instead of 19.8 ms with 5,000 glyphs of point type, 1.8 ms instead of 343 ms with one instance of a symbol of a 200,000-anchor path, 2.0 ms instead of 11.0 ms with a 100 × 100 mesh, and 2.1 ms instead of 274 ms with a placed document of a 200,000-anchor path (release build, median of three runs).
|
||||
When the Layers or Links panel shows another document's rows, the thumbnail thread drops the row thumbnails it has not started for the documents not shown, and it drops all of them when the Layers or Links panel is open after the last document closes. Those rows ask for their thumbnails again when their document shows again, and the thumbnails already made are kept. With 150 rows of 20,000-anchor paths waiting for another document, the 8 rows of such paths of the document shown get their thumbnails in 153 ms instead of 3,265 ms (debug test build, median of three runs).
|
||||
The Links panel keeps its `links.list` rows and Link Info in one shared cache, and a frame that fetches nothing new reads that cache without copying the rows. The cache is replaced when the document or its revision changes, the Show, Sort or Show DCS Transparency Interactions option changes, or the files are looked at again every 2 seconds, and, while an image is selected, when Link Info opens or closes or the first selected image changes. With 2,001 images a frame's cache step takes 0.2 µs instead of 1.79 ms, and with 10,001 images 0.2 µs instead of 12.2 ms (test build, median of 7 wall-clock runs of 1,000 frames, measured while other builds were running).
|
||||
The Document Info panel keeps its `document.info` result in one shared cache, and a frame that fetches nothing new reads that cache without copying the rows. The cache is replaced when the document or its revision changes, Selection Only is turned on or off, or, while the Artboard tool is the current tool, its options change; choosing a category filters the stored result.
|
||||
The Document Info panel keeps its `document.info` result in one shared cache, and a frame that fetches nothing new reads that cache without copying the rows. The cache is replaced when the document or its revision changes, Selection Only is turned on or off, the panel switches between a category that shows Objects (Objects or All Categories, which ask for the paths' area) and one that does not, or, while the Artboard tool is the current tool, its options change; otherwise choosing a category filters the stored result.
|
||||
In the web build, while a pan, zoom or rotation changes the view of a document whose last canvas render took more than 8 ms, the canvas draws the last frame moved with the view, and it renders the art again once the view has been still for 0.2 s.
|
||||
In the web build, an edit while that view moves (a tool drag held near an edge of the canvas, which scrolls the view, or a wheel scroll during a drag) draws only the part of the last frame that the edit changed, at the view that frame was rendered for, and the frame stays drawn moved with the view until the view has been still for 0.2 s (#8688). The part of the canvas a pan uncovers shows the pasteboard and the artboards' paper until then, as for a pan without an edit. Edits that go on after the view stops don't start that 0.2 s again: the whole canvas renders 0.2 s after the view stopped. An edit that changes more than half of the frame, or one while more than the view and the document change, renders the whole canvas at once as before. Tests: `canvas::tests::without_a_worker_a_heavy_canvas_is_reprojected_until_the_view_is_still`, `canvas::tests::without_a_worker_edits_while_the_view_is_still_do_not_hold_off_the_render`.
|
||||
An Alt-drag with the Selection, Direct Selection, Group Selection, Rotate, Scale, Reflect or Shear tool copies the selection on its first move, and the moves after it transform those copies; the previews of the Move, Rotate, Scale, Reflect and Shear dialogs with Copy and Preview on copy the selection once in the same way (#1429).
|
||||
|
||||
Reference in new issue
Block a user