I have the data of a spline curve
And I need to draw this curve by using Direct2D
. At the moment I am using the ID2D1GeometrySink interface to draw geometries but it seems it does not implements a possible AddSpline
method.
Is there a way to draw spline by means of Direct2D
? Even a DirectX
implementation that can be used in a Direct2D
application will be fine.
Direct2D, more clear ID2D1GeometrySink, doesn't support splines, but cubic bezier curves which can be put together to a spline. In the opposite, you can gain b-curves out of your spline data and just add them to your geometry.
The algorithm is simply explained by this picture: .
An article for short and well explanation can be found here. You can split your spline until control points overlap and the degree can be lowered, even until all curves are flat enough to be lines. Last thing isn't a bad idea because your hardware doesn't know curves, so your passed curves get converted to lines later anyway. When you do this conversion, you can determine the tolerance for flatness and avoid ugly edges.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With