Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@turf/bezier-spline
Advanced tools
@turf/bezier-spline is a module in the Turf.js library that allows you to create smooth Bezier spline curves from a set of points. This is particularly useful in geographic information systems (GIS) for creating smooth paths or routes on a map.
Create Bezier Spline from Points
This feature allows you to create a smooth Bezier spline curve from a set of points. The `resolution` option controls the number of points in the resulting spline, and `sharpness` controls the curvature.
const turf = require('@turf/turf');
const points = turf.lineString([
[-75.343, 39.984],
[-75.534, 39.123],
[-75.123, 39.543],
[-75.534, 39.123],
[-75.343, 39.984]
]);
const options = { resolution: 10000, sharpness: 0.85 };
const bezierSpline = turf.bezierSpline(points, options);
console.log(JSON.stringify(bezierSpline));
bezier-js is a library for working with Bezier curves in JavaScript. It provides a wide range of functionalities for creating and manipulating Bezier curves, but it is not specifically tailored for geographic data like @turf/bezier-spline.
d3-shape is a part of the D3.js library that provides tools for creating and manipulating shapes, including Bezier curves. While it is very powerful and flexible, it is more general-purpose and not specifically designed for GIS applications.
Paper.js is a vector graphics scripting framework that runs on top of the HTML5 Canvas. It provides a lot of functionalities for working with vector graphics, including Bezier curves. However, it is more focused on graphic design rather than GIS.
Takes a line and returns a curved version by applying a Bezier spline algorithm.
The bezier spline implementation is by Leszek Rybicki.
Parameters
line
Feature<LineString> input LineStringoptions
Object Optional parameters (optional, default {}
)
Examples
var line = turf.lineString([
[-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.bezierSpline(line);
//addToMap
var addToMap = [line, curved]
curved.properties = { stroke: '#0F0' };
Returns Feature<LineString> curved line
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Install this module individually:
$ npm install @turf/bezier-spline
Or install the Turf module that includes it as a function:
$ npm install @turf/turf
6.3.0
(PR https://github.com/Turfjs/turf/pull/2004 - Author r0b0t3d) (PR https://github.com/Turfjs/turf/pull/2011 - Author mfedderly)
@turf/turf
][turf] expose @turf/boolean-intersect(PR https://github.com/Turfjs/turf/pull/2007 - Author rowanwins)
FAQs
turf bezier-spline module
The npm package @turf/bezier-spline receives a total of 296,393 weekly downloads. As such, @turf/bezier-spline popularity was classified as popular.
We found that @turf/bezier-spline demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.