项目作者: RobinCK

项目描述 :
:wavy_dash: Smoothing algorithm for 2D lines and polygons
高级语言: JavaScript
项目地址: git://github.com/RobinCK/smooth-polyline.git
创建时间: 2017-04-27T20:08:44Z
项目社区:https://github.com/RobinCK/smooth-polyline

开源协议:MIT License

下载


smooth-polyline

Smoothing algorithm for 2D lines and polygons



npmBower versionNPM versionnpm

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

  1. npm install smooth-polyline --save

Yarn

  1. yarn add smooth-polyline

Bower

  1. bower install smooth-polyline --save

Development Setup

  1. # install dependencies
  2. npm install
  3. # build dist files
  4. npm run build

Usage

  1. var smoothLine = smooth([[ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ]]);
  2. /*
  3. return [
  4. [1,1],
  5. [1,1.15],
  6. [1,1.8499999999999999],
  7. [1.15,2],
  8. [1.8499999999999999,2],
  9. [2,1.8499999999999999],
  10. [2,1.15],
  11. [2,1]
  12. ]
  13. */
  1. var smoothLine = smooth(smooth([[ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ]]));
  2. /*
  3. return [
  4. [1,1],
  5. [1,1.0225],
  6. [1,1.1275],
  7. [1,1.255],
  8. [1,1.7449999999999997],
  9. [1.0225,1.8724999999999998],
  10. [1.1275,1.9775],
  11. [1.255,2],
  12. [1.7449999999999997,2],
  13. [1.8724999999999998,1.9775],
  14. [1.9775,1.8724999999999998],
  15. [2,1.7449999999999997],
  16. [2,1.255],
  17. [2,1.1275],
  18. [2,1.0225],
  19. [2,1]
  20. ]
  21. */

License

MIT © Igor Ognichenko