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.
Files changed (79) hide show
  1. package/README.md +1 -1
  2. package/dist/accessibility/color_namer.js +4 -4
  3. package/dist/accessibility/index.js +4 -4
  4. package/dist/accessibility/outputs.js +1 -1
  5. package/dist/app.js +4 -4
  6. package/dist/color/color_conversion.js +4 -4
  7. package/dist/color/index.js +1 -1
  8. package/dist/color/setting.js +1 -1
  9. package/dist/{constants-C2DVjshm.js → constants-8IpwyBct.js} +1 -1
  10. package/dist/core/constants.js +1 -1
  11. package/dist/core/environment.js +1 -1
  12. package/dist/core/friendly_errors/fes_core.js +1 -1
  13. package/dist/core/friendly_errors/index.js +1 -1
  14. package/dist/core/friendly_errors/param_validator.js +1 -1
  15. package/dist/core/friendly_errors/sketch_verifier.js +1 -1
  16. package/dist/core/helpers.js +1 -1
  17. package/dist/core/init.js +4 -4
  18. package/dist/core/legacy.js +4 -4
  19. package/dist/core/main.js +4 -4
  20. package/dist/core/p5.Graphics.js +3 -3
  21. package/dist/core/p5.Renderer.js +2 -2
  22. package/dist/core/p5.Renderer2D.js +4 -4
  23. package/dist/core/rendering.js +3 -3
  24. package/dist/dom/dom.js +1 -1
  25. package/dist/dom/index.js +1 -1
  26. package/dist/dom/p5.Element.js +1 -1
  27. package/dist/dom/p5.MediaElement.js +1 -1
  28. package/dist/image/const.js +1 -1
  29. package/dist/image/filterRenderer2D.js +3 -3
  30. package/dist/image/image.js +3 -3
  31. package/dist/image/index.js +3 -3
  32. package/dist/image/loading_displaying.js +3 -3
  33. package/dist/image/p5.Image.js +2 -2
  34. package/dist/io/files.js +3 -3
  35. package/dist/io/index.js +3 -3
  36. package/dist/{main-rEhlsQtb.js → main-B3Z63C6j.js} +3 -3
  37. package/dist/math/Matrices/Matrix.js +1 -1
  38. package/dist/math/Matrices/MatrixNumjs.js +1 -1
  39. package/dist/math/index.js +1 -1
  40. package/dist/math/p5.Matrix.js +1 -1
  41. package/dist/math/p5.Vector.js +1 -1
  42. package/dist/math/trigonometry.js +1 -1
  43. package/dist/{p5.Renderer-DO9wIL55.js → p5.Renderer-DoDzbpcT.js} +1 -1
  44. package/dist/{rendering-CpHn8PfG.js → rendering-BELwvfI6.js} +3 -3
  45. package/dist/shape/2d_primitives.js +1 -1
  46. package/dist/shape/attributes.js +1 -1
  47. package/dist/shape/curves.js +143 -74
  48. package/dist/shape/custom_shapes.js +261 -277
  49. package/dist/shape/index.js +1 -1
  50. package/dist/type/index.js +2 -2
  51. package/dist/type/p5.Font.js +2 -2
  52. package/dist/type/textCore.js +2 -2
  53. package/dist/webgl/3d_primitives.js +3 -3
  54. package/dist/webgl/GeometryBuilder.js +1 -1
  55. package/dist/webgl/ShaderGenerator.js +10 -7
  56. package/dist/webgl/ShapeBuilder.js +1 -1
  57. package/dist/webgl/index.js +3 -3
  58. package/dist/webgl/interaction.js +1 -1
  59. package/dist/webgl/light.js +3 -3
  60. package/dist/webgl/loading.js +3 -3
  61. package/dist/webgl/material.js +3 -3
  62. package/dist/webgl/p5.Camera.js +3 -3
  63. package/dist/webgl/p5.Framebuffer.js +3 -3
  64. package/dist/webgl/p5.Geometry.js +1 -1
  65. package/dist/webgl/p5.Quat.js +1 -1
  66. package/dist/webgl/p5.RendererGL.js +3 -3
  67. package/dist/webgl/p5.Shader.js +3 -3
  68. package/dist/webgl/p5.Texture.js +3 -3
  69. package/dist/webgl/text.js +3 -3
  70. package/lib/p5.esm.js +414 -358
  71. package/lib/p5.esm.min.js +1 -1
  72. package/lib/p5.js +414 -358
  73. package/lib/p5.min.js +1 -1
  74. package/package.json +1 -1
  75. package/types/core/main.d.ts +87 -71
  76. package/types/global.d.ts +87 -71
  77. package/types/p5.d.ts +87 -71
  78. package/types/shape/curves.d.ts +130 -56
  79. package/types/shape/custom_shapes.d.ts +188 -252
package/types/p5.d.ts CHANGED
@@ -3456,7 +3456,7 @@ declare class p5 {
3456
3456
  * Draws a Bézier curve.Bézier curves can form shapes and curves that slope gently. They're defined
3457
3457
  * by two anchor points and two control points. Bézier curves provide more
3458
3458
  * control than the spline curves created with the
3459
- * curve() function.The first two parameters, `x1` and `y1`, set the first anchor point. The
3459
+ * spline() function.The first two parameters, `x1` and `y1`, set the first anchor point. The
3460
3460
  * first anchor point is where the curve starts.The next four parameters, `x2`, `y2`, `x3`, and `y3`, set the two control
3461
3461
  * points. The control points "pull" the curve towards them.The seventh and eighth parameters, `x4` and `y4`, set the last anchor
3462
3462
  * 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
@@ -3519,13 +3519,11 @@ declare class p5 {
3519
3519
 
3520
3520
  /**
3521
3521
  * Draws a curve using a Catmull-Rom spline.Spline curves can form shapes and curves that slope gently. They’re like
3522
- * cables that are attached to a set of points. Splines are defined by two
3523
- * anchor points and two control points.The first two parameters, `x1` and `y1`, set the first control point. This
3524
- * point isn’t drawn and can be thought of as the curve’s starting point.The next four parameters, `x2`, `y2`, `x3`, and `y3`, set the two anchor
3525
- * points. The anchor points are the start and end points of the curve’s
3526
- * visible segment.The seventh and eighth parameters, `x4` and `y4`, set the last control
3527
- * point. This point isn’t drawn and can be thought of as the curve’s ending
3528
- * point.Spline curves can also be drawn in 3D using WebGL mode. The 3D version of
3522
+ * cables that are attached to a set of points. By default (`ends: INCLUDE`),
3523
+ * the curve passes through all four points you provide, in order
3524
+ * `p0(x1,y1)` -> `p1(x2,y2)` -> `p2(x3,y3)` -> `p3(x4,y4)`. Think of them as
3525
+ * points on a curve. If you switch to `ends: EXCLUDE`, p0 and p3 act
3526
+ * 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
3529
3527
  * `spline()` has twelve arguments because each point has x-, y-, and
3530
3528
  * z-coordinates.
3531
3529
  *
@@ -3543,15 +3541,15 @@ declare class p5 {
3543
3541
  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;
3544
3542
 
3545
3543
  /**
3546
- * Calculates coordinates along a spline curve using interpolation.`splinePoint()` calculates coordinates along a spline curve using the
3547
- * anchor and control points. It expects points in the same order as the
3544
+ * Calculates coordinates along a spline curve using interpolation.`splinePoint()` calculates coordinates along a spline curve using four
3545
+ * points p0, p1, p2, p3. It expects points in the same order as the
3548
3546
  * spline() function. `splinePoint()` works one axis
3549
- * at a time. Passing the anchor and control points' x-coordinates will
3550
- * calculate the x-coordinate of a point on the curve. Passing the anchor and
3551
- * control points' y-coordinates will calculate the y-coordinate of a point on
3552
- * the curve.The first parameter, `a`, is the coordinate of the first control point.The second and third parameters, `b` and `c`, are the coordinates of the
3553
- * anchor points.The fourth parameter, `d`, is the coordinate of the last control point.The fifth parameter, `t`, is the amount to interpolate along the curve. 0
3554
- * is the first anchor point, 1 is the second anchor point, and 0.5 is halfway
3547
+ * at a time. Passing the points' x-coordinates will
3548
+ * calculate the x-coordinate of a point on the curve. Passing the
3549
+ * points' y-coordinates will calculate the y-coordinate of a point on
3550
+ * the curve.The first parameter, `a`, is the coordinate of point p0.The second and third parameters, `b` and `c`, are the coordinates of
3551
+ * 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
3552
+ * from p1 to p2. `t = 0` is p1, `t = 1` is p2, and `t = 0.5` is halfway
3555
3553
  * between them.
3556
3554
  *
3557
3555
  * @param
@@ -3564,15 +3562,14 @@ declare class p5 {
3564
3562
 
3565
3563
  /**
3566
3564
  * 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
3567
- * the curve's slope at the point where it intersects.`splineTangent()` calculates coordinates along a tangent line using the
3568
- * spline curve's anchor and control points. It expects points in the same
3569
- * order as the spline() function. `splineTangent()`
3570
- * works one axis at a time. Passing the anchor and control points'
3571
- * x-coordinates will calculate the x-coordinate of a point on the tangent
3572
- * line. Passing the anchor and control points' y-coordinates will calculate
3573
- * the y-coordinate of a point on the tangent line.The first parameter, `a`, is the coordinate of the first control point.The second and third parameters, `b` and `c`, are the coordinates of the
3574
- * anchor points.The fourth parameter, `d`, is the coordinate of the last control point.The fifth parameter, `t`, is the amount to interpolate along the curve. 0
3575
- * is the first anchor point, 1 is the second anchor point, and 0.5 is halfway
3565
+ * the curve's slope at the point where it intersects.`splineTangent()` calculates coordinates along a tangent line using four
3566
+ * points p0, p1, p2, p3. It expects points in the same order as the
3567
+ * spline() function. `splineTangent()` works one
3568
+ * axis at a time. Passing the points' x-coordinates returns the x-component of
3569
+ * the tangent vector; passing the points' y-coordinates returns the y-component.
3570
+ * The first parameter, `a`, is the coordinate of point p0.The second and third parameters, `b` and `c`, are the coordinates of
3571
+ * 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
3572
+ * from p1 to p2. `t = 0` is p1, `t = 1` is p2, and `t = 0.5` is halfway
3576
3573
  * between them.
3577
3574
  *
3578
3575
  * @param
@@ -3607,49 +3604,44 @@ declare class p5 {
3607
3604
  bezierOrder(): number;
3608
3605
 
3609
3606
  /**
3610
- * Adds a spline curve segment to a custom shape.`splineVertex()` adds a curved segment to custom shapes. The spline curves
3611
- * it creates are defined like those made by the
3612
- * curve() function. `splineVertex()` must be called
3613
- * between the beginShape() and
3607
+ * Connects points with a smooth curve (a spline).`splineVertex()` adds a curved segment to custom shapes.
3608
+ * The curve it creates follows the same rules as the ones
3609
+ * made with the spline() function.
3610
+ * `splineVertex()` must be called between the
3611
+ * beginShape() and
3614
3612
  * endShape() functions.Spline curves can form shapes and curves that slope gently. They’re like
3615
- * cables that are attached to a set of points. Splines are defined by two
3616
- * anchor points and two control points. `splineVertex()` must be called at
3617
- * least four times between
3613
+ * cables that are attached to a set of points. `splineVertex()` draws a smooth
3614
+ * curve through the points you give it.
3618
3615
  * beginShape() and
3619
- * endShape() in order to draw a curve:`beginShape();
3616
+ * endShape() in order to draw a curve:If you provide three points, the spline will pass through them.
3617
+ * It works the same way with any number of points.`beginShape();
3620
3618
  *
3621
- * // Add the first control point.
3622
- * splineVertex(84, 91);
3619
+ * // Add the first point.
3620
+ * splineVertex(25, 80);
3623
3621
  *
3624
- * // Add the anchor points to draw between.
3625
- * splineVertex(68, 19);
3626
- * splineVertex(21, 17);
3622
+ * // Add the second point.
3623
+ * splineVertex(20, 30);
3627
3624
  *
3628
- * // Add the second control point.
3629
- * splineVertex(32, 91);
3625
+ * // Add the last point.
3626
+ * splineVertex(85, 60);
3630
3627
  *
3631
- * endShape();`The code snippet above would only draw the curve between the anchor points,
3632
- * similar to the curve() function. The segments
3633
- * between the control and anchor points can be drawn by calling
3634
- * `splineVertex()` with the coordinates of the control points:`beginShape();
3628
+ * endShape();`Passing in `CLOSE` to `endShape()` closes the spline smoothly.`beginShape();
3635
3629
  *
3636
- * // Add the first control point and draw a segment to it.
3637
- * splineVertex(84, 91);
3638
- * splineVertex(84, 91);
3630
+ * // Add the first point.
3631
+ * splineVertex(25, 80);
3639
3632
  *
3640
- * // Add the anchor points to draw between.
3641
- * splineVertex(68, 19);
3642
- * splineVertex(21, 17);
3633
+ * // Add the second point.
3634
+ * splineVertex(20, 30);
3643
3635
  *
3644
- * // Add the second control point.
3645
- * splineVertex(32, 91);
3636
+ * // Add the second point.
3637
+ * splineVertex(85, 60);
3646
3638
  *
3647
- * // Uncomment the next line to draw the segment to the second control point.
3648
- * // splineVertex(32, 91);
3649
- *
3650
- * endShape();`The first two parameters, `x` and `y`, set the vertex’s location. For
3651
- * example, calling `splineVertex(10, 10)` adds a point to the curve at
3652
- * `(10, 10)`.Spline curves can also be drawn in 3D using WebGL mode. The 3D version of
3639
+ * endShape(CLOSE);`By default (`ends: INCLUDE`), the curve passes through
3640
+ * all the points you add with `splineVertex()`, similar to
3641
+ * the spline() function. To draw only
3642
+ * the middle span p1->p2 (skipping p0->p1 and p2->p3), set
3643
+ * `splineProperty('ends', EXCLUDE)`. You don’t need to duplicate
3644
+ * vertices to draw those spans.Spline curves can also be drawn in 3D using WebGL mode. The 3D version of
3653
3645
  * `splineVertex()` has three arguments because each point has x-, y-, and
3654
3646
  * z-coordinates. By default, the vertex’s z-coordinate is set to 0.Note: `splineVertex()` won’t work when an argument is passed to
3655
3647
  * beginShape().
@@ -3666,19 +3658,43 @@ declare class p5 {
3666
3658
  splineVertex(x: number, y: number, z: number, u: number, v: number): void;
3667
3659
 
3668
3660
  /**
3669
- * Sets the property of a curve.For example, set tightness,
3670
- * use `splineProperty('tightness', t)`, with `t` between 0 and 1,
3671
- * at 0 as default.Spline curves are like cables that are attached to a set of points.
3672
- * Adjusting tightness adjusts how tightly the cable is
3673
- * attached to the points. The parameter, tightness, determines
3674
- * how the curve fits to the vertex points. By default,
3675
- * tightness is set to 0. Setting tightness to 1, as in
3676
- * `splineProperty('tightness', 1)`, connects the curve's points
3677
- * using straight lines. Values in the range from –5 to 5
3678
- * deform curves while leaving them recognizable.This function can also be used to set 'ends' property
3679
- * (see also: the curveDetail() example),
3680
- * such as: `splineProperty('ends', EXCLUDE)` to exclude
3681
- * vertices, or `splineProperty('ends', INCLUDE)` to include them.
3661
+ * Gets or sets a given spline property.Use `splineProperty()` to adjust the behavior of splines
3662
+ * created with `splineVertex()` or `spline()`. You can control
3663
+ * two key aspects of a spline: its end behavior (`ends`) and
3664
+ * its curvature (`tightness`).By default, the ends property is set to `INCLUDE`, which means
3665
+ * the spline passes through every point, including the endpoints.
3666
+ * You can also set it to `EXCLUDE` i.e. `splineProperty('ends', EXCLUDE)`,
3667
+ * which makes the spline pass through all points except the endpoints.`INCLUDE` case will have the spline passing through
3668
+ * all points, like this:`splineProperty('ends', INCLUDE); // no need to set this, as it is the default
3669
+ * spline(25, 46, 93, 44, 93, 81, 35, 85);
3670
+ *
3671
+ * point(25, 46);
3672
+ * point(93, 44);
3673
+ * point(93, 81);
3674
+ * point(35, 85);`EXCLUDE case will have the spline passing through
3675
+ * the middle points, like this:`splineProperty('ends', INCLUDE);
3676
+ * spline(25, 46, 93, 44, 93, 81, 35, 85);
3677
+ *
3678
+ * point(25, 46);
3679
+ * point(93, 44);
3680
+ * point(93, 81);
3681
+ * point(35, 85);`By default, the tightness property is set to `0`,
3682
+ * producing a smooth curve that passes evenly through
3683
+ * the vertices. Negative values make the curve looser,
3684
+ * while positive values make it tighter. Common values
3685
+ * range between -1 and 1, though values outside this
3686
+ * range can also be used for different effects.For example, To set tightness, use `splineProperty('tightness', t)`,
3687
+ * (default: t = 0).Here's the example showing negetive value of tightness,
3688
+ * which creates a rounder bulge:`splineProperty('tightness', -5)
3689
+ * stroke(0);
3690
+ * strokeWeight(2);
3691
+ * spline(25, 46, 93, 44, 93, 81, 35, 85);`Here's the example showing positive value of tightness,
3692
+ * which makes the curve tighter and more angular:`splineProperty('tightness', 5)
3693
+ * stroke(0);
3694
+ * strokeWeight(2);
3695
+ * spline(25, 46, 93, 44, 93, 81, 35, 85);`In all cases, the splines in p5.js are cardinal splines.
3696
+ * When tightness is 0, these splines are often known as
3697
+ * Catmull-Rom splines
3682
3698
  *
3683
3699
  * @param
3684
3700
  * @param
@@ -7,7 +7,7 @@ declare module 'p5' {
7
7
  * Draws a Bézier curve.Bézier curves can form shapes and curves that slope gently. They're defined
8
8
  * by two anchor points and two control points. Bézier curves provide more
9
9
  * control than the spline curves created with the
10
- * curve() function.The first two parameters, `x1` and `y1`, set the first anchor point. The
10
+ * spline() function.The first two parameters, `x1` and `y1`, set the first anchor point. The
11
11
  * first anchor point is where the curve starts.The next four parameters, `x2`, `y2`, `x3`, and `y3`, set the two control
12
12
  * points. The control points "pull" the curve towards them.The seventh and eighth parameters, `x4` and `y4`, set the last anchor
13
13
  * 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
@@ -374,49 +374,72 @@ function bezierTangent(a: number, b: number, c: number, d: number, t: number): n
374
374
 
375
375
  /**
376
376
  * Draws a curve using a Catmull-Rom spline.Spline curves can form shapes and curves that slope gently. They’re like
377
- * cables that are attached to a set of points. Splines are defined by two
378
- * anchor points and two control points.The first two parameters, `x1` and `y1`, set the first control point. This
379
- * point isn’t drawn and can be thought of as the curve’s starting point.The next four parameters, `x2`, `y2`, `x3`, and `y3`, set the two anchor
380
- * points. The anchor points are the start and end points of the curve’s
381
- * visible segment.The seventh and eighth parameters, `x4` and `y4`, set the last control
382
- * point. This point isn’t drawn and can be thought of as the curve’s ending
383
- * point.Spline curves can also be drawn in 3D using WebGL mode. The 3D version of
377
+ * cables that are attached to a set of points. By default (`ends: INCLUDE`),
378
+ * the curve passes through all four points you provide, in order
379
+ * `p0(x1,y1)` -> `p1(x2,y2)` -> `p2(x3,y3)` -> `p3(x4,y4)`. Think of them as
380
+ * points on a curve. If you switch to `ends: EXCLUDE`, p0 and p3 act
381
+ * 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
384
382
  * `spline()` has twelve arguments because each point has x-, y-, and
385
383
  * z-coordinates.
386
384
  *
387
- * @param x-coordinate of the first control point.
388
- * @param y-coordinate of the first control point.
389
- * @param x-coordinate of the first anchor point.
390
- * @param y-coordinate of the first anchor point.
391
- * @param x-coordinate of the second anchor point.
392
- * @param y-coordinate of the second anchor point.
393
- * @param x-coordinate of the second control point.
394
- * @param y-coordinate of the second control point.
385
+ * @param x-coordinate of point p0.
386
+ * @param y-coordinate of point p0.
387
+ * @param x-coordinate of point p1.
388
+ * @param y-coordinate of point p1.
389
+ * @param x-coordinate of point p2.
390
+ * @param y-coordinate of point p2.
391
+ * @param x-coordinate of point p3.
392
+ * @param y-coordinate of point p3.
395
393
  * @example <div>
396
394
  * <code>
397
395
  * function setup() {
396
+ * createCanvas(200, 200);
397
+ * background(240);
398
+ * noFill();
399
+ *
400
+ * stroke(0);
401
+ * strokeWeight(2);
402
+ * spline(40, 60, 100, 40, 120, 120, 60, 140);
403
+ *
404
+ * strokeWeight(5);
405
+ * point(40, 60);
406
+ * point(100, 40);
407
+ * point(120, 120);
408
+ * point(60, 140);
409
+ *
410
+ * describe('A black spline passes smoothly through four points');
411
+ * }
412
+ * </code>
413
+ * </div>
414
+ *
415
+ * <div>
416
+ * <code>
417
+ * function setup() {
398
418
  * createCanvas(100, 100);
399
419
  *
400
420
  * background(200);
401
421
  *
422
+ * // Exclude the ends—skip the outer spans (p0→p1 and p2→p3) so only the middle span (p1→p2) is drawn.
423
+ * splineProperty('ends', EXCLUDE);
424
+ *
402
425
  * // Draw a black spline curve.
403
426
  * noFill();
404
427
  * strokeWeight(1);
405
428
  * stroke(0);
406
429
  * spline(5, 26, 73, 24, 73, 61, 15, 65);
407
430
  *
408
- * // Draw red spline curves from the anchor points to the control points.
431
+ * // Draw red spline curves from the points.
409
432
  * stroke(255, 0, 0);
410
433
  * spline(5, 26, 5, 26, 73, 24, 73, 61);
411
434
  * spline(73, 24, 73, 61, 15, 65, 15, 65);
412
435
  *
413
- * // Draw the anchor points in black.
436
+ * // Draw the points in black.
414
437
  * strokeWeight(5);
415
438
  * stroke(0);
416
439
  * point(73, 24);
417
440
  * point(73, 61);
418
441
  *
419
- * // Draw the control points in red.
442
+ * // Draw the points in red.
420
443
  * stroke(255, 0, 0);
421
444
  * point(5, 26);
422
445
  * point(15, 65);
@@ -445,13 +468,16 @@ function bezierTangent(a: number, b: number, c: number, d: number, t: number): n
445
468
  * function draw() {
446
469
  * background(200);
447
470
  *
471
+ * // Exclude the ends—skip the outer spans (p0→p1 and p2→p3) so only the middle span (p1→p2) is drawn.
472
+ * splineProperty('ends', EXCLUDE);
473
+ *
448
474
  * // Draw a black spline curve.
449
475
  * noFill();
450
476
  * strokeWeight(1);
451
477
  * stroke(0);
452
478
  * spline(x1, y1, 73, 24, 73, 61, 15, 65);
453
479
  *
454
- * // Draw red spline curves from the anchor points to the control points.
480
+ * // Draw red spline curves from the points.
455
481
  * stroke(255, 0, 0);
456
482
  * spline(x1, y1, x1, y1, 73, 24, 73, 61);
457
483
  * spline(73, 24, 73, 61, 15, 65, 15, 65);
@@ -462,25 +488,25 @@ function bezierTangent(a: number, b: number, c: number, d: number, t: number): n
462
488
  * point(73, 24);
463
489
  * point(73, 61);
464
490
  *
465
- * // Draw the control points in red.
491
+ * // Draw the points in red.
466
492
  * stroke(255, 0, 0);
467
493
  * point(x1, y1);
468
494
  * point(15, 65);
469
495
  * }
470
496
  *
471
- * // Start changing the first control point if the user clicks near it.
497
+ * // Start changing the first point if the user clicks near it.
472
498
  * function mousePressed() {
473
499
  * if (dist(mouseX, mouseY, x1, y1) < 20) {
474
500
  * isChanging = true;
475
501
  * }
476
502
  * }
477
503
  *
478
- * // Stop changing the first control point when the user releases the mouse.
504
+ * // Stop changing the first point when the user releases the mouse.
479
505
  * function mouseReleased() {
480
506
  * isChanging = false;
481
507
  * }
482
508
  *
483
- * // Update the first control point while the user drags the mouse.
509
+ * // Update the first point while the user drags the mouse.
484
510
  * function mouseDragged() {
485
511
  * if (isChanging === true) {
486
512
  * x1 = mouseX;
@@ -497,6 +523,9 @@ function bezierTangent(a: number, b: number, c: number, d: number, t: number): n
497
523
  *
498
524
  * background('skyblue');
499
525
  *
526
+ * // Exclude the ends—skip the outer spans (p0→p1 and p2→p3) so only the middle span (p1→p2) is drawn.
527
+ * splineProperty('ends', EXCLUDE);
528
+ *
500
529
  * // Draw the red balloon.
501
530
  * fill('red');
502
531
  * spline(-150, 275, 50, 60, 50, 60, 250, 275);
@@ -520,6 +549,9 @@ function bezierTangent(a: number, b: number, c: number, d: number, t: number): n
520
549
  * function draw() {
521
550
  * background('skyblue');
522
551
  *
552
+ * // Exclude the ends—skip the outer spans (p0→p1 and p2→p3) so only the middle span (p1→p2) is drawn.
553
+ * splineProperty('ends', EXCLUDE);
554
+ *
523
555
  * // Rotate around the y-axis.
524
556
  * rotateY(frameCount * 0.01);
525
557
  *
@@ -536,29 +568,29 @@ function bezierTangent(a: number, b: number, c: number, d: number, t: number): n
536
568
  function spline(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): void;
537
569
 
538
570
  /**
539
- * @param z-coordinate of the first control point.
540
- * @param z-coordinate of the first anchor point.
541
- * @param z-coordinate of the second anchor point.
542
- * @param z-coordinate of the second control point.
571
+ * @param z-coordinate of point p0.
572
+ * @param z-coordinate of point p1.
573
+ * @param z-coordinate of point p2.
574
+ * @param z-coordinate of point p3.
543
575
  */
544
576
  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;
545
577
 
546
578
  /**
547
- * Calculates coordinates along a spline curve using interpolation.`splinePoint()` calculates coordinates along a spline curve using the
548
- * anchor and control points. It expects points in the same order as the
579
+ * Calculates coordinates along a spline curve using interpolation.`splinePoint()` calculates coordinates along a spline curve using four
580
+ * points p0, p1, p2, p3. It expects points in the same order as the
549
581
  * spline() function. `splinePoint()` works one axis
550
- * at a time. Passing the anchor and control points' x-coordinates will
551
- * calculate the x-coordinate of a point on the curve. Passing the anchor and
552
- * control points' y-coordinates will calculate the y-coordinate of a point on
553
- * the curve.The first parameter, `a`, is the coordinate of the first control point.The second and third parameters, `b` and `c`, are the coordinates of the
554
- * anchor points.The fourth parameter, `d`, is the coordinate of the last control point.The fifth parameter, `t`, is the amount to interpolate along the curve. 0
555
- * is the first anchor point, 1 is the second anchor point, and 0.5 is halfway
582
+ * at a time. Passing the points' x-coordinates will
583
+ * calculate the x-coordinate of a point on the curve. Passing the
584
+ * points' y-coordinates will calculate the y-coordinate of a point on
585
+ * the curve.The first parameter, `a`, is the coordinate of point p0.The second and third parameters, `b` and `c`, are the coordinates of
586
+ * 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
587
+ * from p1 to p2. `t = 0` is p1, `t = 1` is p2, and `t = 0.5` is halfway
556
588
  * between them.
557
589
  *
558
- * @param coordinate of first control point.
559
- * @param coordinate of first anchor point.
560
- * @param coordinate of second anchor point.
561
- * @param coordinate of second control point.
590
+ * @param coordinate of point p0.
591
+ * @param coordinate of point p1.
592
+ * @param coordinate of point p2.
593
+ * @param coordinate of point p3.
562
594
  * @param amount to interpolate between 0 and 1.
563
595
  * @return coordinate of a point on the curve.
564
596
  * @example <div>
@@ -568,7 +600,7 @@ function spline(x1: number, y1: number, z1: number, x2: number, y2: number, z2:
568
600
  *
569
601
  * background(200);
570
602
  *
571
- * // Set the coordinates for the curve's anchor and control points.
603
+ * // Set the coordinates for the curve's four points (p0, p1, p2, p3).
572
604
  * let x1 = 5;
573
605
  * let y1 = 26;
574
606
  * let x2 = 73;
@@ -616,7 +648,7 @@ function spline(x1: number, y1: number, z1: number, x2: number, y2: number, z2:
616
648
  * function draw() {
617
649
  * background(200);
618
650
  *
619
- * // Set the coordinates for the curve's anchor and control points.
651
+ * // Set the coordinates for the curve's four points (p0, p1, p2, p3).
620
652
  * let x1 = 5;
621
653
  * let y1 = 26;
622
654
  * let x2 = 73;
@@ -646,31 +678,73 @@ function splinePoint(a: number, b: number, c: number, d: number, t: number): num
646
678
 
647
679
  /**
648
680
  * 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
649
- * the curve's slope at the point where it intersects.`splineTangent()` calculates coordinates along a tangent line using the
650
- * spline curve's anchor and control points. It expects points in the same
651
- * order as the spline() function. `splineTangent()`
652
- * works one axis at a time. Passing the anchor and control points'
653
- * x-coordinates will calculate the x-coordinate of a point on the tangent
654
- * line. Passing the anchor and control points' y-coordinates will calculate
655
- * the y-coordinate of a point on the tangent line.The first parameter, `a`, is the coordinate of the first control point.The second and third parameters, `b` and `c`, are the coordinates of the
656
- * anchor points.The fourth parameter, `d`, is the coordinate of the last control point.The fifth parameter, `t`, is the amount to interpolate along the curve. 0
657
- * is the first anchor point, 1 is the second anchor point, and 0.5 is halfway
681
+ * the curve's slope at the point where it intersects.`splineTangent()` calculates coordinates along a tangent line using four
682
+ * points p0, p1, p2, p3. It expects points in the same order as the
683
+ * spline() function. `splineTangent()` works one
684
+ * axis at a time. Passing the points' x-coordinates returns the x-component of
685
+ * the tangent vector; passing the points' y-coordinates returns the y-component.
686
+ * The first parameter, `a`, is the coordinate of point p0.The second and third parameters, `b` and `c`, are the coordinates of
687
+ * 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
688
+ * from p1 to p2. `t = 0` is p1, `t = 1` is p2, and `t = 0.5` is halfway
658
689
  * between them.
659
690
  *
660
- * @param coordinate of first control point.
661
- * @param coordinate of first anchor point.
662
- * @param coordinate of second anchor point.
663
- * @param coordinate of second control point.
691
+ * @param coordinate of point p0.
692
+ * @param coordinate of point p1.
693
+ * @param coordinate of point p2.
694
+ * @param coordinate of point p3.
664
695
  * @param amount to interpolate between 0 and 1.
665
696
  * @return coordinate of a point on the tangent line.
666
697
  * @example <div>
667
698
  * <code>
668
699
  * function setup() {
700
+ * createCanvas(120, 120);
701
+ * describe('A black spline on a gray canvas. A red dot moves along the curve on its own. A short line shows the tangent direction at the dot.');
702
+ * }
703
+ *
704
+ * function draw() {
705
+ * background(240);
706
+ *
707
+ * const x1 = 15, y1 = 40;
708
+ * const x2 = 90, y2 = 25;
709
+ * const x3 = 95, y3 = 95;
710
+ * const x4 = 30, y4 = 110;
711
+ *
712
+ * noFill();
713
+ * stroke(0);
714
+ * strokeWeight(2);
715
+ * spline(x1, y1, x2, y2, x3, y3, x4, y4);
716
+ *
717
+ * const t = 0.5 + 0.5 * sin(frameCount * 0.03);
718
+ *
719
+ * const px = splinePoint(x1, x2, x3, x4, t);
720
+ * const py = splinePoint(y1, y2, y3, y4, t);
721
+ *
722
+ * let tx = splineTangent(x1, x2, x3, x4, t);
723
+ * let ty = splineTangent(y1, y2, y3, y4, t);
724
+ *
725
+ * const m = Math.hypot(tx, ty) || 1;
726
+ * tx = (tx / m) * 16;
727
+ * ty = (ty / m) * 16;
728
+ *
729
+ * stroke(0);
730
+ * strokeWeight(2);
731
+ * line(px, py, px + tx, py + ty);
732
+ *
733
+ * noStroke();
734
+ * fill('red');
735
+ * circle(px, py, 7);
736
+ * }
737
+ * </code>
738
+ * </div>
739
+ *
740
+ * <div>
741
+ * <code>
742
+ * function setup() {
669
743
  * createCanvas(100, 100);
670
744
  *
671
745
  * background(200);
672
746
  *
673
- * // Set the coordinates for the curve's anchor and control points.
747
+ * // Set the coordinates for the curve's four points (p0, p1, p2, p3).
674
748
  * let x1 = 5;
675
749
  * let y1 = 26;
676
750
  * let x2 = 73;