diff --git a/crates/doc/src/blend.rs b/crates/doc/src/blend.rs index c7c3e408b4..f8b62ac815 100644 --- a/crates/doc/src/blend.rs +++ b/crates/doc/src/blend.rs @@ -2174,6 +2174,70 @@ pub fn blend_steps(keys: &[Arc], spec: &BlendSpec) -> Vec { StepCount::default().blend(keys, spec, Rail::new(keys, spec).as_ref()).0 } +/// Does each pair of `keys` blended with `spec` ask for the same number of steps +/// ([`blend_step_count`]) when each coordinate it counts from moves by up to `length` points and, +/// for Smooth Color, the difference between keys of different colors by up to `color` (0 to 1)? +/// False when a count sits that close to where it changes, and for Smooth Color by distance when +/// the keys are at most `4 × length` wide or high. Specified Steps always asks for the same number. +pub fn blend_steps_settled(keys: &[Arc], spec: &BlendSpec, length: f64, color: f64) -> bool { + let rail = Rail::new(keys, spec); + keys.windows(2).enumerate().all(|(i, w)| { + let [a, b] = w else { return true }; + match spec.spacing { + BlendSpacing::Steps(_) => true, + // The count is `len / d` rounded, which grows with `len`. + BlendSpacing::Distance(d) => { + let len = rail.as_ref().map_or_else(|| center_of(a).distance(center_of(b)), |r| r.len(i)); + let count = |len: f64| blend_step_count(a, b, BlendSpacing::Distance(d), len); + count(len - length) == count(len + length) + } + BlendSpacing::SmoothColor => smooth_color_settled(a, b, length, color), + } + }) +} + +/// [`blend_steps_settled`] for one pair of Smooth Color keys. Each count [`blend_step_count`] +/// takes grows with what it counts from (the color difference, the keys' reach, the distance +/// between their edges in key sizes), so the pair is settled when the least and the most of +/// these ask for the same count. +fn smooth_color_settled(a: &Node, b: &Node, length: f64, color: f64) -> bool { + let bounds = a.visual_bounds().zip(b.visual_bounds()); + let by_level = |d: f64| level_steps(d.max(0.0)) as usize; + match (color_distance(a, b), bounds) { + // Colors that differ, but by too little to count, or by little more: moving them may cross + // where they stop counting as the same. (The same colors stay the same.) + (Some(d), _) if d > 0.0 && d * 255.0 <= 1e-3 + color * 255.0 => false, + (Some(d), Some((ba, bb))) if d * 255.0 > 1e-3 => { + let (ca, cb) = (ba.center(), bb.center()); + let reach = + [(ca.x - cb.x).abs(), (ca.y - cb.y).abs(), ba.width(), ba.height(), bb.width(), bb.height()].into_iter().fold(0.0f64, f64::max); + // The centers and sizes move by up to twice `length`. + let by_density = |r: f64| (8.0 * r.max(0.0) + 0.5).floor().clamp(1.0, 254.0) as usize; + let least = by_level(d - color).min(by_density(reach - 2.0 * length)); + let most = by_level(d + color).min(by_density(reach + 2.0 * length)); + reach.is_finite() && least == most + } + (Some(d), None) if d * 255.0 > 1e-3 => by_level(d - color) == by_level(d + color), + (_, Some((ba, bb))) => { + let (w, h) = ((ba.width() + bb.width()) / 2.0, (ba.height() + bb.height()) / 2.0); + if w <= 4.0 * length || h <= 4.0 * length { + return false; + } + let dx = (ba.x0 - bb.x0).abs().max((ba.x1 - bb.x1).abs()); + let dy = (ba.y0 - bb.y0).abs().max((ba.y1 - bb.y1).abs()); + // Each edge moves by up to `length`: the distances between them by up to twice that, + // and the mean sizes too. + let q = |dx: f64, dy: f64, w: f64, h: f64| (dx.max(0.0) / w).max(dy.max(0.0) / h); + let count = |q: f64| ((q + 0.5).floor() - 1.0).clamp(1.0, 1000.0) as usize; + let m = 2.0 * length; + let least = q(dx - m, dy - m, w + m, h + m); + let most = q(dx + m, dy + m, w - m, h - m); + least.is_finite() && most.is_finite() && count(least) == count(most) + } + (_, None) => true, + } +} + /// Evaluate a blend: the keys and generated steps in paint order. The steps keep to /// [`MAX_BLEND_STEPS`] in all ([`blend_steps`]). pub fn blend_expand(keys: &[Arc], spec: &BlendSpec) -> Vec { @@ -3535,4 +3599,46 @@ mod tests { let (keys, spec) = blend_parts(&outer).unwrap(); assert_eq!(blend_steps(keys, spec), vec![99]); } + + /// A count is settled when moving the lengths by 0.01 pt and the colors by 0.001 can't change + /// it: Specified Steps always; Specified Distance unless the spine's length is a half step from + /// where its count changes; Smooth Color unless the colors differ by too little to count, the + /// color difference or the keys' reach sits where its count changes, or keys of the same color + /// are at most four times 0.01 pt wide. + #[test] + fn steps_settle_unless_rounding_can_change_their_count() { + let (length, color) = (0.01, 0.001); + let settled = |a: Node, b: Node, spacing: BlendSpacing| { + let spec = BlendSpec { spacing, ..Default::default() }; + blend_steps_settled(&[Arc::new(a), Arc::new(b)], &spec, length, color) + }; + let filled = |x: f64, size: f64, c: Color| smooth_key((x, 0.0), (size, size), Paint::solid(c), Paint::None, 0.0); + let gray = |x: f64| filled(x, 10.0, Color::rgb(0.5, 0.5, 0.5)); + + // The keys' centers are 100 pt apart: 100 / 25 is 4, and 100 / (100 / 3.5) is 3.5. + assert!(settled(gray(0.0), gray(100.0), BlendSpacing::Steps(3))); + assert!(settled(gray(0.0), gray(100.0), BlendSpacing::Distance(25.0))); + assert!(!settled(gray(0.0), gray(100.0), BlendSpacing::Distance(100.0 / 3.5))); + + // Smooth Color between colors that differ: by a 2,000th of a step, by 51 steps of 255 + // (settled) and by 51.5 (where the count changes). + let red = |x: f64, r: f32| filled(x, 10.0, Color::rgb(r, 0.0, 0.0)); + assert!(!settled(red(0.0, 0.0), red(100.0, 0.0005), BlendSpacing::SmoothColor)); + assert!(settled(red(0.0, 0.0), red(100.0, 51.0 / 255.0), BlendSpacing::SmoothColor)); + assert!(!settled(red(0.0, 0.0), red(100.0, 51.5 / 255.0), BlendSpacing::SmoothColor)); + // Black to white is counted by the keys' reach, eight steps a point: 10 pt is settled, + // 10.0625 pt (80.5 steps) is not. + let near = |size: f64| settled(filled(0.0, size, Color::BLACK), filled(5.0, size, Color::WHITE), BlendSpacing::SmoothColor); + assert!(near(10.0)); + assert!(!near(10.0625)); + // Keys without bounds are counted by their colors alone. + let bare = |r: f32| Node::path(NodeId(1), PathData::default(), Appearance::basic(Paint::solid(Color::rgb(r, 0.0, 0.0)), Paint::None, 0.0)); + assert!(settled(bare(0.0), bare(51.0 / 255.0), BlendSpacing::SmoothColor)); + assert!(!settled(bare(0.0), bare(51.5 / 255.0), BlendSpacing::SmoothColor)); + // Keys of the same color are counted by distance in key sizes; keys 0.04 pt wide or less + // are never settled. + assert!(settled(gray(0.0), gray(100.0), BlendSpacing::SmoothColor)); + assert!(!settled(filled(0.0, 0.04, Color::rgb(0.5, 0.5, 0.5)), filled(100.0, 0.04, Color::rgb(0.5, 0.5, 0.5)), BlendSpacing::SmoothColor)); + assert!(settled(filled(0.0, 0.05, Color::rgb(0.5, 0.5, 0.5)), filled(100.0, 0.05, Color::rgb(0.5, 0.5, 0.5)), BlendSpacing::SmoothColor)); + } } diff --git a/crates/engine/tests/import_fuzz.rs b/crates/engine/tests/import_fuzz.rs index 7fc7285dbb..058476d071 100644 --- a/crates/engine/tests/import_fuzz.rs +++ b/crates/engine/tests/import_fuzz.rs @@ -5066,6 +5066,81 @@ proptest! { survive("mutated .ai brushes", || Some(vectorcraft_eps::layered_ai(&private, Document::new(200.0, 100.0), vec![], false, false, 1.0).0))?; survive("mutated .ai brushes, trusted", || Some(vectorcraft_eps::layered_ai(&private, Document::new(200.0, 100.0), vec![], false, true, 1.0).0))?; } + + /// A `.ai` whose blends, as the writer writes them, are damaged: the keys and spine on `%_` + /// lines with their dictionaries, the drawn steps, the record's `XP` and its hex, and the + /// blend's transparency, cut short or edited. + #[test] + fn ai_written_blends_never_panic(cut in 0usize..BLENDS_FUZZ_CHARS, edits in prop::collection::vec((0usize..BLENDS_FUZZ_CHARS, prop::sample::select(vec!['0', '1', '2', '8', '9', 'A', 'F', '-', '.', ' ', '\n', '(', ')', '/', ',', ';', '%', '_', 'u', 'U', 'K', 'S', 'X', 'P'])), 0..12)) { + let text = mutate_text(blends_text(), cut, &edits); + let private = [b"%AI24_ZStandard_Data".as_slice(), &zstd(&text)].concat(); + survive("mutated .ai blends", || Some(vectorcraft_eps::layered_ai(&private, Document::new(300.0, 200.0), vec![], false, false, 1.0).0))?; + survive("mutated .ai blends, trusted", || Some(vectorcraft_eps::layered_ai(&private, Document::new(300.0, 200.0), vec![], false, true, 1.0).0))?; + } +} + +/// The range of [`ai_written_blends_never_panic`]'s cuts and edits: past the end of [`blends_text`]. +const BLENDS_FUZZ_CHARS: usize = 24_000; + +/// The editing data VectorCraft writes for a document with two blends: red to blue squares with +/// three steps and no spine of its own, at half opacity; and three squares 25 pt apart on a spine +/// edited on the canvas, aligned to the path. +fn blends_text() -> &'static str { + static TEXT: std::sync::OnceLock = std::sync::OnceLock::new(); + TEXT.get_or_init(|| { + use std::sync::Arc; + use vectorcraft_color::{Color, Paint}; + use vectorcraft_doc::live::{BlendOrientation, BlendSpacing, BlendSpec}; + use vectorcraft_doc::{Appearance, Node, NodeKind}; + use vectorcraft_geom::{PathData, Point, Rect, SubPath, shapes}; + let mut doc = Document::new(300.0, 200.0); + let layer = doc.layers[0].id; + let square = |doc: &mut Document, x: f64, y: f64, c: Color| { + Arc::new(Node::path( + doc.alloc_id(), + shapes::rectangle(Rect::new(x, y, x + 20.0, y + 20.0)), + Appearance::basic(Paint::solid(c), Paint::None, 0.0), + )) + }; + let (red, blue, green) = (Color::rgb(1.0, 0.0, 0.0), Color::rgb(0.0, 0.0, 1.0), Color::rgb(0.0, 1.0, 0.0)); + let keys = vec![square(&mut doc, 20.0, 20.0, red), square(&mut doc, 120.0, 20.0, blue)]; + let mut fade = Node::new( + doc.alloc_id(), + NodeKind::Blend { children: keys, spec: Box::new(BlendSpec { spacing: BlendSpacing::Steps(3), ..BlendSpec::default() }) }, + ); + fade.opacity = 0.5; + doc.insert(Some(layer), usize::MAX, fade).unwrap(); + let keys = vec![square(&mut doc, 20.0, 80.0, red), square(&mut doc, 120.0, 80.0, blue), square(&mut doc, 170.0, 80.0, green)]; + let centers: Vec = [30.0, 130.0, 180.0].iter().map(|x| Point::new(*x, 90.0)).collect(); + let spec = BlendSpec { + spacing: BlendSpacing::Distance(25.0), + orientation: BlendOrientation::AlignToPath, + spine: Some(PathData::single(SubPath::polyline(¢ers, false))), + key_anchors: vec![0, 1, 2], + ..BlendSpec::default() + }; + let path = Node::new(doc.alloc_id(), NodeKind::Blend { children: keys, spec: Box::new(spec) }); + doc.insert(Some(layer), usize::MAX, path).unwrap(); + let out = vectorcraft_eps::export_ai_editing(&doc, &vectorcraft_eps::AiEditingOptions::default()).unwrap(); + String::from_utf8(out.program).unwrap() + }) +} + +/// The data [`ai_written_blends_never_panic`] damages, as it is, opens with both blends live, and +/// the property's cuts and edits reach all of it. +#[test] +fn the_written_blends_fuzz_data_opens_live() { + use vectorcraft_doc::NodeKind; + let text = blends_text(); + assert!(text.chars().count() < BLENDS_FUZZ_CHARS, "{}", text.chars().count()); + for mark in ["%AI5_BeginLayer", "%_(K) /String (ShapeBlendPathType) ,", "%_(S) /String (ShapeBlendPathType) ,", "1 0 92 XP", "1 0 116 XP"] { + assert!(text.replace("\r\n", "\n").contains(mark), "{mark}"); + } + let private = [b"%AI24_ZStandard_Data".as_slice(), &zstd(text)].concat(); + let (d, warnings, layered) = vectorcraft_eps::layered_ai(&private, Document::new(300.0, 200.0), vec![], false, true, 1.0); + assert!(layered, "{warnings:?}"); + let art = d.layers[0].children().unwrap(); + assert_eq!(art.iter().map(|n| matches!(n.kind, NodeKind::Blend { .. })).collect::>(), [true, true], "{warnings:?}"); } /// The range of [`ai_written_styles_never_panic`]'s cuts and edits: past the end of [`styles_text`]. diff --git a/crates/eps/src/ai_editing.rs b/crates/eps/src/ai_editing.rs index 5e63cfbc0c..6d0db3d08e 100644 --- a/crates/eps/src/ai_editing.rs +++ b/crates/eps/src/ai_editing.rs @@ -147,6 +147,12 @@ //! reader reads back as the same graph ([`crate::ai_graph`]) is written as its group between //! `%_Gs`, its functional records and `%_GS`, each series' group tagged `Go` right after its end; //! any other graph, and a graph with art left out, as its art, with a warning. +//! - Blends, as the reader reads them (`blend.rs`): the blend's key objects and spine as a group on +//! `%_` lines, each key's `/ArtDictionary` naming it a key and its id and the spine's naming it the +//! spine (written when the blend has a spine of its own); its steps drawn, a group; +//! the blend plugin's `1 0 n XP` line and the blend's record of its spacing, orientation and keys as hex +//! on `%` lines; its name and transparency as a group's after its end (`writer::blends`). A blend is +//! written live only when the reader reads it back with its settings. //! //! Lines end in CR LF. Strings are written in UTF-8. Art space is ruler space: y up, its origin at //! the first artboard's top-left corner. On the canvas ([`CANVAS_SIZE`] points square, y down) the @@ -176,7 +182,8 @@ //! and instances of //! symbols past 4,096 as their art (symbol art past [`vectorcraft_doc::MAX_SYMBOL_NODES`] objects //! in all left out), instances of symbols the document doesn't have as empty groups, symbols' 9-slice -//! guides, export types and dynamic type left out, live objects (placed documents included) as their art, +//! guides, export types and dynamic type left out, blends the reader wouldn't read back live as +//! their steps, other live objects (placed documents included) as their art, //! strokes a plain line can't draw and the object's art style doesn't hold //! as their filled outlines, several fills or strokes as a group of a path for each, freeform //! gradient swatches, gradient swatches of more than 256 stops, swatches of patterns written as @@ -289,6 +296,8 @@ fn export_held(source: &Document, o: &AiEditingOptions, max_objects: usize, keep let links = writer::style_links(doc); // Before baking, which leaves the wrap objects that may be written as they are unchanged. let wraps_held = if keep_wraps { writer::wraps_held(doc, &styled) } else { HashSet::new() }; + // The blends baking leaves as they are, which may be written live. + let unbaked_blends = writer::unbaked_blends(doc); // Live geometry effects as their result, as the PDF part draws them. let baked = baked(doc); let doc = baked.as_ref().unwrap_or(doc); @@ -319,6 +328,8 @@ fn export_held(source: &Document, o: &AiEditingOptions, max_objects: usize, keep // On a large canvas the layers' symbol instances are written as their art. w.symbols_live = scale == 1.0; w.brushes_live = scale == 1.0; + w.blends_live = scale == 1.0; + w.unbaked_blends = unbaked_blends; w.symbol_doc = symbol_doc; w.max_objects = max_objects; w.wraps_held = wraps_held; diff --git a/crates/eps/src/ai_editing/tests.rs b/crates/eps/src/ai_editing/tests.rs index 35d19be0eb..03d02e0ad5 100644 --- a/crates/eps/src/ai_editing/tests.rs +++ b/crates/eps/src/ai_editing/tests.rs @@ -1087,6 +1087,7 @@ fn counted() -> Vec<(&'static str, Document)> { ("styles", styles_document()), ("painted clips", painted_clips()), ("blend", blend_doc()), + ("blends", blends_document()), ("brushes", brushes_document()), ("envelopes", envelopes_document()), ("wrap bounds", wrap_bounds_doc()), @@ -1111,7 +1112,27 @@ fn wrap_bounds_doc() -> Document { doc } -/// A blend of two squares 20 pt apart with a step every 10 pt, written as its steps. +/// A blend whose own art and steps don't all fit within the object limit is written as its steps, +/// as many as fit, with the limit's warning and the blends warning; it writes no part of its own +/// art or its record. +#[test] +fn a_blend_past_the_object_limit_is_written_as_its_steps() { + let doc = blend_doc(); + let all = export_ai_editing(&doc, &opts()).unwrap(); + assert!(String::from_utf8_lossy(&all.program).contains("ShapeBlendPathType"), "written live with room"); + let read = crate::import::objects_read(&all.program).unwrap(); + for max in 1..read { + let out = export_within(&doc, &opts(), max).unwrap(); + let text = String::from_utf8_lossy(&out.program); + assert!(out.warnings.iter().any(|w| w == writer::OBJECT_LIMIT), "room for {max}: {:?}", out.warnings); + assert!(out.warnings.iter().any(|w| w == writer::BLENDS), "room for {max}: {:?}", out.warnings); + assert!(!text.contains("ShapeBlendPathType") && !text.contains("Path Blends)"), "room for {max}: {text}"); + let (back, _) = crate::ai_alone(&out.program).unwrap(); + assert!(!back.layers[0].children().unwrap().iter().any(|n| matches!(n.kind, NodeKind::Blend { .. })), "room for {max}"); + } +} + +/// A blend of two squares 20 pt apart with a step every 10 pt, written live. fn blend_doc() -> Document { let mut doc = Document::new(200.0, 100.0); let layer = doc.layers[0].id; @@ -11391,8 +11412,13 @@ fn envelopes_the_reader_cannot_open_live_are_written_as_their_art() { assert!(!warnings.iter().any(|w| w == writer::LIVE), "{what}: {warnings:?}"); assert!(matches!(back.kind, NodeKind::Group { .. }), "{what}: {back:#?}"); } - let blend = export_ai_editing(&blend_doc(), &opts()).unwrap(); - assert!(blend.warnings.iter().any(|w| w == writer::LIVE) && !blend.warnings.iter().any(|w| w == writer::ENVELOPES), "{:?}", blend.warnings); + let mut doc = Document::new(200.0, 100.0); + let a = Arc::new(square(&mut doc, Rect::new(10.0, 10.0, 20.0, 20.0), Color::gray(0.5))); + let repeat = Node::new(doc.alloc_id(), NodeKind::Repeat(vectorcraft_doc::RepeatSpec::grid(vec![a], 8.0, 12.0))); + let layer = doc.layers[0].id; + doc.insert(Some(layer), usize::MAX, repeat).unwrap(); + let repeat = export_ai_editing(&doc, &opts()).unwrap(); + assert!(repeat.warnings.iter().any(|w| w == writer::LIVE) && !repeat.warnings.iter().any(|w| w == writer::ENVELOPES), "{:?}", repeat.warnings); } /// `points`, a grid of `rows + 1` rows of `cols + 1` points, as `cols + 1` rows of `rows + 1`. @@ -11818,9 +11844,9 @@ fn text_wrap_options_are_written_and_read_back() { same_wraps(&wraps(read_back(&doc).layers[0].children().unwrap()), &[(None, 6.0, true), (None, 1000.0, false), (None, -1000.0, false)]); } -/// The art drawn for an object (a blend's steps, a stained symbol instance's art) is written -/// without the text wrap options of the objects it is made from, which wrap no type; the object -/// keeps its own. A symbol's art and a live instance keep theirs. +/// The art drawn for an object (the steps of a blend written as its steps, a stained symbol +/// instance's art) is written without the text wrap options of the objects it is made from, which +/// wrap no type; the object keeps its own. A symbol's art and a live instance keep theirs. #[test] fn drawn_art_keeps_only_its_objects_text_wrap() { let mut doc = Document::new(200.0, 100.0); @@ -11829,7 +11855,12 @@ fn drawn_art_keeps_only_its_objects_text_wrap() { Arc::new(wrapped(square(&mut doc, Rect::new(10.0, 10.0, 12.0, 12.0), Color::gray(0.5)), 2.0, true)), Arc::new(wrapped(square(&mut doc, Rect::new(30.0, 10.0, 32.0, 12.0), Color::gray(0.5)), 2.0, true)), ]; - let spec = vectorcraft_doc::BlendSpec { spacing: vectorcraft_doc::BlendSpacing::Distance(10.0), ..Default::default() }; + // With easing, written as its steps. + let spec = vectorcraft_doc::BlendSpec { + spacing: vectorcraft_doc::BlendSpacing::Distance(10.0), + ease: BlendEase { kind: BlendEaseType::InOut, ramp: 0.5 }, + ..Default::default() + }; let blend = wrapped(Node::new(doc.alloc_id(), NodeKind::Blend { children: keys, spec: Box::new(spec) }), 8.0, false); let art = wrapped(square(&mut doc, Rect::new(0.0, 0.0, 10.0, 10.0), LEAF), 4.0, true); doc.symbols.push(Symbol { dynamic: false, name: "Leaf".into(), art: Arc::new(art) }); @@ -12426,8 +12457,8 @@ fn two_leaves(doc: &mut Document) { doc.symbols.push(Symbol { dynamic: false, name: "Leaf".into(), art: Arc::new(art) }); } -/// A symbol instance written as its art (its isolation is a group's), a blend and an intertwine, -/// each written as a group of its art, wrap area type below them by their bounds after reopening, +/// A symbol instance written as its art (its isolation is a group's), a blend with easing and an +/// intertwine, each written as a group of its art, wrap area type below them by their bounds after reopening, /// as they did before saving, not by the members of that art: the text wrap options go on an /// unpainted rectangle of the bounds, the group's first member, and the group, which keeps the /// object's name, isolation, lock and visibility, has none. A positive offset, a negative offset @@ -12448,7 +12479,11 @@ fn live_art_written_as_a_group_keeps_wrapping_by_its_bounds() { Arc::new(square(doc, Rect::new(60.0, 80.0, 70.0, 90.0), Color::gray(0.5))), Arc::new(square(doc, Rect::new(220.0, 110.0, 230.0, 120.0), Color::gray(0.5))), ]; - let spec = vectorcraft_doc::BlendSpec { spacing: vectorcraft_doc::BlendSpacing::Distance(60.0), ..Default::default() }; + let spec = vectorcraft_doc::BlendSpec { + spacing: vectorcraft_doc::BlendSpacing::Distance(60.0), + ease: BlendEase { kind: BlendEaseType::InOut, ramp: 0.5 }, + ..Default::default() + }; wrapped(named(Node::new(doc.alloc_id(), NodeKind::Blend { children: keys, spec: Box::new(spec) }), "Thing"), 4.5, false) }; let intertwine = |doc: &mut Document| { @@ -12501,21 +12536,32 @@ fn live_art_written_as_a_group_keeps_wrapping_by_its_bounds() { assert!([b.x0 - want.x0, b.y0 - want.y0, b.x1 - want.x1, b.y1 - want.y1].iter().all(|d| d.abs() < 1e-3), "{name}: {b:?} {want:?}"); } - // An envelope written live opens live and wraps by its bounds, its options its own. - let live = |doc: &mut Document| { + // An envelope and a blend written live open live and wrap by their bounds, their options their + // own. + let envelope = |doc: &mut Document| { use vectorcraft_doc::live::{EnvelopeKind, EnvelopeOptions}; let kind = EnvelopeKind::Mesh { rows: 2, cols: 3, points: envelope_points(2, 3), handles: vec![] }; wrapped(named(envelope_node(doc, kind, 50.0, false, EnvelopeOptions::NEW), "Thing"), -3.0, true) }; - let doc = over_area_type(live); - let text_out = program(&doc); - let back = read_back(&doc); - let (before, after) = (area_wrap_region(&doc), area_wrap_region(&back)); - assert_eq!(before.len(), 1); - assert!(same_region(&before, &after), "{before:?}\n{after:?}\n{text_out}"); - let top = back.layers[0].children().unwrap(); - assert!(matches!(top[1].kind, NodeKind::Envelope { .. }), "{text_out}"); - same_wraps(&wraps(top), &[(Some("Thing".into()), -3.0, true)]); + let blend = |doc: &mut Document| { + let keys = vec![ + Arc::new(square(doc, Rect::new(60.0, 80.0, 70.0, 90.0), Color::gray(0.5))), + Arc::new(square(doc, Rect::new(220.0, 110.0, 230.0, 120.0), Color::gray(0.5))), + ]; + let spec = vectorcraft_doc::BlendSpec { spacing: vectorcraft_doc::BlendSpacing::Distance(60.0), ..Default::default() }; + wrapped(named(Node::new(doc.alloc_id(), NodeKind::Blend { children: keys, spec: Box::new(spec) }), "Thing"), -3.0, true) + }; + for (name, doc) in [("envelope", over_area_type(envelope)), ("blend", over_area_type(blend))] { + let text_out = program(&doc); + let back = read_back(&doc); + let (before, after) = (area_wrap_region(&doc), area_wrap_region(&back)); + assert_eq!(before.len(), 1, "{name}"); + assert!(same_region(&before, &after), "{name}\n{before:?}\n{after:?}\n{text_out}"); + let top = back.layers[0].children().unwrap(); + assert!(matches!(top[1].kind, NodeKind::Envelope { .. } | NodeKind::Blend { .. }), "{name}: {text_out}"); + assert_eq!(std::mem::discriminant(&top[1].kind), std::mem::discriminant(&doc.layers[0].children().unwrap()[1].kind), "{name}"); + same_wraps(&wraps(top), &[(Some("Thing".into()), -3.0, true)]); + } } /// The rectangle that keeps a blend written as its art wrapping by its bounds counts toward the @@ -12529,13 +12575,17 @@ fn live_art_written_as_a_group_keeps_wrapping_by_its_bounds() { fn wrap_bounds_of_live_art_fit_the_object_limit_and_leave_area_type_in_the_art_unwrapped() { use vectorcraft_doc::{TextKind, TextObject, TextRun}; // A blend alone, without a symbol definition, so the objects are the group, the rectangle and - // the steps. + // the steps (with easing, written as its steps). let mut doc = Document::new(300.0, 200.0); let keys = vec![ Arc::new(square(&mut doc, Rect::new(60.0, 80.0, 70.0, 90.0), Color::gray(0.5))), Arc::new(square(&mut doc, Rect::new(220.0, 110.0, 230.0, 120.0), Color::gray(0.5))), ]; - let spec = vectorcraft_doc::BlendSpec { spacing: vectorcraft_doc::BlendSpacing::Distance(60.0), ..Default::default() }; + let spec = vectorcraft_doc::BlendSpec { + spacing: vectorcraft_doc::BlendSpacing::Distance(60.0), + ease: BlendEase { kind: BlendEaseType::InOut, ramp: 0.5 }, + ..Default::default() + }; let thing = wrapped(named(Node::new(doc.alloc_id(), NodeKind::Blend { children: keys, spec: Box::new(spec) }), "Thing"), 4.5, false); let layer = doc.layers[0].id; doc.insert(Some(layer), usize::MAX, thing).unwrap(); @@ -13128,3 +13178,899 @@ fn a_cut_clipping_object_without_room_for_its_mask_gets_no_carrier() { } } } + +// ---------- blends ---------- + +use vectorcraft_doc::live::{BlendEase, BlendEaseType, BlendOrientation, BlendSpacing, BlendSpec}; + +/// A square `s` wide at (x, y) filled with `c`, as a blend's key. +fn key_square(doc: &mut Document, x: f64, y: f64, s: f64, c: Color) -> Arc { + Arc::new(Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(x, y, x + s, y + s)), Appearance::basic(solid(c), Paint::None, 0.0))) +} + +fn blend_of(doc: &mut Document, keys: Vec>, spec: BlendSpec) -> Node { + Node::new(doc.alloc_id(), NodeKind::Blend { children: keys, spec: Box::new(spec) }) +} + +/// The straight lines through the centers of 20 pt squares at `xs` on y 50 (a spine edited on the +/// canvas, its keys on its anchors). +fn spine_through(xs: &[f64], y: f64) -> PathData { + let points: Vec = xs.iter().map(|x| vectorcraft_geom::Point::new(x + 10.0, y + 10.0)).collect(); + PathData::single(vectorcraft_geom::SubPath::polyline(&points, false)) +} + +/// A 400 × 400 document with blends: `Fade`, red to blue squares, three steps, no spine of its own, +/// at half opacity in Multiply, followed by a path at 80%; `Path`, three keys (red, blue, green) on a +/// spine edited on the canvas, 25 pt apart, aligned to the path; `Smooth`, two close blues in Smooth +/// Color; `Curve` and `Bow`, two keys on a replaced curved spine with four steps; `Diagonal`, two +/// keys 45 degrees apart with no spine of their own, aligned to the path; and a hidden, locked blend +/// in a group `Box`. (Turning the steps along the spine leaves their centers in place, so the +/// orientation comes from the record.) +fn blends_document() -> Document { + let mut doc = Document::new(400.0, 400.0); + let (red, blue, green) = (Color::rgb(1.0, 0.0, 0.0), Color::rgb(0.0, 0.0, 1.0), Color::rgb(0.0, 1.0, 0.0)); + let layer = doc.layers[0].id; + let keys = vec![key_square(&mut doc, 20.0, 20.0, 20.0, red), key_square(&mut doc, 120.0, 20.0, 20.0, blue)]; + let mut fade = blend_of(&mut doc, keys, BlendSpec { spacing: BlendSpacing::Steps(3), ..BlendSpec::default() }); + (fade.name, fade.opacity, fade.blend) = (Some("Fade".into()), 0.5, BlendMode::Multiply); + doc.insert(Some(layer), usize::MAX, fade).unwrap(); + let mut after = (*key_square(&mut doc, 200.0, 20.0, 20.0, green)).clone(); + after.opacity = 0.8; + doc.insert(Some(layer), usize::MAX, after).unwrap(); + let keys = vec![ + key_square(&mut doc, 20.0, 80.0, 20.0, red), + key_square(&mut doc, 120.0, 80.0, 20.0, blue), + key_square(&mut doc, 170.0, 80.0, 20.0, green), + ]; + let spec = BlendSpec { + spacing: BlendSpacing::Distance(25.0), + orientation: BlendOrientation::AlignToPath, + spine: Some(spine_through(&[20.0, 120.0, 170.0], 80.0)), + key_anchors: vec![0, 1, 2], + ..BlendSpec::default() + }; + let mut path = blend_of(&mut doc, keys, spec); + path.name = Some("Path".into()); + doc.insert(Some(layer), usize::MAX, path).unwrap(); + let keys = + vec![key_square(&mut doc, 20.0, 140.0, 20.0, Color::rgb(0.0, 0.0, 0.8)), key_square(&mut doc, 140.0, 140.0, 20.0, Color::rgb(0.0, 0.0, 1.0))]; + let mut smooth = blend_of(&mut doc, keys, BlendSpec { spacing: BlendSpacing::SmoothColor, ..BlendSpec::default() }); + smooth.name = Some("Smooth".into()); + doc.insert(Some(layer), usize::MAX, smooth).unwrap(); + let keys = vec![key_square(&mut doc, 20.0, 220.0, 20.0, red), key_square(&mut doc, 220.0, 220.0, 20.0, blue)]; + let curve = PathData::from_bezpath(&kurbo::BezPath::from_vec(vec![ + kurbo::PathEl::MoveTo((30.0, 230.0).into()), + kurbo::PathEl::CurveTo((80.0, 180.0).into(), (180.0, 180.0).into(), (230.0, 230.0).into()), + ])); + let mut curved = blend_of(&mut doc, keys, BlendSpec { spacing: BlendSpacing::Steps(4), spine: Some(curve), ..BlendSpec::default() }); + curved.name = Some("Curve".into()); + doc.insert(Some(layer), usize::MAX, curved).unwrap(); + let keys = vec![key_square(&mut doc, 40.0, 260.0, 20.0, red), key_square(&mut doc, 340.0, 260.0, 20.0, blue)]; + let bow = PathData::from_bezpath(&kurbo::BezPath::from_vec(vec![ + kurbo::PathEl::MoveTo((50.0, 270.0).into()), + kurbo::PathEl::CurveTo((50.0, 270.0).into(), (250.0, 200.0).into(), (350.0, 270.0).into()), + ])); + let mut bowed = blend_of(&mut doc, keys, BlendSpec { spacing: BlendSpacing::Steps(4), spine: Some(bow), ..BlendSpec::default() }); + bowed.name = Some("Bow".into()); + doc.insert(Some(layer), usize::MAX, bowed).unwrap(); + let keys = vec![key_square(&mut doc, 300.0, 20.0, 20.0, red), key_square(&mut doc, 380.0, 100.0, 20.0, blue)]; + let mut diagonal = + blend_of(&mut doc, keys, BlendSpec { spacing: BlendSpacing::Steps(2), orientation: BlendOrientation::AlignToPath, ..BlendSpec::default() }); + diagonal.name = Some("Diagonal".into()); + doc.insert(Some(layer), usize::MAX, diagonal).unwrap(); + let keys = vec![key_square(&mut doc, 20.0, 320.0, 20.0, red), key_square(&mut doc, 100.0, 320.0, 20.0, green)]; + let mut shy = blend_of(&mut doc, keys, BlendSpec { spacing: BlendSpacing::Steps(1), ..BlendSpec::default() }); + (shy.visible, shy.locked) = (false, true); + let mut boxed = Node::group(doc.alloc_id(), vec![Arc::new(shy)]); + boxed.name = Some("Box".into()); + doc.insert(Some(layer), usize::MAX, boxed).unwrap(); + doc +} + +/// Every blend of `doc`, in paint order. +fn blends_in(doc: &Document) -> Vec> { + let mut out = vec![]; + fn walk(n: &Arc, out: &mut Vec>) { + if matches!(n.kind, NodeKind::Blend { .. }) { + out.push(n.clone()); + } else { + n.children().into_iter().flatten().for_each(|c| walk(c, out)); + } + } + doc.layers.iter().for_each(|l| walk(l, &mut out)); + out +} + +/// Do the objects `got` lay out as `want` do: as many, each one's bounds within 0.01 pt and its +/// first fill's color within 0.002 a channel, and a group's members the same way? +fn assert_same_objects(got: &[Node], want: &[Node], what: &str) { + assert_eq!(got.len(), want.len(), "{what}: how many"); + for (i, (g, w)) in got.iter().zip(want).enumerate() { + let bounds = |n: &Node| n.geometric_bounds().map(|b| [b.x0, b.y0, b.x1, b.y1]); + match (bounds(g), bounds(w)) { + (Some(a), Some(b)) => assert!(a.iter().zip(b).all(|(x, y)| (x - y).abs() <= 0.01), "{what}, object {i}: {a:?} for {b:?}"), + (a, b) => assert_eq!(a, b, "{what}, object {i}"), + } + let fill = |n: &Node| match n.appearance.fill_paint() { + Paint::Solid { color, .. } => Some(color.to_rgb()), + _ => None, + }; + match (fill(g), fill(w)) { + (Some(a), Some(b)) => assert!(a.iter().zip(b).all(|(x, y)| (x - y).abs() <= 0.002), "{what}, object {i}: {a:?} for {b:?}"), + (a, b) => assert_eq!(a, b, "{what}, object {i}"), + } + let members = |n: &Node| n.children().map(|c| c.iter().map(|m| (**m).clone()).collect::>()).unwrap_or_default(); + assert_same_objects(&members(g), &members(w), &format!("{what}, object {i}")); + } +} + +/// The blends of `doc` come back live: each with its keys (their points and paint), its spacing +/// and orientation, its name, opacity, blending mode, hidden and locked state, and laying out the +/// same steps (where they sit, how they turn, their colors). A blend with no spine of its own comes +/// back with none, one with a spine edited on the canvas with that spine and its keys' anchors, and +/// one with a replaced spine with a spine anchored at each key (anchors 0 and 1 for two keys). +fn assert_blends_read_back_live(doc: &Document) { + let back = read_back(doc); + let (ours, theirs) = (blends_in(doc), blends_in(&back)); + assert_eq!(theirs.len(), ours.len(), "{:#?}", back.layers[0]); + for (a, b) in ours.iter().zip(&theirs) { + let (NodeKind::Blend { children: ka, spec: sa }, NodeKind::Blend { children: kb, spec: sb }) = (&a.kind, &b.kind) else { panic!() }; + let what = format!("{:?}", a.name); + assert_eq!(kb.len(), ka.len(), "{what}"); + for (x, y) in ka.iter().zip(kb) { + let (g, w) = (art_tree(y), art_tree(x)); + assert!(same_tree(&g, &w), "{what}: {g:#} for {w:#}"); + } + assert_eq!( + (&sb.spacing, sb.orientation, &sb.ease, sb.color_shift, &sb.starts), + (&sa.spacing, sa.orientation, &sa.ease, sa.color_shift, &sa.starts), + "{what}" + ); + match (&sa.spine, sa.key_anchors.is_empty()) { + (None, _) => assert_eq!((&sb.spine, sb.key_anchors.len()), (&None, 0), "{what}: no spine of its own"), + (Some(_), false) => assert!(same_blend_spec(sb, sa), "{what}: {sb:#?} for {sa:#?}"), + (Some(_), true) => { + assert!(sb.spine.is_some(), "{what}"); + assert_eq!(sb.key_anchors, (0..ka.len() as u32).collect::>(), "{what}: an anchor at each key"); + } + } + assert_eq!((&b.name, b.opacity, b.blend, b.visible, b.locked), (&a.name, a.opacity, a.blend, a.visible, a.locked)); + let steps = |k: &[Arc], s: &BlendSpec| vectorcraft_doc::blend::blend_expand(k, s); + assert_same_objects(&steps(kb, sb), &steps(ka, sa), &what); + } +} + +/// Are two blends' settings the same, the spines' points within the written precision? +fn same_blend_spec(got: &BlendSpec, want: &BlendSpec) -> bool { + let points = |s: &Option| { + s.as_ref().map(|p| { + let a: Vec<[f64; 6]> = + p.subpaths.iter().flat_map(|sp| sp.anchors.iter().map(|a| [a.h_in.x, a.h_in.y, a.p.x, a.p.y, a.h_out.x, a.h_out.y])).collect(); + serde_json::json!(a) + }) + }; + let spines = match (points(&got.spine), points(&want.spine)) { + (Some(a), Some(b)) => same_tree(&a, &b), + (None, None) => true, + _ => false, + }; + spines + && (&got.spacing, got.orientation, &got.key_anchors, &got.ease, got.color_shift, &got.starts) + == (&want.spacing, want.orientation, &want.key_anchors, &want.ease, want.color_shift, &want.starts) +} + +/// Each blend comes back live ([`assert_blends_read_back_live`]): no spine of its own, a spine +/// edited on the canvas, replaced curved spines; Specified Steps, Specified Distance, Smooth Color; +/// aligned to the page or the path; named, at half opacity, hidden and locked. The path after the +/// first blend keeps its own opacity. +#[test] +fn blends_are_read_back_live() { + let doc = blends_document(); + let out = export_ai_editing(&doc, &opts()).unwrap(); + assert!(!out.warnings.iter().any(|w| w == writer::BLENDS || w == writer::LIVE), "{:?}", out.warnings); + let text = program(&doc); + assert_eq!(text.matches("(Adobe Path Blends) 1 0 ").count(), 7); // brand-ok: the plugin name the files use + assert_blends_read_back_live(&doc); + let back = read_back(&doc); + let art = back.layers[0].children().unwrap(); + assert_eq!((art[1].opacity, matches!(art[1].kind, NodeKind::Path { .. })), (0.8, true), "the path after the blend keeps its own opacity"); +} + +/// The record names the keys in their order with the anchors they sit on and the steps before each, +/// the spacing and distance, and the orientation (8 and the spine's starting angle for Align to +/// Path); a key's dictionary names it a key and its id, the spine's names it the spine, and a blend +/// with no spine of its own has no spine part; the blend's name follows its record, before its +/// transparency. +#[test] +fn blends_are_written_in_their_form() { + let doc = blends_document(); + let text = program(&doc); + let words = |at: usize| -> Vec { + let head = text.match_indices("(Adobe Path Blends) 1 0 ").nth(at).unwrap().0; // brand-ok: the plugin name the files use + let hex: String = text[head..].lines().skip(1).take_while(|l| l.starts_with('%') && !l.starts_with("%_")).map(|l| &l[1..]).collect(); + let bytes: Vec = (0..hex.len()).step_by(2).map(|i| u8::from_str_radix(&hex[i..i + 2], 16).unwrap()).collect(); + bytes.chunks(4).map(|c| u32::from_le_bytes([c[0], c[1], c[2], c[3]])).collect() + }; + let fade = words(0); + let magic = u32::from_le_bytes(*b"DCBA"); + let f = |x: f32| x.to_bits(); + let ff = u32::MAX; + assert_eq!(fade, [magic, 1, f(25.0), 0, 3, 0, 'C' as u32, 0, 0, 1, 2, 'A' as u32, 0, f(0.0), ff, ff, 0, 'B' as u32, 0, f(1.0), ff, ff, 3]); + let path = words(1); + assert_eq!(path.len(), 11 + 3 * 6); + assert_eq!(&path[..7], [magic, 2, f(25.0), 0, 3, f(8.0), 'D' as u32]); + assert_eq!((path[23], path[25], path[28]), ('C' as u32, f(2.0), 1)); + assert_eq!(words(2)[..3], [magic, 0, f(4.0)]); + // Diagonal runs down to the right on the canvas: 45 degrees below level in art space, whose y + // runs up, so its spine starts at 7π/4. + assert_eq!(words(5)[5], f((8.0 + 7.0 * std::f64::consts::FRAC_PI_4) as f32), "Diagonal's orientation"); + let fade_art = &text[..text.find("(Adobe Path Blends) 1 0 ").unwrap()]; // brand-ok: the plugin name the files use + assert!(fade_art.contains("%_(K) /String (ShapeBlendPathType) ,\n%_(A) /String (ShapeBlendPathID) ,"), "{fade_art}"); + assert!(!fade_art.contains("(S) /String (ShapeBlendPathType)"), "no spine part for a blend with no spine of its own"); + assert!(!fade_art.contains("(Fade)"), "the name follows the record"); + let after = &text[text.find("(Adobe Path Blends) 1 0 ").unwrap()..]; // brand-ok: the plugin name the files use + let state = after.find("\n0 0 Xd\n6 () XW").unwrap(); + assert!( + after[..state].contains("%_/ArtDictionary :\n%_/XMLUID : (Fade) ; (AI10_ArtUID) ,"), + "the name before the state block: {}", + &after[..state] + ); + assert_eq!(text.matches("%_(S) /String (ShapeBlendPathType) ,").count(), 3, "the edited spine and the two replaced ones"); +} + +/// Blends of compound paths, of groups, and of 62 keys (the most the ids name; the record's next +/// free id is then 0) come back live, laying out the same steps. +#[test] +fn blends_of_compound_paths_groups_and_62_keys_are_read_back_live() { + let mut doc = Document::new(400.0, 300.0); + let layer = doc.layers[0].id; + let (red, blue) = (Color::rgb(1.0, 0.0, 0.0), Color::rgb(0.0, 0.0, 1.0)); + // The members carry the compound path's paint, as the reader gives them. + let ring = |doc: &mut Document, x: f64, c: Color| { + let paint = || Appearance::basic(solid(c), Paint::None, 0.0); + let outer = Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(x, 20.0, x + 20.0, 40.0)), paint()); + let inner = Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(x + 5.0, 25.0, x + 15.0, 35.0)), paint()); + let mut ring = Node::new(doc.alloc_id(), NodeKind::Compound { children: vec![Arc::new(outer), Arc::new(inner)], rule: FillRule::EvenOdd }); + ring.appearance = paint().into(); + Arc::new(ring) + }; + let keys = vec![ring(&mut doc, 20.0, red), ring(&mut doc, 120.0, blue)]; + let mut rings = blend_of(&mut doc, keys, BlendSpec { spacing: BlendSpacing::Steps(3), ..BlendSpec::default() }); + rings.name = Some("Rings".into()); + doc.insert(Some(layer), usize::MAX, rings).unwrap(); + let pair = |doc: &mut Document, x: f64, c: Color| { + let members = vec![key_square(doc, x, 80.0, 10.0, c), key_square(doc, x + 15.0, 80.0, 10.0, Color::gray(0.5))]; + Arc::new(Node::group(doc.alloc_id(), members)) + }; + let keys = vec![pair(&mut doc, 20.0, red), pair(&mut doc, 120.0, blue)]; + let mut pairs = blend_of(&mut doc, keys, BlendSpec { spacing: BlendSpacing::Steps(2), ..BlendSpec::default() }); + pairs.name = Some("Pairs".into()); + doc.insert(Some(layer), usize::MAX, pairs).unwrap(); + let keys = (0..62).map(|i| key_square(&mut doc, f64::from(i) * 6.0, 150.0, 2.0, Color::gray(f32::from(i as u8) / 62.0))).collect(); + let mut many = blend_of(&mut doc, keys, BlendSpec { spacing: BlendSpacing::Steps(1), ..BlendSpec::default() }); + many.name = Some("Many".into()); + doc.insert(Some(layer), usize::MAX, many).unwrap(); + let out = export_ai_editing(&doc, &opts()).unwrap(); + assert!(!out.warnings.iter().any(|w| w == writer::BLENDS), "{:?}", out.warnings); + let text = program(&doc); + let last = text.match_indices("(Adobe Path Blends) 1 0 ").nth(2).unwrap().0; // brand-ok: the plugin name the files use + let hex: String = text[last..].lines().skip(1).take_while(|l| l.starts_with('%') && !l.starts_with("%_")).map(|l| &l[1..]).collect(); + assert_eq!(&hex[6 * 8..7 * 8], "00000000", "the next free id after the 62nd"); + assert_blends_read_back_live(&doc); +} + +/// After a path at half opacity, a blend's steps set their own transparency and lock and hidden +/// state on plain lines: readers of the printed form skip the blend's keys on `%_` lines. +#[test] +fn a_blends_steps_set_their_own_state() { + let mut doc = Document::new(300.0, 100.0); + let layer = doc.layers[0].id; + let mut faint = (*key_square(&mut doc, 250.0, 20.0, 20.0, Color::gray(0.5))).clone(); + faint.opacity = 0.5; + doc.insert(Some(layer), usize::MAX, faint).unwrap(); + let keys = + vec![key_square(&mut doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0)), key_square(&mut doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))]; + let n = blend_of(&mut doc, keys, BlendSpec { spacing: BlendSpacing::Steps(3), ..BlendSpec::default() }); + doc.insert(Some(layer), usize::MAX, n).unwrap(); + let text = program(&doc); + let hidden_end = text.find("%_U\n%_9 () XW\n").unwrap(); + let steps = &text[hidden_end..text.find("(Adobe Path Blends) 1 0 ").unwrap()]; // brand-ok: the plugin name the files use + for line in ["\n0 A\n", "\n0 Xw\n", "\n0 1 0 0 0 Xy\n"] { + assert!(steps.contains(line), "{line:?} in {steps}"); + } +} + +/// A live blend's key objects keep their text wrap options on the hidden lines and the blend keeps +/// its own after its record; the steps, drawn art, carry none. +#[test] +fn a_live_blends_steps_carry_no_text_wrap_options() { + let mut doc = Document::new(300.0, 100.0); + let layer = doc.layers[0].id; + let keys = vec![ + Arc::new(wrapped((*key_square(&mut doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0))).clone(), 2.0, true)), + Arc::new(wrapped((*key_square(&mut doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))).clone(), 3.0, false)), + ]; + let n = wrapped(blend_of(&mut doc, keys, BlendSpec { spacing: BlendSpacing::Steps(3), ..BlendSpec::default() }), 8.0, false); + doc.insert(Some(layer), usize::MAX, n).unwrap(); + let out = export_ai_editing(&doc, &opts()).unwrap(); + assert!(!out.warnings.iter().any(|w| w == writer::BLENDS), "{:?}", out.warnings); + let text = program(&doc); + let hidden_end = text.find("%_U\n%_9 () XW\n").unwrap(); + let record = text.find("(Adobe Path Blends) 1 0 ").unwrap(); // brand-ok: the plugin name the files use + assert_eq!(text[..hidden_end].matches("(AI11TextWrapOffset)").count(), 2, "the keys' own: {text}"); + assert!(!text[hidden_end..record].contains("AI11TextWrap"), "the steps: {}", &text[hidden_end..record]); + assert_eq!(text[record..].matches("(AI11TextWrapOffset)").count(), 1, "the blend's own: {text}"); + let back = read_back(&doc); + let [blend] = blends_in(&back).try_into().unwrap(); + assert_eq!(blend.extras().wrap, Some(vectorcraft_doc::TextWrap { offset: 8.0, invert: false })); + let NodeKind::Blend { children, .. } = &blend.kind else { panic!() }; + same_wraps(&wraps(children), &[(None, 2.0, true), (None, 3.0, false)]); +} + +/// A Specified Distance that a 32-bit float doesn't hold exactly (10 mm in points) is written +/// live, and comes back as the float's shortest decimal, laying out the same steps. +#[test] +fn a_blend_spaced_in_millimeters_is_written_live() { + let mut doc = Document::new(300.0, 100.0); + let layer = doc.layers[0].id; + let keys = + vec![key_square(&mut doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0)), key_square(&mut doc, 220.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))]; + let mm = 72.0 / 25.4 * 10.0; + let n = blend_of(&mut doc, keys, BlendSpec { spacing: BlendSpacing::Distance(mm), ..BlendSpec::default() }); + doc.insert(Some(layer), usize::MAX, n).unwrap(); + let out = export_ai_editing(&doc, &opts()).unwrap(); + assert!(!out.warnings.iter().any(|w| w == writer::BLENDS), "{:?}", out.warnings); + let back = read_back(&doc); + let [blend] = blends_in(&back).try_into().unwrap(); + let NodeKind::Blend { children, spec } = &blend.kind else { panic!() }; + assert_eq!(spec.spacing, BlendSpacing::Distance((mm as f32).to_string().parse().unwrap())); + let [ours] = blends_in(&doc).try_into().unwrap(); + let NodeKind::Blend { children: keys, spec: want } = &ours.kind else { panic!() }; + let steps = |k: &[Arc], s: &BlendSpec| vectorcraft_doc::blend::blend_expand(k, s); + assert_same_objects(&steps(children, spec), &steps(keys, want), "10 mm"); +} + +/// The lines of the layers, `%AI5_BeginLayer` to the end. +fn layer_lines(program: &str) -> Vec<&str> { + program.lines().skip_while(|l| !l.starts_with("%AI5_BeginLayer")).collect() +} + +/// A document with blends is written as the same bytes again, and what the reader reads back is +/// written with the same layers, every blend live both times. +#[test] +fn blends_write_the_same_bytes_again() { + let doc = blends_document(); + let first = export_ai_editing(&doc, &opts()).unwrap(); + assert_eq!(first.program, export_ai_editing(&doc, &opts()).unwrap().program); + let again = String::from_utf8(export_ai_editing(&read_back(&doc), &opts()).unwrap().program).unwrap(); + let first = String::from_utf8(first.program).unwrap(); + // Every blend is written live both times. + for text in [&first, &again] { + assert_eq!(text.matches("(Adobe Path Blends) 1 0 ").count(), 7); // brand-ok: the plugin name the files use + } + let (again, first) = (layer_lines(&again), layer_lines(&first)); + let differ = again.iter().zip(&first).enumerate().find(|(_, (a, b))| a != b); + assert_eq!(differ, None, "the first line that differs"); + assert_eq!(again.len(), first.len()); +} + +/// Blends the reader wouldn't read back as they are are written as their steps with a warning, as +/// many as the PDF part draws, each where it draws it. Each is changed from a blend that comes back +/// live by one thing: easing, a color shift, start points, an opacity mask, an effect or a fill of +/// its own; more objects than the reader lays out for one blend (5,006); a key that is type; a key +/// with a width profile, two fills, a hidden stroke or a gradient stroke, a drop shadow, a Lab +/// color, an opacity mask, a fill at half opacity or in Multiply, or a stroke under its fill (which +/// the editing copy writes otherwise); a key with Offset Path or Roughen, a group key with a fill of its own, or a +/// compound shape key (which baking changes); a group key holding an empty path, path keys of two +/// subpaths, a compound path key with a member of two subpaths (which the editing copy writes +/// otherwise); a clipping group +/// key; a hidden key; a key holding a +/// blend; keys with gradient fills (whose steps the reader can't compare); more than 62 keys; a +/// spine of two parts; and step counts on the edge of rounding (Smooth Color of one color with +/// edges four and a half key widths apart, Specified Distance of two and a half steps, and 0.03 pt +/// past them on a spine of 200 segments). Smooth Color of one color with edges five key widths +/// apart comes back live, and so does that Specified Distance blend on a spine of two segments. +#[test] +fn blends_the_reader_cant_read_are_written_as_their_steps() { + let live = |doc: &mut Document| { + let keys = vec![key_square(doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0)), key_square(doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))]; + blend_of(doc, keys, BlendSpec { spacing: BlendSpacing::Steps(3), ..BlendSpec::default() }) + }; + let with_spec = |change: fn(&mut BlendSpec)| { + move |doc: &mut Document| { + let mut n = live(doc); + if let NodeKind::Blend { spec, .. } = &mut n.kind { + change(spec); + } + n + } + }; + let with_keys = |make: fn(&mut Document) -> Vec>| { + move |doc: &mut Document| { + let keys = make(doc); + blend_of(doc, keys, BlendSpec { spacing: BlendSpacing::Steps(1), ..BlendSpec::default() }) + } + }; + type Make = Box Node>; + let cases: Vec<(&str, Make)> = vec![ + ("live", Box::new(live)), + ("easing", Box::new(with_spec(|s| s.ease = BlendEase { kind: BlendEaseType::InOut, ramp: 0.5 }))), + ("color shift", Box::new(with_spec(|s| s.color_shift = 30.0))), + ("start points", Box::new(with_spec(|s| s.starts = vec![Some(1), None]))), + ( + "opacity mask", + Box::new(move |doc: &mut Document| { + let mut n = live(doc); + let art = (*key_square(doc, 0.0, 0.0, 200.0, Color::gray(1.0))).clone(); + n.extras_mut().mask = Some(Box::new(OpacityMask { art: Arc::new(art), clip: false, invert: false, disabled: false, linked: true })); + n + }), + ), + ( + "type key", + Box::new(with_keys(|doc| { + let t = vectorcraft_doc::TextObject::point(vectorcraft_geom::Point::new(150.0, 40.0), "A", vectorcraft_doc::CharStyle::default()); + let text = Node::new(doc.alloc_id(), NodeKind::Text(Box::new(t))); + vec![key_square(doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0)), Arc::new(text)] + })), + ), + ( + "more than 5,000 objects", + Box::new(move |doc: &mut Document| { + let keys = (0..6).map(|i| key_square(doc, f64::from(i) * 60.0, 20.0, 10.0, Color::gray(f32::from(i as u8) / 6.0))).collect(); + blend_of(doc, keys, BlendSpec { spacing: BlendSpacing::Steps(1000), ..BlendSpec::default() }) + }), + ), + ( + "key with a width profile", + Box::new(with_keys(|doc| { + let mut a = (*key_square(doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0))).clone(); + let mut st = StrokeLayer::new(solid(Color::BLACK), 4.0); + st.profile = Some(vectorcraft_doc::WidthProfile { points: vec![(0.0, 1.0, 0.5), (1.0, 0.0, 1.0)] }); + a.appearance.items.retain(|i| matches!(i, AppearanceItem::Fill(_))); + a.appearance.items.push(AppearanceItem::Stroke(st)); + vec![Arc::new(a), key_square(doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))] + })), + ), + ( + "key with two fills", + Box::new(with_keys(|doc| { + let mut a = (*key_square(doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0))).clone(); + a.appearance.items.push(AppearanceItem::Fill(FillLayer::new(solid(Color::rgb(0.0, 1.0, 0.0))))); + vec![Arc::new(a), key_square(doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))] + })), + ), + ( + "key with a hidden stroke", + Box::new(with_keys(|doc| { + let mut a = (*key_square(doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0))).clone(); + let st = StrokeLayer { visible: false, ..StrokeLayer::new(solid(Color::BLACK), 2.0) }; + a.appearance.items.retain(|i| matches!(i, AppearanceItem::Fill(_))); + a.appearance.items.push(AppearanceItem::Stroke(st)); + vec![Arc::new(a), key_square(doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))] + })), + ), + ( + "key with a gradient stroke", + Box::new(with_keys(|doc| { + let mut a = (*key_square(doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0))).clone(); + let stops = vec![GradientStop::new(0.0, Color::rgb(1.0, 1.0, 1.0)), GradientStop::new(1.0, Color::rgb(0.0, 0.0, 0.0))]; + let grad = Paint::Gradient(Box::new(GradientPaint::new(Gradient::new(GradientKind::Linear, stops)))); + a.appearance.items.retain(|i| matches!(i, AppearanceItem::Fill(_))); + a.appearance.items.push(AppearanceItem::Stroke(StrokeLayer::new(grad, 2.0))); + vec![Arc::new(a), key_square(doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))] + })), + ), + ( + "hidden key", + Box::new(with_keys(|doc| { + let mut a = (*key_square(doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0))).clone(); + a.visible = false; + vec![Arc::new(a), key_square(doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))] + })), + ), + ( + "nested blend", + Box::new(with_keys(|doc| { + let inner = + vec![key_square(doc, 20.0, 20.0, 10.0, Color::rgb(1.0, 0.0, 0.0)), key_square(doc, 40.0, 20.0, 10.0, Color::rgb(0.0, 1.0, 0.0))]; + let inner = blend_of(doc, inner, BlendSpec { spacing: BlendSpacing::Steps(1), ..BlendSpec::default() }); + vec![Arc::new(inner), key_square(doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))] + })), + ), + ( + "gradient keys", + Box::new(with_keys(|doc| { + let stops = vec![GradientStop::new(0.0, Color::rgb(1.0, 0.0, 0.0)), GradientStop::new(1.0, Color::rgb(0.0, 0.0, 1.0))]; + let grad = Paint::Gradient(Box::new(GradientPaint::new(Gradient::new(GradientKind::Linear, stops)))); + let mut a = (*key_square(doc, 20.0, 20.0, 20.0, Color::gray(0.0))).clone(); + a.appearance = Appearance::basic(grad, Paint::None, 0.0).into(); + vec![Arc::new(a), key_square(doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))] + })), + ), + ( + "63 keys", + Box::new(with_keys(|doc| { + (0..63).map(|i| key_square(doc, f64::from(i) * 6.0, 20.0, 2.0, Color::gray(f32::from(i as u8) / 63.0))).collect() + })), + ), + ("an effect of its own", Box::new(move |doc: &mut Document| with_own(live(doc), |n| n.appearance.effects.push(drop_shadow())))), + ( + "a fill of its own", + Box::new(move |doc: &mut Document| { + with_own(live(doc), |n| n.appearance.items.push(AppearanceItem::Fill(FillLayer::new(solid(Color::rgb(0.0, 1.0, 0.0)))))) + }), + ), + ( + "key with Offset Path", + Box::new(with_keys(|doc| changed_key(doc, |a| a.appearance.effects.push(fx("path.offsetPath", serde_json::json!({"offset": 3})))))), + ), + ( + "key with Roughen", + Box::new(with_keys(|doc| changed_key(doc, |a| a.appearance.effects.push(fx("distort.roughen", serde_json::json!({})))))), + ), + ("key with a drop shadow", Box::new(with_keys(|doc| changed_key(doc, |a| a.appearance.effects.push(drop_shadow()))))), + ( + "key in a Lab color", + Box::new(with_keys(|doc| { + changed_key(doc, |a| a.appearance = Appearance::basic(solid(Color::Lab { l: 50.0, a: 60.0, b: -40.0 }), Paint::None, 0.0).into()) + })), + ), + ( + // The other key's stroke of no paint is left out, so the steps' strokes would blend from + // none. + "stroked key against a key with a stroke left out", + Box::new(with_keys(|doc| { + changed_key(doc, |a| a.appearance = Appearance::basic(solid(Color::rgb(1.0, 0.0, 0.0)), solid(Color::BLACK), 10.0).into()) + })), + ), + ( + // The reader reads at most 64 dash lengths; with more the stroke opens solid. + "key with a dash of 65 lengths", + Box::new(with_keys(|doc| { + let stroked = |dash: Option| { + move |a: &mut Node| { + let mut look = Appearance::basic(solid(Color::rgb(1.0, 0.0, 0.0)), solid(Color::BLACK), 2.0); + if let Some(AppearanceItem::Stroke(s)) = look.items.get_mut(1) { + s.dash = dash; + } + a.appearance = look.into(); + } + }; + let mut keys = changed_key(doc, stroked(Some(Dash { pattern: vec![2.0; 65], offset: 0.0, align_corners: false }))); + let mut b = (*keys[1]).clone(); + stroked(None)(&mut b); + keys[1] = Arc::new(b); + keys + })), + ), + ( + "key with a fill of no paint against a filled key", + Box::new(with_keys(|doc| changed_key(doc, |a| a.appearance = Appearance::basic(Paint::None, Paint::None, 0.0).into()))), + ), + ( + "key with an opacity mask", + Box::new(with_keys(|doc| { + let art = (*key_square(doc, 0.0, 0.0, 200.0, Color::gray(1.0))).clone(); + changed_key(doc, move |a| { + a.extras_mut().mask = + Some(Box::new(OpacityMask { art: Arc::new(art), clip: false, invert: false, disabled: false, linked: true })) + }) + })), + ), + ( + "key fill at half opacity", + Box::new(with_keys(|doc| { + changed_key(doc, |a| { + if let Some(AppearanceItem::Fill(f)) = a.appearance.items.first_mut() { + f.opacity = 0.5; + } + }) + })), + ), + ( + "key fill in Multiply", + Box::new(with_keys(|doc| { + changed_key(doc, |a| { + if let Some(AppearanceItem::Fill(f)) = a.appearance.items.first_mut() { + f.blend = BlendMode::Multiply; + } + }) + })), + ), + ( + "key stroke under its fill", + Box::new(with_keys(|doc| { + changed_key(doc, |a| { + a.appearance.items.retain(|i| matches!(i, AppearanceItem::Fill(_))); + a.appearance.items.insert(0, AppearanceItem::Stroke(StrokeLayer::new(solid(Color::BLACK), 2.0))); + }) + })), + ), + ( + "group key with a fill of its own", + Box::new(with_keys(|doc| { + let mut g = Node::group(doc.alloc_id(), vec![key_square(doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0))]); + g.appearance.items.push(AppearanceItem::Fill(FillLayer::new(solid(Color::rgb(0.0, 1.0, 0.0))))); + let h = Node::group(doc.alloc_id(), vec![key_square(doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))]); + vec![Arc::new(g), Arc::new(h)] + })), + ), + ( + "compound shape key", + Box::new(with_keys(|doc| { + let members = + vec![key_square(doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0)), key_square(doc, 30.0, 30.0, 20.0, Color::rgb(1.0, 0.0, 0.0))]; + let mut g = Node::group(doc.alloc_id(), members); + g.extras_mut().compound_shape = true; + vec![Arc::new(g), key_square(doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))] + })), + ), + ( + "group key holding an empty path", + Box::new(with_keys(|doc| { + let empty = Node::path(doc.alloc_id(), PathData::default(), Appearance::basic(solid(Color::rgb(1.0, 0.0, 0.0)), Paint::None, 0.0)); + let g = Node::group(doc.alloc_id(), vec![key_square(doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0)), Arc::new(empty)]); + let h = Node::group( + doc.alloc_id(), + vec![ + key_square(doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0)), + key_square(doc, 150.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0)), + ], + ); + vec![Arc::new(g), Arc::new(h)] + })), + ), + ( + "path key of two subpaths", + Box::new(with_keys(|doc| { + let mut ring = shapes::rectangle(Rect::new(20.0, 20.0, 40.0, 40.0)); + ring.subpaths.extend(shapes::rectangle(Rect::new(25.0, 25.0, 35.0, 35.0)).subpaths); + let a = Node::path(doc.alloc_id(), ring, Appearance::basic(solid(Color::rgb(1.0, 0.0, 0.0)), Paint::None, 0.0)); + let mut ring = shapes::rectangle(Rect::new(120.0, 20.0, 140.0, 40.0)); + ring.subpaths.extend(shapes::rectangle(Rect::new(125.0, 25.0, 135.0, 35.0)).subpaths); + let b = Node::path(doc.alloc_id(), ring, Appearance::basic(solid(Color::rgb(0.0, 0.0, 1.0)), Paint::None, 0.0)); + vec![Arc::new(a), Arc::new(b)] + })), + ), + ( + "compound path key with a member of two subpaths", + Box::new(with_keys(|doc| { + let mut two = shapes::rectangle(Rect::new(20.0, 20.0, 40.0, 40.0)); + two.subpaths.extend(shapes::rectangle(Rect::new(25.0, 25.0, 35.0, 35.0)).subpaths); + let paint = || Appearance::basic(solid(Color::rgb(1.0, 0.0, 0.0)), Paint::None, 0.0); + let a = Node::path(doc.alloc_id(), two, paint()); + let b = Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(45.0, 20.0, 50.0, 25.0)), paint()); + let mut c = Node::new(doc.alloc_id(), NodeKind::Compound { children: vec![Arc::new(a), Arc::new(b)], rule: FillRule::EvenOdd }); + c.appearance = paint().into(); + vec![Arc::new(c), key_square(doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))] + })), + ), + ( + "clipping group key", + Box::new(with_keys(|doc| { + let clip = Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(20.0, 20.0, 40.0, 40.0)), Appearance::default()); + let inside = key_square(doc, 15.0, 15.0, 30.0, Color::rgb(1.0, 0.0, 0.0)); + let g = Node::new(doc.alloc_id(), NodeKind::Group { children: vec![Arc::new(clip), inside], clip: true }); + vec![Arc::new(g), key_square(doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))] + })), + ), + ( + "a spine of two parts", + Box::new(move |doc: &mut Document| { + let mut n = live(doc); + if let NodeKind::Blend { spec, .. } = &mut n.kind { + let mut spine = spine_through(&[20.0, 120.0], 20.0); + let (p, q) = (vectorcraft_geom::Point::new(0.0, 100.0), vectorcraft_geom::Point::new(50.0, 150.0)); + spine.subpaths.push(vectorcraft_geom::SubPath::polyline(&[p, q], false)); + (spec.spine, spec.key_anchors) = (Some(spine), vec![0, 1]); + } + n + }), + ), + ( + "Smooth Color of one color, four and a half key widths apart", + Box::new(move |doc: &mut Document| { + let keys = + vec![key_square(doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0)), key_square(doc, 110.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0))]; + blend_of(doc, keys, BlendSpec { spacing: BlendSpacing::SmoothColor, ..BlendSpec::default() }) + }), + ), + ( + "live", + Box::new(move |doc: &mut Document| { + let keys = + vec![key_square(doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0)), key_square(doc, 120.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0))]; + blend_of(doc, keys, BlendSpec { spacing: BlendSpacing::SmoothColor, ..BlendSpec::default() }) + }), + ), + ( + "Specified Distance of two and a half steps", + Box::new(move |doc: &mut Document| { + let keys = + vec![key_square(doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0)), key_square(doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))]; + blend_of(doc, keys, BlendSpec { spacing: BlendSpacing::Distance(40.0), ..BlendSpec::default() }) + }), + ), + ( + "Specified Distance 0.03 pt past two and a half steps on a spine of 200 segments", + Box::new(move |doc: &mut Document| distance_on_segments(doc, 200)), + ), + ("live", Box::new(move |doc: &mut Document| distance_on_segments(doc, 2))), + ]; + /// Red to blue squares whose centers are 100.03 pt apart, on a straight spine of `segments` + /// equal segments between them, in Specified Distance of 40 pt. + fn distance_on_segments(doc: &mut Document, segments: u32) -> Node { + let keys = vec![key_square(doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0)), key_square(doc, 120.03, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))]; + let points: Vec = + (0..=segments).map(|i| vectorcraft_geom::Point::new(30.0 + 100.03 * f64::from(i) / f64::from(segments), 30.0)).collect(); + let spine = PathData::single(vectorcraft_geom::SubPath::polyline(&points, false)); + let spec = BlendSpec { spacing: BlendSpacing::Distance(40.0), spine: Some(spine), key_anchors: vec![0, segments], ..BlendSpec::default() }; + blend_of(doc, keys, spec) + } + // Every case runs, and the cases that fail are listed together. + let failed: Vec<&str> = cases + .into_iter() + .filter(|(what, make)| std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| written_as_steps(what, make))).is_err()) + .map(|(what, _)| what) + .collect(); + assert!(failed.is_empty(), "failed: {failed:?}"); +} + +/// The blend `make` makes, alone on a layer: written live when `what` is "live", else written as its +/// steps with a warning, as many as the PDF part draws, each where it draws it. +fn written_as_steps(what: &str, make: &dyn Fn(&mut Document) -> Node) { + let mut doc = Document::new(400.0, 200.0); + let n = make(&mut doc); + let id = n.id; + let layer = doc.layers[0].id; + doc.insert(Some(layer), usize::MAX, n).unwrap(); + let out = export_ai_editing(&doc, &opts()).unwrap(); + let first = read_back(&doc).layers[0].children().unwrap()[0].clone(); + if what == "live" { + assert!(!out.warnings.iter().any(|w| w == writer::BLENDS), "{what}: {:?}", out.warnings); + assert!(matches!(first.kind, NodeKind::Blend { .. }), "{what}: {:?}", first.kind); + return; + } + assert!(out.warnings.iter().any(|w| w == writer::BLENDS), "{what}: {:?}", out.warnings); + assert!(matches!(first.kind, NodeKind::Group { .. }), "{what}: its steps, as a group: {:?}", first.kind); + assert!(!program(&doc).contains("ShapeBlendPathType"), "{what}"); + // The steps the PDF part draws: the blend as baking left it, laid out. + let baked = vectorcraft_effects::bake_document(&doc).unwrap_or_else(|| doc.clone()); + let blend = baked.layers[0].children().unwrap()[0].clone(); + assert_eq!(blend.id, id, "{what}"); + let steps = vectorcraft_effects::expand_live_deep(Some(&baked), &blend); + let want: Vec = steps.children().unwrap().iter().map(|s| (**s).clone()).collect(); + let got: Vec = first.children().unwrap().iter().map(|s| (**s).clone()).collect(); + // As many, each where the PDF part draws it (strokes written as outlines may move a step's + // bounds by up to half their width). + assert_eq!(got.len(), want.len(), "{what}: how many steps"); + let center = |n: &Node| n.geometric_bounds().map(|b| b.center()).unwrap(); + for (i, (g, w)) in got.iter().zip(&want).enumerate() { + assert!((center(g) - center(w)).hypot() <= 2.5, "{what}, step {i}: {:?} for {:?}", center(g), center(w)); + } +} + +/// `n` changed by `change`. +fn with_own(mut n: Node, change: impl FnOnce(&mut Node)) -> Node { + change(&mut n); + n +} + +/// Two keys, red and blue squares, the red one changed by `change`. +fn changed_key(doc: &mut Document, change: impl FnOnce(&mut Node)) -> Vec> { + let mut a = (*key_square(doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0))).clone(); + change(&mut a); + vec![Arc::new(a), key_square(doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))] +} + +/// A document with `blend` (two squares, three steps) in a context the reader doesn't read a blend +/// in, or one the writer writes as hidden lines. +fn blend_in_context(context: &str) -> Document { + let mut doc = Document::new(400.0, 200.0); + let layer = doc.layers[0].id; + let blend = |doc: &mut Document, x: f64| { + let keys = vec![key_square(doc, x, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0)), key_square(doc, x + 100.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))]; + blend_of(doc, keys, BlendSpec { spacing: BlendSpacing::Steps(3), ..BlendSpec::default() }) + }; + let square_with = |doc: &mut Document, fill: Paint| { + Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(20.0, 100.0, 180.0, 180.0)), Appearance::basic(fill, Paint::None, 0.0)) + }; + let n = match context { + "pattern tile" => { + let b = blend(&mut doc, 0.0); + doc.patterns.push(vectorcraft_doc::PatternDef { + tile: Rect::new(0.0, 0.0, 150.0, 60.0), + ..vectorcraft_doc::PatternDef::new("Fades", vec![Arc::new(b)]) + }); + square_with(&mut doc, Paint::Pattern { pattern: "Fades".into(), xf: Affine::IDENTITY }) + } + "opacity mask" => { + let b = blend(&mut doc, 20.0); + let mut n = square_with(&mut doc, solid(Color::BLACK)); + n.extras_mut().mask = Some(Box::new(OpacityMask { art: Arc::new(b), clip: false, invert: false, disabled: false, linked: true })); + n + } + "symbol" => { + let b = blend(&mut doc, 0.0); + doc.symbols.push(Symbol { dynamic: false, name: "Fade".into(), art: Arc::new(b) }); + instance(&mut doc, "Fade", Affine::translate((20.0, 20.0))) + } + "art cut to a clipping object" => { + let clipper = Node::group(doc.alloc_id(), vec![Arc::new(square_with(&mut doc, Paint::None))]); + let b = blend(&mut doc, 20.0); + Node::new(doc.alloc_id(), NodeKind::Group { children: vec![Arc::new(clipper), Arc::new(b)], clip: true }) + } + // Eight symbols' art inside each other, each instance written as its art (isolated): the + // blend is written eight levels down. + "eight levels down" => { + let b = blend(&mut doc, 0.0); + doc.symbols.push(Symbol { dynamic: false, name: "S0".into(), art: Arc::new(b) }); + for i in 1..8 { + let mut inner = instance(&mut doc, &format!("S{}", i - 1), Affine::IDENTITY); + inner.isolate = true; + doc.symbols.push(Symbol { dynamic: false, name: format!("S{i}"), art: Arc::new(inner) }); + } + let mut top = instance(&mut doc, "S7", Affine::translate((20.0, 20.0))); + top.isolate = true; + top + } + _ => panic!("{context}"), + }; + doc.insert(Some(layer), usize::MAX, n).unwrap(); + doc +} + +/// Blends in pattern tiles, opacity masks and symbols (written as hidden lines or in a symbol's +/// definition), in art cut to a clipping object and eight levels down in art written in place of +/// symbol instances are written as their steps, with a warning. +#[test] +fn blends_in_other_art_are_written_as_their_steps() { + let live = |context: &str| { + let doc = blend_in_context(context); + let out = export_ai_editing(&doc, &opts()).unwrap(); + !out.warnings.iter().any(|w| w == writer::BLENDS) || program(&doc).contains("ShapeBlendPathType") + }; + let contexts = ["pattern tile", "opacity mask", "symbol", "art cut to a clipping object", "eight levels down"]; + let failed: Vec<&str> = contexts.into_iter().filter(|c| live(c)).collect(); + assert!(failed.is_empty(), "written live: {failed:?}"); +} + +/// Blends past what the reader lays out in one file (50,000 objects, each blend counted twice) are +/// written as their steps, with a warning; the blends before them are written live. +#[test] +fn blends_past_the_readers_budget_are_written_as_their_steps() { + let mut doc = Document::new(400.0, 400.0); + let layer = doc.layers[0].id; + // Three keys and 2,003 objects each: twelve take 48,072 and the thirteenth would pass 50,000. + for i in 0..13 { + let y = f64::from(i) * 25.0; + let keys = vec![ + key_square(&mut doc, 20.0, y, 10.0, Color::rgb(1.0, 0.0, 0.0)), + key_square(&mut doc, 120.0, y, 10.0, Color::rgb(0.0, 0.0, 1.0)), + key_square(&mut doc, 220.0, y, 10.0, Color::rgb(0.0, 1.0, 0.0)), + ]; + let n = blend_of(&mut doc, keys, BlendSpec { spacing: BlendSpacing::Steps(1000), ..BlendSpec::default() }); + doc.insert(Some(layer), usize::MAX, n).unwrap(); + } + let out = export_ai_editing(&doc, &opts()).unwrap(); + assert!(out.warnings.iter().any(|w| w == writer::BLENDS), "{:?}", out.warnings); + let back = read_back(&doc); + let art = back.layers[0].children().unwrap(); + let live: Vec = art.iter().map(|n| matches!(n.kind, NodeKind::Blend { .. })).collect(); + assert_eq!(live, [vec![true; 12], vec![false]].concat()); +} + +/// On a large canvas every blend is written as its steps, with a warning. +#[test] +fn a_large_canvas_writes_blends_as_their_steps() { + let mut doc = Document::new(20000.0, 100.0); + let keys = + vec![key_square(&mut doc, 20.0, 20.0, 20.0, Color::rgb(1.0, 0.0, 0.0)), key_square(&mut doc, 120.0, 20.0, 20.0, Color::rgb(0.0, 0.0, 1.0))]; + let n = blend_of(&mut doc, keys, BlendSpec { spacing: BlendSpacing::Steps(3), ..BlendSpec::default() }); + let layer = doc.layers[0].id; + doc.insert(Some(layer), usize::MAX, n).unwrap(); + let out = export_ai_editing(&doc, &opts()).unwrap(); + assert!(out.warnings.iter().any(|w| w == writer::BLENDS), "{:?}", out.warnings); + assert!(matches!(read_back(&doc).layers[0].children().unwrap()[0].kind, NodeKind::Group { .. })); +} diff --git a/crates/eps/src/ai_editing/writer.rs b/crates/eps/src/ai_editing/writer.rs index 38f5b0fe64..35925a3962 100644 --- a/crates/eps/src/ai_editing/writer.rs +++ b/crates/eps/src/ai_editing/writer.rs @@ -15,6 +15,7 @@ use vectorcraft_pathops::BoolOp; use crate::ai_ops::{self, unit}; use crate::ps; +mod blends; mod brushes; mod envelopes; mod images; @@ -24,6 +25,9 @@ mod symbols; mod texts; mod variables; +#[cfg(test)] +pub(super) use blends::BLENDS; +pub(super) use blends::unbaked_blends; #[cfg(test)] pub(super) use brushes::BRUSHES; #[cfg(test)] @@ -58,7 +62,7 @@ pub(super) const PATTERN_TILES: &str = "pattern fills with more tiles than a fil pub(super) const CLIPPING: &str = "clipping groups and clipping layers whose clipping object isn't a path, and the clipping groups inside them, are written as their art cut to that object in the editing data for other apps"; pub(super) const CLIP_PAINT: &str = "the fills and strokes of clipping paths that a plain fill and line can't draw are written as paths of their own inside the clipping (fills under the clipped art, strokes over it) in the editing data for other apps"; pub(super) const CLIP_PAINT_MASKS: &str = "the opacity masks of clipping paths whose fills and strokes are written as paths of their own stay on the clipping path, not on those paths, in the editing data for other apps"; -pub(super) const LIVE: &str = "blends, meshes, repeats, placed documents and intertwines are written as their art in the editing data for other apps"; +pub(super) const LIVE: &str = "meshes, repeats, placed documents and intertwines are written as their art in the editing data for other apps"; pub(super) const GRAPHS: &str = "graphs are written as their art, without their data or settings, in the editing data for other apps"; pub(super) const STROKES: &str = "strokes a plain line can't draw (inside or outside the path, variable width, dots, dashes fitted to corners, gradients, patterns, arrowheads) are written as filled outlines, and brushed strokes as their brush's art, in the editing data for other apps"; pub(super) const ITEM_TRANSPARENCY: &str = @@ -328,6 +332,14 @@ pub(super) struct Writer<'a> { series_tag: Option, /// Where the `Go` lines of the graph being written start in [`Self::body`]. graph_tags: Vec, + /// Blends may be written live; false on a large canvas, where they are written as their steps. + pub(super) blends_live: bool, + /// How many more objects the reader's blends may lay out ([`crate::import::BLEND_BUDGET`]). + blend_budget: usize, + /// The entries naming a blend's key object in its dictionary, and the key's id. + blend_role: Option<(NodeId, String)>, + /// The blends baking left as they are ([`blends::unbaked_blends`]); only these are written live. + pub(super) unbaked_blends: HashSet, } impl<'a> Writer<'a> { @@ -410,6 +422,10 @@ impl<'a> Writer<'a> { in_graph: false, series_tag: None, graph_tags: vec![], + blends_live: true, + blend_budget: crate::import::BLEND_BUDGET, + blend_role: None, + unbaked_blends: HashSet::new(), } } @@ -840,7 +856,9 @@ impl<'a> Writer<'a> { } NodeKind::Envelope { .. } if self.envelope(n, xy) => {} NodeKind::Envelope { .. } => self.drawn_art(n, xy, Some(envelopes::ENVELOPES), true), - NodeKind::Blend { .. } | NodeKind::Mesh(_) | NodeKind::Repeat(_) | NodeKind::PlacedDocument(_) | NodeKind::Intertwine { .. } => { + NodeKind::Blend { .. } if self.blend(n, xy) => {} + NodeKind::Blend { .. } => self.drawn_art(n, xy, Some(blends::BLENDS), true), + NodeKind::Mesh(_) | NodeKind::Repeat(_) | NodeKind::PlacedDocument(_) | NodeKind::Intertwine { .. } => { self.drawn_art(n, xy, Some(LIVE), true); } // Ruler guides are kept in the document's native copy only. @@ -955,9 +973,10 @@ impl<'a> Writer<'a> { /// `n`'s `/ArtDictionary`, after it, when it has a name (`AI10_ArtUID`, see [`Self::take_id`]), /// is bound to variables ([`Self::bound_variables`]; without a name, it gets an XML id and an /// empty `AIArtName`), has text wrap options ([`Self::text_wrap`]), has an opacity mask - /// (`AI9_Mask`, see [`Self::mask`]), or is a symbol's art (its symbol's entries first, see - /// [`Self::define_symbol`]). False when `n` has an opacity mask that is left out: nested too - /// deep, or its art doesn't fit. + /// (`AI9_Mask`, see [`Self::mask`]), is a symbol's art (its symbol's entries first, see + /// [`Self::define_symbol`]), or is a blend's key object (its part and id after the name, see + /// [`blends`]). False when `n` has an opacity mask that is left out: nested too deep, or its art + /// doesn't fit. fn dictionary(&mut self, n: &Node) -> bool { let name = n.name.as_deref().filter(|s| !s.is_empty()); let moved = std::mem::take(&mut self.wrap_moved); @@ -977,7 +996,11 @@ impl<'a> Writer<'a> { Some((id, _)) if *id == n.id => self.root_entries.take().map(|(_, e)| e), _ => None, }; - if name.is_none() && mask.is_none() && bound.is_empty() && entries.is_none() && wrap.is_none() { + let role = match &self.blend_role { + Some((id, _)) if *id == n.id => self.blend_role.take().map(|(_, e)| e), + _ => None, + }; + if name.is_none() && mask.is_none() && bound.is_empty() && entries.is_none() && wrap.is_none() && role.is_none() { return mask_written; } let start = self.body.len(); @@ -998,6 +1021,10 @@ impl<'a> Writer<'a> { self.bound.push((n.id, id, bound)); } } + let has_role = role.is_some(); + if let Some(r) = role { + self.body.push_str(&r); + } if let Some(w) = wrap { self.text_wrap(w); } @@ -1005,7 +1032,7 @@ impl<'a> Writer<'a> { if let Some(m) = mask && !self.mask(m) { - if !has_id && !has_entries && wrap.is_none() { + if !has_id && !has_entries && wrap.is_none() && !has_role { self.body.truncate(start); return false; } diff --git a/crates/eps/src/ai_editing/writer/blends.rs b/crates/eps/src/ai_editing/writer/blends.rs new file mode 100644 index 0000000000..b73749b214 --- /dev/null +++ b/crates/eps/src/ai_editing/writer/blends.rs @@ -0,0 +1,372 @@ +//! Blends: a live blend as the `.ai` reader reads one ([`crate::import`]'s `.ai` reader, `blend.rs` +//! and `read/containers.rs`' `end_blend`). +//! +//! The blend's own art on `%_` lines: `0 Ae`, a group of its key objects, each with an +//! `/ArtDictionary` naming it a key (`ShapeBlendPathType` `K`) and its id (`ShapeBlendPathID`, a +//! letter or digit), and its spine as an unpainted path named the spine (`S`), written only when the +//! blend has a spine of its own; then its steps drawn, a group on plain lines; then `0 Ae`, +//! the `XP` line of the blend plugin ([`BLEND_PLUGIN`], `1 0 n XP`) and the blend's record, `n` bytes +//! as hex on `%` lines; then the blend's name in an `/ArtDictionary` and its transparency, as a +//! group's after its end. The record +//! is `DCBA` and little-endian 32-bit words: 1, the spacing (0 Smooth Color, 1 Specified Steps, 2 +//! Specified Distance); 2, the distance as a float (Specified Steps: the spine's length shared out +//! between the steps; Smooth Color: 4); 4, the steps between the first two keys; 5, the orientation +//! (0 Align to Page, a float of 8 and the spine's starting angle in radians for Align to Path); 6, +//! the next free id (0 after the 62nd); 9, 1; 10, the number of keys; then six words a key: its id, +//! 0, the anchor of the spine it sits on as a float, two words of all ones, and the steps between +//! it and the key before it. The reader reads words 1, 2 (for Specified Distance), 5 (0, or 8 or +//! more), 10 and the keys' ids; the others are written as the record's form has them. +//! +//! Each blend is checked with the reader's own reading ([`crate::import::blend_reads`]) before it is +//! written: one the reader would read with other settings is written as its steps. + +use std::collections::HashSet; +use std::fmt::Write; +use std::sync::Arc; + +use vectorcraft_color::{BlendMode, Color, Paint}; +use vectorcraft_doc::blend::{blend_spine, blend_steps, blend_steps_settled, pin_spine}; +use vectorcraft_doc::live::{BlendOrientation, BlendSpacing, BlendSpec}; +use vectorcraft_doc::{AppearanceItem, Document, Node, NodeId, NodeKind, StrokeLayer}; +use vectorcraft_geom::{FillRule, PathData}; + +use super::{MAX_NEST, Writer, Xy, hide}; +use crate::import::{BLEND_PLUGIN, MAX_BLEND_KEYS, MAX_BLEND_OBJECTS, blend_reads}; + +pub(in crate::ai_editing) const BLENDS: &str = "blends with easing, a color shift or start points of their own, blends with effects, an appearance or an opacity mask of their own, blends of objects other than paths, compound paths and groups, of clipping groups, of more than 62 key objects, of hidden key objects, of key objects that hold a blend, of key objects with geometry or Pathfinder effects or a group's own fills and strokes, or of key objects the editing copy would change (empty paths or subpaths, paths and compound path members of several subpaths, several fills or strokes, strokes a plain line can't draw, dashes of more than 64 lengths, hidden fills or strokes, fills or strokes other than a color, in a Lab color or with transparency or effects of their own, effects or opacity masks), blends where one key object has a fill or stroke of no paint or a stroke of no width and another has one that draws, blends inside objects with geometry or Pathfinder effects or a group's own fills and strokes, blends whose spine has more than one part, blends whose step count is close to where rounding changes it, blends that would open with other settings or not as they are drawn, blends in opacity masks, pattern tiles, symbols and art cut to a clipping object or nested eight levels deep in art written in place of other objects (symbol instances, live objects, brushed strokes), blends whose art would pass the most objects the reader reads, and every blend on a large canvas are written as their steps in the editing data for other apps"; + +/// How far (pt) the lengths a blend counts its steps from may move when written (coordinates are +/// written to 4 decimals and read back through art space) without changing a count. +const SETTLE_LENGTH: f64 = 0.01; +/// How far (pt) each segment of a spine may add to [`SETTLE_LENGTH`]: rounding moves each of its +/// points by up to 0.00005 √2 pt, which moves the segment's length by up to six times that. +const SETTLE_SEGMENT: f64 = 5e-4; +/// How far a key's color (each channel, 0 to 1) may move when written without changing a Smooth +/// Color count. +const SETTLE_COLOR: f64 = 0.001; + +/// The most dash lengths the reader reads; a stroke with more opens solid. +const MAX_DASH_LENGTHS: usize = 64; + +/// The ids the keys take, in their order (letters and digits, as the reader reads them). +const IDS: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + +/// Hex digits on one `%` line of a record. +const HEX_LINE: usize = 60; + +/// A blend to write live. +pub(super) struct LiveBlend { + keys: Vec>, + ids: Vec, + /// Its spine part; `None`: the blend has no spine of its own. + spine: Option, + record: Vec, + steps: Vec>, +} + +impl Writer<'_> { + /// Blend `n` as the reader reads it live, or `None` when it would read other settings or none + /// (the blend is then written as its steps). + pub(super) fn live_blend(&mut self, n: &Node) -> Option { + let NodeKind::Blend { children: keys, spec } = &n.kind else { return None }; + // Hidden lines (pattern tiles, opacity masks), symbols' definitions and art cut to a + // clipping object aren't read as live blends. (No blend is drawn in a look: styled objects + // hold only paths, compound paths and groups of them.) + if !self.blends_live || self.hidden > 0 || self.in_symbol || self.clip.is_some() || self.nest >= MAX_NEST { + return None; + } + // Baking changes its keys, or the art it sits in ([`unbaked_blends`]). + if !self.unbaked_blends.contains(&n.id) { + return None; + } + if !spec.ease.is_default() || spec.color_shift != 0.0 || !spec.starts.is_empty() { + return None; + } + let own = &n.appearance; + if !own.items.is_empty() || !own.effects.is_empty() || n.extras().mask.is_some() { + return None; + } + // The reader shows every key object it reads. + if keys.len() < 2 || keys.len() > IDS.len().min(MAX_BLEND_KEYS) || !keys.iter().all(|k| k.visible && plain_key(k)) { + return None; + } + // A fill or stroke the editing copy leaves out is read back as none at all, and the steps + // blend from it to another key's otherwise. + if left_out_against_drawn(keys) { + return None; + } + // The spine written: a replaced spine (no key anchors) with an anchor where each key sits, a + // spine edited on the canvas with its keys' anchors moved onto them. + let spec: &BlendSpec = spec; + // The blend lays out along the spine's first subpath, and only that part is written: a + // spine of more parts would open without the others. + if spec.spine.as_ref().is_some_and(|s| s.subpaths.len() > 1) { + return None; + } + let written = match &spec.spine { + None => BlendSpec { key_anchors: vec![], ..spec.clone() }, + Some(_) if spec.key_anchors.is_empty() => { + let (path, anchors) = pin_spine(keys, spec)?; + let anchors = anchors.into_iter().map(u32::try_from).collect::, _>>().ok()?; + BlendSpec { spine: Some(path), key_anchors: anchors, ..spec.clone() } + } + Some(_) => BlendSpec { spine: Some(blend_spine(keys, spec)?.0), ..spec.clone() }, + }; + // The record holds Specified Distance as a 32-bit float, which the reader reads back as its + // shortest decimal (10 mm comes back as 28.346457 pt): the blend is compared with that + // distance, and kept live only when it lays out as many steps with it. + let written = match written.spacing { + BlendSpacing::Distance(d) => { + let read: f64 = (d as f32).to_string().parse().ok().filter(|r: &f64| r.is_finite() && *r > 0.0)?; + let stored = BlendSpec { spacing: BlendSpacing::Distance(read), ..written.clone() }; + if blend_steps(keys, &stored) != blend_steps(keys, &written) { + return None; + } + stored + } + _ => written, + }; + // As many objects as the reader lays out for one blend, twice within what its budget has left, + // counted before the steps are drawn. + let objects = blend_steps(keys, &written).into_iter().fold(keys.len(), usize::saturating_add); + if objects > MAX_BLEND_OBJECTS || objects.saturating_mul(2) > self.blend_budget { + return None; + } + // The reader counts the steps from the keys as written, rounded: a count that rounding can + // change may come back other than drawn. Specified Distance counts from the spine's length, + // and every segment of the spine adds to how far that may move. + let segments = written.spine.as_ref().and_then(|s| s.subpaths.first()).map_or(0, |s| s.segment_count()); + let settle = match written.spacing { + BlendSpacing::Distance(_) => SETTLE_LENGTH + segments as f64 * SETTLE_SEGMENT, + _ => SETTLE_LENGTH, + }; + if !blend_steps_settled(keys, &written, settle, SETTLE_COLOR) { + return None; + } + let ids: Vec = IDS.iter().take(keys.len()).map(|c| char::from(*c).to_string()).collect(); + let record = self.record(keys, &written)?; + let steps: Vec> = vectorcraft_effects::expand_live_deep(Some(self.doc), n).children().cloned().unwrap_or_default(); + let drawn: Vec = steps.iter().map(|s| (**s).clone()).collect(); + // The spine part as written: the first subpath of the spine laid out. + let part = written.spine.as_ref().and_then(|s| s.subpaths.first()).map(|sp| PathData::single(sp.clone())); + let mut budget = self.blend_budget; + let read = blend_reads(keys, &ids, part.as_ref(), &record, &drawn, &mut budget)?; + if read != written { + return None; + } + self.blend_budget = budget; + Some(LiveBlend { keys: keys.clone(), ids, spine: part, record, steps }) + } + + /// The record of a blend of `keys` with the settings `spec` (its spine as written). + fn record(&self, keys: &[Arc], spec: &BlendSpec) -> Option> { + let (spine, anchors) = blend_spine(keys, spec)?; + let steps = blend_steps(keys, spec); + let first = u32::try_from(*steps.first()?).ok()?; + let (spacing, value) = match spec.spacing { + BlendSpacing::SmoothColor => (0, 4.0), + BlendSpacing::Steps(n) => (1, spine.length() / (f64::from(n) + 1.0)), + BlendSpacing::Distance(d) => (2, d), + }; + let orientation = match spec.orientation { + BlendOrientation::AlignToPage => 0.0, + BlendOrientation::AlignToPath => 8.0 + self.starting_angle(&spine)?, + }; + let count = u32::try_from(keys.len()).ok()?; + let next = IDS.get(keys.len()).copied().map_or(0, u32::from); + let mut words: Vec = vec![u32::from_le_bytes(*b"DCBA"), spacing, (value as f32).to_bits(), 0, first, (orientation as f32).to_bits()]; + words.extend([next, 0, 0, 1, count]); + for (i, id) in IDS.iter().take(keys.len()).enumerate() { + let anchor = anchors.as_ref().and_then(|a| a.get(i)).copied().unwrap_or(i); + let before = i.checked_sub(1).and_then(|j| steps.get(j)).copied().unwrap_or(0); + words.extend([u32::from(*id), 0, (anchor as f32).to_bits(), u32::MAX, u32::MAX, u32::try_from(before).ok()?]); + } + Some(words.iter().flat_map(|w| w.to_le_bytes()).collect()) + } + + /// The angle in art space (radians, from 0 to 2π) at which `spine` starts. + fn starting_angle(&self, spine: &PathData) -> Option { + let sp = spine.subpaths.first()?; + let first = sp.anchors.first()?; + let towards = if (first.h_out - first.p).hypot() > 1e-9 { first.h_out } else { sp.anchors.get(1)?.p }; + let (a, b) = (self.to_art * first.p, self.to_art * towards); + let angle = (b.y - a.y).atan2(b.x - a.x); + Some(if angle < 0.0 { angle + std::f64::consts::TAU } else { angle }) + } + + /// Blend `n`, of transparency `xy`, written live ([`Self::live_blend`]): its own art on `%_` + /// lines, its steps and its record, then the state block of its transparency, before which the + /// object's dictionary (its name, text wrap options and variables) goes. False, writing + /// nothing, when it is written as its steps: the reader would read it otherwise, or art in it + /// would be left out at the object limit ([`Self::take_objects`]). + pub(super) fn blend(&mut self, n: &Node, xy: Xy) -> bool { + let budget = self.blend_budget; + let Some(b) = self.live_blend(n) else { return false }; + let start = self.body.len(); + let (state, gs, charges, bound, warnings) = (self.state, self.gs, self.charges(), self.bound.len(), self.warnings.len()); + let outer = std::mem::take(&mut self.body); + self.hidden += 1; + self.line("0 Ae"); + let opened = self.open_group("u"); + if opened { + for (k, id) in b.keys.iter().zip(&b.ids) { + self.blend_role = Some((k.id, format!("%_(K) /String (ShapeBlendPathType) ,\n%_({id}) /String (ShapeBlendPathID) ,\n"))); + self.node(k); + self.blend_role = None; + } + if let Some(spine) = &b.spine { + self.plain_object(spine, FillRule::NonZero, None, None, Xy::OPAQUE); + self.body.push_str("%_/ArtDictionary :\n%_(S) /String (ShapeBlendPathType) ,\n%_;\n%_\n"); + } + self.line("U"); + self.line("9 () XW"); + } + self.hidden -= 1; + let part = std::mem::replace(&mut self.body, outer); + hide(&part, &mut self.body); + // Readers of the printed form skip the hidden lines: the steps set their own state. + (self.state, self.gs) = (None, None); + self.state(n.locked, !n.visible); + let steps = self.open_group("u"); + if steps { + // The steps are drawn art: copies of the keys carry no text wrap options of their own. + self.nest += 1; + self.drawn += 1; + for s in &b.steps { + self.node(s); + } + self.drawn -= 1; + self.nest -= 1; + self.state(n.locked, !n.visible); + self.line("U"); + self.line("9 () XW"); + } + if !opened || !steps || self.left_out_since(charges) { + let lines = self.body.split_off(start); + self.give_back(charges, &lines); + self.bound.truncate(bound); + // The warnings of art written as its steps again are those steps'. + if !self.left_out_since(charges) { + self.warnings.truncate(warnings); + } + (self.state, self.gs, self.block_end, self.blend_budget) = (state, gs, usize::MAX, budget); + return false; + } + self.line("0 Ae"); + let hex: String = b.record.iter().map(|x| format!("{x:02X}")).collect(); + let _ = writeln!(self.body, "({BLEND_PLUGIN}) 1 0 {} XP", b.record.len()); + for chunk in hex.as_bytes().chunks(HEX_LINE) { + self.body.push('%'); + self.body.push_str(&String::from_utf8_lossy(chunk)); + self.body.push('\n'); + } + // The blend's dictionary goes after the record and before this block ([`Self::node`]). + self.state_block(xy); + true + } +} + +/// The blends on `doc`'s layers that baking leaves as they are: blends with nothing in them that +/// [`vectorcraft_effects::needs_bake`] evaluates (geometry and Pathfinder effects, a group's own +/// fills and strokes), inside no object that has such things of its own. Baking changes the keys +/// of the others, so they are written as their steps. +pub(in crate::ai_editing) fn unbaked_blends(doc: &Document) -> HashSet { + fn walk(nodes: &[Arc], out: &mut HashSet) { + for n in nodes { + if matches!(n.kind, NodeKind::Blend { .. }) { + if !vectorcraft_effects::needs_bake(n) { + out.insert(n.id); + } + continue; + } + let Some(children) = n.children() else { continue }; + let mut own = (**n).clone(); + if let Some(c) = own.children_mut() { + c.clear(); + } + if !vectorcraft_effects::needs_bake(&own) { + walk(children, out); + } + } + } + let mut out = HashSet::new(); + walk(&doc.layers, &mut out); + out +} + +/// Does the reader read stroke `s`'s dashes back as they are (`read/ops.rs`' `d`): at most 64 +/// lengths, each finite and not negative, and a finite offset? It reads other dashes as a solid +/// line. +fn dash_read_back(s: &StrokeLayer) -> bool { + s.dash + .as_ref() + .is_none_or(|d| d.pattern.len() <= MAX_DASH_LENGTHS && d.pattern.iter().all(|v| v.is_finite() && *v >= 0.0) && d.offset.is_finite()) +} + +/// Do the keys hold a fill or stroke that the editing copy leaves out (a fill of no paint; a stroke +/// of no paint or of no width, as `visible_items` leaves them out) where another holds one of the +/// same kind that it writes? The steps blend the width, paint and settings of the one left out, and +/// the keys read back blend from no fill or stroke, so the steps would open otherwise. +fn left_out_against_drawn(keys: &[Arc]) -> bool { + // [fill, stroke]: is one left out somewhere, is one written somewhere. + let mut left_out = [false; 2]; + let mut drawn = [false; 2]; + for k in keys { + k.walk(&mut |n| { + for i in &n.appearance.items { + let (kind, out) = match i { + AppearanceItem::Fill(f) => (0, f.paint.is_none()), + AppearanceItem::Stroke(s) => (1, s.paint.is_none() || !(s.width > 0.0 && s.width.is_finite())), + }; + if out { + left_out[kind] = true; + } else { + drawn[kind] = true; + } + } + }); + } + (left_out[0] && drawn[0]) || (left_out[1] && drawn[1]) +} + +/// Can `k` be a key object written live, as the reader reads it back: paths, compound paths and +/// groups other than clipping groups (holding no blend), without effects or opacity masks, each with +/// at most one fill and one plain stroke over it (a line the data draws as it is), each fill and +/// stroke shown, in a color other than Lab or none, opaque in the normal blending mode? (A group's own fills and +/// strokes are baked into art of their own, and such blends aren't [`unbaked_blends`].) +fn plain_key(k: &Node) -> bool { + let mut plain = true; + k.walk(&mut |n| { + // A clipping group may be written as its art cut to the clipping object. + let kind = match &n.kind { + // The writer leaves out a path with nothing to draw and subpaths without anchors, and + // writes a path of several subpaths as a compound path. + NodeKind::Path { path, guide: false, .. } => matches!(path.subpaths.as_slice(), [one] if !one.anchors.is_empty()), + // A compound path is written as one path, and read back with a member for each + // subpath. + NodeKind::Compound { children, .. } => { + !children.is_empty() + && children.iter().all(|c| matches!(&c.kind, NodeKind::Path { path, guide: false, .. } if path.subpaths.len() == 1)) + } + NodeKind::Group { clip: false, .. } => true, + _ => false, + }; + let items = &n.appearance.items; + let fills = items.iter().filter(|i| matches!(i, AppearanceItem::Fill(_))).count(); + let strokes = items.iter().filter(|i| matches!(i, AppearanceItem::Stroke(_))).count(); + let order = !matches!(items.as_slice(), [AppearanceItem::Stroke(_), AppearanceItem::Fill(_)]); + let quiet = items.iter().all(|i| { + i.visible() + && matches!(i.paint(), Paint::Solid { .. } | Paint::None) + // A color that names no global or spot swatch is written in RGB, so a Lab color + // would come back as another. + && !matches!(i.paint(), Paint::Solid { color: Color::Lab { .. }, .. }) + && i.effects().is_empty() + && i.opacity() >= 1.0 + && i.blend() == BlendMode::Normal + && !matches!(i, AppearanceItem::Stroke(s) if !vectorcraft_effects::stroke::is_plain(s) || !dash_read_back(s)) + }); + plain &= kind && fills <= 1 && strokes <= 1 && order && quiet && n.appearance.effects.is_empty() && n.extras().mask.is_none(); + }); + plain +} diff --git a/crates/eps/src/import.rs b/crates/eps/src/import.rs index 259be45eac..fb43590b45 100644 --- a/crates/eps/src/import.rs +++ b/crates/eps/src/import.rs @@ -90,9 +90,10 @@ pub use ai::NameEncoding; #[cfg(test)] pub(crate) use ai::objects_read; pub(crate) use ai::{ - BRUSH_MANAGER, BrushesRead, DEFORM_PLUGIN, EnvelopeGridPoint, MAX_CHECKED as ENVELOPE_CHECKS, MAX_EDITING_OBJECTS, MAX_GRADIENT_STOPS, - MAX_LISTED, MAX_LISTED_NAME, MAX_SYMBOLS, brush_plugin_name, brushes_kept, envelope_outline, envelope_upright, read_art_style, read_brush_object, - read_style_list, style_moves_with, symbol_art_member, warp_number, + BLEND_BUDGET, BLEND_PLUGIN, BRUSH_MANAGER, BrushesRead, DEFORM_PLUGIN, EnvelopeGridPoint, MAX_BLEND_KEYS, MAX_BLEND_OBJECTS, + MAX_CHECKED as ENVELOPE_CHECKS, MAX_EDITING_OBJECTS, MAX_GRADIENT_STOPS, MAX_LISTED, MAX_LISTED_NAME, MAX_SYMBOLS, blend_reads, + brush_plugin_name, brushes_kept, envelope_outline, envelope_upright, read_art_style, read_brush_object, read_style_list, style_moves_with, + symbol_art_member, warp_number, }; #[cfg(test)] pub(crate) use ai::{ENVELOPE_DRAWN, ENVELOPE_TYPE_DRAWN}; diff --git a/crates/eps/src/import/ai.rs b/crates/eps/src/import/ai.rs index 6676428408..92847a96ef 100644 --- a/crates/eps/src/import/ai.rs +++ b/crates/eps/src/import/ai.rs @@ -34,6 +34,7 @@ use std::io::Read as _; use super::lex::find; use crate::ps; +pub(crate) use blend::{MAX_BLEND_OBJECTS, MAX_KEYS as MAX_BLEND_KEYS, PLUGIN as BLEND_PLUGIN, blend_reads}; pub(crate) use brush::{BrushesRead, MANAGER_NAME as BRUSH_MANAGER, brushes_kept, plugin_name as brush_plugin_name, read_brush_object}; pub(crate) use envelope::DRAWN as ENVELOPE_DRAWN; pub(crate) use envelope::MAX_CHECKED; @@ -52,14 +53,14 @@ pub(crate) use read::objects_read; pub use read::read; #[cfg(test)] pub(crate) use read::with_image_limits; +pub(crate) use read::{ + BLEND_BUDGET, MAX_NODES as MAX_EDITING_OBJECTS, MAX_SYMBOLS, join_and, read_art_style, read_over_page, read_program, read_style_list, slot_frame, + slot_of, style_moves_with, symbol_art_member, +}; pub use read::{ BindingRef, Brushes, PaletteSwatches, PlacedPage, Structure, Symbols, active_artboard, artboards, bindings_note, brushes, graphic_styles, palette, read_beside, read_in, symbols, variables, }; -pub(crate) use read::{ - MAX_NODES as MAX_EDITING_OBJECTS, MAX_SYMBOLS, join_and, read_art_style, read_over_page, read_program, read_style_list, slot_frame, slot_of, - style_moves_with, symbol_art_member, -}; pub(crate) use read::is_look_slot; pub(crate) use style::{MAX_LISTED, MAX_LISTED_NAME, warp_number}; diff --git a/crates/eps/src/import/ai/blend.rs b/crates/eps/src/import/ai/blend.rs index 530be2647d..d317164d3a 100644 --- a/crates/eps/src/import/ai/blend.rs +++ b/crates/eps/src/import/ai/blend.rs @@ -34,16 +34,16 @@ use vectorcraft_doc::{AppearanceItem, Node, NodeId, NodeKind}; use vectorcraft_geom::{ParamCurve, PathData, Point, SubPath}; /// The plugin that writes blends. -pub(super) const PLUGIN: &str = "Adobe Path Blends"; // brand-ok: the plugin name the files use +pub(crate) const PLUGIN: &str = "Adobe Path Blends"; // brand-ok: the plugin name the files use /// The most bytes of a blend's record read. pub(super) const MAX_RECORD: usize = 4096; /// The most keys read from one blend. -const MAX_KEYS: usize = 64; +pub(crate) const MAX_KEYS: usize = 64; /// The most steps between two keys (Blend Options' limit). const MAX_STEPS: usize = 1000; /// The most objects (keys and steps) one blend may lay out to be read live; more keep their /// drawn steps. -pub(super) const MAX_BLEND_OBJECTS: usize = 5_000; +pub(crate) const MAX_BLEND_OBJECTS: usize = 5_000; /// How far (pt) a step laid out here may be from where the file draws it. const PLACE_TOLERANCE: f64 = 0.5; /// How far a step's colour (each channel, 0 to 1) may be from the drawn one. @@ -227,6 +227,38 @@ pub(super) fn live_blend(edit: &Node, drawn: &Node, record: &Record, roles: &Rol .map(|(_, spec, _)| NodeKind::Blend { children: keys, spec: Box::new(spec.clone()) }) } +/// What the reader makes of a blend written as the key objects `keys`, named by `ids` in their +/// order, the spine `spine` (`None`: no spine part), the record `bytes` and the drawn steps `drawn`: +/// the live blend's settings, or `None` where it keeps the drawn steps. Takes from `budget` as +/// [`live_blend`] does. +pub(crate) fn blend_reads( + keys: &[Arc], + ids: &[String], + spine: Option<&PathData>, + bytes: &[u8], + drawn: &[Node], + budget: &mut usize, +) -> Option { + let record = record(bytes)?; + let mut roles = Roles::new(); + let mut parts: Vec> = Vec::with_capacity(keys.len() + 1); + for (k, id) in keys.iter().zip(ids) { + roles.insert(k.id, ("K".to_string(), Some(id.clone()))); + parts.push(k.clone()); + } + if let Some(s) = spine { + let id = NodeId(u64::MAX); + roles.insert(id, ("S".to_string(), None)); + parts.push(Arc::new(Node::path(id, s.clone(), Default::default()))); + } + let edit = Node::new(NodeId(u64::MAX - 1), NodeKind::Group { children: parts, clip: false }); + let drawn = Node::new(NodeId(u64::MAX - 2), NodeKind::Group { children: drawn.iter().cloned().map(Arc::new).collect(), clip: false }); + match live_blend(&edit, &drawn, &record, &roles, budget)? { + NodeKind::Blend { spec, .. } => Some(*spec), + _ => None, + } +} + /// The anchor of `spine`'s first subpath each key's centre sits on (within a point), each a /// different one. fn on_spine(keys: &[Arc], spine: &PathData) -> Option> { diff --git a/crates/eps/src/import/ai/read.rs b/crates/eps/src/import/ai/read.rs index 67928785ad..b045dd128f 100644 --- a/crates/eps/src/import/ai/read.rs +++ b/crates/eps/src/import/ai/read.rs @@ -156,9 +156,10 @@ use graph::Graph; pub(crate) use ops::{read_art_style, read_style_list, style_moves_with}; #[cfg(test)] pub(crate) use raster::with_image_limits; +pub(crate) use types::BLEND_BUDGET; pub(crate) use types::MAX_NODES; pub use types::PlacedPage; -use types::{BLEND_BUDGET, BrushArtColors, FLIP, Frame, GState, Kind, PatternHead, PendingEnvelope, Place, PlacedTail, Raster, SymbolHead}; +use types::{BrushArtColors, FLIP, Frame, GState, Kind, PatternHead, PendingEnvelope, Place, PlacedTail, Raster, SymbolHead}; #[cfg(test)] pub use types::{GRAPH_PLAIN, GRAPH_UNENDED, LINKED_PLACEHOLDERS, NON_NATIVE_ART, NON_NATIVE_ART_UNREAD, VERSIONED_UNENDED}; pub(super) use types::{blend_mode, blend_name}; diff --git a/crates/eps/src/import/ai/read/types.rs b/crates/eps/src/import/ai/read/types.rs index b6e908c2e1..02d4a3354a 100644 --- a/crates/eps/src/import/ai/read/types.rs +++ b/crates/eps/src/import/ai/read/types.rs @@ -16,7 +16,7 @@ pub(crate) const MAX_NODES: usize = 4_000_000; /// The most objects all the blends of one import may lay out to be checked (each twice) and made /// live; past it, blends keep their drawn steps. -pub(super) const BLEND_BUDGET: usize = 50_000; +pub(crate) const BLEND_BUDGET: usize = 50_000; /// Most points in one path. pub(super) const MAX_POINTS: usize = 4_000_000; diff --git a/crates/pathops/src/addons/pathtools/crossings.rs b/crates/pathops/src/addons/pathtools/crossings.rs index bcc254aa82..90a0d266ea 100644 --- a/crates/pathops/src/addons/pathtools/crossings.rs +++ b/crates/pathops/src/addons/pathtools/crossings.rs @@ -48,6 +48,42 @@ fn chords_cross(a: &CubicBez, b: &CubicBez) -> Option<(f64, f64)> { (within(s) && within(u)).then(|| (s.clamp(0.0, 1.0), u.clamp(0.0, 1.0))) } +/// `(s, t)` moved to where `a` and `b` cross exactly, by Newton's method on a(s) = b(t), or as it +/// was when that doesn't settle within both segments, closer than it started, and within the +/// distance a piece bent by [`FLAT`] can shift a crossing at their angle there. +fn refined(a: &CubicBez, b: &CubicBez, (s0, t0): (f64, f64)) -> (f64, f64) { + let gap = |s: f64, t: f64| a.eval(s).distance(b.eval(t)); + let start = gap(s0, t0); + if start <= 1e-12 || !start.is_finite() { + return (s0, t0); + } + let (da, db) = (a.deriv(), b.deriv()); + let (mut s, mut t) = (s0, t0); + for _ in 0..8 { + let f = a.eval(s) - b.eval(t); + let (u, v) = (da.eval(s).to_vec2(), db.eval(t).to_vec2()); + // a(s + ds) - b(t + dt) ≈ f + u ds - v dt, which is zero for these steps. + let den = u.cross(v); + let (ds, dt) = (-f.cross(v) / den, u.cross(f) / den); + if !(ds.is_finite() && dt.is_finite()) { + return (s0, t0); + } + (s, t) = (s + ds, t + dt); + if !(-1e-12..=1.0 + 1e-12).contains(&s) || !(-1e-12..=1.0 + 1e-12).contains(&t) { + return (s0, t0); + } + if gap(s, t) <= 1e-12 { + break; + } + } + let (s, t) = (s.clamp(0.0, 1.0), t.clamp(0.0, 1.0)); + let (u, v) = (da.eval(s).to_vec2(), db.eval(t).to_vec2()); + let sin = u.cross(v).abs() / (u.hypot() * v.hypot()); + let reach = 4.0 * FLAT / sin + SAME; + let moved = a.eval(s).distance(a.eval(s0)).max(b.eval(t).distance(b.eval(t0))); + if gap(s, t) < start.min(1e-9) && moved <= reach { (s, t) } else { (s0, t0) } +} + /// Where segments `a` and `b` cross: (t on `a`, t on `b`) pairs, halving both while their control /// boxes meet until each piece is straight. `None` once `budget` steps are spent. fn segment_crossings(a: &CubicBez, b: &CubicBez, budget: &mut usize) -> Option> { @@ -80,6 +116,11 @@ fn segment_crossings(a: &CubicBez, b: &CubicBez, budget: &mut usize) -> Option = kurbo::PathSeg::Cubic(arc.subpaths[0].segment(0)) + .intersect_line(kurbo::Line::new(from, to)) + .iter() + .map(|x| from.lerp(to, x.line_t)) + .collect(); + assert_eq!(exact.len(), 2, "{gap}"); + let on = |p: &PathData, other: &PathData| -> Vec { + crossings_on(p, &[other]).unwrap().iter().map(|q| p.subpaths[0].segment(q.1).eval(q.2)).collect() + }; + let both = crossings(&[&arc, &across], false).unwrap(); + let found = [ + on(&arc, &across), + on(&across, &arc), + both[0].iter().map(|q| arc.subpaths[0].segment(q.1).eval(q.2)).collect(), + both[1].iter().map(|q| across.subpaths[0].segment(q.1).eval(q.2)).collect(), + ]; + for places in found { + assert_eq!(places.len(), 2, "{gap}: {places:?}"); + for x in &exact { + let off = places.iter().map(|p| p.distance(*x)).fold(f64::INFINITY, f64::min); + assert!(off < 1e-6, "{gap}: {off} pt from {x:?}"); + } + } + } +} + #[test] fn insert_at_keeps_the_shape_and_names_the_new_anchors() { let sp = line(&[(0.0, 0.0), (100.0, 0.0), (100.0, 100.0)], false); diff --git a/crates/tools/src/cursors.toml b/crates/tools/src/cursors.toml index 07023d390d..e8687a9fae 100644 --- a/crates/tools/src/cursors.toml +++ b/crates/tools/src/cursors.toml @@ -75,6 +75,7 @@ group = "Selection" shown_when = [ "The Group Selection tool: each click selects the next enclosing group.", "Direct Selection with Alt held (Alt makes it Group Selection for the next click).", + "Over a panel where a click or a drop adds something, such as the strip under the Gradient panel's ramp, where a click adds a stop, or the Layers panel's list while rows are Alt-dragged, where the drop adds copies (where the system has no copy cursor the app can show).", ] hotspot = "The arrow's tip." look = "ArrowHollow with a plus badge." diff --git a/crates/ui-egui/src/cursors.rs b/crates/ui-egui/src/cursors.rs index bcb6744c12..e6d3fc1298 100644 --- a/crates/ui-egui/src/cursors.rs +++ b/crates/ui-egui/src/cursors.rs @@ -789,6 +789,27 @@ pub fn os_cursors(build: bool, wayland: bool) -> bool { build && !wayland } +/// The cursor a panel shows where a click or a drop adds something, such as a stop under the +/// Gradient panel's ramp or a copy of rows Alt-dragged in the Layers panel (#8217): the white arrow +/// with a plus that Group Selection shows for a click that adds the next group. Windows has no system copy cursor (winit shows the plain arrow for +/// `CursorIcon::Copy`), so where the window shows glyphs as OS cursors ([`os_cursors`]) the panel +/// hands it this glyph; elsewhere (macOS, Wayland, the web, `VECTORCRAFT_SYSTEM_CURSORS`) the +/// system's copy cursor shows (#8241). Set every frame it shows: the canvas and egui reset it. +pub(crate) fn set_add_cursor(app: &mut crate::VectorcraftApp, ctx: &egui::Context) { + ctx.set_cursor_icon(egui::CursorIcon::Copy); + if add_cursor_is_a_glyph(app) { + // As the canvas sizes its glyphs (User Interface › Scale Cursor Proportional to UI). + let ui_scale = if app.session.prefs.scale_cursor_with_ui { 1.0 } else { ctx.zoom_factor() }; + ctx.set_cursor_image(app.canvas.cursors.get(Cursor::GroupSelection, ctx.pixels_per_point() / ui_scale)); + } +} + +/// Does [`set_add_cursor`] hand the OS its glyph (rather than ask for the system copy cursor)? +/// Where the window shows glyphs as OS cursors, unless `VECTORCRAFT_SYSTEM_CURSORS` opts out. +pub(crate) fn add_cursor_is_a_glyph(app: &crate::VectorcraftApp) -> bool { + std::env::var_os("VECTORCRAFT_SYSTEM_CURSORS").is_none() && os_cursors(OS_CURSORS, app.services.wayland) +} + /// Does the window hide the pointer only while it is the key window? macOS does: winit hides it with /// a cursor rect holding a transparent cursor, and macOS applies the rect only in the key window. /// Over a window behind another app or under a sheet, the system pointer shows (#2020). diff --git a/crates/ui-egui/src/dialogs/command.rs b/crates/ui-egui/src/dialogs/command.rs index 9cd92b5428..9cb59853a6 100644 --- a/crates/ui-egui/src/dialogs/command.rs +++ b/crates/ui-egui/src/dialogs/command.rs @@ -201,10 +201,35 @@ fn choices(command: &str, key: &str) -> Option { (crate::addons::pathtools::COMMON_TANGENTS, "tangents") => Some(crate::addons::pathtools::TANGENT_KINDS), (crate::addons::image::REMOVE_BACKGROUND | crate::addons::image::COLOR_MASK, "background") => Some(crate::addons::image::BACKGROUNDS), (crate::addons::image::REMOVE_BACKGROUND | crate::addons::image::COLOR_MASK, "match") => Some(crate::addons::image::MATCHES), + ("object.rasterize", "antiAlias") => Some(RASTERIZE_ANTI_ALIAS), + ("object.rasterize", "background") => Some(RASTERIZE_BACKGROUNDS), + ("object.mesh.create", "appearance") => Some(MESH_APPEARANCES), + ("object.repeat.options", "gridType") => Some(REPEAT_GRID_TYPES), _ => None, } } +/// Object › Rasterize › Anti-aliasing: the modes `vectorcraft_render::AntiAlias` names, with its +/// labels, as the Rasterize effect's dialog lists them (`effect.rs`, `own_choices`). +const RASTERIZE_ANTI_ALIAS: form::Choices = &[("None", "none"), ("Art Optimized", "art"), ("Type Optimized", "type")]; + +/// Object › Rasterize › Background, as Document Raster Effects Settings and the Rasterize effect +/// list it. A color the command was given another way (black, a hex color) shows as it is. +const RASTERIZE_BACKGROUNDS: form::Choices = &[("White", "white"), ("Transparent", "transparent")]; + +/// Object › Create Gradient Mesh › Appearance: the values `object.mesh.create` takes. +const MESH_APPEARANCES: form::Choices = &[("Flat", "flat"), ("To Center", "center"), ("To Edge", "edge")]; + +/// Repeat Options › Grid Type of a grid repeat: the tile types, labeled as the Pattern Options +/// panel labels them (`panels/pattern_options.rs`, `TILE_LABELS`). +const REPEAT_GRID_TYPES: form::Choices = &[ + ("Grid", "grid"), + ("Brick by Row", "brickByRow"), + ("Brick by Column", "brickByColumn"), + ("Hex by Column", "hexByColumn"), + ("Hex by Row", "hexByRow"), +]; + /// Object › Rasterize › Color Model: the values `object.rasterize` takes, the document's own /// colour model first (#5660). fn rasterize_color_models(command: &str, key: &str, cmyk: bool) -> Option { @@ -688,4 +713,147 @@ mod tests { h.event(egui::Event::PointerButton { pos: ok, button, pressed: false, modifiers }); h.run_steps(3); } + + /// The dialog that is open in `app`, drawn by a kittest harness (the first frame installs the + /// fonts). + fn dialog_harness(app: VectorcraftApp) -> egui_kittest::Harness<'static, VectorcraftApp> { + let mut fonts = false; + let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1100.0, 900.0)).build_ui_state( + move |ui, app: &mut VectorcraftApp| { + if !std::mem::replace(&mut fonts, true) { + crate::theme::install_fonts(ui.ctx()); + return; + } + crate::dialogs::show(app, ui.ctx()); + }, + app, + ); + h.run_steps(5); + h + } + + /// Opens the dropdown labeled `label` and picks `choice` in it: the field must be a dropdown, + /// not a text field. + fn pick(h: &mut egui_kittest::Harness<'_, VectorcraftApp>, label: &str, choice: &str) { + use egui::accesskit::Role; + use egui_kittest::kittest::Queryable; + assert!(h.query_by_role_and_label(Role::TextInput, label).is_none(), "{label} is not a text field"); + h.get_by_role_and_label(Role::ComboBox, label).click(); + h.run_steps(3); + h.get_by_label(choice).click(); + h.run_steps(3); + } + + /// The choices this dialog lists for Rasterize, Create Gradient Mesh and Repeat Options are the + /// values their commands take (#8020, #7991): each one runs, and every language with complete + /// menus has a row for each label. + #[test] + fn choice_fields_list_the_values_their_commands_take() { + use vectorcraft_doc::pattern::TileType; + use vectorcraft_render::AntiAlias; + let listed = |command: &str, key: &str| choices(command, key).unwrap_or_else(|| panic!("{command} {key}: a choice")); + let aa: Vec<(&str, &str)> = AntiAlias::ALL.iter().map(|a| (a.label(), a.id())).collect(); + assert_eq!(listed("object.rasterize", "antiAlias"), aa.as_slice()); + for (_, value) in listed("object.rasterize", "background") { + assert!(vectorcraft_doc::Background::parse(value).is_some(), "{value}"); + } + for (label, value) in listed("object.repeat.options", "gridType") { + let tile = TileType::parse(value, None).unwrap_or_else(|| panic!("{value}")); + assert_eq!((tile.id(), tile.label()), (*value, *label)); + } + let run = |command: &str, key: &str, value: &str| { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + let id = s.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap()["id"].clone(); + if command == "object.repeat.options" { + s.execute("object.repeat.grid", &json!({"ids": [id], "rows": 2, "cols": 2})).unwrap(); + } + s.execute(command, &json!({ key: value })).unwrap_or_else(|e| panic!("{command} {key} {value}: {e}")); + }; + let fields = [ + ("object.rasterize", "antiAlias"), + ("object.rasterize", "background"), + ("object.mesh.create", "appearance"), + ("object.repeat.options", "gridType"), + ]; + for (command, key) in fields { + for (label, value) in listed(command, key) { + run(command, key, value); + for lang in crate::i18n::Lang::all().filter(|l| l.complete_menus()) { + assert!(crate::i18n::has(lang, label), "{}: {label}", lang.code()); + } + } + } + } + + /// Object › Rasterize… shows Anti Alias and Background as dropdowns of the values + /// `object.rasterize` takes. OK rasterizes with the picked ones as one undo step, and a value + /// the dialog doesn't list (black) shows as it is and is sent unchanged. + #[test] + fn rasterize_anti_alias_and_background_are_dropdowns() { + let corner = |app: &VectorcraftApp| { + let st = app.session.active().unwrap(); + let key = st.selection.objects.iter().find_map(|id| match st.doc.node(*id).map(|n| &n.kind) { + Some(NodeKind::Image(i)) => Some(i.key.clone()), + _ => None, + }); + let decoded = craft_image_codecs::decode(&st.doc.images[&key.expect("the ellipse became an image")].bytes).unwrap(); + image::RgbaImage::from_raw(decoded.width(), decoded.height(), decoded.to_rgba8()).unwrap().get_pixel(0, 0).0 + }; + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + let id = app.run("shape.ellipse", json!({"x": 10, "y": 10, "width": 40, "height": 40})).unwrap()["id"].as_u64().unwrap(); + app.run("paint.setFill", json!({"color": "#ff0000", "ids": [id]})).unwrap(); + app.run("select.set", json!({"ids": [id]})).unwrap(); + let steps = app.session.active().unwrap().history.undo.len(); + crate::menus::invoke(&mut app, "object.rasterize", json!({})); + let d = app.ui.dialog.as_ref().unwrap(); + assert_eq!((d.str("antiAlias"), d.str("background")), ("art".into(), "transparent".into())); + let mut h = dialog_harness(app); + pick(&mut h, "Anti Alias:", "Type Optimized"); + pick(&mut h, "Background:", "White"); + let d = h.state().ui.dialog.as_ref().unwrap(); + assert_eq!((d.str("antiAlias"), d.str("background")), ("type".into(), "white".into())); + let app = h.state_mut(); + crate::dialogs::confirm(app).unwrap(); + assert_eq!(app.session.active().unwrap().history.undo.len(), steps + 1, "one undo step"); + assert_eq!(corner(app), [255, 255, 255, 255], "a white background"); + // A background the dialog doesn't list stays as it is. + app.run("edit.undo", json!({})).unwrap(); + app.run("select.set", json!({"ids": [id]})).unwrap(); + crate::menus::invoke(app, "object.rasterize", json!({})); + app.ui.dialog.as_mut().unwrap().fields.insert("background".into(), json!("black")); + frame(app); + assert_eq!(app.ui.dialog.as_ref().unwrap().str("background"), "black", "drawing the dropdown keeps it"); + crate::dialogs::confirm(app).unwrap(); + assert_eq!(corner(app), [0, 0, 0, 255], "a black background"); + } + + /// Create Gradient Mesh… shows Appearance, and Repeat Options for a grid repeat its Grid Type, + /// as dropdowns of the values their commands take; OK applies the picked one. + #[test] + fn mesh_appearance_and_repeat_grid_type_are_dropdowns() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 50})).unwrap(); + let entries = crate::menus::menu_entries(&app); + let item = entries.iter().find(|e| e.path == ["Object"] && e.label == "Create Gradient Mesh…").expect("listed"); + let (cmd, p) = crate::menus::click_target(&item.label, item.command.as_deref().unwrap(), &item.params); + crate::menus::invoke(&mut app, &cmd, p); + let mut h = dialog_harness(app); + pick(&mut h, "Appearance:", "To Center"); + let app = h.state_mut(); + assert_eq!(app.ui.dialog.as_ref().unwrap().str("appearance"), "center"); + crate::dialogs::confirm(app).unwrap(); + let st = app.session.active().unwrap(); + assert!(st.selection.objects.iter().any(|id| matches!(st.doc.node(*id).map(|n| &n.kind), Some(NodeKind::Mesh(_)))), "a mesh"); + + let mut h = dialog_harness(grid_options_app()); + pick(&mut h, "Grid Type:", "Brick by Row"); + let app = h.state_mut(); + assert_eq!(app.ui.dialog.as_ref().unwrap().str("gridType"), "brickByRow"); + crate::dialogs::confirm(app).unwrap(); + let fields = crate::panels::pattern_options::repeat_fields(app).unwrap(); + assert_eq!(fields["gridType"], json!("brickByRow")); + } } diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index f5c3d81538..ce6b8393d0 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -671,6 +671,9 @@ font-technology Variable Променливи Create from Selection Създаване от селекцията Create From: Създаване от: Create Gradient Mesh… Създаване на градиентна мрежа… + Flat Плоско + To Center Към центъра + To Edge Към ръба Create Graph Създаване на диаграма Create New Layer Създаване на нов слой Create New Sublayer Създаване на нов подслой diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 3eb20cef41..e29847cf46 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -218,6 +218,9 @@ Mask Maska Rasterize… Rasteriziraj… Create Gradient Mesh… Kreiraj gradijentnu mrežu… + Flat Ravno + To Center Prema sredini + To Edge Prema ivici Create Object Mosaic… Kreiraj mozaik objekata… Vector Halftone… Vektorski polutonovi… Create Trim Marks Kreiraj oznake za obrezivanje diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index cf2b3aa96b..414acd524d 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -990,6 +990,9 @@ antiAlias Sharp Nítid Create from Selection Crea a partir de la selecció Create From: Crea a partir de: Create Gradient Mesh… Crea una malla de degradat… + Flat Pla + To Center Cap al centre + To Edge Cap a la vora Create Graph Crea un gràfic Create New Fields by Crea camps nous mitjançant Create New Layer Crea una capa nova diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 0f55ec62b5..6fc18c8be6 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -224,6 +224,9 @@ Mask Maska Rasterize… Rastrovat… Create Gradient Mesh… Vytvořit přechodovou síť… + Flat Ploché + To Center Ke středu + To Edge K okraji Create Object Mosaic… Vytvořit mozaiku objektů… Vector Halftone… Vektorový polotón… Create Trim Marks Vytvořit značky ořezu diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 2ef968f154..25b300cba3 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -2905,6 +2905,9 @@ liquify-list-end {0}, {1} {0} og {1} Mask Maskér Rasterize… Rasterisér… Create Gradient Mesh… Opret gradientnet… + Flat Flad + To Center Mod midten + To Edge Mod kanten Create Object Mosaic… Opret objektmosaik… Vector Halftone… Vektorhalvtone… Create Trim Marks Opret beskæringsmærker diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index ccedd8def5..7f51fd8ec8 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -180,6 +180,8 @@ antiAlias Sharp Scharf Crisp Klar Strong Stark Anti-aliasing: Glättung: + Art Optimized Für Grafik optimiert + Type Optimized Für Text optimiert Any Kind Beliebige Art Font Technology Schrifttechnologie font-technology Variable Variabel @@ -671,6 +673,9 @@ font-technology Variable Variabel Create from Selection Aus Auswahl erstellen Create From: Erstellen aus: Create Gradient Mesh… Verlaufsgitter erstellen… + Flat Flach + To Center Zur Mitte + To Edge Zum Rand Create Graph Diagramm erstellen Create New Layer Neue Ebene erstellen Create New Sublayer Neue Unterebene erstellen diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index af13a82f93..77b71485bf 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -652,6 +652,9 @@ font-technology Variable Μεταβλητές Create from Selection Δημιουργία από επιλογή Create From: Δημιουργία από: Create Gradient Mesh… Δημιουργία πλέγματος ντεγκραντέ… + Flat Επίπεδο + To Center Προς το κέντρο + To Edge Προς την ακμή Create Graph Δημιουργία γραφήματος Create New Layer Δημιουργία νέου επιπέδου Create New Sublayer Δημιουργία νέου υποεπιπέδου diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 42018b5f2c..4480960a09 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -693,6 +693,9 @@ font-technology Variable Variables Create from Selection Crear a partir de la selección Create From: Crear a partir de: Create Gradient Mesh… Crear malla de degradado… + Flat Plano + To Center Hacia el centro + To Edge Hacia el borde Create Graph Crear gráfico Create New Layer Crear capa nueva Create New Sublayer Crear subcapa nueva diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 39fc4744fb..e2de80dc71 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -231,6 +231,9 @@ Mask Maski Rasterize… Rasteroi… Create Gradient Mesh… Luo liukuväriverkko… + Flat Tasainen + To Center Keskustaa kohti + To Edge Reunaa kohti Create Object Mosaic… Luo objektimosaiikki… Vector Halftone… Vektorirasterointi… Create Trim Marks Luo leikkuumerkit diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 07208d40e8..54f9e7ca04 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -694,6 +694,9 @@ font-technology Variable Variables Create from Selection Créer à partir de la sélection Create From: Créer à partir de : Create Gradient Mesh… Créer un filet de dégradé… + Flat Plat + To Center Vers le centre + To Edge Vers le bord Create Graph Créer un graphe Create New Layer Créer un calque Create New Sublayer Créer un sous-calque diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index 0529faf266..df8dee1dc9 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -236,6 +236,8 @@ Anti-aliased Artwork એન્ટિ-એલિયાસ્ડ આર્ટવર્ક Anti-aliasing Method એન્ટિ-એલિયાસિંગ પદ્ધતિ Anti-aliasing: એન્ટિ-એલિયાસિંગ: + Art Optimized આર્ટ માટે ઑપ્ટિમાઇઝ કરેલું + Type Optimized ટેક્સ્ટ માટે ઑપ્ટિમાઇઝ કરેલું Appearance દેખાવ Appearance Attribute દેખાવ ગુણધર્મ Appearance Item દેખાવ આઇટમ @@ -429,6 +431,10 @@ Break Text into Words ટેક્સ્ટને શબ્દોમાં તોડો Break Thread થ્રેડ તોડો Brick Offset: ઈંટ ઑફસેટ: + Brick by Row પંક્તિ પ્રમાણે ઈંટ + Brick by Column કૉલમ પ્રમાણે ઈંટ + Hex by Column કૉલમ પ્રમાણે ષટ્કોણ + Hex by Row પંક્તિ પ્રમાણે ષટ્કોણ Brightness તેજ Brightness/Contrast… તેજ/કૉન્ટ્રાસ્ટ… Brightness: તેજ: @@ -792,6 +798,9 @@ Create From: આમાંથી બનાવો: Create Gradient Mesh ગ્રેડિયન્ટ મેશ બનાવો Create Gradient Mesh… ગ્રેડિયન્ટ મેશ બનાવો… + Flat સપાટ + To Center કેન્દ્ર તરફ + To Edge કિનારી તરફ Create Graph ગ્રાફ બનાવો Create New Layer નવો લેયર બનાવો Create New Library નવી લાઇબ્રેરી બનાવો diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 725d5147c1..8206f2ef46 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -1134,6 +1134,9 @@ antiAlias Sharp शार्प Create From: से बनाएँ: Create Gradient Mesh ग्रेडिएंट मेश बनाएँ Create Gradient Mesh… ग्रेडिएंट मेश बनाएँ… + Flat समतल + To Center केंद्र की ओर + To Edge किनारे की ओर Create Graph ग्राफ़ बनाएँ Create New {kind} Style नई {kind} स्टाइल बनाएँ Create New Action नया एक्शन बनाएँ diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 8cd65be0ab..d2eadcb1bb 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -893,6 +893,9 @@ font-technology Variable Változó Create from Selection Létrehozás a kijelölésből Create From: Létrehozás ebből: Create Gradient Mesh… Színátmenetes háló létrehozása… + Flat Sík + To Center A közép felé + To Edge Az él felé Create Graph Diagram létrehozása Create New Fields by Új félképek létrehozása Create New Layer Új réteg létrehozása diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index c6b98ebc8a..d853517ac7 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -211,6 +211,9 @@ Mask Masker Rasterize… Rasterisasi… Create Gradient Mesh… Buat mesh gradien… + Flat Datar + To Center Ke tengah + To Edge Ke tepi Create Object Mosaic… Buat mozaik objek… Vector Halftone… Halftone vektor… Create Trim Marks Buat tanda potong diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 415aa31ca5..64f9be841d 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -205,6 +205,8 @@ antiAlias Sharp Nitido Crisp Definito Strong Forte Anti-aliasing: Anti-aliasing: + Art Optimized Ottimizzato per la grafica + Type Optimized Ottimizzato per il testo Any Kind Qualsiasi tipo Font Technology Tecnologia font font-technology Variable Variabili @@ -693,6 +695,9 @@ font-technology Variable Variabili Create from Selection Crea dalla selezione Create From: Crea da: Create Gradient Mesh… Crea trama sfumatura… + Flat Piatto + To Center Verso il centro + To Edge Verso il bordo Create Graph Crea grafico Create New Layer Crea nuovo livello Create New Sublayer Crea nuovo sottolivello diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 751572fc02..b0921d97f6 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -268,6 +268,9 @@ digits Malayalam マラヤーラム数字 Mask マスク Rasterize… ラスタライズ… Create Gradient Mesh… グラデーションメッシュを作成… + Flat フラット + To Center 中心へ + To Edge エッジへ Create Object Mosaic… モザイクオブジェクトを作成… Vector Halftone… ベクターハーフトーン… Create Trim Marks トリムマークを作成 @@ -1120,6 +1123,8 @@ antiAlias Sharp シャープ Crisp くっきり Strong 太め Anti-aliasing: アンチエイリアス: + Art Optimized アートに最適化 + Type Optimized 文字に最適化 Appearance Item アピアランス項目 Appearance Panel アピアランスパネル Appearance of Black ブラックのアピアランス diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 97ea30797e..1ffbee6b9c 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -2383,6 +2383,9 @@ Mask ნიღაბი Rasterize… რასტრირება… Create Gradient Mesh… გრადიენტული ბადის შექმნა… + Flat ბრტყელი + To Center ცენტრისკენ + To Edge კიდისკენ Create Object Mosaic… ობიექტების მოზაიკის შექმნა… Vector Halftone… ვექტორული ნახევარტონი… Create Trim Marks ჭრის ნიშნების შექმნა diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index d80bd672b8..04cd391076 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -261,6 +261,9 @@ digits Malayalam 말라얄람어 Mask 마스크 Rasterize… 래스터화… Create Gradient Mesh… 그레이디언트 메시 만들기… + Flat 평면 + To Center 가운데로 + To Edge 가장자리로 Create Object Mosaic… 개체 모자이크 만들기… Vector Halftone… 벡터 하프톤… Create Trim Marks 트림 마크 만들기 @@ -1110,6 +1113,8 @@ antiAlias Sharp 날카롭게 Crisp 또렷하게 Strong 강하게 Anti-aliasing: 안티 앨리어싱: + Art Optimized 아트에 최적화 + Type Optimized 문자에 최적화 Appearance Item 모양새 항목 Appearance Panel 모양새 패널 Appearance of Black 검정 표시 방식 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 46d76fdcbb..0128913acd 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -779,6 +779,9 @@ liquify-list-end {0}, {1} {0} en {1} Mask Masker Rasterize… Rasteriseren… Create Gradient Mesh… Verloopmesh maken… + Flat Vlak + To Center Naar het midden + To Edge Naar de rand Create Object Mosaic… Objectmozaïek maken… Vector Halftone… Vectorhalftoon… Create Trim Marks Afsnijtekens maken diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 4e59903186..684d565870 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -188,6 +188,9 @@ Mask Maska Rasterize… Rasteryzuj… Create Gradient Mesh… Utwórz siatkę gradientową… + Flat Płaski + To Center Do środka + To Edge Do krawędzi Create Object Mosaic… Utwórz mozaikę obiektów… Vector Halftone… Półton wektorowy… Create Trim Marks Utwórz znaczniki przycięcia diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index ac559a9266..ed5140abe4 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -616,6 +616,9 @@ antiAlias Sharp Nítido Create Clipping Mask Criar Máscara de Recorte Create From: Criar De: Create Gradient Mesh… Criar Malha de Gradiente… + Flat Plano + To Center Para o Centro + To Edge Para a Borda Create Graph Criar Gráfico Create New Layer Criar Nova Camada Create New Sublayer Criar Nova Subcamada diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 1bcbfbb578..e78dc74a02 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -691,6 +691,9 @@ font-technology Variable Вариативные Create from Selection Создать из выделения Create From: Создать из: Create Gradient Mesh… Создать градиентную сетку… + Flat Плоский + To Center К центру + To Edge К краю Create Graph Создать диаграмму Create New Layer Создать новый слой Create New Sublayer Создать новый подслой diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 89ea62fb01..86fcfac9ee 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -680,6 +680,9 @@ font-technology Variable Variabla Create from Selection Skapa från markering Create From: Skapa från: Create Gradient Mesh… Skapa gradientnät… + Flat Platt + To Center Mot mitten + To Edge Mot kanten Create Graph Skapa diagram Create New Layer Skapa nytt lager Create New Sublayer Skapa nytt underlager diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index e232187cad..84dd5c82ee 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -672,6 +672,9 @@ font-technology Variable Değişken Create from Selection Seçimden Oluştur Create From: Şuradan Oluştur: Create Gradient Mesh… Degrade Kafes Oluştur… + Flat Düz + To Center Merkeze Doğru + To Edge Kenara Doğru Create Graph Grafik Oluştur Create New Layer Yeni Katman Oluştur Create New Sublayer Yeni Alt Katman Oluştur diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index d7815a42ed..1b7ce525a9 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -199,6 +199,8 @@ antiAlias Sharp Різке Crisp Чітке Strong Сильне Anti-aliasing: Згладжування: + Art Optimized Оптимізовано для графіки + Type Optimized Оптимізовано для тексту Any Kind Будь-який тип Font Technology Технологія шрифту font-technology Variable Варіативні @@ -687,6 +689,9 @@ font-technology Variable Варіативні Create from Selection Створити із виділення Create From: Створити з: Create Gradient Mesh… Створити градієнтну сітку… + Flat Плаский + To Center До центру + To Edge До краю Create Graph Створити діаграму Create New Layer Створити новий шар Create New Sublayer Створити новий підшар diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index d288931824..a3873198a7 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -222,6 +222,8 @@ antiAlias Sharp Sắc nét Crisp Rõ nét Strong Đậm Anti-aliasing: Khử răng cưa: + Art Optimized Tối ưu cho hình vẽ + Type Optimized Tối ưu cho chữ Any Kind Bất kỳ loại Font Technology Công nghệ phông chữ font-technology Variable Biến thiên @@ -794,6 +796,9 @@ font-technology Variable Biến thiên Create from Selection Tạo từ vùng chọn Create From: Tạo từ: Create Gradient Mesh… Tạo lưới chuyển sắc… + Flat Phẳng + To Center Về tâm + To Edge Về cạnh Create Graph Tạo biểu đồ Create New Fields by Tạo trường mới bằng Create New Layer Tạo lớp mới diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index bf7a1bcc7c..9ec168eb22 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -153,6 +153,8 @@ antiAlias Sharp 锐利 Crisp 清晰 Strong 强 Anti-aliasing: 消除锯齿: + Art Optimized 图稿优化 + Type Optimized 文字优化 Appearance 外观 Appearance Attribute 外观属性 Appearance Item 外观项目 @@ -637,6 +639,9 @@ antiAlias Sharp 锐利 Create from Selection 从选区创建 Create From: 创建自: Create Gradient Mesh… 创建渐变网格… + Flat 平面 + To Center 向中心 + To Edge 向边缘 Create Graph 创建图表 Create New Layer 创建新图层 Create New Sublayer 创建新子图层 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 87e1bde68b..b35e435234 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -163,6 +163,8 @@ antiAlias Sharp 銳利 Crisp 清晰 Strong 強 Anti-aliasing: 消除鋸齒: + Art Optimized 圖稿最佳化 + Type Optimized 文字最佳化 Any Kind 所有類型 Font Technology 字體技術 font-technology Variable 可變 @@ -655,6 +657,9 @@ font-technology Variable 可變 Create from Selection 從選取範圍建立 Create From: 建立來源: Create Gradient Mesh… 建立漸層網格… + Flat 平面 + To Center 向中心 + To Edge 向邊緣 Create Graph 建立圖表 Create New Layer 建立新圖層 Create New Sublayer 建立新子圖層 diff --git a/crates/ui-egui/src/panels/gradient.rs b/crates/ui-egui/src/panels/gradient.rs index e0e032c086..7baaa062ab 100644 --- a/crates/ui-egui/src/panels/gradient.rs +++ b/crates/ui-egui/src/panels/gradient.rs @@ -815,7 +815,7 @@ fn ramp(app: &mut VectorcraftApp, ui: &mut Ui, g: &Gradient, is_grad: bool, w: f let add_resp = ui.interact(below, ui.scope_id().with("grad-add"), Sense::click()); let bar_resp = ui.interact(bar, ui.scope_id().with("grad-bar"), Sense::click()); if add_resp.hovered() && is_grad { - ui.ctx().set_cursor_icon(egui::CursorIcon::Copy); + crate::cursors::set_add_cursor(app, ui.ctx()); } if !is_grad && (bar_resp.clicked() || add_resp.clicked()) { edit(app, json!({}), Live::Released); diff --git a/crates/ui-egui/src/panels/gradient/tests.rs b/crates/ui-egui/src/panels/gradient/tests.rs index 14a711bf57..bbf833b1aa 100644 --- a/crates/ui-egui/src/panels/gradient/tests.rs +++ b/crates/ui-egui/src/panels/gradient/tests.rs @@ -915,3 +915,43 @@ fn a_stop_dragged_off_the_ramp_or_deleted_with_the_button_beside_it_goes() { p.click(&mut app, del.center()); assert_eq!(hexes(&app), ["#ffffff", "#000000"]); } + +/// #8241: over the strip under the ramp, where a click adds a stop, the panel shows the white arrow +/// with a plus. Where the window shows glyphs as OS cursors (Windows, X11), it hands the glyph to +/// the OS, since winit shows the plain arrow for the system copy cursor there; elsewhere the +/// system copy cursor. Over the ramp itself, which adds nothing, neither. +#[test] +fn the_strip_under_the_ramp_shows_the_add_cursor() { + let stops = json!([{"offset": 0, "color": "#ffffff"}, {"offset": 1, "color": "#000000"}]); + let mut app = app(json!({"gradient": {"stops": stops}})); + let mut p = Panel::new(); + p.frame(&mut app, vec![], Modifiers::NONE); + let bar = p.widget("grad-bar"); + let output = |p: &mut Panel, app: &mut VectorcraftApp, at: Pos2| { + p.time += 0.1; + let events = vec![Event::PointerMoved(at)]; + let input = egui::RawInput { + time: Some(p.time), + events, + screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(260.0, 600.0))), + ..Default::default() + }; + let mut out = p.ctx.run_ui(input, |ui| show(app, ui)); + out.textures_delta.clear(); + out.platform_output + }; + // Between the two stops, just under the ramp. + let under = output(&mut p, &mut app, pos2(bar.center().x, bar.bottom() + 10.0)); + assert_eq!(under.cursor_icon, egui::CursorIcon::Copy); + // The same condition the panel uses (the build, Wayland, VECTORCRAFT_SYSTEM_CURSORS). + if crate::cursors::add_cursor_is_a_glyph(&app) { + let glyph = app.canvas.cursors.get(vectorcraft_tools::Cursor::GroupSelection, 1.0); + assert!(glyph.is_some()); + assert_eq!(under.cursor_image, glyph, "the white arrow with a plus, as an OS cursor"); + } else { + assert!(under.cursor_image.is_none(), "the system copy cursor alone"); + } + let over = output(&mut p, &mut app, bar.center()); + assert_ne!(over.cursor_icon, egui::CursorIcon::Copy); + assert!(over.cursor_image.is_none(), "over the ramp, no add cursor"); +} diff --git a/crates/ui-egui/src/panels/layers.rs b/crates/ui-egui/src/panels/layers.rs index eed20e12cb..6e8c2648fa 100644 --- a/crates/ui-egui/src/panels/layers.rs +++ b/crates/ui-egui/src/panels/layers.rs @@ -378,6 +378,19 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { { drag_ghost(ui, &view, widgets::ghost_row(ids, grabbed), pos); } + let alt = ui.input(|i| i.modifiers.alt); + let over_list = ui.input(|i| i.pointer.hover_pos()).is_some_and(|p| list_rect.contains(p)); + if !released + && let Some(drag) = egui::DragAndDrop::payload::(ui.ctx()) + && let Some(cursor) = drag_cursor(&drag, alt, over_list) + { + // The copy cursor is the panels' add cursor, which Windows can show (#8217, #8241). + if cursor == egui::CursorIcon::Copy { + crate::cursors::set_add_cursor(app, ui.ctx()); + } else { + ui.ctx().set_cursor_icon(cursor); + } + } // Keyboard: Delete removes the highlighted rows while the panel has the keyboard (a row was // clicked last, not the canvas). // The panel keeps it while it is drawn ([`super::has_row_keys`]); the app's shortcuts leave @@ -409,6 +422,19 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { see_selection(app, ui, selected); } +/// The cursor while `drag` is held (`alt` down, `over_list`: the pointer is over the rows): the +/// copy cursor where a drop copies, as a drop in the list with Alt does, else the grabbing hand. +/// The trash and New Layer ignore Alt, so outside the list the hand stays. Read every frame, as +/// the drop reads Alt when it lands (#8217). None for guide rows, which never copy and set their +/// own cursor. +fn drag_cursor(drag: &LayersDrag, alt: bool, over_list: bool) -> Option { + match drag { + LayersDrag::Rows(_) | LayersDrag::Art if alt && over_list => Some(egui::CursorIcon::Copy), + LayersDrag::Rows(_) | LayersDrag::Art => Some(egui::CursorIcon::Grabbing), + LayersDrag::Guides(_) => None, + } +} + /// The search typed into the Layers panel's Search All field, as the panel matches it. fn search_query(ctx: &egui::Context) -> String { ctx.data(|d| d.get_temp::(egui::Id::unique("layers-search"))).unwrap_or_default().trim().to_lowercase() diff --git a/crates/ui-egui/src/panels/layers/rows.rs b/crates/ui-egui/src/panels/layers/rows.rs index f532d4a1f1..62e32f1097 100644 --- a/crates/ui-egui/src/panels/layers/rows.rs +++ b/crates/ui-egui/src/panels/layers/rows.rs @@ -446,9 +446,7 @@ pub(super) fn row(ui: &mut Ui, view: &View, item: &Row, out: &mut Out) { d.insert_temp(key("grabbed"), n.id); }); } - if resp.dragged_by(egui::PointerButton::Primary) { - ui.ctx().set_cursor_icon(egui::CursorIcon::Grabbing); - } + // The cursor of a row drag is the panel's ([`super::drag_cursor`]): Alt can change it on any frame. drop_target(ui, view, n, r, x - 16.0, open, &resp, out); } diff --git a/crates/ui-egui/src/panels/layers/tests.rs b/crates/ui-egui/src/panels/layers/tests.rs index 5e453f5aba..2570e77df7 100644 --- a/crates/ui-egui/src/panels/layers/tests.rs +++ b/crates/ui-egui/src/panels/layers/tests.rs @@ -1493,6 +1493,57 @@ fn dragging_rows_moves_them_into_other_layers_and_alt_copies() { let _ = (layer, c); } +/// One headless frame of the panel with `events` (Alt held when `alt`) → the cursor it asks for, +/// and the cursor bitmap it hands the OS, if any. +fn cursor_frame( + app: &mut VectorcraftApp, + ctx: &egui::Context, + events: Vec, + alt: bool, +) -> (egui::CursorIcon, Option) { + let mut events = events; + events.insert(0, egui::Event::ModifiersChanged(egui::Modifiers { alt, ..Default::default() })); + let mut out = ctx.run_ui(egui::RawInput { events, ..Default::default() }, |ui| show(app, ui)); + out.textures_delta.clear(); + (out.platform_output.cursor_icon, out.platform_output.cursor_image) +} + +/// #8217: a row dragged over the list shows the copy cursor while Alt is held, as the drop then +/// copies, and the grabbing hand otherwise, following Alt as it goes down and up mid-drag. The copy +/// cursor is the panels' add cursor (#8241): where the window shows glyphs as OS cursors (Windows, +/// X11, which have no system copy cursor winit can show), the white arrow with a plus. +#[test] +fn alt_shows_the_copy_cursor_while_rows_are_dragged() { + let (mut app, _) = nested(); + let ctx = egui::Context::default(); + // Rows: Layer 1, Sub, g, b, a, c. + let (circles, _) = frame(&mut app, &ctx, vec![], false); + assert_eq!(circles.len(), 6); + let (from, to) = (egui::pos2(150.0, circles[2].y), egui::pos2(150.0, circles[5].y)); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(from)], false); + frame(&mut app, &ctx, vec![button(from, true)], false); + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(from + vec2(0.0, 6.0))], false); + let glyph = crate::cursors::add_cursor_is_a_glyph(&app).then(|| app.canvas.cursors.get(vectorcraft_tools::Cursor::GroupSelection, 1.0)).flatten(); + assert_eq!(cursor_frame(&mut app, &ctx, vec![egui::Event::PointerMoved(to)], false), (egui::CursorIcon::Grabbing, None), "a move"); + assert_eq!(cursor_frame(&mut app, &ctx, vec![], true), (egui::CursorIcon::Copy, glyph), "Alt held: the drop copies"); + assert_eq!(cursor_frame(&mut app, &ctx, vec![], false), (egui::CursorIcon::Grabbing, None), "Alt let go: a move again"); + cursor_frame(&mut app, &ctx, vec![button(to, false)], false); + assert_ne!(cursor_frame(&mut app, &ctx, vec![], true).0, egui::CursorIcon::Copy, "no drag, no copy cursor"); +} + +/// The selected-art square copies with Alt as rows do; off the list (the trash, New Layer) Alt +/// copies nothing, and guide rows keep their own cursor. +#[test] +fn drag_cursor_shows_a_copy_only_where_the_drop_copies() { + let (copy, grabbing) = (Some(egui::CursorIcon::Copy), Some(egui::CursorIcon::Grabbing)); + for drag in [LayersDrag::Rows(vec![NodeId(1)]), LayersDrag::Art] { + assert_eq!(super::drag_cursor(&drag, true, true), copy); + assert_eq!(super::drag_cursor(&drag, false, true), grabbing); + assert_eq!(super::drag_cursor(&drag, true, false), grabbing, "off the list"); + } + assert_eq!(super::drag_cursor(&LayersDrag::Guides(vec![0]), true, true), None); +} + /// An Intertwine group's row takes a dragged row inside it, as a group's does, and the object /// becomes a member; a row that can't be intertwined gets no inside box and goes beside it. #[test] diff --git a/docs/control-protocol.md b/docs/control-protocol.md index b68a79b4af..adac088a13 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -669,7 +669,9 @@ agents) opens the `rasterEffectsSettings` dialog. Its fields are what `document. (`resolution`, `colorModel`, `background`, `antiAlias`, `clippingMask`, `addAround` in pt, `preserveSpotColors`); `ui.dialog.confirm` runs it with them as one undo step; a bad value keeps the dialog open. Object → Rasterize… opens a `command` dialog for `object.rasterize` whose fields (`ppi`, `colorModel`, `background`, `antiAlias`, `clippingMask`, -`addAround`) start from these settings. +`addAround`) start from these settings. `colorModel`, `antiAlias` (`none`, `art`, `type`) and `background` (`white`, +`transparent`) are dropdowns; `ui.dialog.set` also takes any other value the command takes, and the dialog sends it +unchanged. Missing linked files: `app.open` of a document whose linked images' files can't be found (`document.open`'s `missingLinks`) opens the `missingLinks` dialog for the first (fields `missing`: `[{name, path, ids}]`, `modified`, diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 759565ea86..8239848e91 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -127,7 +127,23 @@ private editing data. VectorCraft: on its stroke; other brushed strokes are written as their brush's art. A document that uses a new document's brushes writes none until a path keeps one on its stroke; then the brushes are written, and the file opens without the new document's Pattern and Bristle - brushes. + brushes. Blends are written live: their key objects, their spine when they have one of their own, their steps + drawn, and their spacing (Smooth Color, Specified Steps, Specified Distance) and orientation (Align to Page, Align to + Path); a replaced spine is written with an anchor where each key object sits, so it opens with those anchors and + lays out the same steps. Blends with easing, a color shift or start points, with effects, an appearance or an + opacity mask of their own, of objects other than paths, compound paths and groups, of clipping groups, of more than + 62 key objects, with a hidden key object, holding another blend, of key objects with geometry or Pathfinder effects + or a group's own fills and strokes, of key objects the editing copy would change (empty paths or subpaths, paths and + compound path members of several subpaths, several fills or strokes, strokes a plain line can't draw, dashes of + more than 64 lengths, hidden fills or strokes, fills or strokes other than a color, in a Lab color or with + transparency or effects of their own, effects, opacity masks), where one key object has a fill or stroke of no paint + or a stroke of no width and another has one that draws, whose spine has more than one part, whose step count is + close to where rounding changes it, or that VectorCraft's reader wouldn't open with their settings or as they + are drawn, are written as their steps with a warning, as are blends inside objects with geometry or Pathfinder + effects or a group's own fills and strokes, blends in opacity masks, pattern tiles, symbols and art cut to a + clipping object or nested eight levels deep in art written in place of other objects (symbol instances, live + objects, brushed strokes), blends whose art would pass the most objects VectorCraft's reader reads, and every blend + on a large canvas. Point type, area type (with its rows, columns, gutters and first baseline, threaded frames included) and type on a path are written as text: a text object for each, naming its story in the text document, with the characters, fonts, sizes, leading, tracking, baseline shift, diff --git a/docs/roadmap.md b/docs/roadmap.md index 543b040e15..9373b1f499 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -1,6 +1,6 @@ # Roadmap: milestones and what's next -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-17 · **Change:** minor (PDF import: translucent type filled and stroked comes in as a filled type object and a stroked one, as the file composites them, and an upright glyph is never kept as the outline of its glyph alone, #8015; PDF import: type filled and stroked by one text-showing operator comes in as one type object, filled and stroked, not a stroked copy over a filled one, #8015; Recolor Artwork follow-up (#8031, remaining #4028): native Lab input, picker swatch libraries and Assign-row menus; UI interaction regression coverage; scores and estimates unchanged; previously: #8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: M7: Check Spelling modal dialog (Edit › Spelling › Check Spelling…), #4936; spell check complete; previously: PDF import: stroked type keeps the line cap, line join and miter limit the file strokes it with, a glyph stroked otherwise than the run it joins coming in as a run of its own, #7741; M10/G5: Neon & Glow built-in graphic style library (Cyan Neon, Magenta Laser, Amber Tube, Electric Lime, Pulse Violet, Cobalt Phosphor); previously: Tech Circuit brush library, G5; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: PDF import: glyphs in a span with an empty ActualText come in as outlines, #6971; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: #6865: explicitly requested oversized editing artboard; Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: M10/G5: Energy Beams brush library; MCP docs list Energy Beams; previously minor: M10/G5: Skill Icons symbol library; MCP docs list Skill Icons; previously minor: M10/G5: Status Effects graphic style library; MCP docs catch-up for symbol libraries; previously minor: M10/G5: Inventory Icons built-in symbol library; previously minor: Edit › Edit Custom Dictionary…: its dialog adds, deletes and changes the custom dictionary's words, #4936; previously minor: M10/G5: Game HUD graphic style library; previously minor: resizable icon-strip flyouts and bottom-aligned panel footers, #5713; previously minor: M10/G5: Map Markers built-in symbol library; previously minor: right-click on type: Spelling › Auto Spell Check, with its check mark, #4936; previously minor: right-click on a word Auto Spell Check underlined: its suggestions, Ignore All and Add to Dictionary, #4936; previously minor: G2: Effect Gallery thumbnails and in-dialog preview are in; Auto Spell Check: `edit.autoSpellCheck` underlines the unknown words, #4936; previously minor: PDF editable import preserves authored ActualText once, including empty/nested spans and authored ordering (#6165); cross-line/style layout remains approximate; scores and estimates unchanged; PDF marked-text export (#6309): compatible glyphs stay on one layout line with per-glyph offsets; scores and estimates unchanged; interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; custom dictionary and Ignore All: `text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary` and `ignoreAll`, #4936; previously minor: EPS import: embedded fonts (composite, Type 42, CID-keyed, Type 1, CFF FontSet) draw their glyphs; spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, #4936; previously minor: floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; M4/M7: `.ai`/EPS type keeps its tab stops, and right-aligned lines with tabs lay out as the file's page, #6147; M4/M7: `.ai`/EPS type from the text document lays its lines out closer to the file's page, within limits, #6137; numeric fields step on wheel hover without taking keyboard focus, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Selection QoL: marquee modes and visible feedback, #5313; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; Indian-language hyphenation review and license allowlist, #4947; Hindi catalog and contributor loanword preferences; full wording review in progress; Effect dialogs: a colour swatch beside a hex colour opens the Color Picker, #5365; shape tools move the selection from its centre point and turn it from the zone outside a box corner, #5477; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-17 · **Change:** minor (PDF import: translucent type filled and stroked comes in as a filled type object and a stroked one, as the file composites them, and an upright glyph is never kept as the outline of its glyph alone, #8015; PDF import: type filled and stroked by one text-showing operator comes in as one type object, filled and stroked, not a stroked copy over a filled one, #8015; M1: Layers panel Alt-drag shows the copy cursor, #8217; scores and estimates unchanged; previously: Gradient panel: the add-stop strip shows the white arrow with a plus on Windows and X11, #8241; scores and estimates unchanged; previously: Recolor Artwork follow-up (#8031, remaining #4028): native Lab input, picker swatch libraries and Assign-row menus; UI interaction regression coverage; scores and estimates unchanged; previously: #8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: M7: Check Spelling modal dialog (Edit › Spelling › Check Spelling…), #4936; spell check complete; previously: PDF import: stroked type keeps the line cap, line join and miter limit the file strokes it with, a glyph stroked otherwise than the run it joins coming in as a run of its own, #7741; M10/G5: Neon & Glow built-in graphic style library (Cyan Neon, Magenta Laser, Amber Tube, Electric Lime, Pulse Violet, Cobalt Phosphor); previously: Tech Circuit brush library, G5; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: PDF import: glyphs in a span with an empty ActualText come in as outlines, #6971; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: #6865: explicitly requested oversized editing artboard; Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: M10/G5: Energy Beams brush library; MCP docs list Energy Beams; previously minor: M10/G5: Skill Icons symbol library; MCP docs list Skill Icons; previously minor: M10/G5: Status Effects graphic style library; MCP docs catch-up for symbol libraries; previously minor: M10/G5: Inventory Icons built-in symbol library; previously minor: Edit › Edit Custom Dictionary…: its dialog adds, deletes and changes the custom dictionary's words, #4936; previously minor: M10/G5: Game HUD graphic style library; previously minor: resizable icon-strip flyouts and bottom-aligned panel footers, #5713; previously minor: M10/G5: Map Markers built-in symbol library; previously minor: right-click on type: Spelling › Auto Spell Check, with its check mark, #4936; previously minor: right-click on a word Auto Spell Check underlined: its suggestions, Ignore All and Add to Dictionary, #4936; previously minor: G2: Effect Gallery thumbnails and in-dialog preview are in; Auto Spell Check: `edit.autoSpellCheck` underlines the unknown words, #4936; previously minor: PDF editable import preserves authored ActualText once, including empty/nested spans and authored ordering (#6165); cross-line/style layout remains approximate; scores and estimates unchanged; PDF marked-text export (#6309): compatible glyphs stay on one layout line with per-glyph offsets; scores and estimates unchanged; interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; custom dictionary and Ignore All: `text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary` and `ignoreAll`, #4936; previously minor: EPS import: embedded fonts (composite, Type 42, CID-keyed, Type 1, CFF FontSet) draw their glyphs; spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, #4936; previously minor: floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; M4/M7: `.ai`/EPS type keeps its tab stops, and right-aligned lines with tabs lay out as the file's page, #6147; M4/M7: `.ai`/EPS type from the text document lays its lines out closer to the file's page, within limits, #6137; numeric fields step on wheel hover without taking keyboard focus, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Selection QoL: marquee modes and visible feedback, #5313; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; Indian-language hyphenation review and license allowlist, #4947; Hindi catalog and contributor loanword preferences; full wording review in progress; Effect dialogs: a colour swatch beside a hex colour opens the Color Picker, #5365; shape tools move the selection from its centre point and turn it from the zone outside a box corner, #5477; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x) > > Oversized artboard import update (2026-11-12): Explicit editing-data import retains a single artboard beyond a capped 14,400 pt PDF page (#6865). > @@ -214,6 +214,8 @@ not take the artwork yet. Overflow-menu drag remains separate. Scores and hours |---|---|---| | 2026-11-17 | minor | PDF import (#8015 follow-up): type filled and stroked at less than full opacity is no longer joined into one type object, since the file composites the fill and the stroke apiece, darker where they overlap, while one object's opacity applies to both together; it stays a filled object and a stroked one, as a fill and stroke at different opacities already did. An upright glyph (vertical type) filled and stroked is no longer kept as an outline for a line that comes in as its outlines, as glyphs filled only weren't, so such a line can't lose them. The #8015 entries now say what is left: translucent type filled and stroked, and a `TJ` whose kerning starts a new line part way through, still come in as two objects. Tests: `translucent_fill_and_stroke_text_stays_two_objects`, `a_vertical_line_with_one_glyph_filled_and_stroked_keeps_every_glyph_filled`; scores and estimates unchanged. | | 2026-11-16 | minor | PDF import: fill and stroke rendering (text rendering modes 2 and 6) draws all the glyphs of a text-showing operator (`Tj`, `TJ`, `'`, `"`) filled, then the same glyphs stroked, so a word shown at once came in as two type objects: a stroke-only copy over a fill-only one. Each stroke is now matched, in order, to the glyph filled with the same placement (where, how large, how wide, slanted and turned) in the same font with the same text on the line, and only that glyph takes the stroke, so the word comes in as one type object, filled and stroked; glyphs stroked with another join part way through still split into runs of their own, and stroked type over no filled glyph (modes 1 and 5) stays stroke only (#8015; `a_word_filled_then_stroked_imports_as_one_filled_and_stroked_type` in `crates/pdf/src/tests/textstroke.rs`, `a_vertical_column_filled_then_stroked_is_one_filled_and_stroked_type` in `crates/pdf/src/tests/text_placement.rs`). Scores and estimates unchanged. | +| 2026-11-16 | minor | M1: rows or the selected-art square dragged over the Layers panel's list show the copy cursor while Alt is held, as the drop then copies, and the grabbing hand otherwise (#8217). Scores and estimates unchanged. | +| 2026-11-16 | minor | Gradient panel: the strip under the ramp, where a click adds a stop, shows the white arrow with a plus on Windows and X11, where the system copy cursor showed as the plain arrow (#8241). Scores and estimates unchanged. | | 2026-11-16 | minor | Recolor Artwork follow-up (#8031, remaining #4028): native Lab input, picker swatch libraries and Assign-row menus; UI interaction regression coverage; scores and estimates unchanged. | | 2026-11-16 | minor | Color panel: the spectrum fills the vertical space of a resized panel, with options shown or hidden (#8005). Compact auto-fit flyouts and embedded mixers keep their existing size. Evidence: panels::color::tests::the_spectrum_grows_with_the_color_panel. Scores and estimates unchanged. | | 2026-11-15 | minor | PDF import: stroked type (text rendering modes 1, 2, 5 and 6, and glyphs under `ActualText`) keeps the line cap, line join and miter limit of the graphics state it is stroked with, as paths do, instead of butt caps, miter joins and a miter limit of 10; a glyph filled and then stroked otherwise than the run its fill joined comes in as a run of its own, so the glyphs before it keep their stroke (#7741; `imported_stroked_type_keeps_the_files_cap_join_and_miter_limit` in `crates/pdf/src/tests/textstroke.rs`). Scores and estimates unchanged. | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 264a414667..885f191dc2 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1,6 +1,6 @@ # Parity with Adobe Illustrator -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-17 · **Change:** minor (PDF import: translucent type filled and stroked comes in as a filled type object and a stroked one, as the file composites them, and an upright glyph is never kept as the outline of its glyph alone, #8015; PDF import: type filled and stroked by one text-showing operator comes in as one type object, filled and stroked, not a stroked copy over a filled one, #8015; Properties panel: the Character section shows the font of the Type tool's selection, not the first run's (#8189); scores and estimates unchanged; previously: Recolor Artwork follow-up (#8031, remaining #4028): native Lab input, picker swatch libraries and Assign-row menus; UI interaction regression coverage; scores and estimates unchanged; previously: #8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: Paragraph composers (#4935): the Paragraph panel menu and paragraph styles offer four composers, the Middle Eastern & South Asian Single-line and Every-line (how all type is set, and the default) and a Standard Single-line and Every-line that set Indic, Arabic and Hebrew type glyph by glyph as the font maps it, for legacy fonts that keep a script on Latin character codes; PDF import: stroked type keeps the line cap, line join and miter limit the file strokes it with, a glyph stroked otherwise than the run it joins coming in as a run of its own, #7741; G5: Neon & Glow joins built-in graphic style libraries (Cyan Neon, Magenta Laser, Amber Tube, Electric Lime, Pulse Violet, Cobalt Phosphor); scores and estimates unchanged; previously: Pencil ignores Smart Guides and Snap to Point and shows no Smart Guides, #7252; previously: Pencil continuation, straight-line and closing cursors; scores and estimates unchanged; previously: G5: Weather Icons joins built-in symbol libraries (Sun, Moon, Cloud, Rain, Thunder, Snow); scores and estimates unchanged; previously: a closed Pencil stroke closes with a straight segment; previously: Snap to Point with Smart Guides off draws no Smart Guides labels or lines, #7250; previously: 3D: the seams of Extrude & Bevel, Inflate and Rotate under a white light, and of the faces of Extrude & Bevel (Classic), Revolve (Classic) and Rotate (Classic), went from miter to round joins, so white-light 3D output is expected to differ from the 2026-10-17 comparison at facet corners (not measured: the scenes were not exported again); previously: `.ai` and EPS import: in layers that don't draw as the page, art that differs away from an envelope of type no longer costs it its editable type; it keeps its drawn art where, in the pixels it and its drawn art ink, the layers with it differ from the page more than its own check allows, or past the envelopes' share of the page check, #7141; Character panel: the Set Font Height Reference dropdown shows an icon before each reference, #6304; scores and estimates unchanged; previously: Envelopes: a top object's side whose pieces are all one curve split at anchors follows that curve's parameter, so a top object saved with its sides' curves in pieces draws as its `.ai` drawn art, #7097; scores and estimates unchanged; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: PDF import: glyphs in a span with an empty ActualText come in as outlines, #6971; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously minor: Object › Rasterize with the Grayscale or Bitmap colour model makes a grayscale image, #6969; scores and estimates unchanged; previously minor: `.ai` and EPS import: type in an envelope with Distort Appearance is also tried mapped from the box of what it paints, miter tips and moved strokes included, after its glyphs grown by half its strokes' weight (#6824; #6617: Swatches panel menu: Show Recent Colors; scores unchanged; previously minor: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: #6865: explicitly requested oversized editing artboard; macOS: the canvas cursor stays after the pointer moves, #6362; scores and estimates unchanged; previously minor: Type tool: kerning at a caret at the start of a line moves the character after it, #5111; scores and estimates unchanged; previously minor: Rulers: the zero point dragged out of the rulers' corner snaps as a drawn point does; previously minor: Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: Envelopes: with Distort Appearance, type's strokes paint along the bent glyph outlines at their own weight, as users' `.ai` files draw them, which changes how VectorCraft's own envelopes of stroked type draw (#6644; scores and estimates unchanged); previously minor: G5: Energy Beams brush library; bundled content ~44% → ~46%; previously minor: G5: Skill Icons symbol library; bundled content ~42% → ~44%; previously minor: `.ai` and EPS import: an envelope saved in Edit Contents whose mesh lies away from its drawn art by a move opens live on that art (#6570; scores and estimates unchanged); previously minor: ruler double-click adds a guide at the pointer, #5239; G5: Status Effects graphic style library; bundled content ~40% → ~42%; MCP symbol libraries list UI Frames and Map Markers; previously minor: G5: Inventory Icons built-in symbol library; bundled content ~38% → ~40%; previously minor: `.ai` and EPS import: stroked type in an envelope maps from its glyphs grown by half its stroke (#3179; scores and estimates unchanged); previously minor: `.ai` and EPS import: warps of type open as mesh envelopes on their saved grid where VectorCraft's warp doesn't draw as their drawn art (#3179; scores and estimates unchanged); G5: Game Trails brush library; bundled content ~36% → ~38%; previously minor: Edit › Edit Custom Dictionary…: its dialog adds, deletes and changes the custom dictionary's words, #4936; previously minor: `.ai` and EPS import: envelopes of type open live where they draw as their drawn art and the layers with them draw as the page (#3179; scores and estimates unchanged); G5: Game HUD graphic style library; bundled content ~34% → ~36%; previously minor: Line Arrow arrowhead (#5421; scores and estimates unchanged); G5: Map Markers built-in symbol library; bundled content ~32% → ~34%; previously minor: right-click on type: Spelling › Auto Spell Check, with its check mark, #4936; previously minor: right-click on a word Auto Spell Check underlined: its suggestions, Ignore All and Add to Dictionary, #4936; previously minor: Canvas: a 3D effect changed on type or a group redraws where its solid was; Fit to Artwork Bounds and per-artboard SVG export build each solid once for all artboards; previously minor: Effect Gallery: a thumbnail for each filter and a preview area inside the dialog, on an original drawing; Raster effects 52% → 55%, hours 1–2 → none; headline numbers unchanged; Auto Spell Check: `edit.autoSpellCheck` underlines the unknown words, #4936; previously minor: PDF editable import preserves authored ActualText once, including empty/nested spans and authored ordering (#6165); cross-line/style layout remains approximate; scores and estimates unchanged; PDF marked-text export (#6309): compatible glyphs stay on one layout line with per-glyph offsets; scores and estimates unchanged; G5: UI Frames built-in symbol library with default 9-slice; bundled content ~32%; previously minor: G5: dynamic symbol part on-canvas opacity/blend/gradient/pattern; strokes remaining no longer lists Overlap/auto corners; symbols ~88%; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; previously minor: harakat paint fallback clarified; previously minor: current Guides feature-area rows consolidated using existing ruler evidence; scores and estimates unchanged; previously minor: Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; previously minor: G5 docs: Art brush Overlap and Pattern brush auto corners removed from strokes remaining; symbols remaining lists dynamic on-canvas beyond solid and guides outside the art; previously minor: custom dictionary and Ignore All: `text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary` and `ignoreAll`, #4936; previously minor: EPS import: embedded fonts (composite, Type 42, CID-keyed, Type 1, CFF FontSet) draw their glyphs; spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, #4936; previously minor: floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; `.ai`/EPS type keeps its tab stops, and right-aligned lines with tabs lay out as the file's page, #6147; `.ai`/EPS type from the text document lays its lines out closer to the file's page, within limits, #6137; `.ai` and EPS import: older Art brush objects read; numeric fields step on wheel hover without taking keyboard focus, and a panel wheel turn cannot seed a canvas zoom glide, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Tools stays beside the canvas with left-side panels; new gradients follow document color mode; Selection QoL: marquee modes and visible feedback, #5313; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; the canvas keeps selection outlines and anchors between frames; Indian-language hyphenation review and license allowlist, #4947; Stroke gradients: an arrowhead aligned to the tip is painted to the corners of its base, #5964; Drop Shadow and glow dialogs: spinner arrows, #5367, #5368; Stroke Weight Up and Down shortcuts, #5797; Hindi catalog and contributor loanword preferences; full wording review in progress; Properties in Edit Artboards: a Transform section with the reference point above the Artboards section, #5219; the Control bar's Stroke: and Opacity: links scrub their fields, #4088; an image zoomed in on is separated, colorized or proofed only where it shows (#4155); a document's first frame renders on the render worker, so opening a heavy file no longer freezes the window, #4155; Control bar Paragraph section with type selected, #5372; translating unchanged type reuses its glyph and character-stroke outlines; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026; Units › East Asian Type acts, with Q and Ha units; scores unchanged) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-17 · **Change:** minor (PDF import: translucent type filled and stroked comes in as a filled type object and a stroked one, as the file composites them, and an upright glyph is never kept as the outline of its glyph alone, #8015; PDF import: type filled and stroked by one text-showing operator comes in as one type object, filled and stroked, not a stroked copy over a filled one, #8015; Layers panel: Alt over the list shows the copy cursor while rows or the selection square are dragged, #8217; scores and estimates unchanged; previously: Gradient panel: the add-stop strip under the ramp shows the white arrow with a plus on Windows and X11, #8241; scores and estimates unchanged; previously: Properties panel: the Character section shows the font of the Type tool's selection, not the first run's (#8189); scores and estimates unchanged; previously: Recolor Artwork follow-up (#8031, remaining #4028): native Lab input, picker swatch libraries and Assign-row menus; UI interaction regression coverage; scores and estimates unchanged; previously: #8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: Paragraph composers (#4935): the Paragraph panel menu and paragraph styles offer four composers, the Middle Eastern & South Asian Single-line and Every-line (how all type is set, and the default) and a Standard Single-line and Every-line that set Indic, Arabic and Hebrew type glyph by glyph as the font maps it, for legacy fonts that keep a script on Latin character codes; PDF import: stroked type keeps the line cap, line join and miter limit the file strokes it with, a glyph stroked otherwise than the run it joins coming in as a run of its own, #7741; G5: Neon & Glow joins built-in graphic style libraries (Cyan Neon, Magenta Laser, Amber Tube, Electric Lime, Pulse Violet, Cobalt Phosphor); scores and estimates unchanged; previously: Pencil ignores Smart Guides and Snap to Point and shows no Smart Guides, #7252; previously: Pencil continuation, straight-line and closing cursors; scores and estimates unchanged; previously: G5: Weather Icons joins built-in symbol libraries (Sun, Moon, Cloud, Rain, Thunder, Snow); scores and estimates unchanged; previously: a closed Pencil stroke closes with a straight segment; previously: Snap to Point with Smart Guides off draws no Smart Guides labels or lines, #7250; previously: 3D: the seams of Extrude & Bevel, Inflate and Rotate under a white light, and of the faces of Extrude & Bevel (Classic), Revolve (Classic) and Rotate (Classic), went from miter to round joins, so white-light 3D output is expected to differ from the 2026-10-17 comparison at facet corners (not measured: the scenes were not exported again); previously: `.ai` and EPS import: in layers that don't draw as the page, art that differs away from an envelope of type no longer costs it its editable type; it keeps its drawn art where, in the pixels it and its drawn art ink, the layers with it differ from the page more than its own check allows, or past the envelopes' share of the page check, #7141; Character panel: the Set Font Height Reference dropdown shows an icon before each reference, #6304; scores and estimates unchanged; previously: Envelopes: a top object's side whose pieces are all one curve split at anchors follows that curve's parameter, so a top object saved with its sides' curves in pieces draws as its `.ai` drawn art, #7097; scores and estimates unchanged; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: PDF import: glyphs in a span with an empty ActualText come in as outlines, #6971; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously minor: Object › Rasterize with the Grayscale or Bitmap colour model makes a grayscale image, #6969; scores and estimates unchanged; previously minor: `.ai` and EPS import: type in an envelope with Distort Appearance is also tried mapped from the box of what it paints, miter tips and moved strokes included, after its glyphs grown by half its strokes' weight (#6824; #6617: Swatches panel menu: Show Recent Colors; scores unchanged; previously minor: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: #6865: explicitly requested oversized editing artboard; macOS: the canvas cursor stays after the pointer moves, #6362; scores and estimates unchanged; previously minor: Type tool: kerning at a caret at the start of a line moves the character after it, #5111; scores and estimates unchanged; previously minor: Rulers: the zero point dragged out of the rulers' corner snaps as a drawn point does; previously minor: Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: Envelopes: with Distort Appearance, type's strokes paint along the bent glyph outlines at their own weight, as users' `.ai` files draw them, which changes how VectorCraft's own envelopes of stroked type draw (#6644; scores and estimates unchanged); previously minor: G5: Energy Beams brush library; bundled content ~44% → ~46%; previously minor: G5: Skill Icons symbol library; bundled content ~42% → ~44%; previously minor: `.ai` and EPS import: an envelope saved in Edit Contents whose mesh lies away from its drawn art by a move opens live on that art (#6570; scores and estimates unchanged); previously minor: ruler double-click adds a guide at the pointer, #5239; G5: Status Effects graphic style library; bundled content ~40% → ~42%; MCP symbol libraries list UI Frames and Map Markers; previously minor: G5: Inventory Icons built-in symbol library; bundled content ~38% → ~40%; previously minor: `.ai` and EPS import: stroked type in an envelope maps from its glyphs grown by half its stroke (#3179; scores and estimates unchanged); previously minor: `.ai` and EPS import: warps of type open as mesh envelopes on their saved grid where VectorCraft's warp doesn't draw as their drawn art (#3179; scores and estimates unchanged); G5: Game Trails brush library; bundled content ~36% → ~38%; previously minor: Edit › Edit Custom Dictionary…: its dialog adds, deletes and changes the custom dictionary's words, #4936; previously minor: `.ai` and EPS import: envelopes of type open live where they draw as their drawn art and the layers with them draw as the page (#3179; scores and estimates unchanged); G5: Game HUD graphic style library; bundled content ~34% → ~36%; previously minor: Line Arrow arrowhead (#5421; scores and estimates unchanged); G5: Map Markers built-in symbol library; bundled content ~32% → ~34%; previously minor: right-click on type: Spelling › Auto Spell Check, with its check mark, #4936; previously minor: right-click on a word Auto Spell Check underlined: its suggestions, Ignore All and Add to Dictionary, #4936; previously minor: Canvas: a 3D effect changed on type or a group redraws where its solid was; Fit to Artwork Bounds and per-artboard SVG export build each solid once for all artboards; previously minor: Effect Gallery: a thumbnail for each filter and a preview area inside the dialog, on an original drawing; Raster effects 52% → 55%, hours 1–2 → none; headline numbers unchanged; Auto Spell Check: `edit.autoSpellCheck` underlines the unknown words, #4936; previously minor: PDF editable import preserves authored ActualText once, including empty/nested spans and authored ordering (#6165); cross-line/style layout remains approximate; scores and estimates unchanged; PDF marked-text export (#6309): compatible glyphs stay on one layout line with per-glyph offsets; scores and estimates unchanged; G5: UI Frames built-in symbol library with default 9-slice; bundled content ~32%; previously minor: G5: dynamic symbol part on-canvas opacity/blend/gradient/pattern; strokes remaining no longer lists Overlap/auto corners; symbols ~88%; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; previously minor: harakat paint fallback clarified; previously minor: current Guides feature-area rows consolidated using existing ruler evidence; scores and estimates unchanged; previously minor: Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; previously minor: G5 docs: Art brush Overlap and Pattern brush auto corners removed from strokes remaining; symbols remaining lists dynamic on-canvas beyond solid and guides outside the art; previously minor: custom dictionary and Ignore All: `text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary` and `ignoreAll`, #4936; previously minor: EPS import: embedded fonts (composite, Type 42, CID-keyed, Type 1, CFF FontSet) draw their glyphs; spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, #4936; previously minor: floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; `.ai`/EPS type keeps its tab stops, and right-aligned lines with tabs lay out as the file's page, #6147; `.ai`/EPS type from the text document lays its lines out closer to the file's page, within limits, #6137; `.ai` and EPS import: older Art brush objects read; numeric fields step on wheel hover without taking keyboard focus, and a panel wheel turn cannot seed a canvas zoom glide, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Tools stays beside the canvas with left-side panels; new gradients follow document color mode; Selection QoL: marquee modes and visible feedback, #5313; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; the canvas keeps selection outlines and anchors between frames; Indian-language hyphenation review and license allowlist, #4947; Stroke gradients: an arrowhead aligned to the tip is painted to the corners of its base, #5964; Drop Shadow and glow dialogs: spinner arrows, #5367, #5368; Stroke Weight Up and Down shortcuts, #5797; Hindi catalog and contributor loanword preferences; full wording review in progress; Properties in Edit Artboards: a Transform section with the reference point above the Artboards section, #5219; the Control bar's Stroke: and Opacity: links scrub their fields, #4088; an image zoomed in on is separated, colorized or proofed only where it shows (#4155); a document's first frame renders on the render worker, so opening a heavy file no longer freezes the window, #4155; Control bar Paragraph section with type selected, #5372; translating unchanged type reuses its glyph and character-stroke outlines; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026; Units › East Asian Type acts, with Q and Ha units; scores unchanged) > > Tech Circuit update (2026-11-14): three original procedural brushes; ten built-in brush libraries (G5). > @@ -976,6 +976,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Screen readers get the value of the color and channel sliders that panels and dialogs draw (the Color panel, the Color Picker, Swatch Options, the Navigator's Zoom, the Character panel's variable font axes, the Perspective Grid and flattener options, and the sliders of the effect, tool option and transform dialogs): the number and text of the field beside each one, such as 128 for G or 50% for an opacity, with the slider's range, which extends to include a number past the slider's end. The harmony wheel's Brightness slider, which has no field, reports its brightness in percent. - A layer whose Layer Options › Print is off shows its name italic in the Layers panel, and while its row is dragged, as the reference application shows non-printing layers (#5739); a printing layer stays upright and ticking Print again restores the upright name (`panels::layers` test `a_layer_that_does_not_print_has_its_name_italic`). - In the Layers panel only the primary mouse button drags. A drag with the right or middle button on a row, a guide row, the selection square, the eye or lock column or a target circle moves, copies, hides, locks and transfers nothing and records no undo step, and a right-click still opens the row's menu (`panels::layers` test `only_the_primary_button_drags_rows_guides_art_columns_and_appearances`). + - Rows or the selection square dragged over the Layers panel's list show the copy cursor while Alt is held, as the drop then copies, and the grabbing hand otherwise; the cursor follows Alt pressed or released mid-drag. The copy cursor is the panels' add cursor (#8241): on Windows and X11, which have no system copy cursor winit can show, the white arrow with a plus. Over the trash and New Layer, which delete or duplicate with or without Alt, the hand stays, and guide rows keep their own cursor (#8217; `panels::layers` tests `alt_shows_the_copy_cursor_while_rows_are_dragged` and `drag_cursor_shows_a_copy_only_where_the_drop_copies`). - Rows dragged in the Layers panel and held within 28 points of the list's top or bottom edge scroll a long list that way, faster nearer the edge (60 points a second at the band's inner side, 340 at the edge, at every frame rate), and keep scrolling while the pointer stays still, so a row out of view can take the drop (a move, or a copy with Alt); the Libraries panel's list scrolls by the same rule. In a list view shorter than 56 points each band is half the view, so a pointer in the top half scrolls up, one in the bottom half scrolls down, and a pointer just outside the view does not scroll it toward the far edge. A pointer beside the list, a drag of the eye or lock column and a release stop the scrolling, and scrolling changes nothing in the document. The band and speeds are VectorCraft's own (`panels::layers` tests `rows_held_near_the_bottom_or_top_edge_scroll_the_list_to_a_row_out_of_view`, `a_held_row_scrolls_the_list_as_far_in_the_same_time_at_any_frame_rate` and `the_list_scrolls_only_for_rows_held_over_it`; `panels` test `drag_scrolling_in_a_short_list_goes_toward_the_nearer_edge`). - The other panels' item drags start only with the primary mouse button too: swatches and color groups, brushes, symbols, graphic styles, library items and groups, character and paragraph styles, Appearance rows and its thumbnail, the Fill and Stroke squares, Recent Colors and the Gradient panel's thumbnail. A right or middle drag on one carries nothing, moves, copies, deletes and applies nothing and records no undo step; right-click menus and the Graphic Styles panel's held right-button preview stay as they were (`panels::swatches` test `only_a_primary_drag_moves_swatches_and_groups`, `panels::text_styles` test `only_a_primary_drag_carries_a_style_row`, `panels::tests_symbol_libraries` test `only_a_primary_drag_carries_a_library_symbol_out`, `panels::tests_effectedit` test `only_a_primary_drag_carries_the_thumbnail_or_a_row`). - Panels undock (#495): a dock tab, a panel icon or a popped-out panel's title dragged out of the dock floats that panel (in an OS window of its own on the desktop, #4135), and the strip right of the dock's tabs floats the whole tabbed group. A floating group moves by its title bar, a tab dragged out of it floats on its own, and dropped on another group's title bar or tabs it stacks with that group; dropped on a dock group's tabs, which light up under the pointer, its panels join that group, and on the group's upper or lower half they make a new group above or below it (`window.panel.dock {anchor, zone}`); dropped on the icon column they become icons there, the tabbed group's panels too (`window.panel.dock {icon: true}`); dropped anywhere else on the dock, which lights up, they go back where they live (the tabbed group or the icon column), as its × and the panel menus' Float Panel / Dock Panel do (`window.panel.float`, `window.panel.dock`). The Tools panel floats by its title bar and docks again on the window's left edge. Floating groups stack into sets: dropped on the upper or lower half of another group (a line shows where), a group joins it right above or below it, and the set's groups stack top to bottom, each showing one panel, moving together by the top group's title bar, whose × docks them all; a group dragged by its tab strip leaves the set (`window.panel.float {below, above}`). A double-click on a tab collapses a floating group to its tabs (`collapsed`), and a dock group too, a group below it moving up into the room; a second double-click, or a click on another of its tabs, expands it (`window.panel.collapse`, kept with the preferences and in saved workspaces). Sets dropped on the left edge of the icon column or of another dock column dock as dock columns (a multi-column dock, `window.panel.dock {column}`), whose groups stack, tab and tear out as a floating set's do, and whose top strip floats the column again. Floating panels, their sets and the Tools panel's position are kept with the preferences and in user workspaces, and clamped into a smaller window. Not done: panels in separate OS windows, reordering tabs by dragging, collapsing a set or dock column to icons, dock columns right of the default dock, resizing floating panels and the groups of a set. @@ -1763,6 +1764,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur A gradient stop that loses its link to a spot swatch (the swatch deleted, a recolor or adjustment that unlinks it, a library gradient, or a library character style linked to a swatch the document lacks) keeps the color it shows at full tint and drops the process plates it printed with that ink, as a stop given a plain color does; this is VectorCraft's own rule. Evidence: `tests::mapping_links_drops_the_process_plates_of_unlinked_stops` in `crates/color`, `tests::linked_stops::deleting_a_spot_swatch_takes_the_process_plates_of_the_stops_it_unlinks` and `tests::library::library_stops_unlinked_from_their_swatch_keep_no_process_plates` in `crates/engine`. Merge Swatches (`swatch.merge`) also drops the process plates of the gradient stops linked to a swatch it merges, whether the kept swatch is spot, global process or process that isn't global, in the art, gradient swatches, graphic styles, the art of brushes and the fill and stroke for new art; a stop linked to another swatch keeps its plates, and Undo puts the links and plates back. This is VectorCraft's own rule. Evidence: `tests::linked_stops::merging_swatches_takes_the_process_plates_of_the_stops_it_relinks` in `crates/engine`. - The Gradient panel's Delete Stop sits at the right end of the ramp, level with it, so a panel too short to show the stop fields still shows it; it deletes the selected stop (never below two), as dragging a stop down off the ramp does (#5403). + - Over the strip under the Gradient panel's ramp, where a click adds a stop, the pointer is the white arrow with a plus that Group Selection shows for a click that adds. Windows has no system copy cursor (winit shows the plain arrow for it), so on Windows and X11 the panel hands the glyph to the OS as the canvas hands its tool cursors; macOS, Wayland and the web show the system copy cursor. Over the ramp itself, which adds nothing, the pointer stays the arrow (#8241; `panels::gradient` test `the_strip_under_the_ramp_shows_the_add_cursor`). - Conic gradients, VectorCraft's own gradient type: the stops sweep once around the center from the vector, clockwise on the page (a negative aspect, or a reflection, turns the sweep the other way), with a Conic button in the Gradient panel's Type row and the Gradient tool's extent ellipse and aspect handle; they follow transforms, Expand into wedges or a mesh, open from `.af` files, and export to PDF as a function-based shading that PDF import reads back as a conic gradient; SVG, EPS and legacy `.ai` files get solid wedges, and CSS a `conic-gradient`. - Diamond gradients, VectorCraft's own gradient type: the stops run from the center out to a square with a corner at the end of the vector (the aspect stretches it into a rhombus), with a Diamond button in the Gradient panel's Type row and the Gradient tool's square and aspect handle; they follow transforms, Expand into nested squares or a mesh, and export to PDF, SVG, EPS and legacy `.ai` as four linear gradients, one for each quarter of the square (an image in PDF and SVG for translucent stops, a dithered fill, the Perceptual method other than spot color shadings in PDF, or a square with no area), and on type characters in SVG as a radial gradient; PDF import reads a function-based shading whose color is the same along each square about its origin as a diamond gradient. - Hue Clockwise and Hue Counterclockwise, VectorCraft's own gradient methods, in the Gradient panel's Method menu and on `paint.editGradient` and `paint.setFill` (`method`: `hue-clockwise`, `hue-counterclockwise`): a linear, radial, conic or diamond gradient's colors mix around the hue wheel, with hue, saturation and brightness each changing evenly from one stop to the next and the hue angle keeping one direction, as the fixed-direction rules of [CSS Color 4](https://www.w3.org/TR/css-color-4/#hue-interpolation) do: falling with Hue Clockwise (red, magenta, blue), which is clockwise on the color wheels, and rising with Hue Counterclockwise (red, yellow, green). Hues less than half a color level apart count as one hue, so a color and its tint do not turn the wheel. A gray stop takes the hue of the stop it mixes with, and black its saturation too. The canvas and raster exports draw it through stops on that curve, within half a color level; Reverse Gradient turns the method the other way with the stops, so the ramp keeps its colors. SVG and PDF write it as an RGB image, EPS as a shading in process colors, and a legacy `.ai` file and the `.ai` editing data with the colors between its stops as stops of their own, with a warning. @@ -1926,6 +1928,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur A PDF-compatible `.ai` saved with Include Editing Data for Other Apps keeps envelopes made with a warp, a mesh or a top object editable: its editing copy holds each envelope's contents, shape, Fidelity, Envelope Options and Edit Contents state in the form VectorCraft's `.ai` envelope reader reads, beside its distorted art, so the file opens with the same live envelope, Edit Contents still switching between the contents and the envelope ([Edit the contents of envelopes](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/edit-the-contents-of-envelopes.html)). Envelopes whose type is threaded, has text wrap options or is written as its outlines, envelopes in opacity masks, pattern tiles or another envelope's contents, and envelopes the reader would open with another shape or other settings (a Fidelity that isn't a whole number, bounds margins kept with Distort Appearance off), and envelopes after the first 256 envelopes and images with a Warp in a file are written as their distorted art, with a warning (`envelopes_are_read_back_live` and `envelopes_the_reader_cannot_open_live_are_written_as_their_art` in `crates/eps/src/ai_editing/tests.rs`). On a large canvas ([the help page](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/start-a-new-file/large-canvas-faq.html); VectorCraft writes one when the artboards together are wider or taller than 16,381 points, its own limit), that `.ai` keeps warp, mesh and top object envelopes editable too: the editing copy writes them live at 1/10 of their size with the rest of the art, and VectorCraft's `.ai` reader opens them at their size, from the editing data alone or beside the PDF part. Read from the editing data alone, an envelope's saved box size is compared with its contents at the same scale, so a bounds margin kept with Distort Appearance comes back, and every path's stroke weight, dashes and dash offset come back at their size, not at 1/10 (`large_canvas_envelope_kinds_round_trip_on_both_ai_routes`, `large_canvas_envelope_stroke_margin_round_trips_on_both_ai_routes` and `a_large_canvas_path_keeps_its_stroke_weight_and_dashes_read_alone` in `crates/eps/src/ai_editing/tests.rs`). An envelope whose contents hold type keeps the type editable in that `.ai`: the editing copy writes the type as type in the envelope's contents, in the form the `.ai` reader opens as a live envelope of type (`TypedEnvelope` in `crates/eps/src/import/ai/envelope.rs`), so the file opens with the type shown and editable in the envelope's contents, with Edit Contents off or on. An envelope of type in a symbol's art, and one whose type is threaded, has text wrap options or is written as its outlines (mirrored type, for example), is written as its distorted art, as before (`an_envelope_of_type_is_read_back_live_with_its_type`, `an_envelope_of_type_written_as_its_art_leaves_no_story` and `an_envelope_of_type_in_a_symbol_or_a_thread_is_written_as_its_art` in `crates/eps/src/ai_editing/tests.rs`). + A PDF-compatible `.ai` saved with Include Editing Data for Other Apps keeps blends live: its editing copy holds each blend's key objects, its spine when it has one of its own, its drawn steps, and its spacing (Smooth Color, Specified Steps, Specified Distance) and orientation (Align to Page, Align to Path) ([Blend Options](https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/blend-options-overview.html), [blends and their spine](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=260)), in the form VectorCraft's `.ai` blend reader reads (`crates/eps/src/import/ai/blend.rs`), so the file opens with the same live blend laying out the same steps. Each blend is checked with that reader before it is written; blends it wouldn't open with their settings or as they are drawn are written as their steps with a warning ([file-format-parity.md](file-format-parity.md) lists them) (`blends_are_read_back_live`, `blends_of_compound_paths_groups_and_62_keys_are_read_back_live` and `blends_the_reader_cant_read_are_written_as_their_steps` in `crates/eps/src/ai_editing/tests.rs`). A top object whose top and bottom sides, or left and right sides, have different numbers of segments is also saved live: the side with fewer segments is split into as many as the side across from it has (each segment into equal spans of its curve, a straight one at even steps), up to the 50 a side the grid holds, so the file opens with the same corners and the same mapping of the contents, its outline holding the added anchors. Where the split side would share out the contents another way, as a side of two curves that aren't one curve can, or a side has more than 50 segments, the envelope is written as its distorted art, with the warning (`a_top_object_with_uneven_sides_is_read_back_live`, `a_top_object_split_to_the_grids_limit_is_read_back_live` and `a_top_object_whose_split_side_would_map_another_way_is_written_as_its_art` in `crates/eps/src/ai_editing/tests.rs`). A PDF-compatible `.ai` saved with Include Editing Data for Other Apps writes eligible paths, compound paths and groups with live effects with an art style when the writer supports their appearance and effects (not a filled path that uses the even-odd rule, and none on a large canvas), which VectorCraft's `.ai` reader opens as the same appearance with its effects live (`objects_with_live_effects_are_read_back` and `every_effect_setting_written_on_an_object_is_read_back` in `crates/eps/src/ai_editing/tests.rs`; [file-format-parity.md](file-format-parity.md) lists the objects written without one and the effects they lose). The same holds for the objects of an opacity mask's art, a mask inside another mask's art and a hidden art root included, so a mask whose art has Offset Path opens drawing the image it masks as it did, with the effect live; geometry effects that no art style holds on a mask's art, such as Roughen, are written applied to the art, which opens drawing what it drew (`a_masked_image_with_live_offset_path_round_trips`, `hidden_and_nested_mask_art_keep_live_offset_path` and `a_masks_art_with_an_effect_no_style_holds_is_written_as_it_draws` in `crates/eps/src/ai_editing/tests.rs`). @@ -2201,6 +2204,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Raster-effect resolution in PDF:** when the 64 million pixel cap on an effect image renders an object's raster effects below the document's raster effects resolution, PDF export warns once per object with the requested and the lowest achieved ppi (`crates/engine/src/tests/pdfraster.rs`). - **Rasterize effect:** Effect › Rasterize… (`rasterize`) draws an object as an image of square pixels at its own resolution or the document's raster effects resolution, with Object › Rasterize's color model, background, anti-aliasing, clipping mask and room around the object, while its paths stay editable. Expand Appearance and PDF and SVG export of an object whose only raster effect is Rasterize give the image Object › Rasterize gives (`crates/engine/src/tests/rastersettings.rs`, `crates/render/src/tests/rasterize.rs`). Behavior reference: [How to save artwork in Illustrator](https://helpx.adobe.com/illustrator/using/saving-artwork.html), [Work with effects](https://helpx.adobe.com/illustrator/using/effects.html). - **Rasterize colour models:** Object › Rasterize with the Grayscale colour model makes a grayscale image (a gray PNG, with alpha over a transparent background), and with Bitmap a 1-bit image (a TIFF), or a black-and-white gray PNG with alpha over a transparent background; `image.info` and the Control bar say Grayscale, and a fill color colorizes the image, in RGB and CMYK documents (#6969). Expand Appearance and PDF export of a Rasterize effect make the same images. Regression coverage: `rasterize_to_grayscale_or_bitmap_makes_a_grayscale_image` (`crates/engine/src/tests/rastersettings.rs`) and `gray_and_bilevel_images_store_gray` (`crates/render/src/encode/tests.rs`). Scores and estimates unchanged. +- **Rasterize dialog choices:** Object › Rasterize… shows Anti Alias (None, Art Optimized, Type Optimized) and Background (White, Transparent) as dropdowns, where they were text fields holding the command's values. Object › Create Gradient Mesh… shows its Appearance (Flat, To Center, To Edge) and Repeat Options for a grid repeat its Grid Type the same way (#8020, #7991). A value the dialog does not list, such as a black background set through `ui.dialog.set`, shows as it is and is sent unchanged. Regression coverage: `rasterize_anti_alias_and_background_are_dropdowns`, `mesh_appearance_and_repeat_grid_type_are_dropdowns` and `choice_fields_list_the_values_their_commands_take` (`crates/ui-egui/src/dialogs/command.rs`). Scores and estimates unchanged. - **SVG filters:** Effect › SVG Filters lists 14 default SVG filters and then the document's own below Apply SVG Filter… and Import SVG Filter…, and choosing one applies it to the selection as a live effect in one undo step (`svgFilter.apply`). Apply SVG Filter applies the selected filter, New and Edit open its code, and Delete and Import… remove filters or add those of an SVG file (`svgFilter.define`, `svgFilter.delete`, `svgFilter.import`). The public page names no default set: the defaults (Soft Blur to Hue Shift, `crates/effects/src/svg_filter/defaults.rs`) are VectorCraft's own, written with SVG 1.1 primitives. A default is copied into the document when it is applied or edited, and Delete does not remove a default. The canvas, raster export and PDF draw the filter at the Document Raster Effects resolution; SVG export writes it as a `` element when it is the object's last effect and otherwise draws the object as an image; SVG import keeps filters the other live effects can't express as this effect instead of leaving them out; the native format keeps the filters (`crates/engine/src/tests/svgfilter.rs`, `crates/effects/src/svg_filter/tests.rs`). Behavior reference: [Apply SVG filter effects](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-filter-effects/apply-svg-filter-effects.html), [CS5 help, Apply SVG effects](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=402), [SVG 1.1 Filter Effects](https://www.w3.org/TR/SVG11/filters.html). - **Pattern tiles:** the renderer keeps a tile of each pattern for each scale it rasterizes the pattern at, until the tiles fill the tile cache's budget, and then drops the least recently used tiles first. Objects that show one pattern at different scales, such as a pattern scaled to 25% with Transform Pattern Tiles next to the same pattern at 100%, draw from tiles kept between frames. @@ -2767,6 +2771,8 @@ Edit › Copy and Cut put the selected ruler guides on the clipboard, with the s | Date | Change | Summary | |---|---|---| +| 2026-11-16 | minor | Layers panel: rows or the selected-art square dragged over the list show the copy cursor while Alt is held, as the drop then copies, and the grabbing hand otherwise (#8217). Scores and estimates unchanged. | +| 2026-11-16 | minor | Gradient panel: the strip under the ramp, where a click adds a stop, shows the white arrow with a plus on Windows and X11, where the system copy cursor showed as the plain arrow (#8241). Scores and estimates unchanged. | | 2026-11-16 | minor | Properties panel: while the Type tool edits text, the Character section shows the font family and style and the Variable Font button of the first selected character (or of the character before the caret), not those of the text object's first run (#8189). Evidence: `panels::properties::tests::character_section_shows_the_type_tool_selections_style`. Scores and estimates unchanged. | | 2026-11-16 | minor | Recolor Artwork follow-up (#8031, remaining #4028): native Lab input, picker swatch libraries and Assign-row menus; UI interaction regression coverage; scores and estimates unchanged. | | 2026-11-16 | minor | Color panel: the spectrum fills the vertical space of a resized panel, with options shown or hidden (#8005). Compact auto-fit flyouts and embedded mixers keep their existing size. Evidence: panels::color::tests::the_spectrum_grows_with_the_color_panel. Scores and estimates unchanged. | diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 550da7c469..b312abae1b 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-16 · **Change:** minor (Recolor Artwork follow-up (#8031, remaining #4028): native Lab input, picker swatch libraries and Assign-row menus; UI interaction regression coverage; scores and estimates unchanged; previously: #8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: Pencil continuation, straight-line and closing cursors; scores and estimates unchanged; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: macOS: the canvas cursor stays after the pointer moves, #6362; scores and estimates unchanged; previously minor: Remove Background in the Contextual Task Bar, Properties › Quick Actions and the Control bar; previously minor: Ruler origin: the corner drag snaps as a drawn point does; previously minor: Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: Outline view: images and gradient meshes are picked on what Outline draws, so a click inside them reaches the path behind, #6437; previously minor: a middle-click on a document tab closes it, #6506; previously minor: Blob Brush: a round tip's preview is the outline of the area it adds, round at both ends, as the stroke it commits (#4343); scores and estimates unchanged; previously:; ruler double-click adds a guide at the pointer, #5239; G5: Inventory Icons built-in symbol library (four built-ins); previously minor: files that record no units open in Preferences › Units › General, #5820; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; numeric fields step on wheel hover without taking keyboard focus, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Selection QoL: marquee modes and visible feedback, #5313; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; Drop Shadow and glow dialogs: spinner arrows, #5367, #5368; Stroke Weight Up and Down shortcuts, #5797; Layers: Rename (`ui.rename`) opens the name field of the selected layer, group or object, #5324; Properties in Edit Artboards: Transform section above the Artboards section, #5219; scrubby labels: the Control bar's Stroke: and Opacity: links and the Properties panel's Stroke link scrub their fields, #4088; Properties: Quick Actions has Repeat Options for one selected repeat, #5181; Direct Selection: Shift-click picks several blend spine points, which drag together, #5285; Direct Selection: Cmd/Ctrl held lends the Selection tool and shows its bounding box, #3901; Join tool trims two crossing open paths and joins them at the crossing, #5844; Control bar: Paragraph: link and Align left/center/right while type is selected, #5372; shape tools: a press on the selection's centre point moves it and one in the rotate zone outside a box corner turns it, #5477; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; Units › East Asian Type acts, with Q and Ha units; scores unchanged) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-16 · **Change:** minor (Layers panel: Alt over the list shows the copy cursor while rows or the selected-art square are dragged, #8217; scores and estimates unchanged; previously: Gradient panel: the add-stop strip under the ramp shows the white arrow with a plus on Windows and X11, #8241; scores and estimates unchanged; previously: Recolor Artwork follow-up (#8031, remaining #4028): native Lab input, picker swatch libraries and Assign-row menus; UI interaction regression coverage; scores and estimates unchanged; previously: #8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: Pencil continuation, straight-line and closing cursors; scores and estimates unchanged; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: macOS: the canvas cursor stays after the pointer moves, #6362; scores and estimates unchanged; previously minor: Remove Background in the Contextual Task Bar, Properties › Quick Actions and the Control bar; previously minor: Ruler origin: the corner drag snaps as a drawn point does; previously minor: Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: Outline view: images and gradient meshes are picked on what Outline draws, so a click inside them reaches the path behind, #6437; previously minor: a middle-click on a document tab closes it, #6506; previously minor: Blob Brush: a round tip's preview is the outline of the area it adds, round at both ends, as the stroke it commits (#4343); scores and estimates unchanged; previously:; ruler double-click adds a guide at the pointer, #5239; G5: Inventory Icons built-in symbol library (four built-ins); previously minor: files that record no units open in Preferences › Units › General, #5820; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; numeric fields step on wheel hover without taking keyboard focus, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Selection QoL: marquee modes and visible feedback, #5313; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; Drop Shadow and glow dialogs: spinner arrows, #5367, #5368; Stroke Weight Up and Down shortcuts, #5797; Layers: Rename (`ui.rename`) opens the name field of the selected layer, group or object, #5324; Properties in Edit Artboards: Transform section above the Artboards section, #5219; scrubby labels: the Control bar's Stroke: and Opacity: links and the Properties panel's Stroke link scrub their fields, #4088; Properties: Quick Actions has Repeat Options for one selected repeat, #5181; Direct Selection: Shift-click picks several blend spine points, which drag together, #5285; Direct Selection: Cmd/Ctrl held lends the Selection tool and shows its bounding box, #3901; Join tool trims two crossing open paths and joins them at the crossing, #5844; Control bar: Paragraph: link and Align left/center/right while type is selected, #5372; shape tools: a press on the selection's centre point moves it and one in the rotate zone outside a box corner turns it, #5477; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; Units › East Asian Type acts, with Q and Ha units; scores unchanged) > > Tech Circuit update (2026-11-14): three original procedural brushes; ten built-in brush libraries (G5). > @@ -56,6 +56,8 @@ Artboard Options forwards the active Artboard tool's Scale Artwork with Artboard | 2026-11-09 | minor | Document Setup and Character panel Language lists: Nepali, Konkani and Sindhi complete #4943; Assamese and Sanskrit are already present from #5946. Names in all 27 catalogs come from [CLDR locale language-name data](https://github.com/unicode-org/cldr/tree/main/common/main). The public [language assignment documentation](https://helpx.adobe.com/illustrator/using/spelling-language-dictionaries.html) describes the Character panel Language menu, but does not establish that these five languages are listed there; inclusion and a single Sindhi entry remain maintainer decisions. Scores unchanged | | 2026-11-14 | minor | G5: Tech Circuit adds three original procedural brushes (Circuit Trace, Bus Lines, Terminal Nodes); ten built-in brush libraries. G5 remaining estimate 3–13 h (estimated); parity scores and headline totals unchanged. | | 2026-11-14 | minor | Layers panel: right-clicking a layer/group/object row shows a context menu with Options…, Duplicate, Delete, Lock/Hide Others, Locate Object, and Collect for Export — matching standard desktop layer panel conventions. Scores unchanged. | +| 2026-11-16 | minor | Layers panel: rows or the selected-art square dragged over the list show the copy cursor while Alt is held, as the drop then copies, and the grabbing hand otherwise (#8217). Scores and estimates unchanged. | +| 2026-11-16 | minor | Gradient panel: the strip under the ramp, where a click adds a stop, shows the white arrow with a plus on Windows and X11, where the system copy cursor showed as the plain arrow (#8241). Scores and estimates unchanged. | | 2026-11-13 | minor | Pencil cursors: the continuation cursor (a short rising line) shows over an open end of a selected path before any press, freehand too, and while a continuing stroke nears another selected path's open end it connects to; the straight-line cursor is a short level line; a continued path, a straight line too, shows the closing cursor and closes within Close Paths When Ends Are Within of its other end, and with Alt at the release. Scores and estimates unchanged. | | 2026-11-15 | minor | G12: Swatches item menus validated in all five views: 39 focused tests passed, regression fails without the menu hooks, rendered list/thumbnail layouts inspected, and fresh local deep CodeRabbit review found zero issues. Full workspace CI passed on Linux/WSL on the merged branch (all 13 gates), including the test-helper correction for the upstream compile error tracked in #7727; native Windows full CI has two unchanged engine-test failures. Scores and estimates unchanged. | | 2026-11-13 | minor | Graphic Styles: in a panel made taller the list fills the space above the footer instead of stopping at 220 pt (#2992; `the_list_fills_a_tall_panel_above_its_footer` in `crates/ui-egui/src/panels/graphic_styles.rs`). Scores and estimates unchanged. | @@ -183,6 +185,8 @@ tools, never checked side by side) isn't captured row by row. | Swatches list fills a taller panel (#1638) | done | Docked, floating or in a resized flyout, the swatch list takes the height above the panel's footer, as the Artboards list does; outside a sized panel it stays 150 pt (200 pt for large thumbnails); `the_list_fills_a_tall_panel_above_its_footer` in `panels/swatches/tests.rs` | | Layers panel lists a blend's spine (#4820) | done | an open blend shows a `` row below its key objects, where Release leaves the spine; a click selects the blend (Shift/Cmd toggles it) so Direct Selection edits the spine; a locked blend's row selects nothing; no row while searching or filtering (`a_blends_spine_is_a_row_below_its_keys_that_selects_the_blend`) | | Layers panel: a layer whose Layer Options › Print is off shows its name italic (#5739) | done | the panel row and its drag ghost; a printing layer stays upright, and Print on again restores it; `panels::layers` test `a_layer_that_does_not_print_has_its_name_italic` | +| Layers panel: Alt-drag shows the copy cursor (#8217) | done | rows and the selected-art square dragged over the list show the copy cursor while Alt is held and the grabbing hand otherwise, following Alt mid-drag; on Windows and X11 the copy cursor is the white arrow with a plus (the panels' add cursor, #8241); over the trash and New Layer, which ignore Alt, the hand stays; guide rows keep theirs; `alt_shows_the_copy_cursor_while_rows_are_dragged`, `drag_cursor_shows_a_copy_only_where_the_drop_copies` | +| Gradient panel: add-stop cursor under the ramp (#8241) | done | the white arrow with a plus (the Group Selection glyph) over the strip under the ramp, handed to the OS on Windows and X11 (winit shows the plain arrow for the system copy cursor there), the system copy cursor elsewhere; over the ramp itself the arrow stays; `panels::gradient` test `the_strip_under_the_ramp_shows_the_add_cursor` | | Blend spine Anchor Point conversion and handle editing (#2544) | implemented | symmetric handles, independent drag/retraction, visible-handle policy and selection/stacking covered by tool and engine regressions; Windows native canvas checks and screenshots reviewed in PR #2643 | | Several blend spine points picked and dragged together (#5285) | done | with Direct Selection, Shift-click picks more points of a selected blend's spine or takes one away, as on a path; dragging any picked point moves them all, and the key objects on them, in one undo step (`object.blend.spine.moveAnchor {with}`); a marquee picks the spine points inside it on the topmost selected blend, and with Shift adds or takes them away | | Add/Delete/Anchor Point tools; Anchor Point tool drags segments to reshape | done | #2267: a click on a handle end retracts that handle and leaves the anchor a corner with the other one; Shift held at the press on an anchor moves it, handles and all (Shift kept down: at 45° steps) instead of pulling out handles |