p5 2.0.4 → 2.0.5
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/README.md +1 -1
- package/dist/accessibility/color_namer.js +4 -4
- package/dist/accessibility/index.js +4 -4
- package/dist/accessibility/outputs.js +1 -1
- package/dist/app.js +4 -4
- package/dist/color/color_conversion.js +4 -4
- package/dist/color/index.js +1 -1
- package/dist/color/setting.js +1 -1
- package/dist/{constants-C2DVjshm.js → constants-8IpwyBct.js} +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/environment.js +1 -1
- package/dist/core/friendly_errors/fes_core.js +1 -1
- package/dist/core/friendly_errors/index.js +1 -1
- package/dist/core/friendly_errors/param_validator.js +1 -1
- package/dist/core/friendly_errors/sketch_verifier.js +1 -1
- package/dist/core/helpers.js +1 -1
- package/dist/core/init.js +4 -4
- package/dist/core/legacy.js +4 -4
- package/dist/core/main.js +4 -4
- package/dist/core/p5.Graphics.js +3 -3
- package/dist/core/p5.Renderer.js +2 -2
- package/dist/core/p5.Renderer2D.js +4 -4
- package/dist/core/rendering.js +3 -3
- package/dist/dom/dom.js +1 -1
- package/dist/dom/index.js +1 -1
- package/dist/dom/p5.Element.js +1 -1
- package/dist/dom/p5.MediaElement.js +1 -1
- package/dist/image/const.js +1 -1
- package/dist/image/filterRenderer2D.js +3 -3
- package/dist/image/image.js +3 -3
- package/dist/image/index.js +3 -3
- package/dist/image/loading_displaying.js +3 -3
- package/dist/image/p5.Image.js +2 -2
- package/dist/io/files.js +3 -3
- package/dist/io/index.js +3 -3
- package/dist/{main-rEhlsQtb.js → main-B3Z63C6j.js} +3 -3
- package/dist/math/Matrices/Matrix.js +1 -1
- package/dist/math/Matrices/MatrixNumjs.js +1 -1
- package/dist/math/index.js +1 -1
- package/dist/math/p5.Matrix.js +1 -1
- package/dist/math/p5.Vector.js +1 -1
- package/dist/math/trigonometry.js +1 -1
- package/dist/{p5.Renderer-DO9wIL55.js → p5.Renderer-DoDzbpcT.js} +1 -1
- package/dist/{rendering-CpHn8PfG.js → rendering-BELwvfI6.js} +3 -3
- package/dist/shape/2d_primitives.js +1 -1
- package/dist/shape/attributes.js +1 -1
- package/dist/shape/curves.js +143 -74
- package/dist/shape/custom_shapes.js +261 -277
- package/dist/shape/index.js +1 -1
- package/dist/type/index.js +2 -2
- package/dist/type/p5.Font.js +2 -2
- package/dist/type/textCore.js +2 -2
- package/dist/webgl/3d_primitives.js +3 -3
- package/dist/webgl/GeometryBuilder.js +1 -1
- package/dist/webgl/ShaderGenerator.js +10 -7
- package/dist/webgl/ShapeBuilder.js +1 -1
- package/dist/webgl/index.js +3 -3
- package/dist/webgl/interaction.js +1 -1
- package/dist/webgl/light.js +3 -3
- package/dist/webgl/loading.js +3 -3
- package/dist/webgl/material.js +3 -3
- package/dist/webgl/p5.Camera.js +3 -3
- package/dist/webgl/p5.Framebuffer.js +3 -3
- package/dist/webgl/p5.Geometry.js +1 -1
- package/dist/webgl/p5.Quat.js +1 -1
- package/dist/webgl/p5.RendererGL.js +3 -3
- package/dist/webgl/p5.Shader.js +3 -3
- package/dist/webgl/p5.Texture.js +3 -3
- package/dist/webgl/text.js +3 -3
- package/lib/p5.esm.js +414 -358
- package/lib/p5.esm.min.js +1 -1
- package/lib/p5.js +414 -358
- package/lib/p5.min.js +1 -1
- package/package.json +1 -1
- package/types/core/main.d.ts +87 -71
- package/types/global.d.ts +87 -71
- package/types/p5.d.ts +87 -71
- package/types/shape/curves.d.ts +130 -56
- package/types/shape/custom_shapes.d.ts +188 -252
package/package.json
CHANGED
package/types/core/main.d.ts
CHANGED
|
@@ -3380,7 +3380,7 @@ declare module 'p5' {
|
|
|
3380
3380
|
* Draws a Bézier curve.Bézier curves can form shapes and curves that slope gently. They're defined
|
|
3381
3381
|
* by two anchor points and two control points. Bézier curves provide more
|
|
3382
3382
|
* control than the spline curves created with the
|
|
3383
|
-
*
|
|
3383
|
+
* spline() function.The first two parameters, `x1` and `y1`, set the first anchor point. The
|
|
3384
3384
|
* first anchor point is where the curve starts.The next four parameters, `x2`, `y2`, `x3`, and `y3`, set the two control
|
|
3385
3385
|
* points. The control points "pull" the curve towards them.The seventh and eighth parameters, `x4` and `y4`, set the last anchor
|
|
3386
3386
|
* point. The last anchor point is where the curve ends.Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of
|
|
@@ -3443,13 +3443,11 @@ declare module 'p5' {
|
|
|
3443
3443
|
|
|
3444
3444
|
/**
|
|
3445
3445
|
* Draws a curve using a Catmull-Rom spline.Spline curves can form shapes and curves that slope gently. They’re like
|
|
3446
|
-
* cables that are attached to a set of points.
|
|
3447
|
-
*
|
|
3448
|
-
*
|
|
3449
|
-
* points
|
|
3450
|
-
*
|
|
3451
|
-
* point. This point isn’t drawn and can be thought of as the curve’s ending
|
|
3452
|
-
* point.Spline curves can also be drawn in 3D using WebGL mode. The 3D version of
|
|
3446
|
+
* cables that are attached to a set of points. By default (`ends: INCLUDE`),
|
|
3447
|
+
* the curve passes through all four points you provide, in order
|
|
3448
|
+
* `p0(x1,y1)` -> `p1(x2,y2)` -> `p2(x3,y3)` -> `p3(x4,y4)`. Think of them as
|
|
3449
|
+
* points on a curve. If you switch to `ends: EXCLUDE`, p0 and p3 act
|
|
3450
|
+
* like control points and only the middle span `p1->p2` is drawn.Spline curves can also be drawn in 3D using WebGL mode. The 3D version of
|
|
3453
3451
|
* `spline()` has twelve arguments because each point has x-, y-, and
|
|
3454
3452
|
* z-coordinates.
|
|
3455
3453
|
*
|
|
@@ -3467,15 +3465,15 @@ declare module 'p5' {
|
|
|
3467
3465
|
spline(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, x3: number, y3: number, z3: number, x4: number, y4: number, z4: number): void;
|
|
3468
3466
|
|
|
3469
3467
|
/**
|
|
3470
|
-
* Calculates coordinates along a spline curve using interpolation.`splinePoint()` calculates coordinates along a spline curve using
|
|
3471
|
-
*
|
|
3468
|
+
* Calculates coordinates along a spline curve using interpolation.`splinePoint()` calculates coordinates along a spline curve using four
|
|
3469
|
+
* points p0, p1, p2, p3. It expects points in the same order as the
|
|
3472
3470
|
* spline() function. `splinePoint()` works one axis
|
|
3473
|
-
* at a time. Passing the
|
|
3474
|
-
* calculate the x-coordinate of a point on the curve. Passing the
|
|
3475
|
-
*
|
|
3476
|
-
* the curve.The first parameter, `a`, is the coordinate of
|
|
3477
|
-
*
|
|
3478
|
-
*
|
|
3471
|
+
* at a time. Passing the points' x-coordinates will
|
|
3472
|
+
* calculate the x-coordinate of a point on the curve. Passing the
|
|
3473
|
+
* points' y-coordinates will calculate the y-coordinate of a point on
|
|
3474
|
+
* the curve.The first parameter, `a`, is the coordinate of point p0.The second and third parameters, `b` and `c`, are the coordinates of
|
|
3475
|
+
* points p1 and p2.The fourth parameter, `d`, is the coordinate of point p3.The fifth parameter, `t`, is the amount to interpolate along the span
|
|
3476
|
+
* from p1 to p2. `t = 0` is p1, `t = 1` is p2, and `t = 0.5` is halfway
|
|
3479
3477
|
* between them.
|
|
3480
3478
|
*
|
|
3481
3479
|
* @param
|
|
@@ -3488,15 +3486,14 @@ declare module 'p5' {
|
|
|
3488
3486
|
|
|
3489
3487
|
/**
|
|
3490
3488
|
* Calculates coordinates along a line that's tangent to a spline curve.Tangent lines skim the surface of a curve. A tangent line's slope equals
|
|
3491
|
-
* the curve's slope at the point where it intersects.`splineTangent()` calculates coordinates along a tangent line using
|
|
3492
|
-
*
|
|
3493
|
-
*
|
|
3494
|
-
*
|
|
3495
|
-
*
|
|
3496
|
-
*
|
|
3497
|
-
*
|
|
3498
|
-
*
|
|
3499
|
-
* is the first anchor point, 1 is the second anchor point, and 0.5 is halfway
|
|
3489
|
+
* the curve's slope at the point where it intersects.`splineTangent()` calculates coordinates along a tangent line using four
|
|
3490
|
+
* points p0, p1, p2, p3. It expects points in the same order as the
|
|
3491
|
+
* spline() function. `splineTangent()` works one
|
|
3492
|
+
* axis at a time. Passing the points' x-coordinates returns the x-component of
|
|
3493
|
+
* the tangent vector; passing the points' y-coordinates returns the y-component.
|
|
3494
|
+
* The first parameter, `a`, is the coordinate of point p0.The second and third parameters, `b` and `c`, are the coordinates of
|
|
3495
|
+
* points p1 and p2.The fourth parameter, `d`, is the coordinate of point p3.The fifth parameter, `t`, is the amount to interpolate along the span
|
|
3496
|
+
* from p1 to p2. `t = 0` is p1, `t = 1` is p2, and `t = 0.5` is halfway
|
|
3500
3497
|
* between them.
|
|
3501
3498
|
*
|
|
3502
3499
|
* @param
|
|
@@ -3531,49 +3528,44 @@ declare module 'p5' {
|
|
|
3531
3528
|
bezierOrder(): number;
|
|
3532
3529
|
|
|
3533
3530
|
/**
|
|
3534
|
-
*
|
|
3535
|
-
* it creates
|
|
3536
|
-
*
|
|
3537
|
-
* between the
|
|
3531
|
+
* Connects points with a smooth curve (a spline).`splineVertex()` adds a curved segment to custom shapes.
|
|
3532
|
+
* The curve it creates follows the same rules as the ones
|
|
3533
|
+
* made with the spline() function.
|
|
3534
|
+
* `splineVertex()` must be called between the
|
|
3535
|
+
* beginShape() and
|
|
3538
3536
|
* endShape() functions.Spline curves can form shapes and curves that slope gently. They’re like
|
|
3539
|
-
* cables that are attached to a set of points.
|
|
3540
|
-
*
|
|
3541
|
-
* least four times between
|
|
3537
|
+
* cables that are attached to a set of points. `splineVertex()` draws a smooth
|
|
3538
|
+
* curve through the points you give it.
|
|
3542
3539
|
* beginShape() and
|
|
3543
|
-
* endShape() in order to draw a curve
|
|
3540
|
+
* endShape() in order to draw a curve:If you provide three points, the spline will pass through them.
|
|
3541
|
+
* It works the same way with any number of points.`beginShape();
|
|
3544
3542
|
*
|
|
3545
|
-
* // Add the first
|
|
3546
|
-
* splineVertex(
|
|
3543
|
+
* // Add the first point.
|
|
3544
|
+
* splineVertex(25, 80);
|
|
3547
3545
|
*
|
|
3548
|
-
* // Add the
|
|
3549
|
-
* splineVertex(
|
|
3550
|
-
* splineVertex(21, 17);
|
|
3546
|
+
* // Add the second point.
|
|
3547
|
+
* splineVertex(20, 30);
|
|
3551
3548
|
*
|
|
3552
|
-
* // Add the
|
|
3553
|
-
* splineVertex(
|
|
3549
|
+
* // Add the last point.
|
|
3550
|
+
* splineVertex(85, 60);
|
|
3554
3551
|
*
|
|
3555
|
-
* endShape();`
|
|
3556
|
-
* similar to the curve() function. The segments
|
|
3557
|
-
* between the control and anchor points can be drawn by calling
|
|
3558
|
-
* `splineVertex()` with the coordinates of the control points:`beginShape();
|
|
3552
|
+
* endShape();`Passing in `CLOSE` to `endShape()` closes the spline smoothly.`beginShape();
|
|
3559
3553
|
*
|
|
3560
|
-
* // Add the first
|
|
3561
|
-
* splineVertex(
|
|
3562
|
-
* splineVertex(84, 91);
|
|
3554
|
+
* // Add the first point.
|
|
3555
|
+
* splineVertex(25, 80);
|
|
3563
3556
|
*
|
|
3564
|
-
* // Add the
|
|
3565
|
-
* splineVertex(
|
|
3566
|
-
* splineVertex(21, 17);
|
|
3557
|
+
* // Add the second point.
|
|
3558
|
+
* splineVertex(20, 30);
|
|
3567
3559
|
*
|
|
3568
|
-
* // Add the second
|
|
3569
|
-
* splineVertex(
|
|
3560
|
+
* // Add the second point.
|
|
3561
|
+
* splineVertex(85, 60);
|
|
3570
3562
|
*
|
|
3571
|
-
*
|
|
3572
|
-
*
|
|
3573
|
-
*
|
|
3574
|
-
*
|
|
3575
|
-
*
|
|
3576
|
-
*
|
|
3563
|
+
* endShape(CLOSE);`By default (`ends: INCLUDE`), the curve passes through
|
|
3564
|
+
* all the points you add with `splineVertex()`, similar to
|
|
3565
|
+
* the spline() function. To draw only
|
|
3566
|
+
* the middle span p1->p2 (skipping p0->p1 and p2->p3), set
|
|
3567
|
+
* `splineProperty('ends', EXCLUDE)`. You don’t need to duplicate
|
|
3568
|
+
* vertices to draw those spans.Spline curves can also be drawn in 3D using WebGL mode. The 3D version of
|
|
3577
3569
|
* `splineVertex()` has three arguments because each point has x-, y-, and
|
|
3578
3570
|
* z-coordinates. By default, the vertex’s z-coordinate is set to 0.Note: `splineVertex()` won’t work when an argument is passed to
|
|
3579
3571
|
* beginShape().
|
|
@@ -3590,19 +3582,43 @@ declare module 'p5' {
|
|
|
3590
3582
|
splineVertex(x: number, y: number, z: number, u: number, v: number): void;
|
|
3591
3583
|
|
|
3592
3584
|
/**
|
|
3593
|
-
*
|
|
3594
|
-
*
|
|
3595
|
-
*
|
|
3596
|
-
*
|
|
3597
|
-
*
|
|
3598
|
-
*
|
|
3599
|
-
*
|
|
3600
|
-
*
|
|
3601
|
-
*
|
|
3602
|
-
*
|
|
3603
|
-
* (
|
|
3604
|
-
*
|
|
3605
|
-
*
|
|
3585
|
+
* Gets or sets a given spline property.Use `splineProperty()` to adjust the behavior of splines
|
|
3586
|
+
* created with `splineVertex()` or `spline()`. You can control
|
|
3587
|
+
* two key aspects of a spline: its end behavior (`ends`) and
|
|
3588
|
+
* its curvature (`tightness`).By default, the ends property is set to `INCLUDE`, which means
|
|
3589
|
+
* the spline passes through every point, including the endpoints.
|
|
3590
|
+
* You can also set it to `EXCLUDE` i.e. `splineProperty('ends', EXCLUDE)`,
|
|
3591
|
+
* which makes the spline pass through all points except the endpoints.`INCLUDE` case will have the spline passing through
|
|
3592
|
+
* all points, like this:`splineProperty('ends', INCLUDE); // no need to set this, as it is the default
|
|
3593
|
+
* spline(25, 46, 93, 44, 93, 81, 35, 85);
|
|
3594
|
+
*
|
|
3595
|
+
* point(25, 46);
|
|
3596
|
+
* point(93, 44);
|
|
3597
|
+
* point(93, 81);
|
|
3598
|
+
* point(35, 85);`EXCLUDE case will have the spline passing through
|
|
3599
|
+
* the middle points, like this:`splineProperty('ends', INCLUDE);
|
|
3600
|
+
* spline(25, 46, 93, 44, 93, 81, 35, 85);
|
|
3601
|
+
*
|
|
3602
|
+
* point(25, 46);
|
|
3603
|
+
* point(93, 44);
|
|
3604
|
+
* point(93, 81);
|
|
3605
|
+
* point(35, 85);`By default, the tightness property is set to `0`,
|
|
3606
|
+
* producing a smooth curve that passes evenly through
|
|
3607
|
+
* the vertices. Negative values make the curve looser,
|
|
3608
|
+
* while positive values make it tighter. Common values
|
|
3609
|
+
* range between -1 and 1, though values outside this
|
|
3610
|
+
* range can also be used for different effects.For example, To set tightness, use `splineProperty('tightness', t)`,
|
|
3611
|
+
* (default: t = 0).Here's the example showing negetive value of tightness,
|
|
3612
|
+
* which creates a rounder bulge:`splineProperty('tightness', -5)
|
|
3613
|
+
* stroke(0);
|
|
3614
|
+
* strokeWeight(2);
|
|
3615
|
+
* spline(25, 46, 93, 44, 93, 81, 35, 85);`Here's the example showing positive value of tightness,
|
|
3616
|
+
* which makes the curve tighter and more angular:`splineProperty('tightness', 5)
|
|
3617
|
+
* stroke(0);
|
|
3618
|
+
* strokeWeight(2);
|
|
3619
|
+
* spline(25, 46, 93, 44, 93, 81, 35, 85);`In all cases, the splines in p5.js are cardinal splines.
|
|
3620
|
+
* When tightness is 0, these splines are often known as
|
|
3621
|
+
* Catmull-Rom splines
|
|
3606
3622
|
*
|
|
3607
3623
|
* @param
|
|
3608
3624
|
* @param
|
package/types/global.d.ts
CHANGED
|
@@ -2830,7 +2830,7 @@ declare global {
|
|
|
2830
2830
|
* Draws a Bézier curve.Bézier curves can form shapes and curves that slope gently. They're defined
|
|
2831
2831
|
* by two anchor points and two control points. Bézier curves provide more
|
|
2832
2832
|
* control than the spline curves created with the
|
|
2833
|
-
*
|
|
2833
|
+
* spline() function.The first two parameters, `x1` and `y1`, set the first anchor point. The
|
|
2834
2834
|
* first anchor point is where the curve starts.The next four parameters, `x2`, `y2`, `x3`, and `y3`, set the two control
|
|
2835
2835
|
* points. The control points "pull" the curve towards them.The seventh and eighth parameters, `x4` and `y4`, set the last anchor
|
|
2836
2836
|
* point. The last anchor point is where the curve ends.Bézier curves can also be drawn in 3D using WebGL mode. The 3D version of
|
|
@@ -2872,13 +2872,11 @@ declare global {
|
|
|
2872
2872
|
|
|
2873
2873
|
/**
|
|
2874
2874
|
* Draws a curve using a Catmull-Rom spline.Spline curves can form shapes and curves that slope gently. They’re like
|
|
2875
|
-
* cables that are attached to a set of points.
|
|
2876
|
-
*
|
|
2877
|
-
*
|
|
2878
|
-
* points
|
|
2879
|
-
*
|
|
2880
|
-
* point. This point isn’t drawn and can be thought of as the curve’s ending
|
|
2881
|
-
* point.Spline curves can also be drawn in 3D using WebGL mode. The 3D version of
|
|
2875
|
+
* cables that are attached to a set of points. By default (`ends: INCLUDE`),
|
|
2876
|
+
* the curve passes through all four points you provide, in order
|
|
2877
|
+
* `p0(x1,y1)` -> `p1(x2,y2)` -> `p2(x3,y3)` -> `p3(x4,y4)`. Think of them as
|
|
2878
|
+
* points on a curve. If you switch to `ends: EXCLUDE`, p0 and p3 act
|
|
2879
|
+
* like control points and only the middle span `p1->p2` is drawn.Spline curves can also be drawn in 3D using WebGL mode. The 3D version of
|
|
2882
2880
|
* `spline()` has twelve arguments because each point has x-, y-, and
|
|
2883
2881
|
* z-coordinates.
|
|
2884
2882
|
*/
|
|
@@ -2887,30 +2885,29 @@ declare global {
|
|
|
2887
2885
|
function spline(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, x3: number, y3: number, z3: number, x4: number, y4: number, z4: number): void;
|
|
2888
2886
|
|
|
2889
2887
|
/**
|
|
2890
|
-
* Calculates coordinates along a spline curve using interpolation.`splinePoint()` calculates coordinates along a spline curve using
|
|
2891
|
-
*
|
|
2888
|
+
* Calculates coordinates along a spline curve using interpolation.`splinePoint()` calculates coordinates along a spline curve using four
|
|
2889
|
+
* points p0, p1, p2, p3. It expects points in the same order as the
|
|
2892
2890
|
* spline() function. `splinePoint()` works one axis
|
|
2893
|
-
* at a time. Passing the
|
|
2894
|
-
* calculate the x-coordinate of a point on the curve. Passing the
|
|
2895
|
-
*
|
|
2896
|
-
* the curve.The first parameter, `a`, is the coordinate of
|
|
2897
|
-
*
|
|
2898
|
-
*
|
|
2891
|
+
* at a time. Passing the points' x-coordinates will
|
|
2892
|
+
* calculate the x-coordinate of a point on the curve. Passing the
|
|
2893
|
+
* points' y-coordinates will calculate the y-coordinate of a point on
|
|
2894
|
+
* the curve.The first parameter, `a`, is the coordinate of point p0.The second and third parameters, `b` and `c`, are the coordinates of
|
|
2895
|
+
* points p1 and p2.The fourth parameter, `d`, is the coordinate of point p3.The fifth parameter, `t`, is the amount to interpolate along the span
|
|
2896
|
+
* from p1 to p2. `t = 0` is p1, `t = 1` is p2, and `t = 0.5` is halfway
|
|
2899
2897
|
* between them.
|
|
2900
2898
|
*/
|
|
2901
2899
|
function splinePoint(a: number, b: number, c: number, d: number, t: number): number;
|
|
2902
2900
|
|
|
2903
2901
|
/**
|
|
2904
2902
|
* Calculates coordinates along a line that's tangent to a spline curve.Tangent lines skim the surface of a curve. A tangent line's slope equals
|
|
2905
|
-
* the curve's slope at the point where it intersects.`splineTangent()` calculates coordinates along a tangent line using
|
|
2906
|
-
*
|
|
2907
|
-
*
|
|
2908
|
-
*
|
|
2909
|
-
*
|
|
2910
|
-
*
|
|
2911
|
-
*
|
|
2912
|
-
*
|
|
2913
|
-
* is the first anchor point, 1 is the second anchor point, and 0.5 is halfway
|
|
2903
|
+
* the curve's slope at the point where it intersects.`splineTangent()` calculates coordinates along a tangent line using four
|
|
2904
|
+
* points p0, p1, p2, p3. It expects points in the same order as the
|
|
2905
|
+
* spline() function. `splineTangent()` works one
|
|
2906
|
+
* axis at a time. Passing the points' x-coordinates returns the x-component of
|
|
2907
|
+
* the tangent vector; passing the points' y-coordinates returns the y-component.
|
|
2908
|
+
* The first parameter, `a`, is the coordinate of point p0.The second and third parameters, `b` and `c`, are the coordinates of
|
|
2909
|
+
* points p1 and p2.The fourth parameter, `d`, is the coordinate of point p3.The fifth parameter, `t`, is the amount to interpolate along the span
|
|
2910
|
+
* from p1 to p2. `t = 0` is p1, `t = 1` is p2, and `t = 0.5` is halfway
|
|
2914
2911
|
* between them.
|
|
2915
2912
|
*/
|
|
2916
2913
|
function splineTangent(a: number, b: number, c: number, d: number, t: number): number;
|
|
@@ -2937,49 +2934,44 @@ declare global {
|
|
|
2937
2934
|
function bezierOrder(): number;
|
|
2938
2935
|
|
|
2939
2936
|
/**
|
|
2940
|
-
*
|
|
2941
|
-
* it creates
|
|
2942
|
-
*
|
|
2943
|
-
* between the
|
|
2937
|
+
* Connects points with a smooth curve (a spline).`splineVertex()` adds a curved segment to custom shapes.
|
|
2938
|
+
* The curve it creates follows the same rules as the ones
|
|
2939
|
+
* made with the spline() function.
|
|
2940
|
+
* `splineVertex()` must be called between the
|
|
2941
|
+
* beginShape() and
|
|
2944
2942
|
* endShape() functions.Spline curves can form shapes and curves that slope gently. They’re like
|
|
2945
|
-
* cables that are attached to a set of points.
|
|
2946
|
-
*
|
|
2947
|
-
* least four times between
|
|
2943
|
+
* cables that are attached to a set of points. `splineVertex()` draws a smooth
|
|
2944
|
+
* curve through the points you give it.
|
|
2948
2945
|
* beginShape() and
|
|
2949
|
-
* endShape() in order to draw a curve
|
|
2946
|
+
* endShape() in order to draw a curve:If you provide three points, the spline will pass through them.
|
|
2947
|
+
* It works the same way with any number of points.`beginShape();
|
|
2950
2948
|
*
|
|
2951
|
-
* // Add the first
|
|
2952
|
-
* splineVertex(
|
|
2949
|
+
* // Add the first point.
|
|
2950
|
+
* splineVertex(25, 80);
|
|
2953
2951
|
*
|
|
2954
|
-
* // Add the
|
|
2955
|
-
* splineVertex(
|
|
2956
|
-
* splineVertex(21, 17);
|
|
2952
|
+
* // Add the second point.
|
|
2953
|
+
* splineVertex(20, 30);
|
|
2957
2954
|
*
|
|
2958
|
-
* // Add the
|
|
2959
|
-
* splineVertex(
|
|
2955
|
+
* // Add the last point.
|
|
2956
|
+
* splineVertex(85, 60);
|
|
2960
2957
|
*
|
|
2961
|
-
* endShape();`
|
|
2962
|
-
* similar to the curve() function. The segments
|
|
2963
|
-
* between the control and anchor points can be drawn by calling
|
|
2964
|
-
* `splineVertex()` with the coordinates of the control points:`beginShape();
|
|
2958
|
+
* endShape();`Passing in `CLOSE` to `endShape()` closes the spline smoothly.`beginShape();
|
|
2965
2959
|
*
|
|
2966
|
-
* // Add the first
|
|
2967
|
-
* splineVertex(
|
|
2968
|
-
* splineVertex(84, 91);
|
|
2960
|
+
* // Add the first point.
|
|
2961
|
+
* splineVertex(25, 80);
|
|
2969
2962
|
*
|
|
2970
|
-
* // Add the
|
|
2971
|
-
* splineVertex(
|
|
2972
|
-
* splineVertex(21, 17);
|
|
2963
|
+
* // Add the second point.
|
|
2964
|
+
* splineVertex(20, 30);
|
|
2973
2965
|
*
|
|
2974
|
-
* // Add the second
|
|
2975
|
-
* splineVertex(
|
|
2966
|
+
* // Add the second point.
|
|
2967
|
+
* splineVertex(85, 60);
|
|
2976
2968
|
*
|
|
2977
|
-
*
|
|
2978
|
-
*
|
|
2979
|
-
*
|
|
2980
|
-
*
|
|
2981
|
-
*
|
|
2982
|
-
*
|
|
2969
|
+
* endShape(CLOSE);`By default (`ends: INCLUDE`), the curve passes through
|
|
2970
|
+
* all the points you add with `splineVertex()`, similar to
|
|
2971
|
+
* the spline() function. To draw only
|
|
2972
|
+
* the middle span p1->p2 (skipping p0->p1 and p2->p3), set
|
|
2973
|
+
* `splineProperty('ends', EXCLUDE)`. You don’t need to duplicate
|
|
2974
|
+
* vertices to draw those spans.Spline curves can also be drawn in 3D using WebGL mode. The 3D version of
|
|
2983
2975
|
* `splineVertex()` has three arguments because each point has x-, y-, and
|
|
2984
2976
|
* z-coordinates. By default, the vertex’s z-coordinate is set to 0.Note: `splineVertex()` won’t work when an argument is passed to
|
|
2985
2977
|
* beginShape().
|
|
@@ -2993,19 +2985,43 @@ declare global {
|
|
|
2993
2985
|
function splineVertex(x: number, y: number, z: number, u: number, v: number): void;
|
|
2994
2986
|
|
|
2995
2987
|
/**
|
|
2996
|
-
*
|
|
2997
|
-
*
|
|
2998
|
-
*
|
|
2999
|
-
*
|
|
3000
|
-
*
|
|
3001
|
-
*
|
|
3002
|
-
*
|
|
3003
|
-
*
|
|
3004
|
-
*
|
|
3005
|
-
*
|
|
3006
|
-
* (
|
|
3007
|
-
*
|
|
3008
|
-
*
|
|
2988
|
+
* Gets or sets a given spline property.Use `splineProperty()` to adjust the behavior of splines
|
|
2989
|
+
* created with `splineVertex()` or `spline()`. You can control
|
|
2990
|
+
* two key aspects of a spline: its end behavior (`ends`) and
|
|
2991
|
+
* its curvature (`tightness`).By default, the ends property is set to `INCLUDE`, which means
|
|
2992
|
+
* the spline passes through every point, including the endpoints.
|
|
2993
|
+
* You can also set it to `EXCLUDE` i.e. `splineProperty('ends', EXCLUDE)`,
|
|
2994
|
+
* which makes the spline pass through all points except the endpoints.`INCLUDE` case will have the spline passing through
|
|
2995
|
+
* all points, like this:`splineProperty('ends', INCLUDE); // no need to set this, as it is the default
|
|
2996
|
+
* spline(25, 46, 93, 44, 93, 81, 35, 85);
|
|
2997
|
+
*
|
|
2998
|
+
* point(25, 46);
|
|
2999
|
+
* point(93, 44);
|
|
3000
|
+
* point(93, 81);
|
|
3001
|
+
* point(35, 85);`EXCLUDE case will have the spline passing through
|
|
3002
|
+
* the middle points, like this:`splineProperty('ends', INCLUDE);
|
|
3003
|
+
* spline(25, 46, 93, 44, 93, 81, 35, 85);
|
|
3004
|
+
*
|
|
3005
|
+
* point(25, 46);
|
|
3006
|
+
* point(93, 44);
|
|
3007
|
+
* point(93, 81);
|
|
3008
|
+
* point(35, 85);`By default, the tightness property is set to `0`,
|
|
3009
|
+
* producing a smooth curve that passes evenly through
|
|
3010
|
+
* the vertices. Negative values make the curve looser,
|
|
3011
|
+
* while positive values make it tighter. Common values
|
|
3012
|
+
* range between -1 and 1, though values outside this
|
|
3013
|
+
* range can also be used for different effects.For example, To set tightness, use `splineProperty('tightness', t)`,
|
|
3014
|
+
* (default: t = 0).Here's the example showing negetive value of tightness,
|
|
3015
|
+
* which creates a rounder bulge:`splineProperty('tightness', -5)
|
|
3016
|
+
* stroke(0);
|
|
3017
|
+
* strokeWeight(2);
|
|
3018
|
+
* spline(25, 46, 93, 44, 93, 81, 35, 85);`Here's the example showing positive value of tightness,
|
|
3019
|
+
* which makes the curve tighter and more angular:`splineProperty('tightness', 5)
|
|
3020
|
+
* stroke(0);
|
|
3021
|
+
* strokeWeight(2);
|
|
3022
|
+
* spline(25, 46, 93, 44, 93, 81, 35, 85);`In all cases, the splines in p5.js are cardinal splines.
|
|
3023
|
+
* When tightness is 0, these splines are often known as
|
|
3024
|
+
* Catmull-Rom splines
|
|
3009
3025
|
*/
|
|
3010
3026
|
function splineProperty(property: string, value: any): void;
|
|
3011
3027
|
|