3.0.12 • Published 8 years ago

turf-bezier v3.0.12

Weekly downloads
11,558
License
ISC
Repository
github
Last release
8 years ago

turf-bezier

build status

generate a bezier curve from a linestring

turf.bezier(line, [resolution=10000], [sharpness=0.85])

Takes a LineString|line and returns a curved version by applying a Bezier spline algorithm.

The bezier spline implementation is by Leszek Rybicki.

Parameters

parametertypedescription
lineFeature.\<LineString>input LineString
[resolution=10000]Numberoptional: time in milliseconds between points
[sharpness=0.85]Numberoptional: a measure of how curvy the path should be between splines

Example

var line = {
  "type": "Feature",
  "properties": {
    "stroke": "#f00"
  },
  "geometry": {
    "type": "LineString",
    "coordinates": [
      [-76.091308, 18.427501],
      [-76.695556, 18.729501],
      [-76.552734, 19.40443],
      [-74.61914, 19.134789],
      [-73.652343, 20.07657],
      [-73.157958, 20.210656]
    ]
  }
};

var curved = turf.bezier(line);
curved.properties = { stroke: '#0f0' };

var result = {
  "type": "FeatureCollection",
  "features": [line, curved]
};

//=result

Returns Feature.<LineString>, curved line

Installation

Requires nodejs.

$ npm install turf-bezier

Tests

$ npm test
3.0.12

8 years ago

3.0.10

8 years ago

3.0.7

8 years ago

3.0.6

8 years ago

3.0.5

8 years ago

3.0.1

8 years ago

1.0.3

8 years ago

1.0.2

9 years ago

1.0.0

9 years ago

0.0.0

10 years ago