lines-to-polygons

0.2.1 • Public • Published

Lines to polygons

A JavaScript library to build polygons from an unordered list of independant lines.

Getting started

Install

Install with NPM

npm install lines-to-polygons

How to use

var linesToPolygons = require("lines-to-polygons");

var polygons = linesToPolygons(lines);

Example

lines-to-polygon example

  • AB = [(3, 1), (5, 1)]
  • DC = [(4, 4), (6, 3)]
  • DE = [(4, 4), (2, 3)]
  • CB = [(6, 3), (5, 1)]
  • EA = [(2, 3), (3, 1)]
var lines = [
  [
    // AB
    [3, 1],
    [5, 1],
  ],
  [
    // DC
    [4, 4],
    [6, 3],
  ],
  [
    // DE
    [4, 4],
    [2, 3],
  ],
  [
    // CB
    [6, 3],
    [5, 1],
  ],
  [
    // EA
    [2, 3],
    [3, 1],
  ],
];

var polygons = linesToPolygons(lines);
// result [E, A, B, C, D]

Licence

MIT. Copyright (c) Florent Muller

Dependents (0)

Package Sidebar

Install

npm i lines-to-polygons

Weekly Downloads

3

Version

0.2.1

License

MIT

Unpacked Size

5.15 kB

Total Files

4

Last publish

Collaborators

  • getose