mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-16 20:19:40 +00:00
Image Trace: the seam fills' clip stays within the traced paths' box
The Seam Fills group's clipping path was the image's box. A group with a clip is measured by its clipping path, so on a trace with transparent or ignored margins the expanded trace measured as the whole image, and selection, alignment and resizing used that box. The clipping path is now the image's box cut to the box of the traced paths: on a turned image it has up to eight corners, and the anchor limit counts eight for it. docs/mcp.md, the params text and the progress line describe the clip.
This commit is contained in:
@@ -144,7 +144,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Make",
|
||||
["Object", "Image Trace"],
|
||||
None,
|
||||
"{id?: image or Image Trace group (default: selection), preset?: name (imageTrace.presets), savedPreset?: {settings} (a saved preset's settings, which the journal records so a replay traces with them after the preset is changed, renamed or deleted; used in place of the saved preset `preset` names), enhanced?: false (the preset's enhanced version: with Auto Grouping, and with Shapes in all but High Fidelity Photo; Flat Logo has none and is traced as it is), params?: {mode: \"blackAndWhite\"|\"grayscale\"|\"color\"|\"logo\", threshold: 0-255, palette: \"limited\"|\"fullTone\"|\"automatic\"|\"documentLibrary\" (color mode; limited: the `colors` best colours, fullTone: as many as the tones need, more with colorDetail, automatic: flat art with its own colours, else fullTone, documentLibrary: at most `colors` of the library's colours, as they are), colors: 2-256, colorDetail: 0-100 (fullTone, automatic), library: \"document\" (the document's swatches) or a swatch library id or name (swatch.library.list; documentLibrary), colorGroup?: name (color mode, documentLibrary with library \"document\": the colors of that document color group instead of every swatch; \"\" is every swatch), paths: 0-100, corners: 0-100, noise: px, method: \"abutting\"|\"overlapping\" (abutting with fills, not mode logo: a \"Seam Fills\" clip group under the paths holds strokes along the edges two filled paths share, 1.5 image pixels wide (VectorCraft's own width), in the color of the lower path (on an image stretched more one way than another, each stroke's outline in image pixels as a filled path), clipped to the image's box; paths that became live shapes get none; the paths are not changed), ignoreWhite (leave out white areas), ignoreColor?: \"#rrggbb\" (with ignoreWhite: the colour left out instead of white), ignoreBackground: false (with ignoreWhite: only the areas of the ignored color that reach the image's edge are left out), keepColors?: [\"#rrggbb\"…] (not mode logo: only the palette colors within about 30 levels of a listed color are traced; empty: every color), snapCurvesToLines, shapes: false (filled outlines that are a circle, an ellipse, a rectangle or a regular polygon come out as that live shape), autoGrouping: false (each path that has others inside it is grouped with them), gradients: false (grayscale and color: an area whose colour changes evenly along one direction is one path with a linear gradient fill), fills: true, strokes: false (Create: lines up to strokeWidth wide become stroked centre lines; without fills, wider areas become stroked outlines), strokeWidth: px (10), logoColors?: [\"#rrggbb\"…] (mode logo: flat-colour logos only; colours found automatically or named here, at most ten; white is its own color, and a named color with every channel 245 or more is taken as that white, except with logoColors named, logoWhite false and no ignoreWhite; noise = areas under noise/10 px ignored; edges to a fraction of a pixel, sharp corners restored, lines and circles snapped; enclosed transparent areas are painted white while white is its own color, and stay holes with ignoreWhite or without a white of its own; fills/strokes are ignored; gradients and photos are refused, judged by the image's own colors also when logoColors are named), logoWhite: true (mode logo with logoColors named; false traces the named colors only: white areas take the nearest of them, a named white is kept and enclosed transparent areas stay holes; with ignoreWhite, white areas are left out either way)}, view?: as imageTrace.setView (default: the traced object's own, else tracingResult), ids?: [id…] (instead of id)} → {id, paths, anchors, colors, warnings: [text…] (the image is over 1500 px on a side, so it traces more slowly; or it was traced scaled down; Flat Logo names only the size it traced a larger image at; or a keepColors color matches none the trace found, or nothing was traced)}",
|
||||
"{id?: image or Image Trace group (default: selection), preset?: name (imageTrace.presets), savedPreset?: {settings} (a saved preset's settings, which the journal records so a replay traces with them after the preset is changed, renamed or deleted; used in place of the saved preset `preset` names), enhanced?: false (the preset's enhanced version: with Auto Grouping, and with Shapes in all but High Fidelity Photo; Flat Logo has none and is traced as it is), params?: {mode: \"blackAndWhite\"|\"grayscale\"|\"color\"|\"logo\", threshold: 0-255, palette: \"limited\"|\"fullTone\"|\"automatic\"|\"documentLibrary\" (color mode; limited: the `colors` best colours, fullTone: as many as the tones need, more with colorDetail, automatic: flat art with its own colours, else fullTone, documentLibrary: at most `colors` of the library's colours, as they are), colors: 2-256, colorDetail: 0-100 (fullTone, automatic), library: \"document\" (the document's swatches) or a swatch library id or name (swatch.library.list; documentLibrary), colorGroup?: name (color mode, documentLibrary with library \"document\": the colors of that document color group instead of every swatch; \"\" is every swatch), paths: 0-100, corners: 0-100, noise: px, method: \"abutting\"|\"overlapping\" (abutting with fills, not mode logo: a \"Seam Fills\" clip group under the paths holds strokes along the edges two filled paths share, 1.5 image pixels wide (VectorCraft's own width), in the color of the lower path (on an image stretched more one way than another, each stroke's outline in image pixels as a filled path), clipped to the image's box within the traced paths' box; paths that became live shapes get none; the paths are not changed), ignoreWhite (leave out white areas), ignoreColor?: \"#rrggbb\" (with ignoreWhite: the colour left out instead of white), ignoreBackground: false (with ignoreWhite: only the areas of the ignored color that reach the image's edge are left out), keepColors?: [\"#rrggbb\"…] (not mode logo: only the palette colors within about 30 levels of a listed color are traced; empty: every color), snapCurvesToLines, shapes: false (filled outlines that are a circle, an ellipse, a rectangle or a regular polygon come out as that live shape), autoGrouping: false (each path that has others inside it is grouped with them), gradients: false (grayscale and color: an area whose colour changes evenly along one direction is one path with a linear gradient fill), fills: true, strokes: false (Create: lines up to strokeWidth wide become stroked centre lines; without fills, wider areas become stroked outlines), strokeWidth: px (10), logoColors?: [\"#rrggbb\"…] (mode logo: flat-colour logos only; colours found automatically or named here, at most ten; white is its own color, and a named color with every channel 245 or more is taken as that white, except with logoColors named, logoWhite false and no ignoreWhite; noise = areas under noise/10 px ignored; edges to a fraction of a pixel, sharp corners restored, lines and circles snapped; enclosed transparent areas are painted white while white is its own color, and stay holes with ignoreWhite or without a white of its own; fills/strokes are ignored; gradients and photos are refused, judged by the image's own colors also when logoColors are named), logoWhite: true (mode logo with logoColors named; false traces the named colors only: white areas take the nearest of them, a named white is kept and enclosed transparent areas stay holes; with ignoreWhite, white areas are left out either way)}, view?: as imageTrace.setView (default: the traced object's own, else tracingResult), ids?: [id…] (instead of id)} → {id, paths, anchors, colors, warnings: [text…] (the image is over 1500 px on a side, so it traces more slowly; or it was traced scaled down; Flat Logo names only the size it traced a larger image at; or a keepColors color matches none the trace found, or nothing was traced)}",
|
||||
has_selection_or_ids,
|
||||
|s, p| trace_make(s, p, false)
|
||||
),
|
||||
|
||||
@@ -723,10 +723,11 @@ fn seam_unit(img_xf: vectorcraft_geom::Affine, xf: vectorcraft_geom::Affine) ->
|
||||
/// the paths, the seam fills and their clip together stay within `max` anchors. With `outlined`,
|
||||
/// each stroke is replaced by a filled path, its outline in raster pixels ([`outline_seams`]),
|
||||
/// for an image stretched more one way than another ([`seam_unit`]). The strokes have at most as
|
||||
/// many anchors as the paths and the clip has four, so a trace whose paths have more than half of
|
||||
/// `max` less two gets none. Outlines, which have more anchors, are counted as each is made, and
|
||||
/// none is made when [`SEAM_OUTLINE_ANCHORS`] times the strokes' anchors would not fit, or once
|
||||
/// those made so far no longer fit. [`EngineError::Cancelled`] once `steps` answers `false`.
|
||||
/// many anchors as the paths and the clip at most [`SEAM_CLIP_ANCHORS`], so a trace whose paths
|
||||
/// have more than half of `max` less four gets none. Outlines, which have more anchors, are
|
||||
/// counted as each is made, and none is made when [`SEAM_OUTLINE_ANCHORS`] times the strokes'
|
||||
/// anchors would not fit, or once those made so far no longer fit. [`EngineError::Cancelled`]
|
||||
/// once `steps` answers `false`.
|
||||
fn seams_within(
|
||||
res: &tr::TraceResult,
|
||||
params: &tr::TraceParams,
|
||||
@@ -735,17 +736,17 @@ fn seams_within(
|
||||
outlined: bool,
|
||||
steps: &(dyn Fn(u64, u64) -> bool + Sync),
|
||||
) -> Result<Option<tr::SeamFills>> {
|
||||
if res.anchor_count().saturating_mul(2).saturating_add(4) > max {
|
||||
if res.anchor_count().saturating_mul(2).saturating_add(SEAM_CLIP_ANCHORS) > max {
|
||||
return Ok(None);
|
||||
}
|
||||
let Some(mut seams) = tr::seam_fills(&res.paths, params, size) else { return Ok(None) };
|
||||
if outlined {
|
||||
let strokes = seams.strokes.iter().map(|tp| tp.path.anchor_count()).sum::<usize>();
|
||||
let estimate = strokes.saturating_mul(SEAM_OUTLINE_ANCHORS).saturating_add(seams.clip.anchor_count());
|
||||
let estimate = strokes.saturating_mul(SEAM_OUTLINE_ANCHORS).saturating_add(SEAM_CLIP_ANCHORS);
|
||||
if res.anchor_count().saturating_add(estimate) > max {
|
||||
return Ok(None);
|
||||
}
|
||||
let budget = max.saturating_sub(res.anchor_count()).saturating_sub(seams.clip.anchor_count());
|
||||
let budget = max.saturating_sub(res.anchor_count()).saturating_sub(SEAM_CLIP_ANCHORS);
|
||||
if !outline_seams(&mut seams.strokes, budget, steps)? {
|
||||
return Ok(None);
|
||||
}
|
||||
@@ -757,6 +758,10 @@ fn seams_within(
|
||||
Ok(Some(seams))
|
||||
}
|
||||
|
||||
/// The most anchors the seam fills' clip has: the image's box cut to the box of the traced paths
|
||||
/// ([`within_box`]), four corners and at most four more where the image is turned.
|
||||
const SEAM_CLIP_ANCHORS: usize = 8;
|
||||
|
||||
/// How many seam strokes [`outline_seams`] outlines between asking whether to go on.
|
||||
const SEAM_OUTLINE_STEP: usize = 64;
|
||||
|
||||
@@ -913,7 +918,8 @@ pub(super) fn trace_make(s: &mut Session, p: &Value, expand: bool) -> Result<Val
|
||||
tp.gradient.as_ref().map_or(solid, |g| traced_gradient(g, xf))
|
||||
};
|
||||
// Abutting: the seam fills, in a clip group of their own under every path, clipped to the
|
||||
// image's box: strokes, or on an image stretched more one way, their outlines filled.
|
||||
// image's box within the traced paths' box: strokes, or on an image stretched more one
|
||||
// way, their outlines filled.
|
||||
let strokes: Vec<Arc<Node>> = seam_fills
|
||||
.iter()
|
||||
.flat_map(|f| &f.strokes)
|
||||
@@ -946,16 +952,6 @@ pub(super) fn trace_make(s: &mut Session, p: &Value, expand: bool) -> Result<Val
|
||||
Some(Arc::new(n))
|
||||
})
|
||||
.collect();
|
||||
if let Some(f) = seam_fills.as_ref().filter(|_| !strokes.is_empty()) {
|
||||
let mut clip = shape_node(d, f.clip.transformed(xf), None);
|
||||
if let NodeKind::Path { clipping, .. } = &mut clip.kind {
|
||||
*clipping = true;
|
||||
}
|
||||
let members = std::iter::once(Arc::new(clip)).chain(strokes).collect();
|
||||
let mut g = Node::new(d.alloc_id(), NodeKind::Group { children: members, clip: true });
|
||||
g.name = Some(SEAM_FILLS_NAME.into());
|
||||
children.push(Arc::new(g));
|
||||
}
|
||||
let mut traced = Vec::with_capacity(res.paths.len());
|
||||
for tp in res.paths {
|
||||
let paint = paint_of(&tp);
|
||||
@@ -982,6 +978,23 @@ pub(super) fn trace_make(s: &mut Session, p: &Value, expand: bool) -> Result<Val
|
||||
};
|
||||
traced.push(n);
|
||||
}
|
||||
// The seam fills' clip is the image's box cut to the box of the traced paths, so the group
|
||||
// stays within the box the paths measure.
|
||||
let art = traced.iter().filter_map(Node::geometric_bounds).reduce(|a, b| a.union(b));
|
||||
if let (Some(f), Some(art)) = (seam_fills.as_ref().filter(|_| !strokes.is_empty()), art) {
|
||||
let corners: Vec<Point> = f.clip.subpaths.iter().flat_map(|sp| sp.anchors.iter().map(|a| xf * a.p)).collect();
|
||||
let inside = within_box(&corners, art);
|
||||
if inside.len() >= 3 {
|
||||
let mut clip = shape_node(d, vectorcraft_geom::PathData::single(vectorcraft_geom::SubPath::polyline(&inside, true)), None);
|
||||
if let NodeKind::Path { clipping, .. } = &mut clip.kind {
|
||||
*clipping = true;
|
||||
}
|
||||
let members = std::iter::once(Arc::new(clip)).chain(strokes).collect();
|
||||
let mut g = Node::new(d.alloc_id(), NodeKind::Group { children: members, clip: true });
|
||||
g.name = Some(SEAM_FILLS_NAME.into());
|
||||
children.push(Arc::new(g));
|
||||
}
|
||||
}
|
||||
children.extend(grouped(d, traced, &res.parents));
|
||||
if group_by_color {
|
||||
children = color_groups(c, d, children)?;
|
||||
@@ -1003,6 +1016,28 @@ pub(super) fn trace_make(s: &mut Session, p: &Value, expand: bool) -> Result<Val
|
||||
Ok(json!({ "id": id.0, "paths": npaths, "anchors": anchors, "colors": colors, "warnings": warnings }))
|
||||
}
|
||||
|
||||
/// The part of the convex polygon `poly` inside `r`, as a polygon with at most four more corners
|
||||
/// than `poly` (each side of `r` cuts at most one corner off and adds two); empty when none of it
|
||||
/// is inside.
|
||||
fn within_box(poly: &[Point], r: Rect) -> Vec<Point> {
|
||||
let sides: [&dyn Fn(Point) -> f64; 4] = [&|p| p.x - r.x0, &|p| r.x1 - p.x, &|p| p.y - r.y0, &|p| r.y1 - p.y];
|
||||
let mut out = poly.to_vec();
|
||||
for side in sides {
|
||||
let corners = std::mem::take(&mut out);
|
||||
for (k, &p) in corners.iter().enumerate() {
|
||||
let Some(&q) = corners.get((k + 1) % corners.len()) else { continue };
|
||||
let (dp, dq) = (side(p), side(q));
|
||||
if dp >= 0.0 {
|
||||
out.push(p);
|
||||
}
|
||||
if (dp > 0.0 && dq < 0.0) || (dp < 0.0 && dq > 0.0) {
|
||||
out.push(p + (q - p) * (dp / (dp - dq)));
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Images larger than this on a side are traced, but more slowly: the trace says so.
|
||||
pub const LARGE_TRACE_SIDE: u32 = 1500;
|
||||
|
||||
@@ -1302,7 +1337,7 @@ mod color_group_tests {
|
||||
|
||||
#[cfg(test)]
|
||||
mod trace_limit_tests {
|
||||
use super::{MAX_TRACE_ANCHORS, SEAM_OUTLINE_ANCHORS, keep_warnings, outline_seams, seams_within, trace_warnings};
|
||||
use super::{MAX_TRACE_ANCHORS, SEAM_CLIP_ANCHORS, SEAM_OUTLINE_ANCHORS, keep_warnings, outline_seams, seams_within, trace_warnings};
|
||||
use vectorcraft_trace as tr;
|
||||
|
||||
#[test]
|
||||
@@ -1318,12 +1353,12 @@ mod trace_limit_tests {
|
||||
let all = tr::seam_fills(&res.paths, ¶ms, (24, 16));
|
||||
assert!(all.is_some(), "{res:?}");
|
||||
let anchors = res.anchor_count();
|
||||
assert!(anchors + all.as_ref().map_or(0, tr::SeamFills::anchor_count) <= 2 * anchors + 4);
|
||||
assert!(anchors + all.as_ref().map_or(0, tr::SeamFills::anchor_count) <= 2 * anchors + SEAM_CLIP_ANCHORS);
|
||||
let go = |_: u64, _: u64| true;
|
||||
// Twice the paths' anchors and the clip's four leave room for any seam fills.
|
||||
assert_eq!(seams_within(&res, ¶ms, (24, 16), 2 * anchors + 4, false, &go).unwrap(), all);
|
||||
// Twice the paths' anchors and the clip's eight at most leave room for any seam fills.
|
||||
assert_eq!(seams_within(&res, ¶ms, (24, 16), 2 * anchors + SEAM_CLIP_ANCHORS, false, &go).unwrap(), all);
|
||||
// One anchor short of that: none.
|
||||
assert_eq!(seams_within(&res, ¶ms, (24, 16), 2 * anchors + 3, false, &go).unwrap(), None);
|
||||
assert_eq!(seams_within(&res, ¶ms, (24, 16), 2 * anchors + SEAM_CLIP_ANCHORS - 1, false, &go).unwrap(), None);
|
||||
// Outlined, the seam fills are filled paths, within SEAM_OUTLINE_ANCHORS of the strokes'
|
||||
// anchors each.
|
||||
let strokes = |f: &tr::SeamFills| f.strokes.iter().map(|tp| tp.path.anchor_count()).sum::<usize>();
|
||||
@@ -1342,8 +1377,8 @@ mod trace_limit_tests {
|
||||
let outlined = seams_within(&res, ¶ms, (32, 32), MAX_TRACE_ANCHORS, true, &go).unwrap().unwrap();
|
||||
assert!(strokes(&outlined) > anchors, "{} outline anchors, {anchors} in the paths", strokes(&outlined));
|
||||
assert!(strokes(&outlined) <= SEAM_OUTLINE_ANCHORS * n, "{} outline anchors, {n} stroke anchors", strokes(&outlined));
|
||||
let fits = anchors + SEAM_OUTLINE_ANCHORS * n + 4;
|
||||
assert!(fits > 2 * anchors + 4, "{fits}, {anchors} in the paths");
|
||||
let fits = anchors + SEAM_OUTLINE_ANCHORS * n + SEAM_CLIP_ANCHORS;
|
||||
assert!(fits > 2 * anchors + SEAM_CLIP_ANCHORS, "{fits}, {anchors} in the paths");
|
||||
assert_eq!(seams_within(&res, ¶ms, (32, 32), fits, true, &go).unwrap(), Some(outlined.clone()));
|
||||
assert_eq!(seams_within(&res, ¶ms, (32, 32), fits - 1, true, &go).unwrap(), None);
|
||||
assert_eq!(seams_within(&res, ¶ms, (32, 32), fits - 1, false, &go).unwrap(), Some(all.clone()));
|
||||
@@ -1358,6 +1393,21 @@ mod trace_limit_tests {
|
||||
assert!(matches!(outline_seams(&mut all.strokes.clone(), need, &stop), Err(super::EngineError::Cancelled)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn within_box_cuts_a_turned_box_to_a_box() {
|
||||
use vectorcraft_geom::{Point, Rect};
|
||||
// A square turned by 45° in a smaller box: each side cuts a corner off, 8 corners.
|
||||
let diamond = [Point::new(0.0, -10.0), Point::new(10.0, 0.0), Point::new(0.0, 10.0), Point::new(-10.0, 0.0)];
|
||||
let cut = super::within_box(&diamond, Rect::new(-6.0, -6.0, 6.0, 6.0));
|
||||
assert_eq!(cut.len(), 8, "{cut:?}");
|
||||
assert!(cut.iter().all(|p| p.x.abs() <= 6.0 + 1e-12 && p.y.abs() <= 6.0 + 1e-12 && p.x.abs() + p.y.abs() <= 10.0 + 1e-12), "{cut:?}");
|
||||
// A corner on a side is kept once.
|
||||
let square = [Point::new(0.0, 0.0), Point::new(4.0, 0.0), Point::new(4.0, 4.0), Point::new(0.0, 4.0)];
|
||||
assert_eq!(super::within_box(&square, Rect::new(0.0, 0.0, 4.0, 4.0)), square.to_vec());
|
||||
assert_eq!(super::within_box(&square, Rect::new(1.0, 0.0, 4.0, 4.0)).len(), 4);
|
||||
assert!(super::within_box(&square, Rect::new(5.0, 5.0, 6.0, 6.0)).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn seams_are_strokes_only_where_the_image_is_scaled_alike_every_way() {
|
||||
use super::seam_unit;
|
||||
|
||||
@@ -6133,26 +6133,40 @@ fn image_trace_abutting_seam_fills_sit_under_the_paths() {
|
||||
// Overlapping paths are stacked: no seam fills.
|
||||
let (s, _, r) = made("overlapping", "imageTrace.make", false);
|
||||
assert!(seams(&node(&s, NodeId(r["id"].as_u64().unwrap()))).is_none());
|
||||
// White left out: the strokes are still clipped to the image's box.
|
||||
}
|
||||
|
||||
/// With white left out, the seam fills are clipped to the image's box within the traced paths'
|
||||
/// box, so the expanded trace measures as its paths do, also on a turned image.
|
||||
#[test]
|
||||
fn image_trace_seam_fills_stay_within_the_traced_paths_box() {
|
||||
let seams = |n: &Node| n.children().unwrap().iter().find(|c| c.name.as_deref() == Some("Seam Fills")).cloned();
|
||||
let band = vectorcraft_trace::Raster::from_fn(24, 16, |x, y| match ((4..12).contains(&y), x < 12) {
|
||||
(false, _) => [255; 4],
|
||||
(true, true) => [200, 30, 30, 255],
|
||||
(true, false) => [30, 30, 200, 255],
|
||||
});
|
||||
let mut s = session();
|
||||
add_image(&mut s, &band, Affine::IDENTITY);
|
||||
let r = s
|
||||
.execute(
|
||||
"imageTrace.make",
|
||||
&json!({"params": {"mode": "color", "palette": "limited", "colors": 3, "method": "abutting", "ignoreWhite": true}}),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(r["paths"], 2, "{r}");
|
||||
let group = seams(&node(&s, NodeId(r["id"].as_u64().unwrap()))).unwrap();
|
||||
let clip = &group.children().unwrap()[0];
|
||||
assert!(matches!(clip.kind, NodeKind::Path { .. }), "{clip:?}");
|
||||
let cb = outline(clip).0.bounds().unwrap();
|
||||
assert!([cb.x0, cb.y0, cb.x1 - 24.0, cb.y1 - 16.0].iter().all(|v| v.abs() < 1e-9), "{cb:?}");
|
||||
for xf in [Affine::IDENTITY, Affine::translate((100.0, 100.0)) * Affine::rotate(0.5)] {
|
||||
let mut s = session();
|
||||
add_image(&mut s, &band, xf);
|
||||
let r = s
|
||||
.execute(
|
||||
"imageTrace.makeAndExpand",
|
||||
&json!({"params": {"mode": "color", "palette": "limited", "colors": 3, "method": "abutting", "ignoreWhite": true}}),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(r["paths"], 2, "{r}");
|
||||
let n = node(&s, NodeId(r["id"].as_u64().unwrap()));
|
||||
let group = seams(&n).unwrap();
|
||||
let clip = &group.children().unwrap()[0];
|
||||
assert!(matches!(clip.kind, NodeKind::Path { clipping: true, .. }), "{clip:?}");
|
||||
let cb = outline(clip).0.bounds().unwrap();
|
||||
let paths = n.children().unwrap()[1..].iter().filter_map(|c| c.geometric_bounds()).reduce(|a, b| a.union(b)).unwrap();
|
||||
assert_eq!(n.geometric_bounds(), Some(paths), "{xf:?}");
|
||||
assert!(cb.x0 >= paths.x0 - 1e-9 && cb.y0 >= paths.y0 - 1e-9 && cb.x1 <= paths.x1 + 1e-9 && cb.y1 <= paths.y1 + 1e-9, "{xf:?}: {cb:?}");
|
||||
if xf == Affine::IDENTITY {
|
||||
assert!([cb.x0, cb.y0 - 4.0, cb.x1 - 24.0, cb.y1 - 12.0].iter().all(|v| v.abs() < 1e-9), "{cb:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// On an image stretched more one way than another, the seam fills are the strokes' outlines in
|
||||
|
||||
Reference in New Issue
Block a user