Hello.
I want to draw 2D curvy path with beizer curves and color fill.
Is it possible to do that in kha?
What is the best method to do that? Use some drawing methods of g2, or use some shaders with g4?
-
Draw curvy path
calculateCubicBezierPoint is a helper method for drawCubicBezier / drawCubicBezierPath to work. It returns a point in a section of a simple curve. To get all the points in a curve with many sections, you could modify drawCubicBezierPath to return the points instead of draw, but actually I was already experimenting with this some time ago, you can see here:
https://github.com/RafaelOliveira/KhaGfx/blob/master/Sources/gfx/Geom.hx#L76
With the points of the shape you can try a triangulate algorithm, or draw lines getting the points horizontally. That is something I'm interested but didn't test yet.