[SOLVED] Curved line rendering

I am aware this is an ancient topic, but since I found a use in it, I thought perhaps someone else will. I wanted to update it a little. There is a possibility to re-use an existing Bezier object, instead of creating a new one:

var points = [
    { x: 1, y: 2 },
    { x: 3, y: 4},
    { x: 5, y: 6 }
];
var curve = new Bezier(points);

// say we have new coordinates for the curve:
points.forEach(function(point) {
    point.x = someNewValue;
    point.y = someNewValue;
});

// we can assign new coordinates to the existing curve and update it
curve.points.forEach(function(point, index) {
    point.x = points[index].x;
    point.y = points[index].y;
});
curve.update();
2 Likes