bez_offset = function(bezier) {
const curve_cheb = bez3_to_cheb(bezier);
const [x, y] = curve_cheb;
const Dx = diff(x), Dy = diff(y);
return function bez_offset(p) {
const xp = chebeval(x, p), yp = chebeval(y, p);
const Dxp = chebeval(Dx, p), Dyp = chebeval(Dy, p);
const N = { x: -Dyp, y: Dxp, len: Math.sqrt(Dxp * Dxp + Dyp * Dyp) }
const uN = { x: N.x / N.len, y: N.y / N.len }
const oN = { x: uN.x * offset, y: uN.y * offset }
return [xp + oN.x, yp + oN.y];
}
}