p5bezier 0.3.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +35 -40
- package/lib/p5.bezier.d.ts +22 -0
- package/lib/p5.bezier.min.js +1 -1
- package/lib/p5.bezier.min.js.LICENSE.txt +1 -1
- package/lib/p5.bezier.min.js.map +1 -1
- package/package.json +9 -7
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -6,12 +6,13 @@
|
|
|
6
6
|
[](https://github.com/peilingjiang/p5.bezier/blob/main/LICENSE)
|
|
7
7
|
[](https://www.jsdelivr.com/package/npm/p5bezier)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Introducing **p5.bezier**, a [p5.js](https://p5js.org) library, engineered to assist you in creating Bézier curves with ease. This library is an enhancement of the original p5.js `bezier()` function, extending its capabilities beyond the limitation of four control points.
|
|
10
10
|
|
|
11
11
|
<!-- [**Try it now on p5.js Web Editor!**](https://editor.p5js.org/peilingjiang/sketches/7Z2pRG-TB) -->
|
|
12
|
+
|
|
12
13
|
[**Try it now on p5.js Web Editor!**](https://editor.p5js.org/peilingjiang/sketches/mVXzWEJbT)
|
|
13
14
|
|
|
14
|
-
**
|
|
15
|
+
While **p5.bezier** is designed to integrate with p5.js, it operates independently as well. It's necessary to initialize the library and specify the target canvas by invoking `initBezier(canvas)` at the start of your code.
|
|
15
16
|
|
|
16
17
|
To draw a Bézier curve on canvas, you can simply use `newBezier()`:
|
|
17
18
|
|
|
@@ -25,41 +26,39 @@ newBezier([
|
|
|
25
26
|
])
|
|
26
27
|
```
|
|
27
28
|
|
|
28
|
-
**What is Bézier Curve?**
|
|
29
|
+
**What is a Bézier Curve?**
|
|
29
30
|
|
|
30
|
-
A Bézier curve is a
|
|
31
|
+
A Bézier curve is a type of curve that's widely used in computer graphics, design, etc. It was named after Pierre Bézier who employed it in car design during the 1960s. Due to its smooth and continuous nature, it's ideal for creating visually pleasing shapes and textures in various design fields.
|
|
31
32
|
|
|
32
33
|
## Getting Started
|
|
33
34
|
|
|
34
|
-
To use p5.bezier library, download [p5.bezier.min.js](https://raw.githubusercontent.com/peilingjiang/p5.bezier/main/lib/p5.bezier.min.js) file
|
|
35
|
+
To use the p5.bezier library, first download the [p5.bezier.min.js](https://raw.githubusercontent.com/peilingjiang/p5.bezier/main/lib/p5.bezier.min.js) file and place it in your project directory. Then, include the following line in your HTML file:
|
|
35
36
|
|
|
36
37
|
```HTML
|
|
37
38
|
<script src="p5.bezier.min.js"></script>
|
|
38
39
|
```
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
Alternatively, you can use the library through a content delivery network (CDN):
|
|
41
42
|
|
|
42
43
|
```HTML
|
|
43
44
|
<script src="https://cdn.jsdelivr.net/npm/p5bezier@latest/lib/p5.bezier.min.js"></script>
|
|
44
45
|
```
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
Once included, the entire library is encapsulated within the `p5bezier` object. To call the functions provided by the library, prepend `p5bezier` to the function name:
|
|
47
48
|
|
|
48
49
|
```js
|
|
49
50
|
p5bezier.initBezier(c)
|
|
50
51
|
```
|
|
51
52
|
|
|
52
|
-
The library is still a work-in-progress project. Therefore, code tends to change from time to time. Please come back once a while to download the latest version of the library.
|
|
53
|
-
|
|
54
53
|
### NPM
|
|
55
54
|
|
|
56
|
-
You can also install using the package manager NPM (recommended):
|
|
55
|
+
You can also install the library using the package manager NPM (recommended):
|
|
57
56
|
|
|
58
57
|
```
|
|
59
58
|
npm install p5bezier
|
|
60
59
|
```
|
|
61
60
|
|
|
62
|
-
|
|
61
|
+
Then, import the modules into your project:
|
|
63
62
|
|
|
64
63
|
```js
|
|
65
64
|
import { initBezier, newBezier, newBezierObject } from 'p5bezier'
|
|
@@ -67,7 +66,7 @@ import { initBezier, newBezier, newBezierObject } from 'p5bezier'
|
|
|
67
66
|
|
|
68
67
|
## Init for Bézier
|
|
69
68
|
|
|
70
|
-
|
|
69
|
+
You must initialize the Bézier drawing system with the canvas you are drawing on. Here's an example with p5.js:
|
|
71
70
|
|
|
72
71
|
```diff
|
|
73
72
|
function setup() {
|
|
@@ -78,7 +77,7 @@ function setup() {
|
|
|
78
77
|
|
|
79
78
|
## Draw a Bézier Curve
|
|
80
79
|
|
|
81
|
-
The
|
|
80
|
+
The simplest way to use the library is to call `newBezier()` in your `draw()` function. You can adjust the curve's style using `fill()` or `strokeWeight()` just like other shapes.
|
|
82
81
|
|
|
83
82
|
```
|
|
84
83
|
newBezier(pointsArray [, closeType] [, fidelity]);
|
|
@@ -86,21 +85,21 @@ newBezier(pointsArray [, closeType] [, fidelity]);
|
|
|
86
85
|
|
|
87
86
|
**pointsArray**
|
|
88
87
|
|
|
89
|
-
|
|
88
|
+
This is an array of [x, y] pairs, each representing a control point for the curve. For example, `[[10, 30], [5, 100], [25, 60]]`.
|
|
90
89
|
|
|
91
90
|
**closeType** (Optional)
|
|
92
91
|
|
|
93
|
-
|
|
92
|
+
This is a string, either `"OPEN"` or `"CLOSE"`. Use `"CLOSE"` to automatically close the curve. The default is `"OPEN"`.
|
|
94
93
|
|
|
95
94
|
**fidelity** (Optional)
|
|
96
95
|
|
|
97
|
-
|
|
96
|
+
This is an integer between `0` and `10`, with a default value of `7`. This value determines the accuracy of the Bézier curve. Higher values mean more vertices are used, leading to a more accurate curve, but at the cost of additional computation.
|
|
98
97
|
|
|
99
98
|
## Create a Bézier Object
|
|
100
99
|
|
|
101
|
-
|
|
100
|
+
For advanced operations, such as computing the shortest distance from a point to the curve, use the `newBezierObj()` function. This method can also potentially optimize computation resources if placed within the `setup()` function, as vertices are calculated only once and can then be reused.
|
|
102
101
|
|
|
103
|
-
The
|
|
102
|
+
The usage of `newBezierObj()` is similar to `newBezier()`, but it returns a _Bézier Curve Object_ that can be stored in a variable:
|
|
104
103
|
|
|
105
104
|
```
|
|
106
105
|
let bezierObject = newBezierObj(pointsArray [, closeType] [, fidelity]);
|
|
@@ -110,29 +109,29 @@ The call of `newBezierObj` will not draw the curve on canvas automatically. To d
|
|
|
110
109
|
|
|
111
110
|
- `.draw([dash])`
|
|
112
111
|
|
|
113
|
-
|
|
112
|
+
Renders the curve on the canvas.
|
|
114
113
|
|
|
115
114
|
**dash** (Optional)
|
|
116
115
|
|
|
117
|
-
|
|
116
|
+
Accepts an array of two numbers specifying the length of solid and broken sections of a dashed Bézier curve. For example, `[10, 5]` signifies a solid segment of 10px followed by a 5px break.
|
|
118
117
|
|
|
119
118
|
- `.update(newPointsArray)`
|
|
120
119
|
|
|
121
|
-
|
|
120
|
+
Updates the positions of control points. The number of control points should remain consistent with the initial curve configuration.
|
|
122
121
|
|
|
123
122
|
- `.move(x, y [, z, toDraw, dash])`
|
|
124
123
|
|
|
125
|
-
|
|
124
|
+
Translates the entire curve. This function does not modify the original object but instead generates and returns a new one. Hence, if you wish to update the curve using this method (which is faster than `.update()`), you may:
|
|
126
125
|
|
|
127
126
|
```js
|
|
128
127
|
bezierObject = bezierObject.move(6, 17, -22, false)
|
|
129
128
|
```
|
|
130
129
|
|
|
131
|
-
`toDraw` is `true
|
|
130
|
+
By default, `toDraw` is set to `true`. However, if you wish to only update the curve without drawing it, you can set this parameter to `false`.
|
|
132
131
|
|
|
133
132
|
- `.shortest(pointX, pointY [, pointZ])`
|
|
134
133
|
|
|
135
|
-
|
|
134
|
+
Requires the _x_ and _y_ coordinates of an external point as input. It returns an array containing the coordinates of the nearest point on the curve. For instance, to draw a line between these two points:
|
|
136
135
|
|
|
137
136
|
```js
|
|
138
137
|
pointOnCurve = bezierObject.shortest(pointX, pointY)
|
|
@@ -141,44 +140,40 @@ The call of `newBezierObj` will not draw the curve on canvas automatically. To d
|
|
|
141
140
|
|
|
142
141
|
## Examples
|
|
143
142
|
|
|
144
|
-
To
|
|
143
|
+
To execute the examples locally, download the repository to your local machine. Then, navigate to the `examples` directory using your terminal. Execute the following command:
|
|
145
144
|
|
|
146
145
|
```
|
|
147
146
|
npm install
|
|
148
147
|
node server.js name_of_example
|
|
149
148
|
```
|
|
150
149
|
|
|
151
|
-
For instance,
|
|
150
|
+
For instance, to run the _basic_ example, simply enter `node server.js basic`. Then, open your web browser and navigate to `localhost:8000`.
|
|
152
151
|
|
|
153
152
|
Currently available examples:
|
|
154
153
|
|
|
155
154
|
- **basic** draws a simple Bézier curve with 5 control points across the canvas.
|
|
156
155
|
- **basic_object** create a simple Bézier object with 5 control points across the canvas.
|
|
157
|
-
- **control_points** draws a curve and
|
|
158
|
-
- **fidelity**
|
|
159
|
-
- **
|
|
160
|
-
- **
|
|
161
|
-
|
|
162
|
-
- **perlin** Use Perlin Noise (from p5.js) to control moving Bézier curves.
|
|
156
|
+
- **control_points** draws a curve and its control points, which can be dragged around.
|
|
157
|
+
- **fidelity** showcases curves drawn with varying levels of fidelity.
|
|
158
|
+
- **shortest_point** draws the shortest line from the mouse pointer to the curve.
|
|
159
|
+
- **animation** draws animated Bézier curves.
|
|
163
160
|
|
|
164
161
|
More complex examples to be updated.
|
|
165
162
|
|
|
166
|
-
### Projects and
|
|
163
|
+
### Projects and Demos
|
|
167
164
|
|
|
168
165
|
- [**Hair**](https://no-loss.netlify.app/), a visualization. See the source code here: https://github.com/peilingjiang/hair.
|
|
169
|
-
-
|
|
170
|
-
-
|
|
166
|
+
- _p5.bezier Example - Basic_ on [CodePen](https://codepen.io/peilingjiang/pen/ZEOLVPx).
|
|
167
|
+
- _p5.bezier Example - Perlin_ on [CodePen](https://codepen.io/peilingjiang/pen/eYMRJax).
|
|
171
168
|
|
|
172
169
|
Share your ideas and projects using the library!
|
|
173
170
|
|
|
174
|
-
##
|
|
171
|
+
## TODOs
|
|
175
172
|
|
|
176
173
|
1. More examples.
|
|
177
174
|
2. `offset()`, `intersection()`, and `curvature()`... functions for Bézier object.
|
|
178
|
-
3. Draw B-
|
|
179
|
-
4. Continuous close point when close up a Bézier curve.
|
|
175
|
+
3. Draw B-Spline curves.
|
|
180
176
|
|
|
181
177
|
## References
|
|
182
178
|
|
|
183
|
-
|
|
184
|
-
2. [Bezier.js](https://pomax.github.io/bezierjs/) by [Pomax - GitHub](https://github.com/Pomax) (Concept)
|
|
179
|
+
- [Bézier curve - Wikipedia](https://en.wikipedia.org/wiki/B%C3%A9zier_curve)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare function initBezier(canvas: any, strictMode?: boolean): void;
|
|
2
|
+
export declare function newBezier(pointList: number[][], closeType?: string, accuracy?: number): void;
|
|
3
|
+
export declare function newBezierObj(pointList: Array<Array<number>>, closeType?: string, accuracy?: number): BezierCurve;
|
|
4
|
+
declare class BezierCurve {
|
|
5
|
+
controlPoints: any[];
|
|
6
|
+
closeType: string;
|
|
7
|
+
dimension: number;
|
|
8
|
+
increment: number;
|
|
9
|
+
vertexList: any[];
|
|
10
|
+
vertexListLen: number;
|
|
11
|
+
p: number;
|
|
12
|
+
n: number;
|
|
13
|
+
constructor(pL: any[], closeT: string, tI: number, bD: number, vL?: any[] | null);
|
|
14
|
+
private _buildVertexList;
|
|
15
|
+
private _addVertex;
|
|
16
|
+
private _distVertex;
|
|
17
|
+
draw(dash?: number[]): void;
|
|
18
|
+
update(newControlList: number[][]): void;
|
|
19
|
+
move(x: number, y: number, z?: number | null, toDraw?: boolean, dash?: number[]): BezierCurve;
|
|
20
|
+
shortest(pX: number, pY: number, pZ?: number): number[];
|
|
21
|
+
}
|
|
22
|
+
export {};
|
package/lib/p5.bezier.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see p5.bezier.min.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.p5bezier=t():e.p5bezier=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{initBezier:()=>
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.p5bezier=t():e.p5bezier=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{initBezier:()=>m,newBezier:()=>E,newBezierObj:()=>P});var r=function(e,t,r){if(r||2===arguments.length)for(var i,n=0,o=t.length;n<o;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))};window.console.log("[p5.bezier]");var i,n,o,s,h,a,p,l,f,c=[.2,.1,.05,.04,.02,.01,.008,.002,.001,5e-4,1e-4],d=[1];function u(e,t){return"WebGLRenderingContext"===e.constructor.name||t?3:2}function v(e){for(var t=d.length;t<=e;t++)d[t]=t*d[t-1]}function y(e){return v(e),d[e]}function b(e,t){return v(e),y(e)/(y(t)*y(e-t))}function w(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 4===e.length?Math.hypot(e[0]-e[2],e[1]-e[3]):6===e.length?Math.hypot(e[0]-e[3],e[1]-e[4],e[2]-e[5]):0}function x(){i._doFill&&n.fill(),i._doStroke&&n.stroke()}function g(e){return e.map((function(e){return r([],e,!0)}))}function L(e){var t=e[0],r=e[e.length-1],i=e[1],n=e[e.length-2];return[[2*r[0]-n[0],2*r[1]-n[1]],[2*t[0]-i[0],2*t[1]-i[1]],t]}function m(e,t){if(void 0===t&&(t=!1),n=(i=e).drawingContext,"undefined"!=typeof p5&&e instanceof p5.Graphics)h=!0,o=u(n,!1);else{if(!("undefined"!=typeof p5&&e instanceof p5.Renderer||e.drawingContext))throw new Error("[p5.bezier] Canvas is not supported.");h=!1,"undefined"!=typeof p5&&("undefined"==typeof p5||e instanceof p5.Renderer)||window.console.warn("[p5.bezier] Support for non-p5 canvas is not tested."),o=u(n,e.isP3D)}!function(e,t,r){e?(a=t.beginShape,p=t.vertex,l=t.vertex,f=t.endShape):(a=r.beginPath.bind(r),p=r.moveTo.bind(r),l=r.lineTo.bind(r),f=r.closePath.bind(r))}(h,i,n),s=t}function E(e,t,r){if(void 0===t&&(t="OPEN"),void 0===r&&(r=7),s&&!Array.isArray(e))throw new Error("[p5.bezier] newBezier() function expects an array, got ".concat(typeof e,"."));if(e=g(e),"CLOSE"===t){var i=L(e);e.push.apply(e,i)}var n=c[r],d=e.length-1;if(0!==o){if(s)for(var u=0,y=e;u<y.length;u++){var w=y[u];if(!Array.isArray(e)||w.length!==o)throw new Error("[p5.bezier] One or more points in the array are not input correctly.")}if(v(d),a(),p.apply(void 0,e[0]),2===o){var m=void 0,E=void 0,P=void 0;for(P=0;P<=1;P+=n){m=E=0;for(var z=0;z<=d;z++){m+=(S=b(d,z)*Math.pow(1-P,d-z)*Math.pow(P,z))*e[z][0],E+=S*e[z][1]}l(m,E)}}else if(3===o){P=void 0;for(P=0;P<=1;P+=n){var O=[0,0,0];for(z=0;z<=d;z++)for(var S=b(d,z)*Math.pow(1-P,d-z)*Math.pow(P,z),M=0;M<3;M++)O[M]+=S*e[z][M];l.apply(void 0,O)}}if(l.apply(void 0,e.slice(-1)[0]),h)f(t);else if("CLOSE"===t)f();else if(s&&"OPEN"!==t)throw new Error("[p5.bezier] Close type error. A bezier curve can only be either OPEN or CLOSE.");x()}}function P(e,t,r){void 0===t&&(t="OPEN"),void 0===r&&(r=7);var i=c[r];if(s){if(!Array.isArray(e))throw new Error("[p5.bezier] newBezierObj() function expects an array, got ".concat(typeof e,"."));for(var n=0,h=e;n<h.length;n++){var a=h[n];if(!Array.isArray(a)||a.length!==o)throw new Error("[p5.bezier] One or more points in the array are not input correctly.")}}return new z(e,t,i,o)}var z=function(){function e(e,t,i,n,o){var h;if(void 0===o&&(o=null),s&&2!==n&&3!==n)throw new Error("[p5.bezier] Dimension error. The bezier curve is ".concat(n,"-dimensional and doesn't belong to our world."));if(this.controlPoints=g(e),"CLOSE"===t)(h=this.controlPoints).push.apply(h,L(this.controlPoints)),this.closeType="CLOSE";else{if("OPEN"!==t)throw new Error("[p5.bezier] Close type error. A bezier curve can only be either OPEN or CLOSE.");this.closeType="OPEN"}this.dimension=n,this.increment=i,this.vertexList=[],this.vertexListLen=0,this.p=this.controlPoints.length,this.n=this.p-1,v(this.n),null===o?this._buildVertexList():(this.vertexList=r([],o,!0),this.vertexListLen=this.vertexList.length)}return e.prototype._buildVertexList=function(){if(this.vertexList=[],2===this.dimension)for(var e=0;e<=1;e+=this.increment){for(var t=0,r=0,i=0;i<=this.n;i++){t+=(o=b(this.n,i)*Math.pow(1-e,this.n-i)*Math.pow(e,i))*this.controlPoints[i][0],r+=o*this.controlPoints[i][1]}this.vertexList.push([t,r])}else if(3===this.dimension)for(e=0;e<=1;e+=this.increment){var n=[0,0,0];for(i=0;i<=this.n;i++)for(var o=b(this.n,i)*Math.pow(1-e,this.n-i)*Math.pow(e,i),s=0;s<3;s++)n[s]+=o*this.controlPoints[i][s];this.vertexList.push(n)}return this._addVertex(this.controlPoints[this.controlPoints.length-1]),this.dimension=this.vertexList[0].length,this.vertexListLen=this.vertexList.length,this.vertexList},e.prototype._addVertex=function(e){if(2!==this.dimension&&3!==this.dimension)throw new Error("[p5.bezier] Vertices can only be in 2D or 3D space.");l.apply(void 0,e)},e.prototype._distVertex=function(e,t){return 2===this.dimension?w(e[0],e[1],t[0],t[1]):3===this.dimension?w(e[0],e[1],e[2],t[0],t[1],t[2]):0},e.prototype.draw=function(e){if(e){if(!(Array.isArray(e)&&2===e.length&&this.increment<=.008))throw this.increment>.008?new Error("[p5.bezier] Fidelity is too low for a dash line. It should be at least 6."):new Error("[p5.bezier] Your dash array input is not valid. Make sure it's an array of two numbers.");var t=Math.abs(e[0]),r=t+Math.abs(e[1]),i=0,o=0,s=this.vertexList[0],l=!0;n.save(),n.fillStyle="rgba(0, 0, 0, 0)",a(),p.apply(void 0,this.vertexList[0]);for(u=1;u<this.vertexListLen;u++)(o=(i+=this._distVertex(s,this.vertexList[u]))%r)<=t&&l?this._addVertex(this.vertexList[u]):o>t&&o<=r&&l?l=!1:o<=t&&!l&&(p.apply(void 0,this.vertexList[u]),l=!0),s=this.vertexList[u];x(),n.restore()}else{a();for(var c=0,d=this.vertexList;c<d.length;c++){var u=d[c];this._addVertex(u)}"CLOSE"===this.closeType&&n.closePath(),h?f(this.closeType):"CLOSE"===this.closeType&&f(),x()}},e.prototype.update=function(e){if(e.length!==this.controlPoints.length)throw new Error("[p5.bezier] The number of points changed. (Keep the length of the point array the same.)");this.controlPoints.every((function(t,r){return t===e[r]}))||(this.controlPoints=e,this._buildVertexList())},e.prototype.move=function(t,r,i,n,o){if(void 0===i&&(i=null),void 0===n&&(n=!0),void 0===o&&(o=[0]),null===i&&3===this.dimension)throw new Error("[p5.bezier] To move a 3D curve, please specify (x, y, z).");var s=[t,r];null!==i&&s.push(i);var h=this.vertexList.map((function(e){return e.slice()})),a=new e(this.controlPoints,this.closeType,this.increment,this.dimension,h);return a.vertexList=a.vertexList.map((function(e){return e.map((function(e,t){return e+s[t]}))})),n&&a.draw(o),a},e.prototype.shortest=function(e,t,r){void 0===r&&(r=0);for(var i=[],n=1/0,o=0,s=this.vertexList;o<s.length;o++){var h=s[o],a=this._distVertex(h,[e,t,r]);n>a&&(n=a,i=h)}return i},e}();return t})()));
|
|
3
3
|
//# sourceMappingURL=p5.bezier.min.js.map
|
package/lib/p5.bezier.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p5.bezier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ier/webpack/runtime/define property getters","webpack://p5bezier/webpack/runtime/hasOwnProperty shorthand","webpack://p5bezier/webpack/runtime/make namespace object","webpack://p5bezier/./src/p5.bezier.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"p5bezier\"] = factory();\n\telse\n\t\troot[\"p5bezier\"] = factory();\n})(this, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/*\np5.bezier library by Peiling Jiang\n2020\n*/\n\nconst p5bezierAccuracyListAll = [\n 0.2, 0.1, 0.05, 0.04, 0.02, 0.01, 0.008, 0.002, 0.001, 0.0005, 0.0001,\n]\n\nlet _canvas,\n _ctx,\n _dimension,\n _strict,\n _useP5,\n _beginPath,\n _moveTo,\n _lineTo,\n _closePath\n\nexport function initBezier(canvas, strictMode = false) {\n _canvas = canvas\n _ctx = _canvas.drawingContext\n\n // eslint-disable-next-line no-undef\n if (p5 && canvas instanceof p5.Graphics) {\n // p5 graphics\n _useP5 = true\n _dimension = _ctx.constructor.name === 'WebGLRenderingContext' ? 3 : 2\n\n _beginPath = _canvas.beginShape\n _moveTo = _canvas.vertex\n _lineTo = _canvas.vertex\n _closePath = _canvas.endShape\n // eslint-disable-next-line no-undef\n } else if ((p5 && canvas instanceof p5.Renderer) || canvas.drawingContext) {\n // p5 canvas or other canvas\n // eslint-disable-next-line no-undef\n if (!p5 || (p5 && !(canvas instanceof p5.Renderer))) {\n window.console.warn(\n '[p5.bezier] Support for non-p5 canvas is not tested.'\n )\n _dimension = canvas.isP3D ? 3 : 2\n } else {\n _dimension = _ctx.constructor.name === 'WebGLRenderingContext' ? 3 : 2\n }\n _useP5 = false\n _dimension = _ctx.constructor.name === 'WebGLRenderingContext' ? 3 : 2\n\n _beginPath = _ctx.beginPath.bind(_ctx)\n _moveTo = _ctx.moveTo.bind(_ctx)\n _lineTo = _ctx.lineTo.bind(_ctx)\n _closePath = _ctx.closePath.bind(_ctx)\n } else {\n throw new Error('[p5.bezier] Canvas is not supported.')\n }\n\n _strict = strictMode // Always check and throw errors or not\n}\n\nexport function newBezier(pointList, closeType = 'OPEN', accuracy = 6) {\n if (_strict && !Array.isArray(pointList))\n throw new Error(\n `[p5.bezier] newBezier() function expects an array, got ${typeof pointList}.`\n )\n\n // Define the increment of t based on accuracy\n const tIncrement = p5bezierAccuracyListAll[accuracy]\n\n if (_dimension !== 0) {\n // Check if all points are valid\n if (_strict)\n for (let point of pointList)\n if (!Array.isArray(pointList) || point.length !== _dimension)\n throw new Error(\n '[p5.bezier] One or more points in the array are not input correctly.'\n )\n\n // Add the first point as the last point to close the curve\n if (closeType === 'CLOSE') pointList.push(pointList[0])\n let p = pointList.length // pointList has p points for (p - 1) degree curves\n let n = p - 1\n\n _beginPath()\n _moveTo(...pointList[0])\n // Are we drawing 2D or 3D curves\n if (_dimension === 2) {\n // 2-Dimensional bezier curve\n let x, y, t, i\n for (t = 0; t <= 1; t += tIncrement) {\n x = 0\n y = 0\n for (i = 0; i <= n; i++) {\n // i point in pointList\n x +=\n (_helper_factorial(n) /\n (_helper_factorial(i) * _helper_factorial(n - i))) *\n Math.pow(1 - t, n - i) *\n Math.pow(t, i) *\n pointList[i][0]\n y +=\n (_helper_factorial(n) /\n (_helper_factorial(i) * _helper_factorial(n - i))) *\n Math.pow(1 - t, n - i) *\n Math.pow(t, i) *\n pointList[i][1]\n }\n _lineTo(x, y)\n }\n _lineTo(...pointList.slice(-1)[0])\n } else if (_dimension === 3) {\n // 3-Dimensional bezier curve\n let xyz = [0, 0, 0],\n t,\n i,\n d\n for (t = 0; t <= 1; t += tIncrement) {\n xyz = [0, 0, 0]\n for (i = 0; i <= n; i++) {\n for (d = 0; d < 3; d++) {\n xyz[d] +=\n (_helper_factorial(n) /\n (_helper_factorial(i) * _helper_factorial(n - i))) *\n Math.pow(1 - t, n - i) *\n Math.pow(t, i) *\n pointList[i][d]\n }\n }\n _lineTo(...xyz)\n }\n _lineTo(...pointList.slice(-1)[0])\n }\n\n if (_useP5) _closePath(closeType)\n else if (closeType === 'CLOSE') _closePath()\n else if (_strict && closeType !== 'OPEN')\n throw new Error(\n '[p5.bezier] Close type error. A bezier curve can only be either OPEN or CLOSE.'\n )\n\n _helper_style()\n\n return\n }\n}\n\nexport function newBezierObj(pointList, closeType = 'OPEN', accuracy = 6) {\n // Define the increment of t based on accuracy\n const tIncrement = p5bezierAccuracyListAll[accuracy]\n\n if (_strict && !Array.isArray(pointList))\n throw new Error(\n `[p5.bezier] newBezierObj() function expects an array, got ${typeof pointList}.`\n )\n\n // Check if all points are valid\n if (_strict)\n for (let point of pointList)\n if (!Array.isArray(pointList) || point.length !== _dimension)\n throw new Error(\n '[p5.bezier] One or more points in the array are not input correctly.'\n )\n\n // All checks done\n let bObj = new BezierCurve(pointList, closeType, tIncrement, _dimension)\n return bObj\n}\n\nfunction _helper_factorial(a) {\n // Factorial function for binomial coefficient calculation\n return a > 1 ? a * _helper_factorial(a - 1) : 1\n}\n\nfunction _helper_dist() {\n if (arguments.length === 4)\n return Math.hypot(arguments[0] - arguments[2], arguments[1] - arguments[3])\n else if (arguments.length === 6)\n return Math.hypot(\n arguments[0] - arguments[3],\n arguments[1] - arguments[4],\n arguments[2] - arguments[5]\n )\n return 0\n}\n\nfunction _helper_style() {\n if (_canvas._doFill) _ctx.fill()\n if (_canvas._doStroke) _ctx.stroke()\n}\n\nclass BezierCurve {\n // Take pointList, closeType, tIncrement, bezierDimension into constructor\n constructor(pL, closeT, tI, bD, vL = null) {\n if (_strict && bD !== 2 && bD !== 3)\n throw new Error(\n `Dimension error. The bezier curve is ${bD}-dimensional and doesn't belong to our world.`\n )\n\n this.controlPoints = pL\n\n if (closeT === 'CLOSE') {\n this.controlPoints.push(pL[0])\n this.closeType = 'CLOSE'\n } else if (closeT === 'OPEN') {\n this.closeType = 'OPEN'\n } else {\n throw new Error(\n '[p5.bezier] Close type error. A bezier curve can only be either OPEN or CLOSE.'\n )\n }\n\n this.dimension = bD\n this.increment = tI\n this.vertexList = []\n this.vertexListLen = 0\n this.p = this.controlPoints.length // Has p points for (p - 1) degree curves\n this.n = this.p - 1 // Degree\n // Calculate thr vertex\n if (vL === null) {\n this._buildVertexList()\n } else {\n this.vertexList = vL\n this.vertexListLen = this.vertexList.length\n }\n }\n\n _buildVertexList() {\n /*\n Return vertexList\n */\n this.vertexList = []\n if (this.dimension === 2) {\n // 2-Dimensional bezier curve\n let x, y, t, i\n for (t = 0; t <= 1; t += this.increment) {\n x = 0\n y = 0\n for (i = 0; i <= this.n; i++) {\n // i point in pointList\n x +=\n (_helper_factorial(this.n) /\n (_helper_factorial(i) * _helper_factorial(this.n - i))) *\n Math.pow(1 - t, this.n - i) *\n Math.pow(t, i) *\n this.controlPoints[i][0]\n y +=\n (_helper_factorial(this.n) /\n (_helper_factorial(i) * _helper_factorial(this.n - i))) *\n Math.pow(1 - t, this.n - i) *\n Math.pow(t, i) *\n this.controlPoints[i][1]\n }\n this.vertexList.push([x, y])\n }\n } else if (this.dimension === 3) {\n // 3-Dimensional bezier curve\n let xyz = [0, 0, 0],\n t,\n i,\n d\n for (t = 0; t <= 1; t += this.increment) {\n xyz[0] = 0\n xyz[1] = 0\n xyz[2] = 0\n for (i = 0; i <= this.n; i++) {\n for (d = 0; d < 3; d++) {\n xyz[d] +=\n (_helper_factorial(this.n) /\n (_helper_factorial(i) * _helper_factorial(this.n - i))) *\n Math.pow(1 - t, this.n - i) *\n Math.pow(t, i) *\n this.controlPoints[i][d]\n }\n }\n this.vertexList.push(xyz)\n }\n }\n // Ending fix\n this._addVertex(this.controlPoints.slice(-1)[0])\n\n this.dimension = this.vertexList[0].length // Update dimension\n this.vertexListLen = this.vertexList.length // Update vertexListLen\n return this.vertexList\n }\n\n _addVertex(vArray) {\n // vArray is an array of [x, y] position or [x, y, z] position\n if (this.dimension === 2 || this.dimension === 3) _lineTo(...vArray)\n else throw new Error('Vertices can only be in 2D or 3D space.')\n }\n\n _distVertex(vArray1, vArray2) {\n // Calculate the distance between\n // vertex_array_1 and vertex_array_2\n if (this.dimension === 2) {\n return _helper_dist(vArray1[0], vArray1[1], vArray2[0], vArray2[1])\n } else if (this.dimension === 3) {\n return _helper_dist(\n vArray1[0],\n vArray1[1],\n vArray1[2],\n vArray2[0],\n vArray2[1],\n vArray2[2]\n )\n }\n }\n\n draw(dash) {\n if (!dash) {\n _beginPath()\n for (let v of this.vertexList) {\n this._addVertex(v)\n }\n\n if (this.closeType === 'CLOSE') _ctx.closePath()\n\n if (_useP5) _closePath(this.closeType)\n else if (this.closeType === 'CLOSE') _closePath()\n\n _helper_style()\n } else if (\n Array.isArray(dash) &&\n dash.length === 2 &&\n this.increment <= 0.008\n ) {\n // Draw a dash curve\n let solidPart = Math.abs(dash[0]) // Length of one solid part\n let onePart = solidPart + Math.abs(dash[1]),\n nowLen = 0,\n modOnePart = 0\n let lastVertex = this.vertexList[0]\n let solid = true // true draw, false break\n\n _ctx.save() // push\n _ctx.fillStyle = 'rgba(0, 0, 0, 0)' // TODO: Enable fill\n _beginPath()\n _moveTo(...this.vertexList[0])\n for (let v = 1; v < this.vertexListLen; v++) {\n nowLen += this._distVertex(lastVertex, this.vertexList[v])\n modOnePart = nowLen % onePart\n if (modOnePart <= solidPart && solid) {\n this._addVertex(this.vertexList[v])\n } else if (modOnePart > solidPart && modOnePart <= onePart && solid) {\n // endShape()\n solid = false\n } else if (modOnePart <= solidPart && !solid) {\n _moveTo(...this.vertexList[v])\n solid = true\n }\n lastVertex = this.vertexList[v]\n }\n // if (solid) {\n // // Shape didn't end\n // endShape()\n // }\n _helper_style()\n _ctx.restore()\n } else if (this.increment > 0.008)\n throw new Error(\n 'Fidelity is too low for a dash line. It should be at least 6.'\n )\n else\n throw new Error(\n \"Your dash array input is not valid. Make sure it's an array of two numbers.\"\n )\n }\n\n update(newControlList) {\n /*\n Update the vertexList when control points change\n */\n if (newControlList.length !== this.controlPoints.length) {\n throw new Error(\n 'The number of points changed. (Keep the length of the point array the same.)'\n )\n } else if (equalArrays(this.controlPoints, newControlList)) {\n // Do we really need to update? No.\n // return ;\n } else {\n this.controlPoints = newControlList\n this._buildVertexList()\n }\n }\n\n move(x, y, z = null, toDraw = true, dash = 0) {\n /*\n Move the curve to another place\n Return a new object\n */\n if (z === null && this.dimension === 3) {\n // A 3D curve treated as 2D error\n throw new Error('To move a 3D curve, please specify (x, y, z).')\n } else {\n let toMove = [x, y]\n if (z !== null) toMove.push(z)\n // Copy to a new object\n let newCurveV = []\n for (let i = 0; i < this.vertexListLen; i++)\n newCurveV.push(this.vertexList[i].slice())\n let newCurveObj = new BezierCurve(\n this.controlPoints,\n this.closeType,\n this.increment,\n this.dimension,\n newCurveV\n )\n // Move\n for (let i = 0; i < newCurveObj.vertexListLen; i++) {\n for (let j = 0; j < newCurveObj.dimension; j++) {\n newCurveObj.vertexList[i][j] += toMove[j]\n }\n }\n if (toDraw) {\n newCurveObj.draw(dash)\n }\n return newCurveObj\n }\n }\n\n shortest(pX, pY, pZ = 0) {\n // Return the point on curve that is closest to the point outside\n // Always return array length of 3\n // Last position (z) be 0 for all 2D calculation\n let dMin = -1,\n nowMin = 0\n let minVertex\n for (let v of this.vertexList) {\n if (dMin === -1) {\n dMin = this._distVertex(v, [pX, pY, pZ])\n minVertex = v\n } else {\n nowMin = this._distVertex(v, [pX, pY, pZ])\n if (dMin > nowMin) {\n dMin = nowMin\n minVertex = v\n }\n }\n }\n return minVertex // An array of vertex position\n }\n}\n\n/* --------------------------------- HELPERS -------------------------------- */\n\n// https://www.30secondsofcode.org/blog/s/javascript-array-comparison\nconst equalArrays = (a, b) =>\n a.length === b.length && a.every((v, i) => v === b[i])\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","p5bezierAccuracyListAll","_canvas","_ctx","_dimension","_strict","_useP5","_beginPath","_moveTo","_lineTo","_closePath","initBezier","canvas","strictMode","drawingContext","p5","Graphics","constructor","name","beginShape","vertex","endShape","Renderer","Error","window","console","warn","isP3D","beginPath","bind","moveTo","lineTo","closePath","newBezier","pointList","closeType","accuracy","Array","isArray","tIncrement","point","length","push","n","x","y","t","i","_helper_factorial","Math","pow","slice","d","xyz","_helper_style","newBezierObj","BezierCurve","a","_helper_dist","arguments","hypot","_doFill","fill","_doStroke","stroke","pL","closeT","tI","bD","vL","controlPoints","dimension","increment","vertexList","vertexListLen","p","_buildVertexList","_addVertex","vArray","_distVertex","vArray1","vArray2","draw","dash","solidPart","abs","onePart","nowLen","modOnePart","lastVertex","solid","save","fillStyle","v","restore","update","newControlList","equalArrays","move","z","toDraw","toMove","newCurveV","newCurveObj","j","shortest","pX","pY","pZ","minVertex","dMin","nowMin","b","every"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"p5.bezier.min.js","mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAkB,SAAID,IAEtBD,EAAe,SAAIC,GACpB,CATD,CASGK,MAAM,IACT,mBCTA,IAAIC,EAAsB,CCA1BA,EAAwB,CAAC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,IACtCE,EAAOE,IACPF,EAAOE,EACPH,EAAY3F,EAEpB,CACA,OAAO2F,CACX,EACO9C,CACX,CA1LgC,aLtLhC","sources":["webpack://p5bezier/webpack/universalModuleDefinition","webpack://p5bezier/webpack/bootstrap","webpack://p5bezier/webpack/runtime/define property getters","webpack://p5bezier/webpack/runtime/hasOwnProperty shorthand","webpack://p5bezier/webpack/runtime/make namespace object","webpack://p5bezier/./src/p5.bezier.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"p5bezier\"] = factory();\n\telse\n\t\troot[\"p5bezier\"] = factory();\n})(this, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/*\np5.bezier library by Peiling Jiang\n2020\n\nupdated May 2023\n*/\nvar __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n};\nwindow.console.log('[p5.bezier]');\n// fidelity 0-10\nvar p5bezierAccuracyListAll = [\n 0.2, 0.1, 0.05, 0.04, 0.02, 0.01, 0.008, 0.002, 0.001, 0.0005, 0.0001,\n];\nvar _canvas, _ctx, _dimension, _strict, _useP5, _beginPath, _moveTo, _lineTo, _closePath;\nvar _precalculatedFactorials = [1];\n/* -------------------------------------------------------------------------- */\n/* -------------------------------------------------------------------------- */\n/* -------------------------------------------------------------------------- */\n// helpers\nfunction _determineDimension(context, isP3D) {\n return context.constructor.name === 'WebGLRenderingContext' || isP3D ? 3 : 2;\n}\nfunction _setCanvasFunctions(useP5, canvas, context) {\n if (useP5) {\n _beginPath = canvas.beginShape;\n _moveTo = canvas.vertex;\n _lineTo = canvas.vertex;\n _closePath = canvas.endShape;\n }\n else {\n _beginPath = context.beginPath.bind(context);\n _moveTo = context.moveTo.bind(context);\n _lineTo = context.lineTo.bind(context);\n _closePath = context.closePath.bind(context);\n }\n}\nfunction _ensureFactorials(n) {\n for (var i = _precalculatedFactorials.length; i <= n; i++) {\n _precalculatedFactorials[i] = i * _precalculatedFactorials[i - 1];\n }\n}\nfunction _helper_factorial(i) {\n _ensureFactorials(i);\n return _precalculatedFactorials[i];\n}\nfunction _binomialCoefficient(n, i) {\n _ensureFactorials(n);\n return (_helper_factorial(n) / (_helper_factorial(i) * _helper_factorial(n - i)));\n}\nfunction _helper_dist() {\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n if (args.length === 4)\n return Math.hypot(args[0] - args[2], args[1] - args[3]);\n else if (args.length === 6)\n return Math.hypot(args[0] - args[3], args[1] - args[4], args[2] - args[5]);\n return 0;\n}\nfunction _helper_style() {\n if (_canvas._doFill)\n _ctx.fill();\n if (_canvas._doStroke)\n _ctx.stroke();\n}\nfunction _deepCopyArray(arr) {\n return arr.map(function (v) { return __spreadArray([], v, true); });\n}\nfunction _findCloseCurveExtraPoints(pointList) {\n var first = pointList[0];\n var last = pointList[pointList.length - 1];\n var second = pointList[1];\n var secondLast = pointList[pointList.length - 2];\n var point1 = [2 * last[0] - secondLast[0], 2 * last[1] - secondLast[1]];\n var point2 = [2 * first[0] - second[0], 2 * first[1] - second[1]];\n return [point1, point2, first];\n}\n/* -------------------------------------------------------------------------- */\n/* -------------------------------------------------------------------------- */\n/* -------------------------------------------------------------------------- */\nexport function initBezier(canvas, strictMode) {\n if (strictMode === void 0) { strictMode = false; }\n _canvas = canvas;\n _ctx = _canvas.drawingContext;\n if (typeof p5 !== 'undefined' && canvas instanceof p5.Graphics) {\n _useP5 = true;\n _dimension = _determineDimension(_ctx, false);\n }\n else if ((typeof p5 !== 'undefined' && canvas instanceof p5.Renderer) ||\n canvas.drawingContext) {\n _useP5 = false;\n if (typeof p5 === 'undefined' ||\n (typeof p5 !== 'undefined' && !(canvas instanceof p5.Renderer))) {\n window.console.warn('[p5.bezier] Support for non-p5 canvas is not tested.');\n }\n _dimension = _determineDimension(_ctx, canvas.isP3D);\n }\n else {\n throw new Error('[p5.bezier] Canvas is not supported.');\n }\n _setCanvasFunctions(_useP5, _canvas, _ctx);\n _strict = strictMode;\n}\nexport function newBezier(pointList, closeType, accuracy) {\n if (closeType === void 0) { closeType = 'OPEN'; }\n if (accuracy === void 0) { accuracy = 7; }\n if (_strict && !Array.isArray(pointList)) {\n throw new Error(\"[p5.bezier] newBezier() function expects an array, got \".concat(typeof pointList, \".\"));\n }\n pointList = _deepCopyArray(pointList);\n if (closeType === 'CLOSE') {\n var closeCurveExtraPoints = _findCloseCurveExtraPoints(pointList);\n pointList.push.apply(pointList, closeCurveExtraPoints);\n }\n var tIncrement = p5bezierAccuracyListAll[accuracy];\n var p = pointList.length; // pointList has p points for (p - 1) degree curves\n var n = p - 1;\n if (_dimension !== 0) {\n if (_strict) {\n for (var _i = 0, pointList_1 = pointList; _i < pointList_1.length; _i++) {\n var point = pointList_1[_i];\n if (!Array.isArray(pointList) || point.length !== _dimension) {\n throw new Error('[p5.bezier] One or more points in the array are not input correctly.');\n }\n }\n }\n _ensureFactorials(n);\n _beginPath();\n _moveTo.apply(void 0, pointList[0]);\n if (_dimension === 2) {\n var x = void 0, y = void 0, t = void 0;\n for (t = 0; t <= 1; t += tIncrement) {\n x = y = 0;\n for (var i = 0; i <= n; i++) {\n var coefficient = _binomialCoefficient(n, i) * Math.pow(1 - t, n - i) * Math.pow(t, i);\n x += coefficient * pointList[i][0];\n y += coefficient * pointList[i][1];\n }\n _lineTo(x, y);\n }\n }\n else if (_dimension === 3) {\n var t = void 0;\n for (t = 0; t <= 1; t += tIncrement) {\n var xyz = [0, 0, 0];\n for (var i = 0; i <= n; i++) {\n var coefficient = _binomialCoefficient(n, i) * Math.pow(1 - t, n - i) * Math.pow(t, i);\n for (var d = 0; d < 3; d++) {\n xyz[d] += coefficient * pointList[i][d];\n }\n }\n _lineTo.apply(void 0, xyz);\n }\n }\n _lineTo.apply(void 0, pointList.slice(-1)[0]);\n if (_useP5) {\n _closePath(closeType);\n }\n else if (closeType === 'CLOSE') {\n _closePath();\n }\n else if (_strict && closeType !== 'OPEN') {\n throw new Error('[p5.bezier] Close type error. A bezier curve can only be either OPEN or CLOSE.');\n }\n _helper_style();\n }\n}\nexport function newBezierObj(pointList, closeType, accuracy) {\n if (closeType === void 0) { closeType = 'OPEN'; }\n if (accuracy === void 0) { accuracy = 7; }\n var tIncrement = p5bezierAccuracyListAll[accuracy];\n if (_strict) {\n if (!Array.isArray(pointList)) {\n throw new Error(\"[p5.bezier] newBezierObj() function expects an array, got \".concat(typeof pointList, \".\"));\n }\n for (var _i = 0, pointList_2 = pointList; _i < pointList_2.length; _i++) {\n var point = pointList_2[_i];\n if (!Array.isArray(point) || point.length !== _dimension) {\n throw new Error('[p5.bezier] One or more points in the array are not input correctly.');\n }\n }\n }\n return new BezierCurve(pointList, closeType, tIncrement, _dimension);\n}\nvar BezierCurve = /** @class */ (function () {\n // take pointList, closeType, tIncrement, bezierDimension into constructor\n function BezierCurve(pL, closeT, tI, bD, vL) {\n var _a;\n if (vL === void 0) { vL = null; }\n if (_strict && bD !== 2 && bD !== 3) {\n throw new Error(\"[p5.bezier] Dimension error. The bezier curve is \".concat(bD, \"-dimensional and doesn't belong to our world.\"));\n }\n this.controlPoints = _deepCopyArray(pL);\n if (closeT === 'CLOSE') {\n (_a = this.controlPoints).push.apply(_a, _findCloseCurveExtraPoints(this.controlPoints));\n this.closeType = 'CLOSE';\n }\n else if (closeT === 'OPEN') {\n this.closeType = 'OPEN';\n }\n else {\n throw new Error('[p5.bezier] Close type error. A bezier curve can only be either OPEN or CLOSE.');\n }\n this.dimension = bD;\n this.increment = tI;\n this.vertexList = [];\n this.vertexListLen = 0;\n this.p = this.controlPoints.length; // has p points for (p - 1) degree curves\n this.n = this.p - 1; // degree\n // ensure enough factorials are calculated up to this.n\n _ensureFactorials(this.n);\n if (vL === null) {\n this._buildVertexList();\n }\n else {\n this.vertexList = __spreadArray([], vL, true);\n this.vertexListLen = this.vertexList.length;\n }\n }\n BezierCurve.prototype._buildVertexList = function () {\n this.vertexList = [];\n if (this.dimension === 2) {\n for (var t = 0; t <= 1; t += this.increment) {\n var x = 0;\n var y = 0;\n for (var i = 0; i <= this.n; i++) {\n var binomialCoefficient = _binomialCoefficient(this.n, i);\n var term = binomialCoefficient * Math.pow(1 - t, this.n - i) * Math.pow(t, i);\n x += term * this.controlPoints[i][0];\n y += term * this.controlPoints[i][1];\n }\n this.vertexList.push([x, y]);\n }\n }\n else if (this.dimension === 3) {\n for (var t = 0; t <= 1; t += this.increment) {\n var xyz = [0, 0, 0];\n for (var i = 0; i <= this.n; i++) {\n var binomialCoefficient = _binomialCoefficient(this.n, i);\n var term = binomialCoefficient * Math.pow(1 - t, this.n - i) * Math.pow(t, i);\n for (var d = 0; d < 3; d++) {\n xyz[d] += term * this.controlPoints[i][d];\n }\n }\n this.vertexList.push(xyz);\n }\n }\n this._addVertex(this.controlPoints[this.controlPoints.length - 1]);\n this.dimension = this.vertexList[0].length; // update dimension\n this.vertexListLen = this.vertexList.length; // update vertexListLen\n return this.vertexList;\n };\n BezierCurve.prototype._addVertex = function (vArray) {\n // vArray is an array of [x, y] position or [x, y, z] position\n if (this.dimension === 2 || this.dimension === 3)\n _lineTo.apply(void 0, vArray);\n else\n throw new Error('[p5.bezier] Vertices can only be in 2D or 3D space.');\n };\n BezierCurve.prototype._distVertex = function (vArray1, vArray2) {\n // calculate the distance between\n // vertex_array_1 and vertex_array_2\n if (this.dimension === 2) {\n return _helper_dist(vArray1[0], vArray1[1], vArray2[0], vArray2[1]);\n }\n else if (this.dimension === 3) {\n return _helper_dist(vArray1[0], vArray1[1], vArray1[2], vArray2[0], vArray2[1], vArray2[2]);\n }\n return 0;\n };\n BezierCurve.prototype.draw = function (dash) {\n if (!dash) {\n _beginPath();\n for (var _i = 0, _a = this.vertexList; _i < _a.length; _i++) {\n var v = _a[_i];\n this._addVertex(v);\n }\n if (this.closeType === 'CLOSE')\n _ctx.closePath();\n if (_useP5)\n _closePath(this.closeType);\n else if (this.closeType === 'CLOSE')\n _closePath();\n _helper_style();\n }\n else if (Array.isArray(dash) &&\n dash.length === 2 &&\n this.increment <= 0.008) {\n // draw a dash curve\n var solidPart = Math.abs(dash[0]); // length of one solid part\n var onePart = solidPart + Math.abs(dash[1]), nowLen = 0, modOnePart = 0;\n var lastVertex = this.vertexList[0];\n var solid = true; // true draw, false break\n _ctx.save(); // push\n _ctx.fillStyle = 'rgba(0, 0, 0, 0)'; // TODO enable fill\n _beginPath();\n _moveTo.apply(void 0, this.vertexList[0]);\n for (var v = 1; v < this.vertexListLen; v++) {\n nowLen += this._distVertex(lastVertex, this.vertexList[v]);\n modOnePart = nowLen % onePart;\n if (modOnePart <= solidPart && solid) {\n this._addVertex(this.vertexList[v]);\n }\n else if (modOnePart > solidPart && modOnePart <= onePart && solid) {\n // endShape();\n solid = false;\n }\n else if (modOnePart <= solidPart && !solid) {\n _moveTo.apply(void 0, this.vertexList[v]);\n solid = true;\n }\n lastVertex = this.vertexList[v];\n }\n _helper_style();\n _ctx.restore();\n }\n else if (this.increment > 0.008)\n throw new Error('[p5.bezier] Fidelity is too low for a dash line. It should be at least 6.');\n else\n throw new Error(\"[p5.bezier] Your dash array input is not valid. Make sure it's an array of two numbers.\");\n };\n BezierCurve.prototype.update = function (newControlList) {\n if (newControlList.length !== this.controlPoints.length) {\n throw new Error('[p5.bezier] The number of points changed. (Keep the length of the point array the same.)');\n }\n else if (this.controlPoints.every(function (v, i) { return v === newControlList[i]; })) {\n return;\n }\n else {\n this.controlPoints = newControlList;\n this._buildVertexList();\n }\n };\n BezierCurve.prototype.move = function (x, y, z, toDraw, dash) {\n if (z === void 0) { z = null; }\n if (toDraw === void 0) { toDraw = true; }\n if (dash === void 0) { dash = [0]; }\n if (z === null && this.dimension === 3) {\n throw new Error('[p5.bezier] To move a 3D curve, please specify (x, y, z).');\n }\n else {\n var toMove_1 = [x, y];\n if (z !== null)\n toMove_1.push(z);\n var newCurveV = this.vertexList.map(function (v) { return v.slice(); });\n var newCurveObj = new BezierCurve(this.controlPoints, this.closeType, this.increment, this.dimension, newCurveV);\n newCurveObj.vertexList = newCurveObj.vertexList.map(function (v) {\n return v.map(function (val, i) { return val + toMove_1[i]; });\n });\n if (toDraw) {\n newCurveObj.draw(dash);\n }\n return newCurveObj;\n }\n };\n BezierCurve.prototype.shortest = function (pX, pY, pZ) {\n if (pZ === void 0) { pZ = 0; }\n var minVertex = [];\n var dMin = Infinity;\n for (var _i = 0, _a = this.vertexList; _i < _a.length; _i++) {\n var v = _a[_i];\n var nowMin = this._distVertex(v, [pX, pY, pZ]);\n if (dMin > nowMin) {\n dMin = nowMin;\n minVertex = v;\n }\n }\n return minVertex;\n };\n return BezierCurve;\n}());\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","__spreadArray","to","from","pack","arguments","length","ar","i","l","Array","slice","concat","window","console","log","_canvas","_ctx","_dimension","_strict","_useP5","_beginPath","_moveTo","_lineTo","_closePath","p5bezierAccuracyListAll","_precalculatedFactorials","_determineDimension","context","isP3D","constructor","name","_ensureFactorials","n","_helper_factorial","_binomialCoefficient","_helper_dist","args","_i","Math","hypot","_helper_style","_doFill","fill","_doStroke","stroke","_deepCopyArray","arr","map","v","_findCloseCurveExtraPoints","pointList","first","last","second","secondLast","initBezier","canvas","strictMode","drawingContext","p5","Graphics","Renderer","Error","warn","useP5","beginShape","vertex","endShape","beginPath","bind","moveTo","lineTo","closePath","_setCanvasFunctions","newBezier","closeType","accuracy","isArray","closeCurveExtraPoints","push","apply","tIncrement","pointList_1","point","x","y","t","coefficient","pow","xyz","d","newBezierObj","pointList_2","BezierCurve","pL","closeT","tI","bD","vL","_a","controlPoints","dimension","increment","vertexList","vertexListLen","p","_buildVertexList","term","_addVertex","vArray","_distVertex","vArray1","vArray2","draw","dash","solidPart","abs","onePart","nowLen","modOnePart","lastVertex","solid","save","fillStyle","restore","update","newControlList","every","move","z","toDraw","toMove_1","newCurveV","newCurveObj","val","shortest","pX","pY","pZ","minVertex","dMin","Infinity","nowMin"],"sourceRoot":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "p5bezier",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Bezier library for canvas-based graphics on the web, built to work with p5.js.",
|
|
5
5
|
"main": "lib/p5.bezier.min.js",
|
|
6
6
|
"keywords": [
|
|
@@ -19,13 +19,15 @@
|
|
|
19
19
|
},
|
|
20
20
|
"homepage": "https://github.com/peilingjiang/p5.bezier#readme",
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"eslint": "^8.
|
|
22
|
+
"eslint": "^8.41.0",
|
|
23
23
|
"husky": "^8.0.3",
|
|
24
|
-
"lint-staged": "^13.
|
|
25
|
-
"prettier": "^2.8.
|
|
26
|
-
"terser-webpack-plugin": "^5.3.
|
|
27
|
-
"
|
|
28
|
-
"
|
|
24
|
+
"lint-staged": "^13.2.2",
|
|
25
|
+
"prettier": "^2.8.8",
|
|
26
|
+
"terser-webpack-plugin": "^5.3.9",
|
|
27
|
+
"ts-loader": "^9.4.2",
|
|
28
|
+
"typescript": "^5.0.4",
|
|
29
|
+
"webpack": "^5.83.1",
|
|
30
|
+
"webpack-cli": "^5.1.1"
|
|
29
31
|
},
|
|
30
32
|
"scripts": {
|
|
31
33
|
"format": "prettier --write \"**/*.{js,json,md,html,css}\"",
|