Yeah, sorry about that! I’m not great at commenting for others.
There are two ways to use the bezier code from that file. One is as a drawing command, the other is as an instance of a class.
For the former, the command is:
bezier(<start>, <first control>, <second control>, <end>, [<taper>])
The points should be vec2
s. The taper
is an optional 0
or 1
to control whether the bezier is constant width or tapers. There are a few other possible inputs, in that it can handle quadratic and linear beziers.
This version picks up the current strokewidth, colour, and linecapmode.
For the latter, you start by instantiating a bezier object:
b = Bezier(<start>, <first control>, <second control>, <end>)
then you can set various attributes
b:setStyle({<table of style options>})
Once this one has been set up, after the first time it has been drawn, via b:draw()
, then those options are “baked in”.
If drawing the same bezier (with the same options) many times then the OO approach is best. If the bezier will vary, then the functional version will be better.