turf-bezier

generate a bezier curve from a linestring

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
turf-bezier
713.0.127 years ago9 years agoMinified + gzip package size for turf-bezier in KB

Readme

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

| parameter | type | description | | -------------------- | ----------------------- | --------------------------------------------------------------------- | | line | Feature\.\ | input LineString | | [resolution=10000] | Number | optional: time in milliseconds between points | | [sharpness=0.85] | Number | optional: 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