Security News
New axobject-query Maintainer Faces Backlash Over Controversial Decision to Support Legacy Node.js Versions
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.
@jiaminghi/bezier-curve
Advanced tools
Changelog
0.0.4-alpha (2019-04-11)
Readme
Ability to abstract a Bezier curve into a polyline consisting of N uniformly distributed points.
Get the length of bezier curve.
Abstracting a polyline consisting of N points into a Bezier curve.
$ npm install @jiaminghi/bezier-curve
// Bezier curve data structure
const bezierCurve = [
// Start point
[20, 20],
// Multiple sets of bezier curve
[
// controlPoint1,controlPoint2,endPoint
[100, 20],[100, 80],[180,80]
],
// [...],[...]
]
bezierCurve in SVG
/**
* @description Get the polyline corresponding to the Bezier curve
* @param {Array} bezierCurve BezierCurve data
* @param {Number} precision Calculation accuracy. Recommended for 5-10. Default = 5
* @return {Array} Point data that constitutes a polyline after calculation
*/
function bezierCurveToPolyline (bezierCurve, precision = 5) {
// ...
}
const precision = 5
const polyline = bezierCurveToPolyline(bezierCurve, precision)
// polyline = [
// [[20,20],
// [25.998752507628243,20.11632023466343],[31.698106846035834,20.457189096242345],
// [37.11424670004552,21.010468821119716],[42.263355754480024,21.764021645678454],
// ...]
polyline in SVG
/**
* @description Get the polyline corresponding to the Bezier curve
* @param {Array} bezierCurve bezierCurve data
* @param {Number} precision calculation accuracy. Recommended for 5-10. Default = 5
* @return {Number} BezierCurve length
*/
export function getBezierCurveLength (bezierCurve, precision = 5) {
// ...
}
// Normally the default precision can achieve better visual effects.
const length = bezierCurveToPolyline(bezierCurve)
// polyline data structure
const polyline = [
[20, 70],
[50, 30],
[100, 70],
[150, 30],
[180, 70]
]
polyline in SVG
/**
* @description Abstract the polyline formed by N points into a set of bezier curve
* @param {Array} polyline A set of points that make up a polyline
* @param {Boolean} close Closed curve
* @param {Number} offsetA Smoothness
* @param {Number} offsetB Smoothness
* @return {Array} A set of bezier curve
*/
function polylineToBezierCurve (polyline, close = false, offsetA = 0.25, offsetB = 0.25) {
// ...
}
const bezierCurve = polylineToBezierCurve(polyline)
// bezierCurve = [
// [
// [20,70],
// [[27.5,60],[30,30],[50,30]],
// [[70,30],[75,70],[100,70]],
// [[125,70],[130,30],[150,30]],
// [[170,30],[172.5,60],[180,70]]]
//]
const closedBezierCurve = polylineToBezierCurve(polyline, true)
// closedBezerCurve = [
// [20,70],
// [[-12.5,60],[30,30],[50,30]],
// [[70,30],[75,70],[100,70]],
// [[125,70],[130,30],[150,30]],
// [[170,30],[212.5,60],[180,70]],
// [[147.5,80],[52.5,80],[20,70]]
// ]
bezierCurve in SVG
closedBezierCurve in SVG
FAQs
Bezier curve extension
The npm package @jiaminghi/bezier-curve receives a total of 2,737 weekly downloads. As such, @jiaminghi/bezier-curve popularity was classified as popular.
We found that @jiaminghi/bezier-curve demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.
Security News
Results from the 2023 State of JavaScript Survey highlight key trends, including Vite's dominance, rising TypeScript adoption, and the enduring popularity of React. Discover more insights on developer preferences and technology usage.
Security News
The US Justice Department has penalized two consulting firms $11.3 million for failing to meet cybersecurity requirements on federally funded projects, emphasizing strict enforcement to protect sensitive government data.