66 Commits

Author SHA1 Message Date
bflatastic c14fd6f2e0 fix(pathops): find meeting region boxes with a sweep ordered by their tops, so a column of them stays fast (#2982) 2026-12-03 22:45:57 +07:00
bflatastic e185d6dff5 fix(pathops): rebuild the outline only for regions whose boxes meet, within the rows' budget (#2982) 2026-12-03 22:41:09 +07:00
bflatastic b03d0c39d1 fix(pathops): a corner regions share keeps the join one of them gives it (#2982) 2026-12-03 22:21:19 +07:00
bflatastic 4ff7ec74ae fix(pathops): regions overlap where the outline has a point of its own, and joins go by the point they are (#2982)
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.
2026-12-03 22:21:18 +07:00
bflatastic a0fa90f81f fix(pathops): regions that overlap only in part, and a corner's own join, on a flattened layer's aligned stroke (#2982)
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.
2026-12-03 22:21:18 +07:00
BFlat 1a5fff2d04 fix(pathops): a flattened layer's inside and outside stroke follows its whole outline (#2982) (#2984) 2026-12-03 22:17:18 +07:00
BFlat c6cdefa326 fix(pathops): path operations leave out zero-width sliver contours (#1572) (#2910) 2026-12-02 09:03:29 +07:00
bflatastic 6911d897c2 M1: Vectorize turns image layers into editable vector layers, one per colour (#2497)
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.
2026-12-01 12:02:02 +07:00
Livio Sidler 0dc67b5983 M4, #2766: the rows' bound stays as it is on main
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.
2026-11-30 01:35:56 +01:00
Livio Sidler cc8185bd5b M4, #2766: a line's end is trimmed as far as the stroke gets wide, and rows are bounded by the fullest of them
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.
2026-11-30 00:56:07 +01:00
Livio Sidler 6d3bd1c88c M4, #2731: the step beside a segment is shortened until the two sides differ as the loops say they must
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.
2026-11-29 13:10:05 +01:00
Livio Sidler 8b509fc155 M4, #2731: the fill is asked beside a segment at the least distance its numbers tell apart, and by rows only where that stays cheap
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.
2026-11-29 13:03:23 +01:00
Livio Sidler 946bed1328 M4, #2731: lines that are not the outline are stroked together and trimmed by their own stroke; the fill is asked by rows
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.
2026-11-29 12:51:07 +01:00
Livio Sidler 1d18f795d0 M4, #2731: a vector's lines are placed by what is filled beside them, and trimmed only where they end on the outline
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.
2026-11-29 12:34:14 +01:00
bflatastic b60e8acdfe pathops: pass the fill test by value (clippy needless borrow) 2026-11-29 18:11:14 +07:00
ls254 27aac6e002 M4, #2731: a vector's inside or outside stroke aligns only its fill's outline
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.
2026-11-29 12:03:30 +01:00
Ridzzz0Alam 3a374ba85c M4: a near-degenerate boolean no longer hangs Save (#2394)
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.
2026-11-21 22:34:46 +01:00
Trevor Brown 4641f9deeb Merge upstream/main into fix/boolean-corner-radius-2222
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 17:49:04 -05:00
Dylan M. Taylor 554ad0ea77 pathops: budget the closed faces input, share the dash allowance, index point incidence (#2249)
* 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
2026-11-11 14:49:49 -05:00
Trevor Brown 4c91f9084b M4: round_corners: each contour's own size sets its weld tolerance (#2222)
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
2026-11-10 15:39:09 -05:00
Trevor Brown c48d844d22 M4: round the sharp corners of a closed path (pathops, #2222)
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
2026-11-10 13:11:56 -05:00
BFlat 7cf1dea7b0 Merge pull request #1780 from AxylumRust/fix/pathops-isolate-lowest-one
fix(pathops): M2.1: keep Fenwick indices Rust 1.95 compatible
2026-11-07 12:23:42 +08:00
BFlat f569ff683e Merge pull request #1849 from samhyun/fix/stroke-corner-reach
M8: a stroke's square dash ends and brush shapes paint within its bounds
2026-11-07 12:21:35 +08:00
bflatastic f1a5360859 Merge main into #1942 2026-11-07 10:54:18 +07:00
Dylan M. Taylor 44bec70a47 fix(pathops): cap an arrowhead's weight like a stroke's width 2026-11-04 04:25:42 +00:00
Dylan M. Taylor 53ebf1f39c fix(pathops): sanitize a brush's width profile once before sampling (#1948) 2026-11-03 14:40:54 -05:00
Dylan M. Taylor 411b16931b fix(geom): keep arc subdivision bounded whatever the radius
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.
2026-11-03 15:45:48 +00:00
samhyun ed2747e9a4 M8: a stroke's square dash ends and brush shapes paint within its bounds
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>
2026-11-02 14:21:44 +09:00
Cédric Legrand c41471d20b build(pathops): M2.1: inherit workspace Rust version 2026-11-01 19:54:54 +01:00
Cédric Legrand f137e9df9a fix(pathops): M2.1: keep Fenwick indices Rust 1.95 compatible 2026-10-31 20:29:10 +01:00
BFlat 6b28ef57dc M4: Dash cap setting for Dash and Custom strokes (#1728) 2026-10-31 09:41:39 +07:00
BFlat 87e42a14f2 M4: a dashed line starts and ends with a half-length dash (#1718) 2026-10-31 05:28:15 +07:00
BFlat 974ab39503 M8: keep unsaved files when a panic stops the browser build (#1123) (#1580)
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.
2026-10-30 06:36:33 +07:00
BFlat cc3052de5e M8: cap the input of boolean operations (#1104) (#1581)
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.
2026-10-30 06:03:35 +07:00
bflatastic 789fa33444 Merge main into #634 2026-10-29 12:25:06 +07:00
Guillermo Bueno fe7872708f M4: draw bounded dots for zero-length round dashes 2026-10-27 21:11:32 +01:00
Skyfuller1303 a4076caaf4 Merge main and preserve vector region paints through path operations
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.
2026-10-26 19:50:00 +01:00
bflatastic 3b56f18e8e Merge main into #1202
# Conflicts:
#	crates/engine/src/codegen.rs
#	docs/mcp.md
2026-10-26 09:21:24 +07:00
BFlat abc5105111 Merge pull request #1297 from Silvertree2010/fix/h2089-arrowhead-cap-disappears-when-an
Skip zero-length segments when finding arrowhead direction
2026-10-26 09:05:13 +07:00
BFlat 1172cfa444 Merge pull request #1324 from Silvertree2010/fix/h2487-end-arrowhead-missing-on-an-open
Fix missing end arrowhead when a closed subpath follows an open one
2026-10-26 09:05:08 +07:00
bflatastic 9c57ba1beb Merge main into #1202 2026-10-26 08:43:07 +07:00
NetterSilver a107e62bcc Fix missing end arrowhead when a closed subpath follows an open one
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>
2026-10-25 12:13:55 +01:00
NetterSilver 42fbe8f00c Skip zero-length segments when finding arrowhead direction
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>
2026-10-24 18:52:03 +00:00
Ridzzz0Alam 2baeff3452 M1: dash limit counts the pattern restarting at each subpath (#1060)
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.
2026-10-24 12:44:55 +02:00
Ridzzz0Alam 494387a6a8 M1: a dash pattern too fine for its path strokes solid (#1060)
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).
2026-10-24 12:13:40 +02:00
NetterSilver 7df328d1ca Clip Inside/Outside strokes by the shape's even-odd fill rule (#1253)
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>
2026-10-24 05:23:23 -04:00
bflatastic 31d4c6eba4 Batch r2-1 review: per-side strokes follow smoothed corners for every alignment 2026-10-24 10:31:24 +07:00
bflatastic 62a3072134 Merge main and the community batch into #1202
# Conflicts:
#	crates/engine/src/component_codegen.rs
#	crates/engine/src/tools.rs
#	crates/ui-egui/locales/fi.toml
#	crates/ui-egui/locales/nl.toml
#	crates/ui-egui/src/dev_mode_tests.rs
#	crates/ui-egui/src/shortcuts.rs
#	docs/dev-mode-parity.md
#	docs/file-format-parity.md
#	docs/ui-parity.md
2026-10-24 09:39:52 +07:00
Nicek 5b97d03701 fix: 修复异形描边生成重叠区域的问题
通过将自相交路径简化为简单轮廓,解决了中心描边在异形尖角处产生重叠区域的问题。新增clean_poly函数清理多边形中的重复点和亚像素细条,修改路径处理逻辑确保生成的区域不重叠,同时添加相关测试验证正确性。
2026-10-23 09:49:32 +08:00
MortenHusted 6db58d32cb M4: individual stroke weights follow the corner radius like CSS borders
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.
2026-10-22 11:20:24 +02:00