From cd03842fb132530ecc127dcd425714a5af57f9af Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 21 Nov 2026 21:18:03 -0800 Subject: [PATCH] Docs: path.smoothRegion states its sampling limits and acceptance test docs/mcp.md now says the measuring spacing is a target (at least 4 and at most 1,024 pieces per curved segment, fewer on subpaths of more than 256 segments) and gives the acceptance test as formulas: t1 <= t0 + 0.001 * s and fewer anchors, t0 - t1 >= 0.000001 * s, or b0 - b1 > 0.0001 * b0, with s the larger of t0 and 1. The roughness doc comment says the points are about `step` apart. --- crates/engine/src/cmd/draw2/smooth.rs | 2 +- docs/mcp.md | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd/draw2/smooth.rs b/crates/engine/src/cmd/draw2/smooth.rs index 0e357cd8bf..53c72f63d3 100644 --- a/crates/engine/src/cmd/draw2/smooth.rs +++ b/crates/engine/src/cmd/draw2/smooth.rs @@ -686,7 +686,7 @@ const ROUGHNESS_SEGMENT_PIECES: usize = 1024; const ROUGHNESS_PIECES: usize = 1 << 18; /// How rough the subpath `sp` is, measured along the lines between points on each curved segment -/// no more than `step` apart along its control polygon (at least 4 and at most +/// about `step` apart along its control polygon (at least 4 and at most /// [`ROUGHNESS_SEGMENT_PIECES`] pieces a segment, fewer on a subpath of very many segments): how /// much it turns along its length in radians, from the direction each segment leaves its first anchor /// along to the one it arrives at its last anchor along, with each turn at an anchor counted twice; diff --git a/docs/mcp.md b/docs/mcp.md index d5f64dd9c2..6b074c69ca 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -7234,11 +7234,16 @@ own, and the corner keeps its place and the directions the path arrives and leav `fidelity`. A call that changes no anchor returns `{ids: [], before: 0, after: 0}` and adds no undo step. The 57.5° threshold is VectorCraft's own value. -`path.smoothRegion` keeps a subpath's result only when it is smoother. Measured along lines between points no more -than an eighth of `radius` apart (or 1/512 of the subpath's size when that is smaller), the result must turn no more -than a thousandth more than the subpath did, with each turn at an anchor counted twice, and it must have fewer -anchors, turn less, or bend more than a ten-thousandth less (the sum of each turn squared over the length it is taken -over). Any other result is dropped and the subpath stays as it was. A path none of whose subpaths is kept stays a Live +`path.smoothRegion` keeps a subpath's result only when it is smoother. It measures the subpath and the result along +lines between points on each curved segment, spaced about `step` apart along the segment's control polygon, where +`step` is an eighth of `radius` or 1/512 of the diagonal of the box around the subpath's anchors and handles, +whichever is smaller. The spacing is a target: each curved segment is cut into at least 4 and at most 1,024 pieces, +and on a subpath of more than 256 segments into at most 262,144 divided by the number of segments (but never fewer +than 4). The turning `t` is how far the path's direction turns along its length, in radians, with each turn at an +anchor counted twice; the bending `b` is the sum of each turn between two pieces squared over their mean length. +With `t0` and `b0` measured on the subpath, `t1` and `b1` on the result, and `s` the larger of `t0` and 1, the result +is kept when `t1 <= t0 + 0.001 * s` and at least one of these holds: it has fewer anchors, `t0 - t1 >= 0.000001 * s`, +or `b0 - b1 > 0.0001 * b0`. Any other result is dropped and the subpath stays as it was. A path none of whose subpaths is kept stays a Live Shape if it was one, is left out of `ids` and is not counted in `before` or `after`. The measure and both thresholds are VectorCraft's own.