Repository navigation
Brushes: art along a smooth curve keeps smooth edges - #7321
Conversation
Art and pattern brushes bent their art along the chords of the flattened path, with the tangent blended linearly between vertices, and scatter brushes placed and turned their copies on the same chords. On a smooth curve the bent art's edges followed the chords, and the curve fitted to the result turned by up to a few degrees at its smooth anchors. - On a chord that comes from flattening a curve, the frame now follows the cubic through both vertices with their tangents, so position and tangent meet at every vertex. A vertex tangent between two such chords is the tangent of the circle through the vertex and its neighbors, and it stays within a few times the flattening tolerance of each chord, so the frame stays near the curve next to a long chord. A curved chord whose end tangents turn further than that keeps to the chord. - Art on a line of the path stays on the line, and a line keeps its own direction where it meets a curve. - A calligraphic nib that follows the pen samples between vertices on the same frame, so its outline keeps its distance from the curve.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Merged, thanks @dotCooCoo! It passed its CI checks. |
What and why
Art and pattern brushes bend their art along the path through
Track::frame(crates/brush/src/track.rs), and scatter brushes place and turn their copies with it. The frame put each point on a chord of the flattened path and blended the tangent linearly between vertices. On a smooth curve the bent art's edges followed those chords, so the curve fitted to the result turned at its smooth anchors. With a straight-sided Stretch art brush on a half circle, the edges turned by 0.8° to 6.2° at those anchors (radius 2,000 pt to 30 pt).samplesincrates/brush/src/calli.rs).How it was tested
New tests, each shown failing without the part of the change it covers:
art_brush_edges_stay_smooth_along_a_curve(crates/brush/src/tests.rs): a Stretch art brush on half circles of radius 30, 100, 300 and 2,000 pt; no edge turns by 0.5° or more at a smooth anchor.pen_driven_nib_outline_follows_the_curve_between_vertices(crates/brush/src/tests.rs): a pressure-driven round nib on a half circle; the outline stays within 0.05 pt of the nib's reach.a_straight_curve_element_beside_a_tight_bend_stays_on_its_line(track.rs): a 200 pt straight cubic joined to a quarter circle of radius 5, either way round; the frame stays within 0.1 pt of the line, and its tangent's component across the line stays under 0.01.a_long_curve_flattened_coarser_is_still_followed(track.rs): a quarter circle of radius 5,000,000 pt, which flattening gives a larger tolerance; the frame stays within 0.05 pt of the curve.a_curve_of_no_length_leaves_a_line_a_line(track.rs): a curve of no length between two lines leaves both lines.New tests that pin the lines and seams:
a_polylines_frame_stays_on_its_lines,a_line_into_a_smooth_curve_keeps_its_direction,a_closed_curves_frame_is_smooth_across_its_seamandan_implicit_closing_line_is_not_a_curve(track.rs).Focused checks on x86-64 Linux. The branch is one commit on
mainat4558196e16and merges cleanly withmainat28bd9c9292. It sharescrates/brush/src/calli.rsandcrates/brush/src/tests.rswith open #1858 andcrates/brush/src/tests.rswith open #7103. The commands run were:cargo fmt --all -- --checkcargo check --workspace --testscargo clippy -p vectorcraft-brush --all-targets -- -D warningscargo test -p vectorcraft-brush: 84 passed, 0 failed.cargo test -p vectorcraft-render -p vectorcraft-svg -p vectorcraft-pdf -p vectorcraft-eps -p vectorcraft-engine -p vectorcraft-tools brush: 277 passed, 0 failed.cargo xtask ciruns in this pull request's CI.The art, pattern and scatter paths share the frame; the measurements above are for art brushes and the pen-driven nib.
cargo xtask cipassed in this pull request's CI run on90be8fba18: https://github.com/storytold/vectorcraft/actions/runs/43525329385/job/132229541081Checklist
cargo xtask cipasses (fmt, clippy, tests, assets, brands, layers, wasm).unwrap(),expect(),panic!,unreachable!,todo!orunimplemented!outside tests, and no unchecked indexing on data from files, parameters ormessages. Errors are returned as
Resultand shown to the user(why and how).
ASSETS.md.Summary by CodeRabbit