I am trying to create a bezier spline curve that goes through four points.But it looks like MGraphics only supports curves of three points.
curve_to(x1, y1, x2, y2, x3, y3);
How can I create a curve using MGraphics that will support more points?
For some reason the images i posted do not show.
autowatch = 1;
var width = 500;
var height = 300;
// create a [jit.gl.render] object for drawing into our window:
var glrender = new JitterObject("jit.gl.render","render-ctx");
// use a 2-dimensional projection:
glrender.ortho = 2;
glrender.blend_enable = 1;
glrender.blend = "alphablend";
glrender.depth_enable = 0;
glrender.erase_color = [0,0,0,1]; // set background to black with full erase opacity (no trails):
i will make a feature request for this.
FWIW, on quick google, here's a processing.js example of converting a catmull rom curve to a cubic bezier approximation. That's the route I'd probably take to build a processing curve() workalike. You can begin a curve/path and then when ending it convert all the points to bezier form and then issue the corresponding mgraphics curve_to() calls.
Since this thread is more than a year old, I'm sure Anthony has already found the answer to his original question, but since I'm working on bezier curves and trying to port from processing and other sources. I thought I'd update.
As I've discovered in the documentation, mgraphics' curve_to call does utilizes 4 points. I believe both Processing and mgraphics utilize cubic bezier formulas. The start point is the current point.Then curve_to call takes 2 control points and an end point. Here's the edited draw function: