Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@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.
line
Feature<LineString> input LineString
options
Object Optional parameters (optional, default {}
)
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 single module individually:
$ npm install @turf/bezier-spline
Or install the all-encompassing @turf/turf module that includes all modules as functions:
$ npm install @turf/turf
FAQs
turf bezier-spline module
The npm package @turf/bezier-spline receives a total of 726,835 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
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.