-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: support for quadratic curves #26
Comments
Any updates on this issue? |
As stated: any help is welcome. This is not a top priority issue for me... |
I had a second look and committed a working version in: https://github.com/typemytype/booleanOperations/tree/quadratics but there are some serious considerations to thinking about: Quads with more then one off curve points will have to add the implied on curve point, as there is no other option to split a quad with x-amount off curves in just 2 curves. This means that an overlap with an outline of 2 curved parts (tail of a Q) not only adds the 4 intersection point but also adds a maximum of 8 implied on curves. That makes adding 12 on curves, which is not nice at all... The current state of the quadratics branch adds those implied on curves, pathOps also add those implied on curves. Maybe a different quadratic splitting must be possible:
any assistance or help is appreciated :) |
to clarify and some visual explanation: The implied on curves on the original curve are required in the splitted quadratics. This is unavoidable but this is also causing much bigger problems after a union the intersection points are added but also the original implied on curves became fixed on curves: This action adds 12 on curves point and 8 off curves, from booleanOperation point of view this is not nice. Add rounding to all those points and your tail of the Q became a monster... So my questions for the smart quad friends is: is there an other way to split a quad at a given point, t-value without adding those previous implied on curve points. Ive already investigated to add lots of off curve point but this is not sustainable as this could be really lots of off curve points if the split request is close to an implied on curve point. thanks (this is the code example drawing: https://gist.github.com/typemytype/d699cdc8b08c44b4f8584ee5d09373f8) |
Maybe you could elevate the quadratic spline to a cubic Bézier curve using the algorithm in googlefonts/cu2qu#29, split the cubic at intersection points and then convert the remaining segments back to quadratic using again cu2qu. |
this only works with one super heavy assumption: it was originally converted from a cubic... this does not work for the "o"-like shape without any on curves |
TrueType quadratic curve segments with implied on-curve points can be thought of as quadratic B-spline curves. If we know the t parameter for a point on a B-spline curve (i.e. your intersection points after clipping), it should be possible to subdivide the curve into two B-spline curves, one on [0,t] and the other on [t,1] using the De Boor algorithm (a generalization of De Casteljiau algorithm): That website contains other useful notes about b-splines (see "Unit 6" of http://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/) It's been a while since I first studied these topics, I forgot most of it..
I remember I also found quite useful this book by G. Farin, "Curves and Surfaces for CAGD" https://www.amazon.com/Curves-Surfaces-CAGD-Practical-Kaufmann/dp/1558607374/ I hope this helps... |
there's a C++ library called tinyspline for manipulating B-spline curves, which comes with (SWIG-generated) python bindings https://github.com/msteinbeck/tinyspline/blob/master/examples/python/quickstart.py |
hm.. actually it's not enough to apply De Boor algorithm and subdivide a single B-spline into two segments, because after the split the "knots" in the resulting segments may no longer be uniformly spaced and thus we won't be able to convert them back into TrueType qcurve segments -- where the "implied" oncurve points, aka. "knot points", must be separated from each other by equal t intervals. EDIT: I'd love to be proven otherwise, of course ;) |
You need to insert an explicit on-curve point adjacent to wherever the curve is cut. There's no way around that. |
There are some not implemented errors, mostly related to support for quadratic curves.
While splitting and merging existing curves there are three scenarios possible:
A quadratic curves exists of one or more sub quadratic segments, in fontTools those can be created with
decomposeQaudraticSegment(...)
Therefore the
inputContour.split(tValues)
have to split the quad curve nicely in parts, without adding points (by decomposing the curve).This is work in progress, any help is welcome!
The text was updated successfully, but these errors were encountered: