Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/robinck/smooth-polyline

:wavy_dash: Smoothing algorithm for 2D lines and polygons
https://github.com/robinck/smooth-polyline

2d-graph-functions 2d-graphics smooth smooth-polygon smooth-polyline

Last synced: 3 months ago
JSON representation

:wavy_dash: Smoothing algorithm for 2D lines and polygons

Awesome Lists containing this project

README

        

# smooth-polyline

Smoothing algorithm for 2D lines and polygons

[![npm](https://img.shields.io/npm/dt/smooth-polyline.svg?style=flat-square)](https://github.com/RobinCK/smooth-polyline)[![Bower version](https://img.shields.io/bower/v/smooth-polyline.svg?style=flat-square)](https://github.com/RobinCK/smooth-polyline)[![NPM version](https://img.shields.io/npm/v/smooth-polyline.svg?style=flat-square)](https://www.npmjs.com/package/smooth-polyline)[![npm](https://img.shields.io/npm/l/smooth-polyline.svg?style=flat-square)](https://github.com/RobinCK/smooth-polyline/blob/master/LICENSE)

## Install
#### CDN

Recommended: https://unpkg.com/smooth-polyline, which will reflect the latest version as soon as it is published to npm. You can also browse the source of the npm package at https://unpkg.com/smooth-polyline/

#### NPM

``` bash
npm install smooth-polyline --save
```

#### Yarn

``` bash
yarn add smooth-polyline
```

#### Bower

``` bash
bower install smooth-polyline --save
```

## Development Setup

``` bash
# install dependencies
npm install

# build dist files
npm run build
```

## Usage
```javascript
var smoothLine = smooth([[ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ]]);
/*
return [
[1,1],
[1,1.15],
[1,1.8499999999999999],
[1.15,2],
[1.8499999999999999,2],
[2,1.8499999999999999],
[2,1.15],
[2,1]
]
*/
```

```javascript
var smoothLine = smooth(smooth([[ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ]]));

/*
return [
[1,1],
[1,1.0225],
[1,1.1275],
[1,1.255],
[1,1.7449999999999997],
[1.0225,1.8724999999999998],
[1.1275,1.9775],
[1.255,2],
[1.7449999999999997,2],
[1.8724999999999998,1.9775],
[1.9775,1.8724999999999998],
[2,1.7449999999999997],
[2,1.255],
[2,1.1275],
[2,1.0225],
[2,1]
]
*/
```

## License
MIT © [Igor Ognichenko](https://github.com/RobinCK)