On-curve control points
Move the red pads with your mouse.
The green lines are where the traditional off-curve control points would be located.
// array of points that lie on the Bezier path
let A = ;
// resulting control points conveniently located here
// B = ;
// coefficients for a 10 point closed path
let coef = [ 56.0/209.0, -15.0/209.0, 4.0/209.0, -1.0/209.0, 0, 1.0/209.0, -4.0/209.0, 15.0/209.0, -56.0/209.0, 1 ];
// determine first control point
let m = 10;
let B = [];
for (let i=0; i<m; i++) {
let x = 0;
let y = 0;
for (let j=0; j<m; j++) {
x += A[(i+j+1)%m].x * coef[j];
y += A[(i+j+1)%m].y * coef[j];
}
B[i] = { x: x, y: y };
}