flatten-js provides a lot of useful methods and algorithms like finding intersections, checking inclusion, calculating distance, applying affine transformations, performing boolean operations and more.
Library consists of several packages, published under scope @flatten-js/:
|@flatten-js/core||Basic classes and operations|
|@flatten-js/interval-tree||Interval binary search tree|
NOTE: Package flatten-js is not supported and will be deprecated soon.
Packages are distributed in 3 formats: commonjs, umd and es6 modules. Package.json file provides various entry points suitable for different targets.
TypeScript users may take advantage of static type checking with typescript definition file index.d.ts included into the package.
flatten-js does not concern too much about visualization. Anyway, all classes have svg() methods, that returns a string which may be inserted into SVG container. This works pretty well together with d3js library. But it is definitely possible to create bridges to other graphic libraries.
Full documentation may be found here: https://alexbol99.github.io/flatten-js/index.html
Follow me on Twitter @alex_bol_
npm install --save @flatten-js/core
It is possible to import Flatten namespace as default import, and then destruct all classes from it.
const Point Vector Circle Line Segment Arc Box Polygon Matrix PlanarSet = Flatten;
Some classes have shortcuts to avoid annoying new constructor:
After module imported, it is possible to create some construction:
// extract object creators;// make some constructionlet s1 = ;let s2 = ;let c = ;let ip = s1;
You may test the code above also in NPM RunKit