Text Along a Spline III
Here is an update on the new arc-length parameterizaton for the cubic Bezier spline. The current algorithm lacks a certain elegance I would normally desire, but it’s a reasonable starting point. I’m hoping performance will be be good, but that still needs to be stress tested.
The following screenshot shows a much longer text string than in previous examples and a longer spline with numerous inflections.
The example is still a bit crude, but it’s getting there 🙂 The cubic Bezier spline is currently optimized for fast drawing (it was intended to be used in animation), so it performs a minimal number of subdivisions in each segment, meaning that for static plots, it is not drawn accurately. There will be certain letters that appear to ‘pull away’ from the spline that are an artifact of this implementation. Also, only the text width and height are taken into account when placing text in the current demo; the font metrics are not currently used.
In the Degrafa port, the FastBezier class will be replaced by the Degrafa cubic Bezier, so the spline will be suitable for static drawing.
Another refinement that will probably make its way into a future version of the code is to look at the curve tangent halfway along the width of the letter as opposed to the current approach of estimating the tangent at the beginning of the letter. Next step, however, is to handle instances where the text string extends beyond the final spline knot.