Avoid hardcoding a tolerance in Vello API, instead require the user to provide it #1376
+215
−35
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.
This was one of the key points raised for follow-up in #1360, to make this API harder to misuse.
The implementation strategy is to have a new
ExactPathElementstrait, which is implemented forShapes which don't require approximation.To allow shapes which do require a tolerance to be used without allocation, the
withinfunction can be used, which creates an exact shape from an inexact shape within the provided tolerance.This ensures that the common-case of rectangles and similar is ergonomic, whilst the case where tolerance is needed is handled by the user. This still completely avoids per-path allocations.
The
ExactPathElementsis based on code by @tomcur from #vello > Determining correct `Shape` tolerance. There are reasonable arguments thatExactPathElementsactually belongs in Kurbo, but I also think that, if this is the direction we decide to go, migrating that code into Kurbo would (relatively) straightforward.