diff --git a/crates/color/src/palette_io.rs b/crates/color/src/palette_io.rs index 996c963c11..9be00b4b21 100644 --- a/crates/color/src/palette_io.rs +++ b/crates/color/src/palette_io.rs @@ -192,14 +192,23 @@ fn write_css(lib: &SwatchLibrary, keep: impl Fn(&&Swatch) -> bool) -> String { // A mirrored conic turns counterclockwise, and CSS only turns clockwise: its stops // are written mirrored about the seam instead. let mirrored = g.gradient.kind == GradientKind::Conic && g.geom.is_some_and(|geom| geom.is_mirrored()); - let stop = |s: &crate::GradientStop| { - let at = if mirrored { 1.0 - s.offset } else { s.offset }; - format!("{} {}%", css_color(&s.color, s.opacity), at * 100.0) + let stop = |&(t, c, o): &(f32, Color, f32)| { + let at = if mirrored { 1.0 - t } else { t }; + format!("{} {}%", css_color(&c, o), at * 100.0) }; - // Stops that repeat or reflect run that many times across the box. + // Stops that repeat or reflect run that many times across the box. CSS mixes + // hex colors evenly in sRGB between two stops + // (https://www.w3.org/TR/css-color-4/#interpolation-space), so an off-center + // midpoint and the curve of a Perceptual or hue gradient are written as stops + // of their own, each with its color and opacity. A gradient that would need + // more than `MAX_SPREAD_STOPS` stops that way is written with its own stops. let unrolled = g.gradient.unrolled(); - let stops: Vec = - if mirrored { unrolled.stops.iter().rev().map(stop).collect() } else { unrolled.stops.iter().map(stop).collect() }; + let expanded: Vec<(f32, Color, f32)> = if unrolled.expanded().nth(crate::gradient::MAX_SPREAD_STOPS).is_none() { + unrolled.expanded_stops() + } else { + unrolled.stops.iter().map(|s| (s.offset, s.color, s.opacity)).collect() + }; + let stops: Vec = if mirrored { expanded.iter().rev().map(stop).collect() } else { expanded.iter().map(stop).collect() }; match g.gradient.kind { GradientKind::Radial => format!("radial-gradient(circle, {})", stops.join(", ")), // CSS sweeps clockwise from straight up; the angle is counted counterclockwise diff --git a/crates/color/src/palette_io/tests.rs b/crates/color/src/palette_io/tests.rs index f3de69baf9..bbbae16a53 100644 --- a/crates/color/src/palette_io/tests.rs +++ b/crates/color/src/palette_io/tests.rs @@ -284,6 +284,99 @@ fn css_writes_spread_gradient_swatches_with_their_stops_repeated() { } } +/// The color and opacity a written CSS gradient value has at `p` (0..1 along its stops), by the +/// CSS rule (https://www.w3.org/TR/css-images-3/#coloring-gradient-line): between two stops the +/// color mixes evenly with premultiplied alpha, in sRGB for hex colors +/// (https://www.w3.org/TR/css-color-4/#interpolation-space); before the first stop and after the +/// last the end colors hold. +fn css_gradient_at(value: &str, p: f64) -> ([f64; 3], f64) { + let list = value.split_once(", ").map_or("", |(_, rest)| rest).trim_end_matches(')'); + let stops: Vec<([f64; 3], f64, f64)> = list + .split(", ") + .map(|stop| { + let (hex, at) = stop.split_once(' ').unwrap_or_else(|| panic!("stop {stop:?}")); + let byte = |i: usize| hex.get(1 + 2 * i..3 + 2 * i).map_or(255.0, |h| f64::from(u8::from_str_radix(h, 16).unwrap())); + let at: f64 = at.trim_end_matches('%').parse().unwrap(); + ([byte(0), byte(1), byte(2)].map(|v| v / 255.0), byte(3) / 255.0, at / 100.0) + }) + .collect(); + let p = p.clamp(stops[0].2, stops[stops.len() - 1].2); + let i = stops.windows(2).position(|w| p <= w[1].2).unwrap_or(0); + let ((c0, a0, p0), (c1, a1, p1)) = (stops[i], stops[i + 1]); + let w = if p1 > p0 { (p - p0) / (p1 - p0) } else { 1.0 }; + let a = a0 + (a1 - a0) * w; + let c = std::array::from_fn(|k| if a > 0.0 { (c0[k] * a0 + (c1[k] * a1 - c0[k] * a0) * w) / a } else { 0.0 }); + (c, a) +} + +/// A gradient swatch's CSS draws, by the CSS rule, the colors and opacity the swatch has: an +/// off-center midpoint and the curve of a Perceptual or hue gradient are written as stops of their +/// own, also on a reflected and a mirrored conic swatch. +#[test] +fn css_gradient_swatches_draw_their_midpoints_and_curves() { + let check = |label: &str, gp: GradientPaint, at: &dyn Fn(f64) -> f64| { + let lib = SwatchLibrary { + name: "x".into(), + swatches: vec![Swatch { name: "x".into(), paint: Paint::Gradient(Box::new(gp.clone())), global: false, spot: false }], + groups: vec![], + }; + let text = written(&lib, PaletteFormat::Css); + let value = text.lines().find_map(|l| l.trim().strip_prefix("--x: ")).unwrap_or_else(|| panic!("{text}")).trim_end_matches(';'); + for i in 0..64 { + let p = (f64::from(i) + 0.5) / 64.0; + let (css, css_alpha) = css_gradient_at(value, p); + let (color, opacity) = gp.gradient.sample(at(p) as f32); + let want = color.to_rgb(); + let off = (0..3).map(|k| (css[k] - f64::from(want[k])).abs()).fold((css_alpha - f64::from(opacity)).abs(), f64::max); + assert!(off < 2.0 / 255.0, "{label} at {p}: {css:?} {css_alpha} vs {want:?} {opacity}: {value}"); + } + }; + let ramp = |method| Gradient { + method, + ..Gradient::new( + GradientKind::Linear, + vec![GradientStop { midpoint: 0.25, ..GradientStop::new(0.0, Color::rgb8(255, 0, 0)) }, GradientStop::new(1.0, Color::rgb8(0, 0, 255))], + ) + }; + for method in crate::GradientMethod::ALL { + check(&format!("{method:?}"), GradientPaint::new(ramp(method)), &|p| p); + } + // Opacity through an off-center midpoint, on one color so premultiplying does not change it. + let fade = Gradient::new( + GradientKind::Linear, + vec![ + GradientStop { midpoint: 0.25, ..GradientStop::new(0.0, Color::BLACK) }, + GradientStop { opacity: 0.0, ..GradientStop::new(1.0, Color::BLACK) }, + ], + ); + check("fade", GradientPaint::new(fade), &|p| p); + let reflected = Gradient { spread: crate::GradientSpread::Reflect, repeats: 2, ..ramp(crate::GradientMethod::Classic) }; + let spread = reflected.spreader(); + check("reflect", GradientPaint::new(reflected), &spread); + let mut conic = GradientPaint::new(Gradient { kind: GradientKind::Conic, ..ramp(crate::GradientMethod::HueClockwise) }); + conic.geom = Some(crate::GradientGeom { start: kurbo::Point::ZERO, end: kurbo::Point::new(0.0, -10.0), aspect: -1.0, focal: None }); + check("mirrored conic", conic, &|p| 1.0 - p); +} + +/// A gradient swatch whose curve would need more than `MAX_SPREAD_STOPS` stops is written with its +/// own stops. +#[test] +fn css_gradient_swatches_keep_their_stop_count_bounded() { + let n = 4000; + let stops = (0..n) + .map(|i| GradientStop::new(i as f32 / (n - 1) as f32, if i % 2 == 0 { Color::rgb8(255, 0, 0) } else { Color::rgb8(0, 255, 255) })) + .collect(); + let g = Gradient { method: crate::GradientMethod::HueClockwise, ..Gradient::new(GradientKind::Linear, stops) }; + assert!(g.expanded().nth(crate::gradient::MAX_SPREAD_STOPS).is_some(), "the curve needs more stops than allowed"); + let lib = SwatchLibrary { + name: "x".into(), + swatches: vec![Swatch { name: "x".into(), paint: Paint::Gradient(Box::new(GradientPaint::new(g))), global: false, spot: false }], + groups: vec![], + }; + let text = written(&lib, PaletteFormat::Css); + assert_eq!(text.matches('%').count(), n, "one stop for each of the gradient's own"); +} + #[test] fn holds_counts_the_swatches_each_format_writes() { // `sample()` holds the spot color Ink, the linear gradient Fade, the pattern Tiles and two solid colors in a group. diff --git a/crates/effects/src/preview.rs b/crates/effects/src/preview.rs index ad36ab56dc..8d330a606b 100644 --- a/crates/effects/src/preview.rs +++ b/crates/effects/src/preview.rs @@ -1,4 +1,4 @@ -//! Use Preview Bounds: objects measured as they are drawn, with their geometry effects. +//! Use Preview Bounds: objects measured as they are drawn, with geometry and projected 3D effects. //! //! [`drawn_art`] gives an object whose geometry effects change what it draws as plain art. A path //! or compound path is given as its effected geometry, and a fill or stroke with geometry effects @@ -11,12 +11,15 @@ //! ([`expanded_live_group`]), with each of those objects given as its own art. A clip group or //! layer whose clipping path has strokes with geometry effects is given as that path's geometry //! before its effects, which the renderer clips by, and those strokes as drawn. Fills and -//! strokes that paint nothing (hidden, or painted None) are left out. [`bounds_of`], +//! strokes that paint nothing (hidden, or painted None) are left out. Extrude & Bevel, Revolve, +//! Inflate and Rotate are measured by the same projected vector art the renderer draws, with +//! any geometry effects after projection applied to that art; [`drawn_art`], which clicks and +//! marquees use, leaves 3D effects unprojected. [`bounds_of`], //! [`oriented_bounds`] and [`anchor_bounds`] measure the visual bounds of that art, strokes //! included, where [`Document::bounds_of`], [`Document::oriented_bounds`] and //! [`Selection::anchor_bounds`] measure the objects themselves. Raster effects (shadows, glows, //! blurs) are not measured. In one object, the art of at most 4,096 symbol instances is measured -//! with its geometry effects, and the other instances in it are measured without them. +//! with its geometry and 3D effects, and the other instances in it are measured without them. //! [`bounds_of_with`], [`oriented_bounds_with`] and [`anchor_bounds_with`] measure as these do and, //! with [`Measure::glyphs`], take point type by the ink of its glyphs (Measure Type by Glyph Bounds). @@ -31,12 +34,12 @@ use vectorcraft_geom::{Affine, PathData, Rect, Shape, union_opt}; use crate::group::has_own_paint; use crate::reshape::{geometry_effects, leaf_geometry}; use crate::{ - GeomContext, apply_geometry_with, evaluate_container, expanded_live_group, has_geometry, has_item_geometry, has_pathfinder, has_transform_art, - needs_outline, outline_art, paints, reshape, + GeomContext, apply_geometry_with, evaluate_container, expanded_live_group, has_geometry, has_item_geometry, has_pathfinder, has_revolve, + has_solid, has_transform_art, needs_outline, outline_art, paints, reshape, revolve_art_in, solid_art_in, }; -/// Most symbol instances in one object whose art [`Drawn`] measures with its geometry effects: -/// past it, the other instances in the object are measured without geometry effects. +/// Most symbol instances in one object whose art [`Drawn`] measures with geometry or 3D effects: +/// past it, the other instances in the object are measured without those effects. const MAX_INSTANCES: usize = 4096; /// The bounds of `ids`: with `preview`, their visual bounds as drawn ([`visual_bounds`]), else @@ -191,8 +194,8 @@ pub fn laid_out_ink(layout: &vectorcraft_text::TextLayout, t: &vectorcraft_doc:: .fold(layout.ink_bounds(), |acc, (_, bar)| union_opt(acc, Some(bar.bounding_box()))) } -/// The visual bounds of `n` as drawn: those of its [`drawn_art`], else -/// [`Node::visual_bounds_with`]. +/// The visual bounds of `n` as drawn: those of its [`drawn_art`] with its 3D effects projected, +/// else [`Node::visual_bounds_with`]. pub fn visual_bounds(symbols: &SymbolBoxes, n: &Node) -> Option { Drawn::new(symbols).visual_bounds(n) } @@ -204,31 +207,45 @@ pub fn bounds_in(symbols: &SymbolBoxes, n: &Node, a: Affine) -> Option { } /// `n` as plain art with the geometry effects in it applied, at every depth, symbol instances -/// measured by `symbols`. Raster effects stay on the art. A group, layer or intertwine without a -/// clip is rebuilt with the drawn art of each member that has one. A clip group or layer becomes a -/// group of its clipping path without strokes and the drawn art of the path's strokes, when they -/// have one. `None` when no geometry effect in `n` changes what it draws. +/// measured by `symbols`, for clicks and marquees. Raster effects stay on the art. A group, layer or +/// intertwine without a clip is rebuilt with the drawn art of each member that has one. A clip group +/// or layer becomes a group of its clipping path without strokes and the drawn art of the path's +/// strokes, when they have one. 3D effects stay on the art unprojected, so each object in it keeps +/// its own id. `None` when no geometry effect in `n` changes what it draws. pub fn drawn_art(symbols: &SymbolBoxes, n: &Node) -> Option { - Drawn::new(symbols).drawn_art(n) + Drawn::without_3d(symbols).drawn_art(n) } -/// Whether [`drawn_art`] gives `n` art of its own, or would give one to an object in it. A symbol -/// instance in `n` counts when its symbol's art has a geometry effect. +/// Whether `n` is measured by art of its own with Use Preview Bounds, or an object in it is: a +/// geometry or 3D effect in it changes what it draws. A symbol instance in `n` counts when its +/// symbol's art has geometry or 3D effects. pub fn draws_geometry(symbols: &SymbolBoxes, n: &Node) -> bool { Drawn::new(symbols).draws_geometry(n) } -/// One measurement: whether the art of each symbol checked so far draws geometry, by symbol name, -/// and how many more instances' art it measures with its geometry effects in the current object ([`MAX_INSTANCES`]). +/// One measurement: whether each symbol checked so far draws geometry or 3D art, by symbol name, +/// and how many more instances it measures with those effects in the current object ([`MAX_INSTANCES`]). +/// With `three_d` false, 3D effects are left on the art unprojected ([`drawn_art`]). struct Drawn<'s, 'd> { symbols: &'s SymbolBoxes<'d>, draws: RefCell>, left: Cell, + three_d: bool, } impl<'s, 'd> Drawn<'s, 'd> { fn new(symbols: &'s SymbolBoxes<'d>) -> Self { - Drawn { symbols, draws: RefCell::default(), left: Cell::new(MAX_INSTANCES) } + Drawn { symbols, draws: RefCell::default(), left: Cell::new(MAX_INSTANCES), three_d: true } + } + + /// A measurement that projects no 3D effect, for clicks and marquees ([`drawn_art`]). + fn without_3d(symbols: &'s SymbolBoxes<'d>) -> Self { + Drawn { three_d: false, ..Self::new(symbols) } + } + + /// Whether `n` has a 3D effect of its own that this measurement projects. + fn projects(&self, n: &Node) -> bool { + self.three_d && (has_revolve(n) || has_solid(n)) } /// Sets the count of instances left back to [`MAX_INSTANCES`], for the next object. @@ -273,6 +290,7 @@ impl<'s, 'd> Drawn<'s, 'd> { let mut found = false; n.walk(&mut |c| { found = found + || self.projects(c) || match &c.kind { NodeKind::SymbolInstance { symbol, .. } => !geometry_effects(c).is_empty() || self.symbol_draws(symbol), _ => reshapes(c), @@ -292,14 +310,29 @@ impl<'s, 'd> Drawn<'s, 'd> { d } - /// The art the geometry effects of `n` itself give it, or that a symbol instance gets from the - /// geometry effects in its symbol's art. A group or layer with fills or strokes of its own that + /// The art the geometry or 3D effects of `n` itself give it, or that a symbol instance gets from + /// those effects in its symbol's art, with the instance's appearance overrides applied. + /// A group or layer with fills or strokes of its own that /// paint, around members with geometry effects, is evaluated too: its fills and strokes paint /// the members' geometry before their effects. A blend, envelope or repeat whose objects have /// geometry effects is evaluated as the renderer evaluates it ([`expanded_live_group`]), and /// the objects in its evaluated art keep their geometry effects. `None` when it has none, and /// for a symbol instance past [`MAX_INSTANCES`]. fn own_art(&self, n: &Node) -> Option { + let doc = Some(self.symbols.document()); + // A symbol instance with a 3D effect of its own counts toward MAX_INSTANCES before its art is built. + let counted = matches!(n.kind, NodeKind::SymbolInstance { .. }) && self.projects(n); + if counted { + let left = self.left.get().checked_sub(1)?; + self.left.set(left); + } + if self.three_d + && let Some(art) = revolve_art_in(doc, n).or_else(|| solid_art_in(doc, n)) + { + // The builders retain later geometry on the projected group. Measure it after that + // geometry too; item-level effects are handled by the ordinary member traversal. + return Some(self.own_art(&art).unwrap_or(art)); + } let inner = || n.children().is_some_and(|ch| ch.iter().any(|c| self.draws_geometry(c))); let painted = || has_own_paint(n) && inner(); match &n.kind { @@ -312,9 +345,14 @@ impl<'s, 'd> Drawn<'s, 'd> { if geometry_effects(n).is_empty() && !self.symbol_draws(symbol) { return None; } - let left = self.left.get().checked_sub(1)?; - self.left.set(left); + if !counted { + let left = self.left.get().checked_sub(1)?; + self.left.set(left); + } let art = self.symbols.measure_art(symbol, Arc::clone)?; + // Paint overrides can remove a projected surface or change its stroke outline. + let art = + if n.extras().symbol_overrides.is_empty() { art } else { Arc::new(vectorcraft_doc::symbol_overrides::dynamic_art(&art, n)) }; // An instance in perspective is projected by `reshape`. let doc = Some(self.symbols.document()); reshape(doc, n, Some(&*art)).or_else(|| outline_art(doc, n, Some(&*art))) diff --git a/crates/engine/src/cmd/brushsym/brushes.rs b/crates/engine/src/cmd/brushsym/brushes.rs index 89f3893b24..7a92ff130a 100644 --- a/crates/engine/src/cmd/brushsym/brushes.rs +++ b/crates/engine/src/cmd/brushsym/brushes.rs @@ -5,15 +5,16 @@ use super::{ // ---------- brushes ---------- -/// Brushable nodes (paths and compound paths) under `ids`. +/// Brushable nodes (paths and compound paths) under `ids`, in walk order, each listed once where it is first reached. pub(crate) fn brush_targets(d: &Document, ids: &[NodeId]) -> Vec { let mut out = vec![]; + let mut seen = std::collections::HashSet::new(); for id in ids { let Some(n) = d.node(*id) else { continue }; n.walk(&mut |c| { let own = matches!(c.kind, NodeKind::Path { guide: false, clipping: false, .. } | NodeKind::Compound { .. }); let in_compound = d.parent_of(c.id).and_then(|p| d.node(p)).is_some_and(|p| matches!(p.kind, NodeKind::Compound { .. })); - if own && !in_compound && !out.contains(&c.id) { + if own && !in_compound && seen.insert(c.id) { out.push(c.id); } }); @@ -748,3 +749,92 @@ pub(super) fn brush_freehand(s: &mut Session, p: &Value) -> Result { let checked = crate::schemas::check(spec, p, s.replaying())?; crate::cmd::draw2::freehand_brushed(s, checked.as_ref().unwrap_or(p), name.as_deref()) } + +#[cfg(test)] +mod tests { + use super::*; + use vectorcraft_doc::Appearance; + use vectorcraft_geom::PathData; + + /// The collector with a linear search of its output, kept to compare results with. + fn listed_targets(d: &Document, ids: &[NodeId]) -> Vec { + let mut out = vec![]; + for id in ids { + let Some(n) = d.node(*id) else { continue }; + n.walk(&mut |c| { + let own = matches!(c.kind, NodeKind::Path { guide: false, clipping: false, .. } | NodeKind::Compound { .. }); + let in_compound = d.parent_of(c.id).and_then(|p| d.node(p)).is_some_and(|p| matches!(p.kind, NodeKind::Compound { .. })); + if own && !in_compound && !out.contains(&c.id) { + out.push(c.id); + } + }); + } + out + } + + fn path(d: &mut Document) -> Node { + Node::path(d.alloc_id(), PathData::default(), Appearance::default()) + } + + fn compound(d: &mut Document, children: Vec) -> Node { + Node::new(d.alloc_id(), NodeKind::Compound { children: children.into_iter().map(Arc::new).collect(), rule: Default::default() }) + } + + fn add(d: &mut Document, node: Node) -> NodeId { + let layer = d.layers.first().map(|l| l.id); + d.insert(layer, usize::MAX, node).unwrap() + } + + #[test] + fn brush_targets_list_each_target_once_in_first_reached_order() { + let mut d = Document::new(400.0, 300.0); + let a = path(&mut d); + let a = add(&mut d, a); + let mut guide = path(&mut d); + if let NodeKind::Path { guide: g, .. } = &mut guide.kind { + *g = true; + } + let guide = add(&mut d, guide); + let mut clip = path(&mut d); + if let NodeKind::Path { clipping, .. } = &mut clip.kind { + *clipping = true; + } + let clip = add(&mut d, clip); + // A group holding a path and a compound path of two members. + let p1 = path(&mut d); + let p1_id = p1.id; + let (m1, m2) = (path(&mut d), path(&mut d)); + let m1_id = m1.id; + let cp1 = compound(&mut d, vec![m1, m2]); + let cp1_id = cp1.id; + let group = Node::group(d.alloc_id(), vec![Arc::new(p1), Arc::new(cp1)]); + let group = add(&mut d, group); + // A compound path holding a compound path. + let m3 = path(&mut d); + let cp3 = compound(&mut d, vec![m3]); + let cp3_id = cp3.id; + let cp2 = compound(&mut d, vec![cp3]); + let cp2 = add(&mut d, cp2); + + let ids = [cp1_id, a, group, p1_id, a, guide, clip, m1_id, cp2, cp3_id, NodeId(u64::MAX)]; + let got = brush_targets(&d, &ids); + assert_eq!(got, [cp1_id, a, p1_id, cp2], "repeats keep their first place; guides, clipping paths and compound members are left out"); + assert_eq!(got, listed_targets(&d, &ids)); + assert!(brush_targets(&d, &[]).is_empty()); + + // Many paths in groups, each group listed with some of its members. + let mut ids = vec![]; + for _ in 0..50 { + let members: Vec = (0..20).map(|_| path(&mut d)).collect(); + let member_ids: Vec = members.iter().map(|m| m.id).collect(); + let g = Node::group(d.alloc_id(), members.into_iter().map(Arc::new).collect()); + let g = add(&mut d, g); + ids.push(member_ids[7]); + ids.push(g); + ids.push(member_ids[3]); + } + let got = brush_targets(&d, &ids); + assert_eq!(got.len(), 50 * 20); + assert_eq!(got, listed_targets(&d, &ids)); + } +} diff --git a/crates/engine/src/cmd/fileio/commands.rs b/crates/engine/src/cmd/fileio/commands.rs index ccd3439730..818aaa632f 100644 --- a/crates/engine/src/cmd/fileio/commands.rs +++ b/crates/engine/src/cmd/fileio/commands.rs @@ -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), 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, ,