The fill's outline keeps the network's points as they are and adds one
where two regions' edges cross, so a new point says the regions overlap,
however small the overlap, and a corner takes the join of the point it
is, not of one close by.
Regions overlap when a segment lies under another region or the fill's
outline is shorter than the segments on it, so an overlap at corners
(no edge's middle covered) is seen too. The fill's outline is stroked as
a network whose points keep the join of the point they lie on.
Object ▸ Vectorize, the right-click menu (when every selected layer has an image fill), the
Actions palette, figcraft-cli and MCP run `image.vectorize {ids?, colors?, detail?,
keepOriginal?}`. Each layer's visible image fills, as they draw in its box, are traced into a
group of filled vector layers in the layer's place: one per colour, the largest area at the
bottom and each reaching under the ones above it, so they never leave hairline gaps. Transparent
areas get no shape, specks are dropped, outlines are simplified and gentle bends become curves
while corners stay sharp. The layer is replaced, or hidden under the result with keepOriginal;
one undo step.
The tracer is our own, in figcraft-pathops (`trace`): k-means colours from spread-out seeds,
pixel-edge outlines with holes, Douglas-Peucker simplification and midpoint curves.
Bounding the rows by the fullest of them sent more networks to placing by loops, which is
wrong where loops are nested under the non-zero rule. Until the lookups have a better index,
a crowded row is slow and right, not fast and wrong.
From the review of #2732:
- Around a point where a line ends on the outline, an inside stroke is trimmed as far as a
cap or mitre reaches at the stroke's widest (StrokeProps::max_weight): a width profile or
a brush makes it wider than its weight.
- Whether the rows are worth building goes by the fullest row, not the average: one tall
shape made many rows while thousands of level shapes all lay in the first.
From the review of #2732: any fixed step reaches past the other edge of a shape thin
enough. The winding numbers on the two sides of a segment differ by one for each time a
loop goes along it, so a step that crossed another edge shows as the wrong parity and is
quartered, up to twelve times; then the loops decide.
From the third review of #2732:
- The step beside a segment's middle is a ten-millionth of the larger of its coordinates and
its length: below what is drawn, whatever the network's size or the edge's length. A share
of either stepped over a long thin shape.
- Rows hold eight times the fill's segments at most (fewer rows where segments are tall),
and are not built where the points would look at more than fifty million segments between
them: such a network's segments are placed by the loops, as before this change.
From the second review of #2732:
- How far beside a segment the fill is looked for goes by the segment's length: by the
network's size it stepped over a small shape far from another.
- The fill's winding number comes from the segments of the point's row (Rows): asking the
path went through all of it for every segment, 2 s for 2,500 squares and 34 ms now.
- The lines in the fill and the ones outside it are stroked as one network, so a join
between two of them stays a join.
- What an inside stroke takes off past the outline is what the lines ending there paint,
not what another line paints beside them.
From the review of #2732:
- A segment is on the outline when the fill lies on one side of it, in the fill or outside it
when on both or neither. The loops alone don't say: a loop inside another that turns the
same way bounds nothing under the non-zero rule, and was stroked as outline.
- An inside stroke cut every line in the fill by the fill. Now only what shows past the
outline around a point where such a line ends on it: a line that goes through the fill
keeps its parts outside, and one close to the edge its whole stroke.
- A segment's middle comes from its own curve, not from a copy of the network.
- The stroke cache's key takes in the segments and the points' places: the loops name
segments by number, and two networks can have the same path with other numbers.
A network with a line across its fill (or a tail leaving it) was stroked at twice the
weight and cut by the stroke path read as a fill: such a line came out twice as thick as
the outline or not at all. The outline is now aligned as asked for and the other segments
are stroked on their centre.
Saving a large imported icon library froze until the system ran out of
memory. The crash dump's stack (v0.18.1) runs Save, the thumbnail render,
a boolean group and then linesweeper 0.4.0's sweep, which loops and keeps
allocating on near-touching curves. The input is small, so the sweep caps
don't stop it.
linesweeper 0.5 fixes that loop. VectorCraft's pathops already uses 0.5,
so the lockfile drops the second copy.
Test: two shapes reduced from linesweeper's own regression input; the
boolean runs on a thread and must finish within 10 s. It times out on
0.4.0 and finishes in milliseconds on 0.5.
* pathops: check closed inputs before faces normalises, share the dash allowance across subpaths, index point incidence once
* pathops: leave out move-only subpaths when closing, budget dashes by the fitted pattern, index only join points
The tolerance that drops the sweep's slivers came from the whole path's bounding box, so a
contour a million units wide welded away the real half-unit edges of a separate small contour.
Each closed subpath now sets its own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Model-Effort: Opus 5.5 drove and wrote
Add figcraft_pathops::round_corners(path, radius, smoothing): every vertex of a closed subpath that is still sharp rounds with a circular arc, convex and concave alike. The sweep's noise is cleaned first (short pieces welded, straight runs merged), smooth joins are not corners, and a corner shrinks to what the edges beside it can hold (half an edge when both ends round, the whole piece beside a smooth join). Corners between straight edges use smoothed_corner; corners beside a curve cut both sides and join them with one cubic. A subpath with nothing to round comes back unchanged.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Model-Effort: Opus 5.5 drove; Fable 5.1 designed; Sonnet 5.5 wrote at medium
kurbo turns an arc into cubics by radius divided by tolerance, so the fixed
0.01 let an ellipse, polygon corner, rounded rectangle, per-side stroke
corner or SVG arc with a radius like 1e300 ask for more cubics than memory
holds before any size check saw the geometry. Arcs now use a tolerance
that scales with the radius, and SVG path data from documents, commands and
imports is refused before parsing when a number passes 1e9.
Three ways a stroke painted past the bounds an export and a redraw go
by, with no effects at all:
- A dash's square end stands out along the path as far as the band
does across it, so its corners reach √2 times as far from the path.
Round a curve that is past the box grown by the stroke.
- The ink brush's ragged edges reach 0.54 of the weight from the path,
not 0.5.
- A scatter brush's copies stray by the weight whatever a width profile
does, but the profile's scale was applied to the stray as well, so a
thinning profile left them out.
`outline_reach` now counts square dash ends as √2 at least, and
`Brush::reach_factor` takes the profile's scale for the shapes only and
counts the shapes' reach (`Brush::SHAPE_REACH`), which a test checks
every preset against.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wasm32 can't catch a panic, so the command and frame guards do nothing in the browser and a panic ended the page with its unsaved changes. The page now follows its files with unsaved changes after every frame; its panic hook writes them to local storage as .figcraft copies (as many as fit) and says on the page that it stopped. The next page opens them again as unsaved files: file.recover also takes the copy as base64 data. The recovery-copy helpers move from the desktop app into figcraft_engine::branches so both share them.
Each sweep takes at most 250 000 segments and 2 million possible crossings (pairs of segments whose bounds overlap, counted in O(n log n)), and a fold at most 4 million segments swept over its steps; past them the operation is refused with PathOpsError::TooComplex before it runs. A boolean group past the caps draws without its result, with a warning once, and the refusal is cached; vector.flatten refuses it instead of dropping it.
Retain regional paint stacks and coordinate frames through simplify, offset, flatten, bucket normalization and Shape Builder. Preserve legacy fill semantics and synchronize importer warning catalogs. Verified with cargo xtask ci on Windows and Ubuntu/WSL, native UI screenshots, and CLI round-trip/export checks.
Found while testing crates/pathops/src/points.rs:89-92 (Styled::arrowheads)
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Found while testing crates/pathops/src/lib.rs:352 (path_end, used by arrowhead)
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
kurbo restarts the dash pattern at every MoveTo, so many short subpaths
with a pattern of tiny dashes before a long gap made ~1M dashes (5M path
elements) while the length-based estimate allowed them. stroke_center
now adds one pattern's length per subpath to the estimate: an upper
bound on the dashes kurbo makes.
Test: each_subpath_restarting_the_dash_pattern_counts_toward_the_limit
(5M elements before).
Reported by CodeRabbit on #1278.
stroke_center handed any dash pattern to kurbo::stroke, which makes one
outline per dash: a 0.01/0.01 pattern on a 10,000-unit line made 2.5M
path elements, and a long line with a tiny pattern ran out of memory.
The variable width stroke already drew solid past MAX_DASHES (20,000);
that estimate is now width::dashes_fit and stroke_center uses it too, so
both strokes follow one rule. The path length is only measured for
dashed strokes.
Test: a_dash_pattern_too_fine_for_its_path_strokes_solid (2.5M elements
on the old code).
Found while testing crates/pathops/src/lib.rs:326-333 (stroke_outline_of, StrokeAlign::Inside and Outside arms calling binary(), which uses FillRule::NonZero at :82)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
stroke_area used rect_side_strokes only for square corners; a rounded
rect-like layer with individual weights fell through to a uniform ring at
stroke.weight (canvas, SVG, PDF, shadows, shape builder, outline stroke).
pathops::rounded_side_strokes now draws them as CSS does: the outer edge is
the rounded rect (the fill outline for inside strokes), the inner edge is
inset by each side's weight with elliptical corners max(0, R - weight), so
border-l-4 rounded-r-lg is a straight bar and a weight that differs across
a rounded corner tapers through it. Center and outside grow the outer box
and each non-zero radius by half or all of the weight (CSS has only
inside). The inner edge runs against the outer one, so the ring is a ring
under non-zero too; where it could leave the outer edge (radii shrunk to
fit a narrow inner box, smoothed outer corners) it is cut out instead.