Repository navigation
Conversation
A Path is now an immutable, shared Shape plus a placement transform and a style. Transforming a path composes the placement and shares the shape, so Copy, Translate, Rotate, Scale, Skew, Align, Fit and Reflect no longer copy points. Every accessor returns placed points; contours() borrows them when the placement is the identity.
convert_paths converts each shape once and keeps the placement as an Affine. Fills draw the shared shape with the placement. Strokes do too when the placement is a rotation and uniform scale, with the width divided by the scale; otherwise they stroke the placed points, so the stroke width is never scaled. The desktop viewer uses the shared scene builder. AGENTS.md states the rule that every point a Path hands out is placed.
# Conflicts: # crates/nodebox-core/src/geometry/path.rs
Member
Author
|
Closing: NodeBox 4 renderer and path-model work continues in fdb/nodebox4 only. The branch stays as a reference. Generated by Claude Code |
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.
Requested by Frederik · project thread
Before: Copy, Translate, Rotate, Scale, Skew, Align, Fit and Reflect copied every point of every path, and Vello converted every path separately.
After: a
Pathis an immutable, sharedShapeplus a placement transform and a style. Those ops only compose the placement, and Vello converts each shape once. The output looks the same: all tests pass unchanged, and Vello's pixels for placed and baked copies differ by at most 1/255 (checked on llvmpipe).The rule, now in AGENTS.md: every point a
Pathhands out is placed.contours()borrows the shape's points when the placement is the identity and computes them otherwise. Onlyshape()plusplacement()expose shape coordinates, for renderers and caches. Building or editing points goes throughwith_contours()orcontours_mut(), which copies a shared shape first.How:
contoursbecame private behindcontours(),contours_mut(),contour_count()and friends, andPath::transformcomposes the placement. Bounds are cached per shape. Serde still writes placed contours, so the TypeScript side sees no change. In Vello, fills draw the shared shape with the placement. Strokes do too when the placement is a rotation plus uniform scale (the width divided by the scale); mirrored, skewed or unevenly scaled paths stroke their placed points, so the stroke width is never scaled. SVG export keeps writing placed points, because an SVGtransformwould scale the stroke.benches/copy_paths.rs, 64-point shape, againstnodebox4:Rotated bounds are slower because they transform points on each call. Bounds of translated or scaled copies come from the cached shape bounds.
Tests run:
cargo test --workspace --exclude nodebox-python(751 passed),cargo test -p nodebox-core --features serde,cargo check -p nodebox-electron --target wasm32-unknown-unknown,cargo bench -p nodebox-core --bench copy_paths. Not run: the Electron Playwright suite.nodebox-pythonalready fails to build onnodebox4(pyo3 API), and its two touched files were updated by hand.Generated by Claude Code