diff --git a/crates/trace/src/logo/tests.rs b/crates/trace/src/logo/tests.rs index 2f346a80a1..4e152b0b8c 100644 --- a/crates/trace/src/logo/tests.rs +++ b/crates/trace/src/logo/tests.rs @@ -966,6 +966,168 @@ fn a_gray_between_black_and_white_is_one_shape() { } } +/// Flat Logo with the black of the tests below, `gray` and white named exactly. +fn black_gray_white(gray: [u8; 3]) -> TraceParams { + let logo_colors = vec!["#040403".into(), format!("#{:02X}{:02X}{:02X}", gray[0], gray[1], gray[2]), "#FFFFFF".into()]; + TraceParams { logo_colors, ..logo_params() } +} + +/// A black disc and a gray square on white, blurred by 1 to 3 pixels: the edge pixels around the +/// disc as light as the gray read as blends of black and white, so the gray is one shape (the +/// square) and no gray lines the disc, with the colors found or named. At a blur of 3 pixels, with +/// the colors named, a gray of 128 is still one shape, a gray of 200 leaves 4 slivers of no area, +/// and a light gray (230) leaves at most 8 slivers, touching the disc's edge at no more than 4 of +/// 192 samples. (Without named colors, an image blurred by 3 pixels traces without its gray.) +#[test] +fn blurred_black_edges_beside_gray_leave_no_gray_slivers() { + const INK: [u8; 3] = [4, 4, 3]; + for gray in [[230u8, 230, 230], [200, 200, 200], [128, 128, 128]] { + for blur in [1.0, 1.5, 2.0, 3.0] { + let img = render(120, 60, blur, |x, y| { + Some(if (x - 30.0).hypot(y - 30.0) <= 20.0 { + INK + } else if (60.0..=110.0).contains(&x) && (10.0..=50.0).contains(&y) { + gray + } else { + WHITE + }) + }); + for by_name in [false, true] { + if !by_name && blur > 2.0 { + continue; + } + let res = trace(&img, &if by_name { black_gray_white(gray) } else { logo_params() }); + let what = format!("gray {}, blur {blur}, named {by_name}", gray[0]); + let paths: Vec<_> = res.paths.iter().map(|t| (t.color, t.pixels)).collect(); + assert_eq!(top_color(&res, Point::new(85.0, 30.0)), Some(gray), "{what}: the square; {paths:?}"); + let mut rim = 0; + for r in [19.0, 20.0, 21.0] { + for k in 0..64 { + let a = f64::from(k) * std::f64::consts::TAU / 64.0; + if top_color(&res, Point::new(30.0 + r * a.cos(), 30.0 + r * a.sin())) == Some(gray) { + rim += 1; + } + } + } + let mut grays: Vec<_> = res.paths.iter().filter(|t| t.color == gray).map(|t| t.pixels).collect(); + grays.sort_unstable(); + grays.pop(); + match (gray[0], blur == 3.0) { + (230, true) => { + assert!(grays.len() <= 8, "{what}: {} slivers; {paths:?}", grays.len()); + assert!(rim <= 4, "{what}: {rim} of 192 samples along the disc's edge traced gray"); + } + (200, true) => { + assert!(grays.len() <= 4 && grays.iter().all(|&n| n == 0), "{what}: slivers {grays:?}"); + assert_eq!(rim, 0, "{what}: samples along the disc's edge traced gray"); + } + _ => { + assert!(grays.is_empty(), "{what}: slivers {grays:?}; {paths:?}"); + assert_eq!(rim, 0, "{what}: samples along the disc's edge traced gray"); + } + } + } + } + } +} + +/// A soft-edged gray band 2 to 4 pixels wide lying along a black disc, blurred by 1.5 or 2 pixels, +/// traces as black and white: its pixels are reached from the disc and from the white through +/// pixels that keep getting darker and lighter, as across a blurred black-to-white edge. A band 8 +/// pixels wide keeps at least half of its gray. With sharp edges every band stays gray. +#[test] +fn a_soft_gray_band_along_black_traces_as_black_and_white() { + const INK: [u8; 3] = [4, 4, 3]; + for gray in [[230u8, 230, 230], [200, 200, 200], [128, 128, 128]] { + for blur in [0.0, 1.5, 2.0] { + for wide in [2u8, 3, 4, 8] { + let img = render(120, 60, blur, |x, y| { + Some(if (x - 25.0).hypot(y - 28.0) <= 18.0 { + INK + } else if (40.0..43.0 + f64::from(wide)).contains(&x) && (20.0..36.0).contains(&y) { + gray + } else { + WHITE + }) + }); + let res = trace(&img, &black_gray_white(gray)); + // The band's samples: 16 rows of its `wide` columns outside the disc. + let kept = (0..wide) + .flat_map(|c| (20..36).map(move |y| Point::new(43.5 + f64::from(c), f64::from(y) + 0.5))) + .filter(|&at| top_color(&res, at) == Some(gray)) + .count(); + let all = 16 * usize::from(wide); + let what = format!("gray {}, blur {blur}, {wide} px band: {kept} of {all} samples traced gray", gray[0]); + if blur == 0.0 { + assert_eq!(kept, all, "{what}"); + } else if wide <= 4 { + assert_eq!(kept, 0, "{what}"); + } else { + assert!(2 * kept >= all, "{what}"); + } + } + } + } +} + +/// A soft-edged gray spoke two or three pixels wide running straight out of a black disc, blurred +/// by 1 or 1.5 pixels, loses 3 or 4 of its 16 samples nearest the disc and keeps the rest. +#[test] +fn a_soft_gray_spoke_loses_a_few_pixels_where_it_meets_black() { + const INK: [u8; 3] = [4, 4, 3]; + for gray in [[230u8, 230, 230], [128, 128, 128]] { + for blur in [1.0, 1.5] { + for wide in [2.0, 3.0] { + let img = render(120, 60, blur, |x, y| { + Some(if (x - 25.0).hypot(y - 28.0) <= 18.0 { + INK + } else if (38.0..90.0).contains(&x) && (27.0..27.0 + wide).contains(&y) { + gray + } else { + WHITE + }) + }); + let res = trace(&img, &black_gray_white(gray)); + let at = |x: i32| Point::new(f64::from(x) + 0.5, 27.0 + wide / 2.0); + let near = (44..60).filter(|&x| top_color(&res, at(x)) == Some(gray)).count(); + let far = (60..86).filter(|&x| top_color(&res, at(x)) == Some(gray)).count(); + let what = format!("gray {}, blur {blur}, {wide} px spoke", gray[0]); + assert!((12..=13).contains(&near), "{what}: {near} of the 16 samples nearest the disc traced gray"); + assert_eq!(far, 26, "{what}: the rest of the spoke"); + } + } + } +} + +/// A soft-edged light gray stroke 2 pixels wide beside a black disc, blurred by 1.5 pixels: 2 +/// pixels from the disc it keeps less than half of its gray, 4 pixels away it loses a few pixels, +/// and 6 or 8 pixels away it keeps all of it. +#[test] +fn a_soft_gray_stroke_near_black_loses_gray_by_its_distance() { + const INK: [u8; 3] = [4, 4, 3]; + const GRAY: [u8; 3] = [230, 230, 230]; + for gap in [2, 4, 6, 8] { + let x0 = 43.0 + f64::from(gap); + let img = render(120, 60, 1.5, |x, y| { + Some(if (x - 25.0).hypot(y - 28.0) <= 18.0 { + INK + } else if (x0..x0 + 2.0).contains(&x) && (8.0..50.0).contains(&y) { + GRAY + } else { + WHITE + }) + }); + let res = trace(&img, &black_gray_white(GRAY)); + let kept = (12..46).filter(|&y| top_color(&res, Point::new(x0 + 1.0, f64::from(y) + 0.5)) == Some(GRAY)).count(); + let what = format!("{gap} px from the disc: {kept} of 34 samples traced gray"); + match gap { + 2 => assert!(2 * kept < 34, "{what}"), + 4 => assert!((24..34).contains(&kept), "{what}"), + _ => assert_eq!(kept, 34, "{what}"), + } + } +} + /// A one-pixel gray line between flat black and flat white, with the three colors named, stays a /// gray line along its whole length, beside a black disc whose edge pixels are as light as the gray. #[test] diff --git a/crates/trace/src/logo/unmix.rs b/crates/trace/src/logo/unmix.rs index d148309d50..7080b78701 100644 --- a/crates/trace/src/logo/unmix.rs +++ b/crates/trace/src/logo/unmix.rs @@ -7,7 +7,8 @@ //! white among the classes, a black-to-white edge pixel is a mix of black and gray as well as of //! black and white, and a gray-to-black edge pixel is a mix of white and black as well as of gray //! and black), the pixel takes the mix whose classes lie nearest it in the flat areas around it, -//! when its neighbors show an edge between those classes. +//! or, on an edge blurred over several pixels, along the pixels that lead across the edge, when its +//! neighbors show an edge between those classes. use std::collections::{HashMap, HashSet}; @@ -22,6 +23,8 @@ const PURE: f64 = 4.0 / 255.0; const REPRODUCES: f64 = PURE * PURE; /// How far (in pixels, each way) a class is looked for around a pixel that two mixes reproduce. const NEARBY: usize = 6; +/// How many steps a path across an edge takes at most ([`across_edge`]). +const WALK: usize = 5; /// A pixel whose neighbors are all this close to it (in 0..1 premultiplied RGBA) lies in a flat area. const FLAT: f64 = 1.5 / 255.0; /// How many joined pixels within [`PURE`] of one class are taken as art of that class, such as a @@ -200,9 +203,11 @@ pub(crate) fn unmix(pix: &[Px], width: usize, height: usize, classes: &[[f64; 4] if tied.is_empty() { return (planes, residual, switched); } - // A pixel two mixes reproduce takes another mix of two classes whose farthest class lies nearer - // it than the best mix's does, in the flat areas around it ([`flat_classes`], [`RowDistances::around`]), - // when the pixel lies on an edge between that mix's classes ([`across_edge`]). For the best mix, + // A pixel two mixes reproduce takes another mix of two classes, when the pixel lies on an edge + // between that mix's classes ([`across_edge`]) and that mix lies nearer it than the best mix + // does. A mix lies as near as its farthest class in the flat areas around the pixel + // ([`flat_classes`], [`RowDistances::around`]); the other mix lies as near as the steps that + // `across_edge` counts when those are fewer. For the best mix, // the classes held by flat areas between two classes count as well ([`between_classes`]). A // pixel within `PURE` of a class that is joined to at least [`LINE`] such pixels of that class // (itself included) keeps it ([`pure_runs`]), as a one-pixel line of gray between black and white. @@ -218,7 +223,11 @@ pub(crate) fn unmix(pix: &[Px], width: usize, height: usize, classes: &[[f64; 4] continue; } let Some(mixes) = mixed.get(&key) else { continue }; - let edges: Vec<&Weights> = mixes.tied.iter().filter(|m| across_edge(pix, &flat, (width, height), i, classes, &mixes.best, m)).collect(); + let edges: Vec<(&Weights, usize)> = mixes + .tied + .iter() + .filter_map(|m| across_edge(pix, (&flat, &stands_for), (width, height), i, classes, &mixes.best, m).map(|r| (m, r))) + .collect(); if edges.is_empty() { continue; } @@ -231,8 +240,8 @@ pub(crate) fn unmix(pix: &[Px], width: usize, height: usize, classes: &[[f64; 4] } } let now = farthest(&mixes.best, &kept); - let other = edges.into_iter().filter(|m| farthest(m, &dist) < now).min_by_key(|m| farthest(m, &dist)); - if let Some(other) = other { + let other = edges.into_iter().map(|(m, r)| (m, farthest(m, &dist).min(r))).filter(|&(_, d)| d < now).min_by_key(|&(_, d)| d); + if let Some((other, _)) = other { switched.push((i, planes.iter().map(|pl| pl.get(i).copied().unwrap_or(0.0)).collect())); // (`residual` keeps the best mix's error; the mix taken comes within `REPRODUCES` of the // pixel as well.) @@ -244,31 +253,39 @@ pub(crate) fn unmix(pix: &[Px], width: usize, height: usize, classes: &[[f64; 4] } /// Whether pixel `i` lies on an edge between the two classes of `other`, rather than in an area of -/// a class of `best` that `other` leaves out: for each such class, the pixel has a neighbor beyond -/// it toward each class of `other`, along the line between them, or, for a class that lies beyond -/// both classes of `other` on that line, a neighbor on each side of the pixel itself, none past -/// the class of `other` nearer the class left out, and a chain of neighbors from the pixel to that -/// nearer class or a flat area of it (`flat`), each nearer it than the one before. (A black-to-white -/// edge pixel as light as a gray has a darker neighbor and a lighter one; a gray stroke on white -/// has no neighbor darker than the gray; a gray-to-black edge pixel has a lighter neighbor and a -/// darker one, and lighter pixels lead to the flat gray; a pale line one pixel wide on black has -/// only darker neighbors; the pixels beside a blurred pale line's middle reach no flat gray; and a -/// white gap between black and gray has a neighbor lighter than the gray.) +/// a class of `best` that `other` leaves out. For a class left out that lies between the classes of +/// `other` on the line between them, a path of pixels from `i` that keeps going toward one class of +/// `other` gets past the class left out within [`WALK`] steps through the eight neighbors, and so +/// does one that keeps going toward the other. For a class left out that lies beyond both classes of +/// `other` on that line, the pixel has a neighbor on each side of that class, or a neighbor on each +/// side of the pixel itself, none past the class of `other` nearer the class left out, and a chain +/// of neighbors from the pixel to that nearer class or a flat area of it (`flat`), each nearer it +/// than the one before. (A black-to-white edge pixel as light as a gray has a darker neighbor and a +/// lighter one, or, on an edge blurred over several pixels, reaches darker and lighter pixels through +/// pixels that keep getting darker or lighter; from a gray stroke on white, a path that keeps getting +/// darker ends in the stroke, at the gray; a gray-to-black edge pixel has a lighter neighbor and a +/// darker one, and lighter pixels lead to the flat gray; a pale line one pixel wide on black has only +/// darker neighbors; the pixels beside a blurred pale line's middle reach no flat gray; and a white +/// gap between black and gray has a neighbor lighter than the gray.) +/// +/// When it does, the number of steps the longer of the two paths takes to a pixel that stands for its +/// class of `other` (`stands_for`), the largest over the classes left out. It is `NEARBY + 1` when a +/// path does not come to such a pixel, and when a class left out lies beyond both classes of `other`. fn across_edge( pix: &[Px], - flat: &[Option], + (flat, stands_for): (&[Option], &[Option]), (width, height): (usize, usize), i: usize, classes: &[[f64; 4]], best: &Weights, other: &Weights, -) -> bool { - let [(a, _), (b, _)] = other.as_slice() else { return false }; - let (Some(ca), Some(cb)) = (classes.get(*a), classes.get(*b)) else { return false }; +) -> Option { + let [(a, _), (b, _)] = other.as_slice() else { return None }; + let (ca, cb) = (classes.get(*a)?, classes.get(*b)?); let ab: [f64; 4] = std::array::from_fn(|j| cb[j] - ca[j]); let len2: f64 = ab.iter().map(|v| v * v).sum(); if len2 <= 1e-12 { - return false; + return None; } let len = len2.sqrt(); // Where `v` lies along the line from `a` to `b` (0 at `a`, 1 at `b`), and how far off it. @@ -333,20 +350,46 @@ fn across_edge( } false }; - !left_out.is_empty() - && left_out.iter().all(|&c| { - let Some(&cv) = classes.get(c) else { return false }; - let (tc, _) = place(cv); - if straddled(tc) { - return true; + // A path from `i` toward `a` (`toward` -1) or `b` (`toward` 1): each step goes to the neighbor + // near the line that lies farthest that way, while it lies farther than the pixel before (the + // first step is taken whatever `i` itself is). `None` when it does not get more than `PURE` past + // `tc` in [`WALK`] steps; otherwise the steps to the first pixel past it that stands for `class` + // (`stands_for`), or `NEARBY + 1`. + let walk = |toward: f64, tc: f64, class: usize| { + let (mut cur, mut t) = (i, f64::NEG_INFINITY * toward); + let mut past = false; + for step in 1..=WALK { + match around(cur).filter_map(|j| at(j).map(|tj| (j, tj))).max_by(|p, q| (p.1 * toward).total_cmp(&(q.1 * toward))) { + Some((j, tj)) if (tj - t) * toward > 0.0 => (cur, t) = (j, tj), + _ => break, } - if (0.0..=1.0).contains(&tc) { - return false; + past = past || (t - tc) * toward * len > PURE; + if past && stands_for.get(cur).copied().flatten() == Some(class) { + return Some(step); } - let beyond = |tn: f64| if tc < 0.0 { -tn * len > PURE } else { (tn - 1.0) * len > PURE }; - let (to, near) = if tc < 0.0 { (0.0, *a) } else { (1.0, *b) }; - !neighbors.iter().any(|&tn| beyond(tn)) && at(i).is_some_and(straddled) && reaches(to, near, &beyond) - }) + } + past.then_some(NEARBY + 1) + }; + if left_out.is_empty() { + return None; + } + let mut reach = 0; + for &c in &left_out { + let (tc, _) = place(*classes.get(c)?); + if (0.0..=1.0).contains(&tc) { + let ra = walk(-1.0, tc, *a)?; + let rb = walk(1.0, tc, *b)?; + reach = reach.max(ra.max(rb)); + continue; + } + let beyond = |tn: f64| if tc < 0.0 { -tn * len > PURE } else { (tn - 1.0) * len > PURE }; + let (to, near) = if tc < 0.0 { (0.0, *a) } else { (1.0, *b) }; + if !(straddled(tc) || !neighbors.iter().any(|&tn| beyond(tn)) && at(i).is_some_and(straddled) && reaches(to, near, &beyond)) { + return None; + } + reach = NEARBY + 1; + } + Some(reach) } /// How far the farthest class of `mix` lies, by the distances `dist` ([`RowDistances::around`]). diff --git a/docs/image-trace-adjustments.md b/docs/image-trace-adjustments.md index 4d96ec6299..c679ec3105 100644 --- a/docs/image-trace-adjustments.md +++ b/docs/image-trace-adjustments.md @@ -118,13 +118,32 @@ transparent that has the largest share in the blend of them that comes closest t **Flat Logo with a color between two others.** When a traced color lies between two others, as a gray lies between black and white, an anti-aliased edge pixel between the outer two is also a blend of the -middle color and one of them. Flat Logo then reads the pixel as the blend of the colors that lie nearest -it in the flat areas within 6 pixels, when the pixel has a neighbor darker and a neighbor lighter than the -middle color, along the line between the other two. A black disc beside a gray square on white traces -with one gray shape, the square, and no gray slivers around the disc, when its edges are sharp or blurred -by up to about half a pixel. An edge blurred by a pixel or more can still leave gray slivers along the -disc, and so can an image with noise of a level or more in its pixels. A gray stroke two or three pixels -wide beside black has no darker pixel next to it and stays gray. A soft-edged gray stroke about two +middle color and one of them. Flat Logo then reads the pixel as a blend of the outer two when the pixel +lies on an edge between them and that blend lies nearer the pixel than the blend with the middle color. +The pixel lies on such an edge when, along the line between the outer two colors, it reaches a pixel +darker than the middle color in at most 5 steps, each to the neighbor that lies farthest toward the +darker color while the pixels keep getting darker, and reaches a pixel lighter than the middle color the +same way. A blend lies as near the pixel as the farther of its colors' nearest flat areas within 6 +pixels. The blend of the outer two also lies as near as the larger of the two step counts to a pixel of +each outer color, when that number is smaller. + +A black disc beside a gray square on white traces with one gray shape, the square, and no gray slivers +around the disc, when its edges are sharp or blurred by up to 2 pixels, with the colors found or named. +With the colors named and edges blurred by 3 pixels, a gray of 128 is still one shape, a gray of 200 +leaves 4 slivers with no area, and a light gray (230) leaves 8 slivers of up to 21 pixels. An image with +noise of a level or more in its pixels can still leave gray slivers along the disc. + +With sharp edges, a gray stroke two or three pixels wide beside black has no darker pixel next to it and +stays gray, and so does a gray band along black. On edges blurred by a pixel or more, gray near black +loses some of its pixels. A soft-edged gray band up to 4 pixels wide lying along black traces as black +and white at blurs of 1.5 and 2 pixels, and so does one up to 3 pixels wide at blurs of 1 and 3 pixels; a +wider band loses some of its pixels next to black, and one 8 pixels wide keeps at least half of its gray +at blurs of 1.5 and 2 pixels. A soft-edged gray stroke 2 pixels from black can lose some or all of its +gray, one 4 pixels from black loses a few pixels (a light gray stroke 2 pixels wide, blurred by 1.5 +pixels, keeps 28 of 34), and the pixels of one 6 pixels or more from black do not reach black in 5 steps +and are not read as an edge of black and white. A soft-edged gray +stroke 2 or 3 pixels wide running straight out of black, blurred by 1 or 1.5 pixels, loses 3 or 4 of +the 16 pixels nearest black. A soft-edged gray stroke about two pixels wide that touches black traces as black and white, and one about three pixels wide that touches black can lose most or all of its gray when it is short (12 pixels long or less). A line of gray one pixel wide between black and white stays gray when at least 13 of its pixels touch: such a line and a diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index cb7677aa70..954266b11f 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1590,7 +1590,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Image Trace Flat Logo mode:** a fourth mode beside Black and White, Grayscale and Color, for flat-colour logos. Each pixel is read as a blend of the logo's colours (found automatically or named), the blend is interpolated smoothly and every outline is placed where two colours are equally present, so edges are accurate to a fraction of a pixel. Outlines are then cleaned: corners the blur rounded are put back, near-straight runs and near-circular arcs become exact lines and arcs, the rest is fitted with as few Béziers as the tolerance allows, touching colours overlap by a hair so no gap opens, and an outline that strays from the raw contour is fitted plainly instead. Gradients and photos are refused with advice to use Color. Line art whose only solid area is white paper (strokes a pixel or two wide) takes its colours from the strokes' cores, with the lighter shades along a stroke's anti-aliased edge folded into its ink; a page whose ink (a channel at least 48 below white) covers under 1% of it traces to nothing, as blank paper does. *Measured* (a local experiment, not run in CI): a flat-colour logo's vector original was rendered down to a soft 199 × 100 px transparent PNG, traced, and the result compared with the original at 1600 px wide. The built-in colour presets (6 Colors, 16 Colors, High Fidelity Photo, Low Fidelity Photo) had a mean edge error of 2.5 to 3.4 px and region overlap of 0.88 to 0.91; Flat Logo had 0.78 px and 0.966 (0.48 px and 0.975 from a crisp source), in about 0.1 s. Limits: flat-colour art only; needle-thin sharp tips are shortened by about 1.7 source pixels because the blur erases them; it works at no more than 1024 px on the long side (larger images are averaged down first); only one logo family has been scored against a vector original. - **Image Trace, Flat Logo named colors only:** with `logoColors` named, `"logoWhite": false` traces those colors only, so white areas take the nearest of them and no white is added; a named white is kept, and enclosed transparent areas stay holes; code-drawn tests in `crates/trace` and `crates/engine`. - **Image Trace, Flat Logo flat-art check with named colors:** with `logoColors` named, whether the image is flat art is judged by its own colors, as many as are named, with white, or as the Colors setting gives, whichever is more. Named colors 20 levels off a flat badge's colors still trace it, a hatch on a light ground gives the same result with close and far named colors, a gradient's refusal score does not depend on how far the named colors are from it, and areas of colors that were not named are traced in the named colors instead of being refused; code-drawn tests in `crates/trace`. -- **Image Trace, Flat Logo with a color between two others:** an anti-aliased edge pixel between black and white is read as a blend of black and white, not of black and a gray that lies between them, when the flat areas around it and the pixels beside it show that edge, so a black disc beside a gray square on white, with sharp edges or edges blurred by up to about half a pixel, traces with one gray path, the square, instead of the square plus 8 to 24 gray slivers around the disc with the colors found or named exactly (an edge blurred by a pixel or more, or pixel noise of a level or more, can still leave gray slivers); gray strokes two and three pixels wide beside black stay gray (a soft-edged gray stroke about two pixels wide that touches black traces as black and white, and a short one about three pixels wide can lose most or all of its gray), and a one-pixel gray line of at least 13 touching pixels between black and white stays gray (a shorter one, or one that falls between pixels or is blurred, traces as black and white); code-drawn tests in `crates/trace`. +- **Image Trace, Flat Logo with a color between two others:** an anti-aliased edge pixel between black and white is read as a blend of black and white, not of black and a gray that lies between them, when the flat areas around it and the pixels beside it show that edge, so a black disc beside a gray square on white, with sharp edges or edges blurred by up to about half a pixel, traces with one gray path, the square, instead of the square plus 8 to 24 gray slivers around the disc with the colors found or named exactly; on edges blurred by 1 to 3 pixels, the pixel also counts as on that edge when paths of up to 5 steps through pixels that keep getting darker and lighter reach past the gray both ways, and black and white then lie as near as the steps to them, so the same disc and square trace with one gray path at blurs of 1 to 2 pixels, where up to 33 gray paths were traced before (at a blur of 3 pixels with the colors named, a gray of 200 leaves 4 slivers with no area and a light gray of 230 leaves 8 small slivers, against 11 and 14 gray paths before; pixel noise of a level or more can still leave gray slivers); with sharp edges, gray strokes two and three pixels wide beside black stay gray (a soft-edged gray stroke about two pixels wide that touches black traces as black and white, and a short one about three pixels wide can lose most or all of its gray); on edges blurred by a pixel or more, a soft-edged gray band up to 4 pixels wide along black traces as black and white at blurs of 1.5 and 2 pixels, a soft-edged gray stroke 2 pixels from black can lose some or all of its gray and one 4 pixels away a few pixels, and a soft-edged gray stroke running out of black loses 3 or 4 pixels where it meets black; a one-pixel gray line of at least 13 touching pixels between black and white stays gray (a shorter one, or one that falls between pixels or is blurred, traces as black and white); code-drawn tests in `crates/trace`. - **Image Trace, Flat Logo with a color beyond both colors of an edge:** an edge pixel between a gray panel and a charcoal disc on a paler gray ground is read as a blend of the panel and the disc, not of the ground and the disc, when the pixels beside it lie on each side of it, none lies past the panel toward the ground, and lighter pixels lead from it to the panel's color or to a flat area of the panel, so the disc traces with three paths, one per color, with the colors found or named, instead of with 28 slivers of the ground around it when its edges are sharp and one sliver when they are blurred by 0.7 pixel (an edge blurred by a pixel or more can still leave slivers of the ground); the pixels of a pale line on the disc, one pixel wide, blurred over three pixels or falling between two pixels, and the edge of a gap of the ground's color between the disc and the panel keep the ground in their blends; code-drawn tests in `crates/trace`. - **Image Trace, Keep Colors:** `"keepColors": ["#rrggbb", …]` traces only the palette colors near a listed color (Abutting: each with the paths the trace of every color gives it; Overlapping: not reaching under the colors left out), in Black and White, Grayscale and Color; code-drawn tests in `crates/trace` and `crates/engine`. - **Advanced art:** live Blends (steps/distance/smooth colour, editable spine, anchor-targeted Blend tool, faithful interpolation, knockout), Envelope Distort (warp/mesh/top object, Reset, full Envelope Options, mesh handles, Edit Contents; type, images, symbols, gradients, patterns and appearance distorted everywhere), Liquify tools with options and pen pressure, Puppet Warp with rotating pins, Perspective Grid with presets, movable planes and projected type (choosing a perspective tool shows the grid; Hide Grid hides it with the tool still chosen), Gradient Mesh, Shape Builder (stroke-only open paths and lines cut the regions they cross and enclose regions of their own, and regions they bound merge without seams where the lines cross at rounded coordinates (#893); filled open paths count as closed; erase mode while Alt/Option is held: a minus pointer, red highlights of what will go, a click or drag deletes the regions touched, the pieces of open lines and the edges (outline pieces between the points where paths meet, opening their paths there) it passes over, one undo step, `shapeBuilder.merge {erase}` and `shapeBuilder.regions` edges over MCP), Live Paint (every path an edge, open lines included), Image Trace (12 presets, colour layers traced in parallel; a trace past two million anchor points is refused with advice rather than running out of memory, an image over 64 megapixels is traced scaled down to that size (aspect kept, paths at the image's own size) and one over 192 megapixels is refused, and a selection too large to outline shows its bounds (#525); Object › Image Trace › Make and Make and Expand trace at once with the Default preset, #543; with an image selected the Control bar and the Properties panel show Image Trace, whose arrow traces with any preset, Mask (`object.maskImage`: a clipping path on the image's outline, selected so its handles crop), Crop Image (a crop box on the image, starting on its part over the artboard, dragged by its handles or inside it, the outside dimmed, with X/Y/W/H, Apply and Cancel in the Control bar, Enter and Escape, #734; an image that isn't turned or skewed, isn't CMYK and can be read at its recorded size is cut from its own pixels when the crop edges fall on its pixel grid, copied as they are without resampling; any other image is drawn, #5534; `object.cropImage {rect}` for agents, `{trim: true}` cuts an image to its pixels that aren't fully transparent, pixel for pixel) and Embed or Unembed in place of Fill and Stroke; with an Image Trace object selected, its Preset (choosing another traces again), View, the Image Trace panel and Expand, plus Release in Properties; the five View modes (Tracing Result, with Outlines, Outlines, Outlines with Source Image, Source Image) redraw a trace on screen without tracing again, are saved with it and `imageTrace.setView` sets them, while exports and Expand keep the result; the panel's Advanced section is a header that stays open or closed as it was left (part of #641); Color mode's Palette: Limited, Full Tone (as many colours as the tones need, Less … More), Automatic (flat art with its own colours, else Full Tone; a heuristic) and Document Library (the most used colours of the document's swatches or a swatch library, filled with the swatch colours as they are), part of #641; Advanced › Create: Fills and/or Strokes, where lines up to the Stroke width trace as stroked centre lines (distance transform, thinning, a skeleton graph with spurs pruned, curve fitting; one width per line; without Fills, wider areas become stroked outlines), part of #641), pattern swatches with pattern editing mode, live Repeat (radial/grid/mirror). A single selected mirror repeat shows a prominent axis with a center move handle and two rotation handles. Drag the line or center to change spacing, or an end to change angle; Shift snaps rotation to 45°. The original artwork stays in place, the reflected copy previews live, Escape cancels and each drag takes one undo step through `object.repeat.options`. Controls follow zoom/view rotation and hide with edges or the bounding box. Engine and headless canvas regressions passed for gestures, history and visibility; native move, rotation and Escape screenshots were reviewed. [Public mirror-repeat reference](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/set-mirror-repeat-options.html). A single selected grid repeat shows a handle below the grid for rows, one right of it for columns and one past its bottom-right corner for both, and sliders between its first two columns and rows for the horizontal and vertical spacing; the source keeps its size, each drag is one undo step and Escape cancels it ([public grid-repeat reference](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/set-grid-repeat-options.html), #2691). Object › Expand turns radial, grid and mirror repeats into groups of their instances (#1765, #1756).