1.2.0 • Published 7 years ago

code42day-vis-why v1.2.0

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

NPM version Build Status Dependency Status

vis-why

M Visvalingam and J D Whyatt line simplification algorithm Implementation based on Mike Bostock's code but without a d3 dependency.

Live demo is here

Installation

Install with component(1):

$ component install code42day/vis-why

Install with npm:

$ npm install vis-why

API

simplify(polyline, limit)

Simplify polyline by repeated elimination of the smallest area.

  • polyline - array of points representing a polyline, each point represented by coordinate array [x, y]
  • limit - number of points/vortexes that will remain in the resulting polyline

simplify(polyline, limit, areaFn)

You can specify a custom areaFn if your points are not represented by [x, y] pair. For example if you have an array of {x, y} objects you can use something like this:

function area(a, b, c) {
  return Math.abs(
    (a.x - c.x) * (b.y - a.y) - (a.x - b.x) * (c.y - a.y)
  );
}

simplify(poly, 4, area);

License

The MIT License (MIT)

Copyright (c) 2014 <code42day>

1.2.0

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.3

8 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.0

10 years ago