diff --git a/Cargo.lock b/Cargo.lock index ec51dec88c..e51d5bde7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9274,6 +9274,8 @@ dependencies = [ name = "vectorcraft-ui-egui" version = "0.25.1" dependencies = [ + "brotli 9.1.3", + "brotli-decompressor 6.3.2", "bytemuck", "chrono", "craft", diff --git a/crates/doc/src/corners.rs b/crates/doc/src/corners.rs index ba12eafabb..56bbb29845 100644 --- a/crates/doc/src/corners.rs +++ b/crates/doc/src/corners.rs @@ -28,12 +28,19 @@ pub fn resolve_stored_radii(base: &PathData, stored: &[f64], relative: bool) -> out } +fn dormant_radius_scale(base: &PathData) -> f64 { + base.length().max(1e-12) +} + /// Turn stored absolute radii into fractions of each corner's maximum, or the other way. +/// Anchors without a cuttable corner use the outline's length (at least 1e-12 document units). +/// Their fractions are not capped at 1. +/// When an anchor edit straightens or bends a corner, [`edit_corner_anchors`] converts its +/// radius between these reference lengths, preserving its document length at that edit. pub fn convert_radii_relative(live: &mut LiveShape, relative: bool) { if live.radii_relative() == relative { return; } - let was_relative = live.radii_relative(); let base = match live { LiveShape::Rectangle { w, h, .. } => shapes::rectangle(Rect::new(0.0, 0.0, *w, *h)), LiveShape::Polygon { .. } | LiveShape::Star { .. } => live.polygon_outline(), @@ -41,22 +48,22 @@ pub fn convert_radii_relative(live: &mut LiveShape, relative: bool) { LiveShape::Ellipse { .. } | LiveShape::Line { .. } => return, }; let corners = path_corners(&base); + let dormant_scale = dormant_radius_scale(&base); let radii: &mut [f64] = match live { LiveShape::Rectangle { radii, .. } => radii, LiveShape::Polygon { radii, .. } | LiveShape::Star { radii, .. } => radii, LiveShape::Path { radii, .. } => radii, LiveShape::Ellipse { .. } | LiveShape::Line { .. } => return, }; - for c in corners { - if let Some(r) = radii.get(c.index) { - let max = c.max_radius(); - radii[c.index] = if relative { - if max > 1e-12 && !was_relative { (*r / max).clamp(0.0, 1.0) } else { *r } - } else if was_relative { - (*r).clamp(0.0, 1.0) * max - } else { - *r - }; + for (index, r) in radii.iter_mut().enumerate() { + let corner = corners.binary_search_by_key(&index, |c| c.index).ok().map(|i| &corners[i]); + let max = corner.map_or(dormant_scale, Corner::max_radius); + if relative { + if max > 0.0 { + *r = if corner.is_some() { (*r / max).clamp(0.0, 1.0) } else { (*r / max).max(0.0) }; + } + } else { + *r = if corner.is_some() { (*r).clamp(0.0, 1.0) } else { (*r).max(0.0) } * max; } } match live { @@ -143,7 +150,8 @@ impl<'a> LiveCorners<'a> { } /// The radius corner `index` is stored at: document lengths, or a fraction in 0..1 when - /// [`LiveCorners::radii_relative`]. + /// [`LiveCorners::radii_relative`]. Dormant anchors use the reference length documented in + /// [`convert_radii_relative`], and their fractions can exceed 1. pub fn radius(&self, index: usize) -> f64 { self.radii.get(index).copied().unwrap_or(0.0) } @@ -206,8 +214,8 @@ impl<'a> LiveCorners<'a> { /// Set `radius` (document units; negative: 0) and/or `kind` on the `corners` (anchor indices of /// the uncut outline, see [`LiveCorners`]) of a path and its live shape, then cut the path again. /// A path that isn't a live shape keeps its uncut outline as a [`LiveShape::Path`], which is a -/// plain path again once no corner is cut. Ellipses and lines have no corners: they stay as they -/// are. +/// plain path again once no radius or nondefault corner kind is stored. A straight anchor keeps +/// its stored radius. Ellipses and lines have no corners: they stay as they are. pub fn set_corners(path: &mut PathData, live: &mut Option>, corners: &BTreeSet, radius: Option, kind: Option) { fn edit( base: &PathData, @@ -286,13 +294,31 @@ pub fn set_corners(path: &mut PathData, live: &mut Option>, corne } } +/// Convert relative `radii` (fractions, one per anchor of the outline) after the outline changed +/// from `before` to `after`: a corner that straightened keeps its document length as a fraction of +/// `after`'s length, and a corner that bent again takes that length back as a fraction of its new +/// maximum. Other radii are left as they are. +pub fn rebase_relative_radii(before: &PathData, after: &PathData, radii: &mut [f64]) { + let (old_corners, new_corners) = (path_corners(before), path_corners(after)); + let (old_dormant_scale, new_dormant_scale) = (dormant_radius_scale(before), dormant_radius_scale(after)); + for (index, r) in radii.iter_mut().enumerate() { + let old = old_corners.binary_search_by_key(&index, |c| c.index).ok().map(|i| &old_corners[i]); + let new = new_corners.binary_search_by_key(&index, |c| c.index).ok().map(|i| &new_corners[i]); + match (old, new) { + (Some(c), None) => *r = (*r).clamp(0.0, 1.0) * c.max_radius() / new_dormant_scale, + (None, Some(c)) => *r = (*r * old_dormant_scale / c.max_radius()).clamp(0.0, 1.0), + _ => {} + } + } +} + /// Edit the anchors of the uncut outline that `anchors` (of the path as drawn) come from, while the /// path keeps its Live Corners: `edit` gets the outline in document space and those of its anchors, /// and the path is cut again with the same radii and kinds. A live rectangle or polygon becomes a /// [`LiveShape::Path`] with that outline. [`LiveCorners::sources`] before and after the edit map /// the anchors as drawn to the corners they come from. /// Returns `None`, leaving the path unchanged, when the path has no live shape or -/// no cut corner, or is a rectangle sheared or scaled unevenly. +/// no corner with a radius, or is a rectangle sheared or scaled unevenly. pub fn edit_corner_anchors( path: &mut PathData, live: &mut Option>, @@ -307,9 +333,11 @@ pub fn edit_corner_anchors( return None; } } - let (mut base, moved, radii, kinds, relative) = { + let (mut base, moved, mut radii, kinds, relative) = { let lc = LiveCorners::new(path, live.as_deref())?; - if !lc.drawn.iter().any(|r| *r > 0.0) { + // The stored radii decide, not the drawn ones: a corner the edit straightened draws no + // arc but keeps its radius, and rounds again when a later edit bends it. + if !lc.radii.iter().any(|r| *r > 0.0) { return None; } let moved: BTreeSet = anchors.iter().filter_map(|(si, ai)| lc.sources.get(*si)?.get(*ai).copied()).collect(); @@ -330,7 +358,11 @@ pub fn edit_corner_anchors( k += 1; } } + let before = relative.then(|| base.clone()); edit(&mut base, &on_base); + if let Some(before) = before { + rebase_relative_radii(&before, &base, &mut radii); + } let l = LiveShape::Path { base, radii, kinds, radii_relative: relative }; *path = l.to_path(); *live = Some(Box::new(l)); @@ -423,6 +455,48 @@ mod tests { assert!(!p.transform(Affine::translate((5.0, 0.0))), "a move needs no new cuts"); } + /// Moving the anchor of the only rounded corner into a straight line and back keeps its + /// stored radius, so the corner is rounded again. + #[test] + fn a_straightened_corner_rounds_again_when_it_bends_back() { + let pen = PathData::single(SubPath::polyline(&[Point::new(0.0, 0.0), Point::new(100.0, 0.0), Point::new(100.0, 80.0)], false)); + let (mut path, mut live) = (pen.clone(), None); + set_corners(&mut path, &mut live, &set(&[1]), Some(10.0), None); + let corner = LiveCorners::new(&path, live.as_deref()).unwrap().anchors_of(&set(&[1])); + let move_corner = |path: &mut PathData, live: &mut Option>, to: Point| { + let sel = LiveCorners::new(path, live.as_deref()).unwrap().anchors_of(&set(&[1])); + let sel = if sel.is_empty() { anchors(&[1]) } else { sel }; + edit_corner_anchors(path, live, &sel, |base, on_base| { + for &(si, ai) in on_base { + if let Some(a) = base.anchor_mut(si, ai) { + (a.p, a.h_in, a.h_out) = (to, to, to); + } + } + }) + }; + assert_eq!(corner.len(), 2, "the corner is cut"); + // Straight: the corner has nothing to cut. + assert!(move_corner(&mut path, &mut live, Point::new(50.0, 40.0)).is_some()); + assert!(matches!(live.as_deref(), Some(LiveShape::Path { radii, .. }) if radii.get(1) == Some(&10.0))); + assert_eq!(LiveCorners::new(&path, live.as_deref()).unwrap().drawn_radius(1), 0.0, "the straight corner draws no arc"); + // Bent again: the stored radius cuts it again. + assert!(move_corner(&mut path, &mut live, Point::new(100.0, 0.0)).is_some(), "the straightened corner stays live"); + let c = LiveCorners::new(&path, live.as_deref()).unwrap(); + assert!((c.drawn_radius(1) - 10.0).abs() < 1e-6, "the corner keeps its radius: {live:?}"); + + for relative in [true, false] { + assert!(move_corner(&mut path, &mut live, Point::new(50.0, 40.0)).is_some()); + assert_eq!(LiveCorners::new(&path, live.as_deref()).unwrap().drawn_radius(1), 0.0); + let l = live.as_deref_mut().unwrap(); + convert_radii_relative(l, relative); + assert_eq!(l.radii_relative(), relative); + path = l.to_path(); + assert!(move_corner(&mut path, &mut live, Point::new(100.0, 0.0)).is_some()); + let c = LiveCorners::new(&path, live.as_deref()).unwrap(); + assert!((c.drawn_radius(1) - 10.0).abs() < 1e-6, "the corner keeps its radius after changing modes: {live:?}"); + } + } + #[test] fn relative_radii_scale_with_rectangle_size() { let l = LiveShape::Rectangle { diff --git a/crates/doc/src/lib.rs b/crates/doc/src/lib.rs index 059a3d4bdc..7bddc2c482 100644 --- a/crates/doc/src/lib.rs +++ b/crates/doc/src/lib.rs @@ -103,7 +103,7 @@ pub use appearance::{ }; pub use assets::ExportAsset; pub use compound_shape::ShapeMode; -pub use corners::{LiveCorners, edit_corner_anchors}; +pub use corners::{LiveCorners, edit_corner_anchors, rebase_relative_radii}; pub use depth::{MAX_DEPTH, MAX_SYMBOL_NODES}; pub use graph::{ ColumnDesign, ColumnType, DEFAULT_FILLED_LINE_WIDTH, FILLED_LINE_OUTLINE_WIDTH, Fractions, GraphDesign, GraphKind, GraphSpec, LabelRows, diff --git a/crates/engine/src/cmd/addons/arrange/artboard_guides.rs b/crates/engine/src/cmd/addons/arrange/artboard_guides.rs index d849047fb9..982b3cd757 100644 --- a/crates/engine/src/cmd/addons/arrange/artboard_guides.rs +++ b/crates/engine/src/cmd/addons/arrange/artboard_guides.rs @@ -117,13 +117,17 @@ fn traces(path: &PathData, corners: &[Point; 4]) -> bool { if (0..n).any(|i| !straight(&sp.anchors[i], &sp.anchors[(i + 1) % n])) { return false; } + // A last anchor on the first one only closes the path: the check above has kept its handles on that + // point, so the corners are read without it. + let m = if sp.anchors[n - 1].p == sp.anchors[0].p { n - 1 } else { n }; let points: Vec = sp .anchors .iter() + .take(m) .enumerate() .filter_map(|(i, a)| { - let prev = sp.anchors[(i + sp.anchors.len() - 1) % sp.anchors.len()].p; - let next = sp.anchors[(i + 1) % sp.anchors.len()].p; + let prev = sp.anchors[(i + m - 1) % m].p; + let next = sp.anchors[(i + 1) % m].p; let interior = (prev.x == a.p.x && a.p.x == next.x && a.p.y > prev.y.min(next.y) && a.p.y < prev.y.max(next.y)) || (prev.y == a.p.y && a.p.y == next.y && a.p.x > prev.x.min(next.x) && a.p.x < prev.x.max(next.x)); (!interior).then_some(a.p) diff --git a/crates/engine/src/cmd/addons/arrange/artboard_guides/tests.rs b/crates/engine/src/cmd/addons/arrange/artboard_guides/tests.rs index 5152dcffe9..492af2a371 100644 --- a/crates/engine/src/cmd/addons/arrange/artboard_guides/tests.rs +++ b/crates/engine/src/cmd/addons/arrange/artboard_guides/tests.rs @@ -198,6 +198,30 @@ fn collinear_midpoints_do_not_add_another_guide_or_history_step() { } } +#[test] +fn a_closing_anchor_on_the_first_one_does_not_add_another_guide_or_history_step() { + let mut s = session(); + let r = s.execute(COMMAND, &json!({})).unwrap(); + let [id] = ids(&r)[..] else { panic!("one guide: {r}") }; + let b = board(&s, 0); + let corners = [Point::new(b.x0, b.y0), Point::new(b.x1, b.y0), Point::new(b.x1, b.y1), Point::new(b.x0, b.y1)]; + for reverse in [false, true] { + let mut points = corners.to_vec(); + if reverse { + points.reverse(); + } + points.push(points[0]); + let d = Arc::make_mut(&mut s.doc_mut().unwrap().doc); + let NodeKind::Path { path, .. } = &mut d.node_mut(id).unwrap().kind else { panic!("guide path") }; + *path = PathData::single(SubPath::polyline(&points, true)); + let (before, n) = (s.doc().unwrap().doc.clone(), steps(&s)); + let again = s.execute(COMMAND, &json!({})).unwrap(); + assert_eq!(again, json!({"ids": [], "layer": r["layer"], "skipped": 1}), "reverse: {reverse}"); + assert_eq!(steps(&s), n); + assert_eq!(s.doc().unwrap().doc, before); + } +} + #[test] fn handles_along_a_side_still_match_and_handles_off_it_do_not() { let mut s = session(); diff --git a/crates/engine/src/cmd/compositefonts.rs b/crates/engine/src/cmd/compositefonts.rs index 54c1db0f41..3b15730f9a 100644 --- a/crates/engine/src/cmd/compositefonts.rs +++ b/crates/engine/src/cmd/compositefonts.rs @@ -99,12 +99,19 @@ fn family_names(d: &Document) -> Result> { note(family); } } - let mut graphs = Vec::new(); + let (mut graphs, mut dimensions) = (Vec::new(), Vec::new()); view.visit_stored(|node, _| { + // A dimension's options name the family its label is redrawn in. + if let Some(dimension) = &node.extras().dimension { + dimensions.push(dimension.options.font_family.clone()); + } if node.extras().graph.is_some() { graphs.push(node.id); } }); + for mut family in dimensions { + note(&mut family); + } for id in graphs { if let Some(node) = view.stored_node_mut(id) { graph_families(node, &mut note); @@ -112,6 +119,9 @@ fn family_names(d: &Document) -> Result> { } fn brush_graphs(node: &mut Node, note: &mut impl FnMut(&mut String)) { graph_families(node, note); + if let Some(dimension) = node.extras_if_any().and_then(|extras| extras.dimension.as_mut()) { + note(&mut dimension.options.font_family); + } if let Some(mask) = node.extras_if_any().and_then(|extras| extras.mask.as_mut()) { brush_graphs(Arc::make_mut(&mut mask.art), note); } @@ -145,9 +155,15 @@ pub(super) fn node_families(node: &mut Node, visit: &mut impl FnMut(&mut String) visit(&mut font.family); } } - // A live dimension makes its label again from its options. - if let Some(dimension) = node.extras_if_any().and_then(|extras| extras.dimension.as_deref_mut()) { - visit(&mut dimension.options.font_family); + // A dimension redraws its label from its own options, so they follow the label's family. + // A spelling that already names the same font, or one too long for the options, is kept. + if let Some(dimension) = node.extras_if_any().and_then(|extras| extras.dimension.as_mut()) { + let family = &mut dimension.options.font_family; + let mut renamed = family.clone(); + visit(&mut renamed); + if !CompositeFont::same_name(&renamed, family) && renamed.len() <= ALIAS_BYTES_MAX { + *family = renamed; + } } graph_families(node, visit); } @@ -170,12 +186,22 @@ impl CompositeImport { } } +/// The longest family name in bytes that a dimension's options keep (`DimensionOptions::validate`). +const ALIAS_BYTES_MAX: usize = 256; + fn composite_alias(base: &str, reserved: &BTreeSet, cmd: &str) -> Result { let db = FontDb::global(); let mut number = 2_u64; loop { let suffix = format!(" {number}"); - let stem: String = base.chars().take(COMPOSITE_NAME_MAX.saturating_sub(suffix.chars().count())).collect(); + let bytes = ALIAS_BYTES_MAX.saturating_sub(suffix.len()); + let mut stem = String::new(); + for c in base.chars().take(COMPOSITE_NAME_MAX.saturating_sub(suffix.chars().count())) { + if stem.len() + c.len_utf8() > bytes { + break; + } + stem.push(c); + } let name = format!("{}{suffix}", stem.trim_end()); if CompositeFont::clean_name(&name).as_deref() == Some(name.as_str()) && !reserved.contains(&name.to_lowercase()) @@ -189,7 +215,13 @@ fn composite_alias(base: &str, reserved: &BTreeSet, cmd: &str) -> Result /// Plan used incoming definitions before changing either document or the font database. /// Keep existing meanings even for an uninstalled family that destination art still names. -pub(super) fn plan_import(source: Vec, source_families: BTreeSet, target: &Document, cmd: &str) -> Result { +pub(super) fn plan_import( + source: Vec, + source_families: BTreeSet, + dimension_families: BTreeSet, + target: &Document, + cmd: &str, +) -> Result { if source.len() > COMPOSITE_FONTS_MAX || target.composite_fonts.len() > COMPOSITE_FONTS_MAX { return Err(bad(cmd, format!("a document keeps at most {COMPOSITE_FONTS_MAX} composite fonts"))); } @@ -230,12 +262,15 @@ pub(super) fn plan_import(source: Vec, source_families: BTreeSet< let mut names = BTreeMap::new(); let mut combined = target.composite_fonts.to_vec(); for font in source { - let equivalent = |other: &&CompositeFont| other.parts == font.parts && other.custom == font.custom; - let mut reused = CompositeFont::named(&target.composite_fonts, &font.name).filter(equivalent); + let dimension = dimension_families.contains(&font.name.to_lowercase()); + let equal = |other: &&CompositeFont| other.parts == font.parts && other.custom == font.custom; + // A dimension keeps its own spelling of a reused name of the same font, so only an alias + // under another name has to fit the bytes its options keep. + let mut reused = CompositeFont::named(&target.composite_fonts, &font.name).filter(equal); let needs_alias = reused.is_none() && (target_taken.contains(&font.name.to_lowercase()) || db.has_installed_family(&font.name)); if needs_alias { // A repeated import reuses its already-installed equal alias. - reused = target.composite_fonts.iter().find(equivalent); + reused = target.composite_fonts.iter().find(|other| equal(other) && (!dimension || other.name.len() <= ALIAS_BYTES_MAX)); } let name = match reused { Some(other) => other.name.clone(), diff --git a/crates/engine/src/cmd/fileio.rs b/crates/engine/src/cmd/fileio.rs index 1a24bf623b..9e67ab1916 100644 --- a/crates/engine/src/cmd/fileio.rs +++ b/crates/engine/src/cmd/fileio.rs @@ -117,8 +117,8 @@ pub use save::{ }; pub(crate) use screens::{ PARAM_KEYS as SCREEN_PARAM_KEYS, ROW_KEYS as SCREEN_ROW_KEYS, UNWRITTEN_FORMATS as SCREEN_UNWRITTEN_FORMATS, - check_settings as check_screen_settings, export as export_screens, safe_file_name, store_settings as store_screen_settings, - with_export_preset as with_screen_export_preset, + check_settings as check_screen_settings, export as export_screens, safe_file_name, sharing_names as sharing_screen_names, + store_settings as store_screen_settings, with_export_preset as with_screen_export_preset, }; pub use screens::{ PRESET_FILE_EXTS as SCREEN_EXPORT_PRESET_EXTS, PRESET_FILE_FORMAT as SCREEN_EXPORT_PRESET_FORMAT, PRESET_KEYS as SCREEN_EXPORT_PRESET_KEYS, @@ -184,7 +184,7 @@ pub use formats::{ DOC_EXTS, DOCX_EXTS, FORMATS, Format, FormatOption, OPEN_EXTS, PLACE_EXTS, RTF_EXTS, TEXT_EXTS, UNASSOCIATED_EXTS, builtin_open_filters, export_extensions, extension, file_stem, format, format_for_name, has_own_title, importer_formats, library_open_filters, open_extensions, open_filters, opens_as_other, opens_with_importer, place_dialog_filters, place_filters, places_with_importer, plugin_formats, read_extensions, - readable_format, readable_format_for_name, titled_for_export, writable_format, + readable_format, readable_format_for_name, reads_as_dwg, titled_for_export, writable_format, }; #[cfg(test)] diff --git a/crates/engine/src/cmd/fileio/batch.rs b/crates/engine/src/cmd/fileio/batch.rs index dcb26b94b5..821c74acb0 100644 --- a/crates/engine/src/cmd/fileio/batch.rs +++ b/crates/engine/src/cmd/fileio/batch.rs @@ -28,6 +28,7 @@ pub(super) fn batch(s: &mut Session, p: &Value) -> Result { // file, format and saved state share their data with the open ones until a step changes them. let start = s.docs.clone(); let active = s.active; + let style_trail = s.script_in_run.then(|| s.script_style_trail.clone()); // A rollback puts back the swatch renames recorded before the batch, including any its steps pushed out of the record. let swatch_renames = s.swatch_renames.clone(); let opens = s.plugin_events_mark(); @@ -46,6 +47,10 @@ pub(super) fn batch(s: &mut Session, p: &Value) -> Result { Err(e) => { s.swatch_renames = swatch_renames; roll_back(s, start, &stash); + if let Some(mut trail) = style_trail { + trail.resources_scanned = s.script_style_trail.resources_scanned; + s.script_style_trail = trail; + } // The documents the steps opened are closed again: plug-ins are not told of them. s.forget_plugin_opens_since(opens); s.notify_text_tool("batch.rollBack"); diff --git a/crates/engine/src/cmd/fileio/commands.rs b/crates/engine/src/cmd/fileio/commands.rs index c35ad702f4..0d7cfd03c7 100644 --- a/crates/engine/src/cmd/fileio/commands.rs +++ b/crates/engine/src/cmd/fileio/commands.rs @@ -36,7 +36,7 @@ pub fn specs() -> Vec { "Export Document", [], None, - "{path?, format?: svg|svgz|pdf|ai|png|jpg|webp|gif|png8|txt|dxf|eps|emf|wmf|hpgl|tiff|bmp|tga|psd|cmx|vectorcraft|template (default: from the path's extension, else png; png8 writes an indexed .png; ait, a .ait template, is written by file.saveAsTemplate; an exporter plug-in's format is plugin., which an extension only it lists picks too), params?: {…} (an exporter plug-in's parameters; missing ones take their defaults, see plugin.info), selectedOnly?: false (the selected objects alone, in the layers and groups that hold them; an object of a blend, envelope, repeat or intertwine on its own), includeArtboardFill?: true (raster, PDF, SVG and EPS draw each exported artboard's background color behind its art, a transparent background too; false leaves it out), artboard?: 0, artboards?: [i…], rect?: [x, y, width, height] (raster formats: that area of the page in points, y down, instead of an artboard; not with artboard, artboards, range or useArtboards), range?: \"1-3, 5\" | \"all\" (1-based; PDF and .ai write one page per artboard, default all; SVG writes one file per artboard, {stem}-{artboard}.svg; raster formats write one artboard), useArtboards?: true (raster: one file per chosen artboard, default all, {stem}-{artboard}.{ext}; pdf/ai: every page) | false (pdf/ai/raster: the bounds of the visible art; pdf/ai: of the layers the file draws, without editing data, with a warning, and ai refuses pdfCompatible: false; SVG has it as an SVG option), ppi?: number (raster formats: pixels per inch, stored in the file; wins over scale; without either, the document's raster effects resolution), scale?: number (pixels per point), background?: transparent|white|black|\"#rrggbb\" (jpg: white when transparent; #rrggbbaa and #rgba are refused here and in matte), antiAlias?: none|art (default)|type (text snapped to pixels), interlaced?: false (png, Adam7), embedIcc?: true (png: an sRGB chunk marks the colours as sRGB), quality?: 90 (jpg: 0–100), colorModel?: rgb|cmyk|gray (jpg), method?: baseline|optimized|progressive, scans?: 3 (3–5, progressive), embedIcc?: true, imageMap?: none|client|server (an HTML or NCSA map of the objects with a URL, written as .html / .map), colors?: 256 (gif/png8: 2–256), reduction?: perceptual|selective (default)|adaptive|web|blackWhite|gray, dither?: none|diffusion (default)|pattern|noise, ditherAmount?: 100, transparency?: true, transparencyDither?: none (default: pixels under half opacity become transparent)|diffusion|pattern|noise (with transparency: as document.exportForWeb), transparencyDitherAmount?: 100 (0–100: the diffusion transparency dither's strength), matte?: white|\"#rrggbb\"|none, interlaced?, lossless?: true (webp: every pixel kept exactly; false writes lossy WebP, a smaller file that loses some detail), quality?: 90 (webp with lossless: false: 0–100, higher keeps more detail in a larger file; more than 100 is refused), encoding?: utf8|utf16 (txt: the stories in stacking order, back to front, a thread once; utf16 with a byte order mark), lineEndings?: lf|crlf, selectionOnly?: false, svg?: {styling, outlineText, images, objectIds, decimals, minify, responsive, units, useArtboards, preserveEditing, metadata, fewerTspans, hiddenLayers, encoding, profile, embedFonts, variableData} (see document.formats), …the SVG options given flat instead, …the PDF options of document.exportPdf, …the DXF options of document.exportDxf (useArtboards: one drawing per artboard), …the EPS options of document.exportEps (useArtboards: one file per artboard, {stem}_{artboard}.eps, after a central {stem}.eps of the whole document when there are two or more and art shows; else the visible art), …emf and wmf write one picture of the artboard (useArtboards: true one file per chosen artboard, false the bounds of the visible art; EMF keeps curves, clipping, transparent images and gradients as images clipped to their shape; WMF flattens curves into polygons behind a placeable header; what a format leaves out comes back in warnings), …hpgl writes a plot of the artboard as pen moves for plotters and cutters (each visible path once along its line in plotter units; useArtboards: true one file per chosen artboard, false the bounds of the art it plots, without placed images, unpainted paths and art at 0% opacity), hpglVersion?: hpgl (default: IN, SP, PU, PD) | hpgl2 (also NP and PC pen colors, each pen's paths as one encoded polyline PE), curveTolerance?: 0.1 (points, 0.01 to 10), pens?: [\"#rrggbb\"…] (pen 1 first, up to 255; each path takes the nearest; default a pen per color in the order the art first draws in it, numbered alike in every file), origin?: bottomLeft (default) | center, sortPaths?: false (each pen's next path the nearest), insideFirst?: false (a path after the pen's paths that lie inside it), …cmx writes one file with a page for the artboard (useArtboards: true a page for each chosen artboard, false the bounds of the visible art; a layer for each layer with art on the page, holding the art's fills and strokes as curves in their colors: CMYK, RGB, gray, spot colors at their tints, Registration; type as outlines, gradients and patterns as one color, nonzero fills as even-odd, dashes in whole stroke widths, no miter limit, art across a page's edge written whole, without images, clipping masks or transparency; warnings name each of these losses), colorModel?: rgb|cmyk|gray (tiff: rgb keeps transparency as an alpha channel), lzw?: true, byteOrder?: little|big, embedIcc?: true, colorModel?: rgb|gray (bmp), depth?: 24 (bmp: 1 black and white, 4|8 a palette by reduction and dither, 16, 24, 32 with alpha), fileFormat?: windows|os2 (1, 4, 8 or 24 bits), rle?: false (4 and 8 bits, windows), flipRows?: false (top-down rows), depth?: 24 (tga: 16 one-bit alpha, 24, 32 with alpha), colorModel?: rgb|cmyk|gray (psd), layers?: true (each top-level layer a pixel layer with its opacity and blend mode; a background colour is a Background layer; false: one flat image, on white), preserveText?: false (with layers: horizontal and vertical point type in solid colors, with left-to-right paragraphs that set only their alignment, without strokes, effects or an appearance of its own, becomes editable type layers with their pixels; a layer holding it becomes a group, unless other art in it blends in a mode other than normal; refused with layers: false), maxEditability?: false (layers and sublayers become groups, each object a layer named as in the Layers panel, text by its text; clipping, masked or knockout layers stay one layer), hiddenLayers?: false (hidden layers and objects written hidden instead of left out), embedIcc?: true (at most 30000 pixels a side; formats without alpha are flattened on white)} → {path, format, bytes, warnings, files?: [path…] (several), linked?: [path…] (linked images, image maps)}; no path → {dataBase64, format, bytes, warnings, files?: [{name, dataBase64}], linked?: [{name, dataBase64}]}. A key no format takes, and an unknown key inside a PDF or EPS option's object, are refused; a key only another format takes is not used, and warnings name it. Under automation read roots, svg and svgz, and the files that carry the native document (vectorcraft, template, eps, ai of every artboard with useArtboards not false but a version 7 file, pdf of every artboard with preserveEditing on and useArtboards not false), are refused, before any file is written, while the document links a JavaScript file outside them (svgInteractivity; a URL is not checked), or while the file would name a linked image's file outside them (images: link, preserveEditing, or an image whose pixels the document doesn't hold; a URL is not checked). Never changes the document's path", + "{path?, format?: svg|svgz|pdf|ai|png|jpg|webp|gif|png8|txt|dxf|eps|emf|wmf|hpgl|tiff|bmp|tga|psd|cmx|vectorcraft|template (default: from the path's extension, else png; png8 writes an indexed .png; ait, a .ait template, is written by file.saveAsTemplate; an exporter plug-in's format is plugin., which an extension only it lists picks too), params?: {…} (an exporter plug-in's parameters; missing ones take their defaults, see plugin.info), selectedOnly?: false (the selected objects alone, in the layers and groups that hold them; an object of a blend, envelope, repeat or intertwine on its own), includeArtboardFill?: true (raster, PDF, SVG and EPS draw each exported artboard's background color behind its art, a transparent background too; false leaves it out), artboard?: 0, artboards?: [i…], rect?: [x, y, width, height] (raster formats: that area of the page in points, y down, instead of an artboard; not with artboard, artboards, range or useArtboards), range?: \"1-3, 5\" | \"all\" (1-based; PDF and .ai write one page per artboard, default all; SVG writes one file per artboard, {stem}-{artboard}.svg; raster formats write one artboard), useArtboards?: true (raster: one file per chosen artboard, default all, {stem}-{artboard}.{ext}; pdf/ai: every page) | false (pdf/ai/raster: the bounds of the visible art; pdf/ai: of the layers the file draws, without editing data, with a warning, and ai refuses pdfCompatible: false; SVG has it as an SVG option), ppi?: number (raster formats: pixels per inch, stored in the file; wins over scale; without either, the document's raster effects resolution), scale?: number (pixels per point), background?: transparent|white|black|\"#rrggbb\" (jpg: white when transparent; #rrggbbaa and #rgba are refused here and in matte), antiAlias?: none|art (default)|type (text snapped to pixels), interlaced?: false (png, Adam7), embedIcc?: true (png: an sRGB chunk marks the colours as sRGB), quality?: 90 (jpg: 0–100), colorModel?: rgb|cmyk|gray (jpg), method?: baseline|optimized|progressive, scans?: 3 (3–5, progressive), embedIcc?: true, imageMap?: none|client|server (an HTML or NCSA map of the objects with a URL, written as .html / .map), colors?: 256 (gif/png8: 2–256), reduction?: perceptual|selective (default)|adaptive|web|blackWhite|gray, dither?: none|diffusion (default)|pattern|noise, ditherAmount?: 100, transparency?: true, transparencyDither?: none (default: pixels under half opacity become transparent)|diffusion|pattern|noise (with transparency: as document.exportForWeb), transparencyDitherAmount?: 100 (0–100: the diffusion transparency dither's strength), matte?: white|\"#rrggbb\"|none, interlaced?, lossless?: true (webp: every pixel kept exactly; false writes lossy WebP, a smaller file that loses some detail), quality?: 90 (webp with lossless: false: 0–100, higher keeps more detail in a larger file; more than 100 is refused), embedIcc?: true (webp: the sRGB profile in an ICCP chunk), encoding?: utf8|utf16 (txt: the stories in stacking order, back to front, a thread once; utf16 with a byte order mark), lineEndings?: lf|crlf, selectionOnly?: false, svg?: {styling, outlineText, images, objectIds, decimals, minify, responsive, units, useArtboards, preserveEditing, metadata, fewerTspans, hiddenLayers, encoding, profile, embedFonts, variableData} (see document.formats), …the SVG options given flat instead, …the PDF options of document.exportPdf, …the DXF options of document.exportDxf (useArtboards: one drawing per artboard), …the EPS options of document.exportEps (useArtboards: one file per artboard, {stem}_{artboard}.eps, after a central {stem}.eps of the whole document when there are two or more and art shows; else the visible art), …emf and wmf write one picture of the artboard (useArtboards: true one file per chosen artboard, false the bounds of the visible art; EMF keeps curves, clipping, transparent images and gradients as images clipped to their shape; WMF flattens curves into polygons behind a placeable header; what a format leaves out comes back in warnings), …hpgl writes a plot of the artboard as pen moves for plotters and cutters (each visible path once along its line in plotter units; useArtboards: true one file per chosen artboard, false the bounds of the art it plots, without placed images, unpainted paths and art at 0% opacity), hpglVersion?: hpgl (default: IN, SP, PU, PD) | hpgl2 (also NP and PC pen colors, each pen's paths as one encoded polyline PE), curveTolerance?: 0.1 (points, 0.01 to 10), pens?: [\"#rrggbb\"…] (pen 1 first, up to 255; each path takes the nearest; default a pen per color in the order the art first draws in it, numbered alike in every file), origin?: bottomLeft (default) | center, sortPaths?: false (each pen's next path the nearest), insideFirst?: false (a path after the pen's paths that lie inside it), …cmx writes one file with a page for the artboard (useArtboards: true a page for each chosen artboard, false the bounds of the visible art; a layer for each layer with art on the page, holding the art's fills and strokes as curves in their colors: CMYK, RGB, gray, spot colors at their tints, Registration; type as outlines, gradients and patterns as one color, nonzero fills as even-odd, dashes in whole stroke widths, no miter limit, art across a page's edge written whole, without images, clipping masks or transparency; warnings name each of these losses), colorModel?: rgb|cmyk|gray (tiff: rgb keeps transparency as an alpha channel), lzw?: true, byteOrder?: little|big, embedIcc?: true, colorModel?: rgb|gray (bmp), depth?: 24 (bmp: 1 black and white, 4|8 a palette by reduction and dither, 16, 24, 32 with alpha), fileFormat?: windows|os2 (1, 4, 8 or 24 bits), rle?: false (4 and 8 bits, windows), flipRows?: false (top-down rows), depth?: 24 (tga: 16 one-bit alpha, 24, 32 with alpha), colorModel?: rgb|cmyk|gray (psd), layers?: true (each top-level layer a pixel layer with its opacity and blend mode; a background colour is a Background layer; false: one flat image, on white), preserveText?: false (with layers: horizontal and vertical point type in solid colors, with left-to-right paragraphs that set only their alignment, without strokes, effects or an appearance of its own, becomes editable type layers with their pixels; a layer holding it becomes a group, unless other art in it blends in a mode other than normal; refused with layers: false), maxEditability?: false (layers and sublayers become groups, each object a layer named as in the Layers panel, text by its text; clipping, masked or knockout layers stay one layer), hiddenLayers?: false (hidden layers and objects written hidden instead of left out), embedIcc?: true (at most 30000 pixels a side; formats without alpha are flattened on white)} → {path, format, bytes, warnings, files?: [path…] (several), linked?: [path…] (linked images, image maps)}; no path → {dataBase64, format, bytes, warnings, files?: [{name, dataBase64}], linked?: [{name, dataBase64}]}. A key no format takes, and an unknown key inside a PDF or EPS option's object, are refused; a key only another format takes is not used, and warnings name it. Under automation read roots, svg and svgz, and the files that carry the native document (vectorcraft, template, eps, ai of every artboard with useArtboards not false but a version 7 file, pdf of every artboard with preserveEditing on and useArtboards not false), are refused, before any file is written, while the document links a JavaScript file outside them (svgInteractivity; a URL is not checked), or while the file would name a linked image's file outside them (images: link, preserveEditing, or an image whose pixels the document doesn't hold; a URL is not checked). Never changes the document's path", has_doc, export::export ), @@ -54,7 +54,7 @@ pub fn specs() -> Vec { "Export for Screens", ["File", "Export"], None, - "{folder?, zip?: false (one .zip of every file, each deflated or stored, whichever is smaller: no folder → {name, dataBase64, bytes, files: [name…]}; with a folder it is written there → {path, bytes, files}), artboard?: index | artboards?: [index…] | range?: \"1-3\" (default all), assets?: [asset id…] (instead of artboards: each asset's art alone, cropped to its bounds and named after the asset; see assets.list), layers?: [layer id…] (instead of artboards: each layer's art alone, sublayers included, named after the layer), selection?: one|each (instead of artboards: the selected art as one file, or a file per selected object, named after it), fullDocument?: false (one file per format instead: a PDF of every artboard, other formats the bounds of all visible art, named after the document), includeBleed?: false (artboards grown by the document's bleed; a PDF page keeps the artboard as its TrimBox and puts its row's bleed around it once, the document's bleed when the row sets none and its preset gives none or 0; a native, .ai or EPS file of an artboard holds the grown artboard with a bleed of 0), includeArtboardFill?: true (Include Artboard Fill: each artboard's background color behind its art; false leaves it out), pdfs?: multiple|single (Export PDFs As: with several artboards, single writes them as the pages of one PDF per PDF row, named after the document; refused with assets, layers or selection: each), exportPreset?: (a preset of document.exportPresets.list: its settings, under these params), subfolders?: false (each row's files in a sub-folder: its folder, else its size for raster (1x, 2x, 100w…) or its format (SVG, PDF)), folders?: none|rows (as subfolders)|format (a folder per extension: png, svg, pdf…)|item (a folder per artboard, asset, layer or object)|itemFormat (item/extension) (default: rows with subfolders or a preset, else none), name?: (a file name pattern instead of the item's name, with for the document, for the artboard, asset, layer or object, from 1, #### for the counter zero-padded to the run of #, , , (else the row's suffix ends the name), YYYYMMDD, YYYY-MM-DD, YYYY, ,