UNPKG

cubic-beziers-through-points

Version:

A function to fit fair (bending energy minimizing) cubic bezier curves through a set of given ordered points in the plane.

28 lines (20 loc) 999 B
// /// <reference path="../chai-extensions.d.ts" /> // import { closeTo } from "./close-to.js"; // import { ObjOrArray } from "./obj-or-array.js"; // const nearly: Chai.ChaiPlugin = (chai, utils) => { // var Assertion = chai.Assertion; // utils.addMethod(Assertion.prototype, 'nearly', // function(ulpsOrEps: number | number[], value: ObjOrArray<number>) { // // @ts-ignore // const obj = this._obj as ObjOrArray<number>; // let isUlps = !Array.isArray(ulpsOrEps); // // @ts-ignore // this.assert( // closeTo(ulpsOrEps)(obj, value), // `expected \n${JSON.stringify(obj)}\n to be nearly (${ulpsOrEps} ${isUlps ? 'ulps' : 'eps'}) \n${JSON.stringify(value)}`, // `expected \n${JSON.stringify(obj)}\n to not be nearly (${ulpsOrEps} ${isUlps ? 'ulps' : 'eps'}) \n${JSON.stringify(value)}` // ); // } // ); // } // export { nearly }