Conversation
Preserve endpoint differentials before flattening, adjust disjoint supports, and apply arc-length miter clipping. Include geometry regressions, a mesh-rendered SVG example, and same-input benchmarks. Permit nonnegative SVG 2 miter limits.
Expose ArcsClip::Butt (SVG 2 default) and ArcsClip::Round (nonstandard extension). Preserve base geometry and vertex metadata; add regression tests and JSON migration coverage.
Author
|
Closing this upstream draft while the implementation is prepared and reviewed in the fork: SonyStone#1. The API, correctness and performance work is still in progress. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The issue: #868
Summary
Adds
LineJoin::Arcstolyon_pathand implements it inlyon_tessellation.Original segment tangents and curvature are retained before flattening. Private
modules construct support geometry and triangulate the join, reusing scratch
allocations.
The construction follows the SVG 2 Candidate Recommendation, 4 October 2018:
support-circle intersection and radius adjustment, the excessive-curvature guard,
opposite-parallel rectangle handling, and arc-length miter clipping. Nonnegative
miter limits are accepted, including zero and sub-unit limits.
A second, separable commit adds the nonstandard
ArcsClip::Roundextension.It fits tangent-continuous biarcs to actual miter-cut directions, without moving
the existing stroke mesh. It is not necessarily a semicircle and may extend past
the miter limit. Invalid or non-convex fits retain the flat cut. SVG behavior
remains the default.
No editor, canvas persistence, support-preview API, historical join modes, or
public profiling switches are included.
Commit sequence
455ff35— SVG 2 construction, regression tests, SVG example, and benchmarks.1692323— optional rounded clipping, metadata/winding tests, and serialization migration test.The first commit builds and passes the workspace tests independently. The second
can be considered separately if the extension is outside Lyon's desired scope.
API
Compatibility points requiring maintainer review:
LineJoinenum breaks downstreamexhaustive matches. Release/version policy must be decided before merging.
The new variant is appended so existing serialized variant indices are not shifted.
StrokeOptionsis already non-exhaustive. The second commit adds a field andbuilder method. Missing fields in old JSON default to flat clipping; binary
serialization compatibility is not claimed.
MINIMUM_MITER_LIMITchanges from 1 to 0 for all joins, not only arcs.serde_jsonis a dev dependency forthe migration test.
Validation
On Windows x86_64, stable Rust 1.90.0:
cargo test --workspace --all-featurespasses.cargo check -p lyon_tessellation --no-default-featurespasses.cargo check --workspace --target wasm32-unknown-unknownpasses.cargo +nightly test -p lyon_tessellation --all-featurespasses.git diff --checkpasses.overly_complex_bool_exprdiagnostic in
crates/tessellation/src/fill.rs:772, reproduced on the unchangedbase. With that lint allowed, the check succeeds; existing test warnings remain.
No warnings were reported in the newly added arcs modules, integration test, or example.
Linux CI and any maintainer-selected MSRV still need validation. Existing unused
num_traits::Floatimport warnings remain in the no-std build.Generate a comparison rendered from the actual triangle meshes:
The example compares Round, MiterClip, SVG 2 Arcs, and SVG 2 with rounded cuts,
without relying on browser support for arcs joins.
Performance: open merge blocker
Do not merge on the assumption that existing joins are unaffected.
The unchanged upstream logo benchmarks were built separately at base
994526f2766c7e9bc5bb16687232fd7e8999dbdfand at this candidate. Four completealternating pairs were measured with default release settings on an Intel
Core i9-13900H, Windows x86_64, Rust 1.90.0. Medians of reported ns/iteration:
This is a local microbenchmark result, not a cross-platform estimate. The
standard-only commit also regressed these cases in an earlier five-pair run.
Profiling and reducing this cost is required before calling the implementation
merge-ready.
Reproduce the existing tests in separate checkouts:
The new same-input, reused-buffer benchmarks can be selected with
arcs,round_curved, andmiter_clip_lines. Initial smoke measurements were noisy;they are not sufficient to quantify the overhead of rounded clipping.
Remaining correctness/scope questions
path without normalizing their winding. Overlapping triangles with opposite
winding cancel, producing apparent holes. Coordinate checks confirm coverage
in those regions. The exporter needs correction, and mixed mesh winding needs
a separate review for back-face culling. This has not been fixed in these commits.
fallback. SVG 2 describes a line construction for degenerate Bezier handles;
that behavior still needs reconciliation and dedicated conformance tests.
This PR does not claim complete SVG conformance.
profile.
Elliptical arcs converted to Beziers use those Beziers' curvature.
Please review the public API and desired scope of the rounded-cut extension while
the performance and degenerate-handle questions are addressed.
Replaces #964 after renaming the source branch. The implementation commits are unchanged.