Comments (3)
Hello @mbutterick
Thank you once again for the level of detail you've gone into opening this issue.
I believe that what's going on here is that offset
doesn't work properly with corners. I haven't given the offset
method the attention it should get to ensure correctness. The behavior you're seeing at 90 degree corners where the point moves 1/2 the expected distance is because the code to compute the corner position is based on taking the average of the point's position if it were moved along one edge (vertically) and moved along the other edge (horizontally). The code needs a better approach.
from bezierkit.
Instead of using a linear average of the startPoint
and endPoint
of curves that are noncontiguous after offset
, I propose that the better idea is to project the intersection of the two segments, and then move the startPoint
and endPoint
of the offset curves to that intersection.
Here’s how that looks using the original test cases, still applying offset(10)
.
All curves
In this case, no change. Just like before, each on-curve point is shifted in the offset direction by 10 units.
All straights
Previously, with linear averaging, the points were only moving a net 5 units from their original positions. But with projection, they all move 10 points.
Mix of curves and straights
Previously, with linear averaging, the straight segments were moving only half the distance, but curve points were moving the full distance, resulting in top and bottom edges that were no longer horizontal. With projection, however, every point moves the correct distance, and parallelism is preserved:
from bezierkit.
PR #98 shows how I did this, though it is not offered as a fully tested work of art.
from bezierkit.
Related Issues (20)
- boundingBox vs boundingBoxOfPath follows opposite convention as CoreGraphics
- Hard to work with ends of simple, unclosed bezier path HOT 2
- Path and PathComponent hash and hashValue is simply memory address HOT 1
- Unknown references to BezierKit.min(...) and BezierKit.max(...) HOT 3
- Path.offset(distance:) hits assertion failure when called on a Path where all points are equal HOT 1
- Union of 2 overlapping paths returns an empty path HOT 4
- `union` with nonzero winding rule HOT 9
- Path.crossingRemoved() produces wrong result HOT 11
- simplifying a curve? HOT 2
- feature request: permit separate x and y inputs for scale, outline, reduce HOT 8
- this contour crashes `crossingsRemoved` HOT 9
- `crossingsRemoved` makes these two contours disappear HOT 12
- how to quiet the SwiftLint warning? HOT 2
- `crossingsRemoved` gets confused by coincident points HOT 3
- droots can have low precision in some cases, which could affect Path.contains(_ point:)
- Newton iteration may fail to converge, producing wrong results in curve.project()
- `offset` fatalError when all control points of segments are the same HOT 3
- Impossible to make closed PathComponent HOT 19
- Proposal: Use Sylvester Matrix for finding the intersection of cubic beziers HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bezierkit.