SDL2_gfx bezierColor() parameters


#1

I’m trying to use the bezierColor() function in SDL2_gfx but I’m confused by the parameters it is expecting. I had assumed that it would want arrays of endpoints and control points, similar to what the Windows PolyBezier() function requires, but that’s not giving the expected results.

The SDL2_gfx documentation implies that the points supplied in the arrays are all on the curve, that is they are all ‘endpoints’ rather than ‘control points’, which has left me puzzled because I don’t understand how to specify a Bezier curve without control points! Can anybody help?


#2

I have received an explanation from the author of SDL2_gfx, whom I contacted privately. Although the bezierColor() function takes an arbitrary number of points as its parameter, it is not a ‘poly’ Bézier like the Windows GDI function: the first and last points are ‘endpoints’ and all the rest are ‘control points’.

To emulate PolyBezier() it is necessary to call bezierColor() multiple times, with the endpoint of one being the start point of the next. Setting the number of points to 4 (two endpoints and two control points) corresponds to the PolyBezier() behavior.