Search code examples
postscriptbezierspline

How to generate control points for postscripts curveto operator?


I'm looking for a way to render a bunch of connected lines as a nice continuous curve in postscript. It's important that the rendered curve passes through all my points.

curveto seems to be the only available way to draw curves, but that function requires bezier control points, which I don't have.

So, is there a way to calculate control points for my points so curveto can be used? Preferably in postscript.

For reference, I've previously used GraphicsPath.addCurve(float[]) in .NET which does the conversion to cubic Bézier control points internally before rendering them. I'm looking for something similar in postscript.

(I am able to interpolate the points using a spline function and then render it using lots and lots of individual lines. It looks ok, but is not really a great solution)


Solution

  • I solved this problem by using the code example here ("Draw a Smooth Curve through a Set of 2D Points with Bezier Primitives").