Comments (9)
BTW if I disable the assert
, nothing bad seems to happen, so I can’t tell if the assert
is protecting against a stricter condition than necessary, or if there is some subtle logic or math error happening deeper. Considering that the error seems very sensitive to the exact relative positions of the handles, I suspect the latter.
from bezierkit.
Wow, I've never seen that assert
hit before!
I am not sure why it's happening here. addNeighbor
is called on a per-intersection basis and it does not appear that the path self-intersects so I'm unsure why it is called at all.
I'll try to reproduce this issue soon.
from bezierkit.
This contour also crashes crossingsRemoved
— seemingly related to having four points at the same Y coordinate on the top edge. Is there a way I can print a text-based representation of a path that would make reconstructing the test case easier? (Because these errors seem to be very sensitive to point position)
from bezierkit.
@mbutterick if you have the debugger paused at the assert, try navigating the stack up to AugmentedGraph.init(...)
and type:
po path1.components.map { $0.curves }
This should print out the curves that make up the contour and I can make a test case directly from that.
from bezierkit.
Seems likely it’s a different bug so I’ll post a separate issue (see #81)
from bezierkit.
Here’s a test case that produces same error. Slightly different shape on top but the problematic inflected curve at the bottom is the same.
Text:
path.components.map { $0.curves } =
[[BezierKit.CubicCurve(p0: (275.0, 656.0), p1: (325.0, 656.0), p2: (324.0, 594.0), p3: (372.0, 594.0)), BezierKit.CubicCurve(p0: (372.0, 594.0), p1: (406.0, 594.0), p2: (426.0, 616.0), p3: (426.0, 645.0)), BezierKit.CubicCurve(p0: (426.0, 645.0), p1: (426.0, 691.0), p2: (377.0, 713.0), p3: (329.0, 713.0)), BezierKit.CubicCurve(p0: (329.0, 713.0), p1: (228.0, 713.0), p2: (240.0, 656.0), p3: (275.0, 656.0))]]
path.crossingsRemoved().components.map { $0.curves } =
[[BezierKit.CubicCurve(p0: (275.0, 656.0), p1: (300.5, 656.0), p2: (312.7349, 639.8738000000001), p3: (324.96979999999996, 624.0701239999999)), BezierKit.CubicCurve(p0: (324.96979999999996, 624.0701239999999), p1: (336.7249, 608.8862), p2: (348.48, 594.0), p3: (372.0, 594.0)), BezierKit.CubicCurve(p0: (372.0, 594.0), p1: (406.0, 594.0), p2: (426.0, 616.0), p3: (426.0, 645.0)), BezierKit.CubicCurve(p0: (426.0, 645.0), p1: (426.0, 691.0), p2: (377.0, 713.0), p3: (329.0, 713.0)), BezierKit.CubicCurve(p0: (329.0, 713.0), p1: (228.0, 713.0), p2: (240.0, 656.0), p3: (275.0, 656.0))]]
from bezierkit.
@mbutterick I am unfortunately not able to reproduce the issue. Here is the code I'm running trying to hit the assert with your first path:
let mutablePath = CGMutablePath()
mutablePath.move(to: CGPoint(x: 0, y: 62))
mutablePath.addCurve(to: CGPoint(x: 97, y: 0),
control1: CGPoint(x: 50, y: 62),
control2: CGPoint(x: 49, y: 0))
mutablePath.addLine(to: CGPoint(x: 78, y: 102))
mutablePath.addLine(to: CGPoint(x: 0, y: 62))
let path = Path(cgPath: mutablePath)
let result = path.crossingsRemoved()
assert(path == result)
Here is the code I'm running to try to reproduce the issue with the second path
let points = [CGPoint(x: 275.0, y: 656.0), CGPoint(x: 325.0, y: 656.0), CGPoint(x: 324.0, y: 594.0), CGPoint(x: 372.0, y: 594.0),
CGPoint(x: 406.0, y: 594.0), CGPoint(x: 426.0, y: 616.0), CGPoint(x: 426.0, y: 645.0),
CGPoint(x: 426.0, y: 691.0), CGPoint(x: 377.0, y: 713.0), CGPoint(x: 329.0, y: 713.0),
CGPoint(x: 228.0, y: 713.0), CGPoint(x: 240.0, y: 656.0), CGPoint(x: 275.0, y: 656.0)]
let path = Path(components: [PathComponent(points: points, orders: [3, 3, 3, 3])])
let result = path.crossingsRemoved()
assert(path == result)
Everything seems ok on my end. If you run these code snippets are things working ok on your end?
I might need more information, like what branch you are using, OS version, XCode version, hardware things are running (especially 32 vs 64 bit).
from bezierkit.
Sorry, that was my error. My copy of BezierKit was a little behind the current one. I’ve updated and the issue no longer recurs.
from bezierkit.
good to know BezierKit is at least improving over time :)
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
- `offset` seems to treat straight & curved segments differently HOT 3
- feature request: permit separate x and y inputs for scale, outline, reduce HOT 8
- `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.