Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@flatten-js/core
Advanced tools
flatten-js is a javascript library for manipulating abstract geometrical shapes like point, vector, line, segment, circle, arc and polygon. Shapes may be organized into Planar Set - searchable container which support spatial queries.
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/:
Name | Description |
---|---|
@flatten-js/core | Basic classes and operations |
@flatten-js/interval-tree | Interval binary search tree |
@flatten-js/boolean-op | Boolean operations |
@flatten-js/polygon-offset | Polygon offset |
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.
The best way to start working with FlattenJS is to use awesome Observable javascript interactive notebooks. There are several tutorials published in Observable Notebooks, see below.
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
import {Point, Vector, Circle, Line, Segment, Arc, Box, Polygon, Matrix, PlanarSet} from '@flatten-js/core';
It is possible to import Flatten namespace as default import, and then destruct all classes from it.
import Flatten from '@flatten-js/core'
const {Point, Vector, Circle, Line, Segment, Arc, Box, Polygon, Matrix, PlanarSet} = Flatten;
Some classes have shortcuts to avoid annoying new constructor:
import {point, vector, circle, line, segment, arc, ray, matrix} from '@flatten-js/core';
After module imported, it is possible to create some construction:
// extract object creators
import {point, circle, segment} from '@flatten-js/core';
// make some construction
let s1 = segment(10,10,200,200);
let s2 = segment(10,160,200,30);
let c = circle(point(200, 110), 50);
let ip = s1.intersect(s2);
You may test the code above also in NPM RunKit
FAQs
Javascript library for 2d geometry
The npm package @flatten-js/core receives a total of 19,008 weekly downloads. As such, @flatten-js/core popularity was classified as popular.
We found that @flatten-js/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.