Following a suggestion of @Pkeod, I am posting here a minimal Defold project with a shader for drawing cubic bezier curves.
You can use the mouse to move the start and end points and the control points. The controls points define the tangents at the start and end points of the curve. (Note that moving a start/end point does not move the corresponding control point, this may look strange if you are used to a vector drawing program…).
A (planar) Bezier cubic curve is just a curve parametrized by two polynomials of degree 3. The math in the vertex shader is quite simple: a linear system to pass from points data to coefficients of these two polynomials, the evaluations of these polynomials and of their derivative to compute the tangent (and then the normal) to a point of the curve. If someone is interested I may explain it in detail.
The shader works in world coordinates, but one should be able to adapt it to local coordinates.
The model is just a rectangle with two opposite sides subdivided in 64 segments with texture uv-coordinates. The points are then moved on the curve by the vertex shader. (EDIT: here I was wrong, I am not using the uv-coordinates, just the absolute position of the vertices of the model.)
There is a little trick: the texture used is a small 2x4 rectangle with only the central 2x2 pixel blacks and the upper and lower pixels transparent. In this way the GPU interpolates among black and transparent and gives us a perfect smooth curve (no antialias used!).
For any further info please ask here or on Slack.
defold_bezier.zip (935.4 KB)