to-smooth
TypeScript icon, indicating that this package has built-in type declarations

2.2.0 • Public • Published

To Smooth

Make your lines to curves

undefined

Chaikin's smoothing algorithm for polylines of any dimensions. Impressed by chaikin-smooth but, to-smooth is dimension generalized version of chaikin-smooth with iteration option.

You can use to-smooth instead of chaikin-smooth

Demo

From

To


Usage

import smooth from 'to-curve'
import geojson from 'geojson.json'


if (geojson.geometry.type === 'LineString')
  geojson.geometry.coordinates = smooth(geojson.geometry.coordinates)
else if (geojson.geometry.type === 'MultiLineString')
  geojson.geometry.coordinates = geojson.geometry.coordinates.map(points => smooth(points))

Docs

export default function smooth(points, options: {iteration, factor} = {iteration: 1, factor: 0.75})

points

same dimension point array like LineString Coordinates

  • type - Array<Array<number>>

options

  • iteration
    • default - 1
    • description - if this increase, more smoother line return
    • iteration how many algorithm applied
  • factor
    • default - 0.75
    • range - 0.5 - 1
    • do not have to change or assign

License

MIT

Package Sidebar

Install

npm i to-smooth

Weekly Downloads

49

Version

2.2.0

License

MIT

Unpacked Size

14.4 kB

Total Files

10

Last publish

Collaborators

  • seonglae