0.2.1 • Published 3 years ago

lines-to-polygons v0.2.1

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

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

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