Socket
Socket
Sign inDemoInstall

@jiaminghi/bezier-curve

Package Overview
Dependencies
1
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.6 to 0.0.7

build/entry.js

6

CHANGELOG.md

@@ -0,1 +1,7 @@

# 0.0.7-alpha (2019-08-28)
### Perfect
- **babel:** Upgrade babel compilation mode.
# 0.0.6-alpha (2019-07-08)

@@ -2,0 +8,0 @@

2

lib/index.js

@@ -26,2 +26,4 @@ "use strict";

require("regenerator-runtime/runtime");
var _bezierCurveToPolyline = require("./core/bezierCurveToPolyline");

@@ -28,0 +30,0 @@

10

package.json
{
"name": "@jiaminghi/bezier-curve",
"version": "0.0.6",
"version": "0.0.7",
"author": "JiaMing <743192023@qq.com>",

@@ -12,4 +12,5 @@ "description": "Bezier curve extension",

"scripts": {
"compile": "babel -d lib/ src/",
"prepublish": "npm run compile",
"build": "node build/index.js",
"prepublish": "npm run build",
"deploy": "node deploy/index.js",
"test": "mocha"

@@ -33,2 +34,4 @@ },

"@babel/register": "^7.4.4",
"@jiaminghi/fs": "^0.0.2",
"ftp": "^0.3.10",
"chai": "^4.2.0",

@@ -38,5 +41,4 @@ "mocha": "^6.1.4"

"dependencies": {
"@babel/polyfill": "^7.4.4",
"core-js": "^3.1.4"
}
}

@@ -1,2 +0,2 @@

[中文](./README_CN.md)
[ENGLISH](./README_EN.md)

@@ -11,17 +11,17 @@ <h1 align="center">Bezier Curve Extension</h1>

### This plugin provides three extension methods for Bezier curves.
### 这是一个提供如下几个方法的三次贝塞尔曲线插件。
- **[bezierCurveToPolyline](#bezierCurveToPolyline)**
Ability to abstract a Bezier curve into a polyline consisting of N **uniformly distributed** points.
将贝塞尔曲线抽象成由N个**均匀分布**的点构成的折线
- **[getBezierCurveLength](#getBezierCurveLength)**
Get the length of bezier curve.
获取贝塞尔曲线的长度
- **[polylineToBezierCurve](#polylineToBezierCurve)**
Abstracting a polyline consisting of N points into a Bezier curve.
将由N个点构成的折线抽象成光滑的贝塞尔曲线
### Install with npm
### npm安装

@@ -32,3 +32,3 @@ ```shell

### Use
### 使用

@@ -38,8 +38,22 @@ ```javascript

bezierCurve.bezierCurveToPolyline(curve)
// do something
```
### 快速体验
```html
<!--资源位于个人服务器仅供体验和测试,请勿在生产环境使用-->
<!--调试版-->
<script src="http://lib.jiaminghi.com/bezierCurve/bezierCurve.map.js"></script>
<!--压缩版-->
<script src="http://lib.jiaminghi.com/bezierCurve/bezierCurve.min.js"></script>
<script>
const { bezierCurveToPolyline, getBezierCurveLength, polylineToBezierCurve } = window.bezierCurve
// do something
</script>
```
------
<h3 align="center">Examples</h3>
<h3 align="center">示例</h3>

@@ -49,12 +63,12 @@ #### bezierCurve

```javascript
// Bezier curve data structure
// 贝塞尔曲线数据结构
const bezierCurve = [
// Start point
// 起始点
[20, 20],
// Multiple sets of bezier curve
// 多段贝塞尔曲线
[
// controlPoint1,controlPoint2,endPoint
// 控制点1,控制点2,结束点
[100, 20],[100, 80],[180,80]
],
// The starting point of the next bezier curve is the end point of the previous bezier curve
// 下一段贝塞尔曲线的起始点是上一段的结束点
// [...],[...]

@@ -74,6 +88,6 @@ ]

/**
* @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|Boolean} Point data that constitutes a polyline after calculation (Invalid input will return false)
* @description 通过贝塞尔曲线获取折线
* @param {Array} bezierCurve 贝塞尔曲线数据
* @param {Number} precision 计算精度 建议5-10 默认为5
* @return {Array|Boolean} 构成折线的点集 (无效输入将返回false)
*/

@@ -102,7 +116,7 @@ function bezierCurveToPolyline (bezierCurve, precision = 5) {

- The calculation result of *bezierCurveToPolyline* consists of N points, and N depends on the precision you set.
- Ideally, the distance between two adjacent points in the calculation result is equal to the set accuracy (unit px).
- Recommended precision is 5-10.
- If the setting precision is less than 1 or too large, the calculation result may be abnormal.
- Sometimes it is **impossible** to achieve precision.
- *bezierCurveToPolyline*的计算结果是由N个点构成的折线,N取决于设置的精度。
- 理想情况下,计算结果中相邻的两个点的距离等于设置的精度(单位px)。
- 建议精度5-10。
- 如果设置的精度过小或过大(小于1或大于10),可能导致计算异常。
- 设置的精度并不是每次都能达到。

@@ -115,6 +129,6 @@

/**
* @description Get the bezier curve length
* @param {Array} bezierCurve bezierCurve data
* @param {Number} precision calculation accuracy. Recommended for 5-10. Default = 5
* @return {Number|Boolean} BezierCurve length (Invalid input will return false)
* @description 获取贝塞尔曲线长度
* @param {Array} bezierCurve 贝塞尔曲线数据
* @param {Number} precision 计算精度 建议5-10 默认为5
* @return {Number|Boolean} 贝塞尔曲线长度 (无效输入将返回false)
*/

@@ -125,3 +139,3 @@ export function getBezierCurveLength (bezierCurve, precision = 5) {

// Normally the default precision can achieve better visual effects.
// 通常情况下,默认精度已经能够达到较好的视觉效果。
const length = bezierCurveToPolyline(bezierCurve)

@@ -135,3 +149,3 @@ ```

```javascript
// polyline data structure
// 折线数据结构
const polyline = [

@@ -158,8 +172,8 @@ [20, 70],

/**
* @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|Boolean} A set of bezier curve (Invalid input will return false)
* @description 将由N个点构成的折线抽象为光滑的贝塞尔曲线
* @param {Array} polyline 由N个点构成的折线数据
* @param {Boolean} close 是否闭合
* @param {Number} offsetA 光滑程度
* @param {Number} offsetB 光滑程度
* @return {Array|Boolean} 贝塞尔曲线数据 (无效输入将返回false)
*/

@@ -166,0 +180,0 @@ function polylineToBezierCurve (polyline, close = false, offsetA = 0.25, offsetB = 0.25) {

@@ -19,3 +19,3 @@ const { expect } = require('chai')

function findNoNInArray (arr) {
function findNaNInArray (arr) {
return arr.findIndex(n => !Number.isFinite(n)) !== -1

@@ -185,5 +185,5 @@ }

if (i === 0) {
return findNoNInArray(item)
return findNaNInArray(item)
} else {
return item.find(itemElement => findNoNInArray(itemElement))
return item.find(itemElement => findNaNInArray(itemElement))
}

@@ -198,5 +198,5 @@ })

if (i === 0) {
return findNoNInArray(item)
return findNaNInArray(item)
} else {
return item.find(itemElement => findNoNInArray(itemElement))
return item.find(itemElement => findNaNInArray(itemElement))
}

@@ -203,0 +203,0 @@ })

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc