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/lib/p5.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! p5.js v2.0.4 August 5, 2025 */
1
+ /*! p5.js v2.0.5 September 1, 2025 */
2
2
  /**
3
3
  * @module Constants
4
4
  * @submodule Constants
@@ -12,7 +12,7 @@ const _PI = Math.PI;
12
12
  * @property {String} VERSION
13
13
  * @final
14
14
  */
15
- const VERSION = '2.0.4';
15
+ const VERSION = '2.0.5';
16
16
 
17
17
  // GRAPHICS RENDERER
18
18
  /**
@@ -25128,67 +25128,73 @@ function customShapes(p5, fn) {
25128
25128
  };
25129
25129
 
25130
25130
 
25131
+
25131
25132
  /**
25132
- * Adds a spline curve segment to a custom shape.
25133
+ * Connects points with a smooth curve (a spline).
25133
25134
  *
25134
- * `splineVertex()` adds a curved segment to custom shapes. The spline curves
25135
- * it creates are defined like those made by the
25136
- * <a href="#/p5/curve">curve()</a> function. `splineVertex()` must be called
25137
- * between the <a href="#/p5/beginShape">beginShape()</a> and
25135
+ * `splineVertex()` adds a curved segment to custom shapes.
25136
+ * The curve it creates follows the same rules as the ones
25137
+ * made with the <a href="#/p5/spline">spline()</a> function.
25138
+ * `splineVertex()` must be called between the
25139
+ * <a href="#/p5/beginShape">beginShape()</a> and
25138
25140
  * <a href="#/p5/endShape">endShape()</a> functions.
25139
25141
  *
25140
25142
  * Spline curves can form shapes and curves that slope gently. They’re like
25141
- * cables that are attached to a set of points. Splines are defined by two
25142
- * anchor points and two control points. `splineVertex()` must be called at
25143
- * least four times between
25143
+ * cables that are attached to a set of points. `splineVertex()` draws a smooth
25144
+ * curve through the points you give it.
25144
25145
  * <a href="#/p5/beginShape">beginShape()</a> and
25145
25146
  * <a href="#/p5/endShape">endShape()</a> in order to draw a curve:
25146
25147
  *
25148
+ *
25149
+ * If you provide three points, the spline will pass through them.
25150
+ * It works the same way with any number of points.
25151
+ *
25152
+ *
25153
+ *
25147
25154
  * ```js
25148
25155
  * beginShape();
25149
25156
  *
25150
- * // Add the first control point.
25151
- * splineVertex(84, 91);
25157
+ * // Add the first point.
25158
+ * splineVertex(25, 80);
25152
25159
  *
25153
- * // Add the anchor points to draw between.
25154
- * splineVertex(68, 19);
25155
- * splineVertex(21, 17);
25160
+ * // Add the second point.
25161
+ * splineVertex(20, 30);
25156
25162
  *
25157
- * // Add the second control point.
25158
- * splineVertex(32, 91);
25163
+ * // Add the last point.
25164
+ * splineVertex(85, 60);
25159
25165
  *
25160
25166
  * endShape();
25161
25167
  * ```
25162
- *
25163
- * The code snippet above would only draw the curve between the anchor points,
25164
- * similar to the <a href="#/p5/curve">curve()</a> function. The segments
25165
- * between the control and anchor points can be drawn by calling
25166
- * `splineVertex()` with the coordinates of the control points:
25167
- *
25168
+ *
25169
+ * <img src="assets/openCurveSpline.png"></img>
25170
+ *
25171
+ *
25172
+ * Passing in `CLOSE` to `endShape()` closes the spline smoothly.
25168
25173
  * ```js
25169
25174
  * beginShape();
25170
- *
25171
- * // Add the first control point and draw a segment to it.
25172
- * splineVertex(84, 91);
25173
- * splineVertex(84, 91);
25174
- *
25175
- * // Add the anchor points to draw between.
25176
- * splineVertex(68, 19);
25177
- * splineVertex(21, 17);
25178
- *
25179
- * // Add the second control point.
25180
- * splineVertex(32, 91);
25181
- *
25182
- * // Uncomment the next line to draw the segment to the second control point.
25183
- * // splineVertex(32, 91);
25184
- *
25185
- * endShape();
25175
+ *
25176
+ * // Add the first point.
25177
+ * splineVertex(25, 80);
25178
+ *
25179
+ * // Add the second point.
25180
+ * splineVertex(20, 30);
25181
+ *
25182
+ * // Add the second point.
25183
+ * splineVertex(85, 60);
25184
+ *
25185
+ * endShape(CLOSE);
25186
25186
  * ```
25187
- *
25188
- * The first two parameters, `x` and `y`, set the vertex’s location. For
25189
- * example, calling `splineVertex(10, 10)` adds a point to the curve at
25190
- * `(10, 10)`.
25191
- *
25187
+ *
25188
+ * <img src="assets/closeCurveSpline.png"></img>
25189
+ *
25190
+ *
25191
+ * By default (`ends: INCLUDE`), the curve passes through
25192
+ * all the points you add with `splineVertex()`, similar to
25193
+ * the <a href="#/p5/spline">spline()</a> function. To draw only
25194
+ * the middle span p1->p2 (skipping p0->p1 and p2->p3), set
25195
+ * `splineProperty('ends', EXCLUDE)`. You don’t need to duplicate
25196
+ * vertices to draw those spans.
25197
+ *
25192
25198
  * Spline curves can also be drawn in 3D using WebGL mode. The 3D version of
25193
25199
  * `splineVertex()` has three arguments because each point has x-, y-, and
25194
25200
  * z-coordinates. By default, the vertex’s z-coordinate is set to 0.
@@ -25206,46 +25212,29 @@ function customShapes(p5, fn) {
25206
25212
  * <code>
25207
25213
  * function setup() {
25208
25214
  * createCanvas(100, 100);
25209
- *
25210
- * background(200);
25211
- *
25212
- * // Style the shape.
25215
+ *
25216
+ * background(220);
25213
25217
  * noFill();
25214
25218
  * strokeWeight(1);
25215
- *
25216
- * // Start drawing the shape.
25219
+ *
25217
25220
  * beginShape();
25218
- *
25219
- * // Add the first control point.
25220
- * splineVertex(32, 91);
25221
- *
25222
- * // Add the anchor points.
25223
- * splineVertex(21, 17);
25224
- * splineVertex(68, 19);
25225
- *
25226
- * // Add the second control point.
25227
- * splineVertex(84, 91);
25228
- *
25229
- * // Stop drawing the shape.
25221
+ * splineVertex(25, 80);
25222
+ * splineVertex(20, 30);
25223
+ * splineVertex(85, 60);
25230
25224
  * endShape();
25231
- *
25232
- * // Style the anchor and control points.
25225
+ *
25233
25226
  * strokeWeight(5);
25234
- *
25235
- * // Draw the anchor points in black.
25236
25227
  * stroke(0);
25237
- * point(21, 17);
25238
- * point(68, 19);
25239
- *
25240
- * // Draw the control points in red.
25241
- * stroke(255, 0, 0);
25242
- * point(32, 91);
25243
- * point(84, 91);
25244
- *
25228
+ *
25229
+ * point(25, 80);
25230
+ * point(20, 30);
25231
+ * point(85, 60);
25232
+ *
25245
25233
  * describe(
25246
- * 'A black curve drawn on a gray background. The curve has black dots at its ends. Two red dots appear near the bottom of the canvas.'
25234
+ * 'On a gray background, a black spline passes through three marked points.'
25247
25235
  * );
25248
25236
  * }
25237
+ *
25249
25238
  * </code>
25250
25239
  * </div>
25251
25240
  *
@@ -25253,204 +25242,63 @@ function customShapes(p5, fn) {
25253
25242
  * <code>
25254
25243
  * function setup() {
25255
25244
  * createCanvas(100, 100);
25245
+ * background(220);
25256
25246
  *
25257
- * background(200);
25258
- *
25259
- * // Style the shape.
25260
- * noFill();
25261
- * strokeWeight(1);
25262
- *
25263
- * // Start drawing the shape.
25264
25247
  * beginShape();
25265
- *
25266
- * // Add the first control point and draw a segment to it.
25267
- * splineVertex(32, 91);
25268
- * splineVertex(32, 91);
25269
- *
25270
- * // Add the anchor points.
25271
- * splineVertex(21, 17);
25272
- * splineVertex(68, 19);
25273
- *
25274
- * // Add the second control point.
25275
- * splineVertex(84, 91);
25276
- *
25277
- * // Stop drawing the shape.
25278
- * endShape();
25279
- *
25280
- * // Style the anchor and control points.
25281
- * strokeWeight(5);
25282
- *
25283
- * // Draw the anchor points in black.
25284
- * stroke(0);
25285
- * point(21, 17);
25286
- * point(68, 19);
25287
- *
25288
- * // Draw the control points in red.
25289
- * stroke(255, 0, 0);
25290
- * point(32, 91);
25291
- * point(84, 91);
25248
+ * splineVertex(25, 80);
25249
+ * splineVertex(20, 30);
25250
+ * splineVertex(85, 60);
25251
+ * endShape(CLOSE);
25292
25252
  *
25293
25253
  * describe(
25294
- * 'A black curve drawn on a gray background. The curve passes through one red dot and two black dots. Another red dot appears near the bottom of the canvas.'
25254
+ * 'On a gray background, a closed black spline with a white interior forms a triangular shape with smooth corners.'
25295
25255
  * );
25296
25256
  * }
25257
+ *
25297
25258
  * </code>
25298
25259
  * </div>
25299
25260
  *
25300
25261
  * <div>
25301
25262
  * <code>
25302
- * function setup() {
25303
- * createCanvas(100, 100);
25304
- *
25305
- * background(200);
25263
+ * let ringInnerRadius, ringWidth;
25264
+ * let radius, dRadius;
25265
+ * let theta, dTheta;
25266
+ * let time, dTime;
25267
+ * let vertexCount, unit, offset;
25306
25268
  *
25307
- * // Style the shape.
25308
- * noFill();
25309
- * strokeWeight(1);
25310
- *
25311
- * // Start drawing the shape.
25312
- * beginShape();
25313
- *
25314
- * // Add the first control point and draw a segment to it.
25315
- * splineVertex(32, 91);
25316
- * splineVertex(32, 91);
25317
- *
25318
- * // Add the anchor points.
25319
- * splineVertex(21, 17);
25320
- * splineVertex(68, 19);
25321
- *
25322
- * // Add the second control point and draw a segment to it.
25323
- * splineVertex(84, 91);
25324
- * splineVertex(84, 91);
25325
- *
25326
- * // Stop drawing the shape.
25327
- * endShape();
25328
- *
25329
- * // Style the anchor and control points.
25330
- * strokeWeight(5);
25331
- *
25332
- * // Draw the anchor points in black.
25333
- * stroke(0);
25334
- * point(21, 17);
25335
- * point(68, 19);
25336
- *
25337
- * // Draw the control points in red.
25338
- * stroke(255, 0, 0);
25339
- * point(32, 91);
25340
- * point(84, 91);
25341
- *
25342
- * describe(
25343
- * 'A black U curve drawn upside down on a gray background. The curve passes from one red dot through two black dots and ends at another red dot.'
25344
- * );
25345
- * }
25346
- * </code>
25347
- * </div>
25269
+ * function setup() {
25270
+ * createCanvas(400, 400);
25348
25271
  *
25349
- * <div>
25350
- * <code>
25351
- * // Click the mouse near the red dot in the bottom-left corner
25352
- * // and drag to change the curve's shape.
25272
+ * vertexCount = 15;
25273
+ * unit = createVector(1, 0);
25274
+ * dTheta = TAU / vertexCount;
25275
+ * dTime = 0.004;
25353
25276
  *
25354
- * let x1 = 32;
25355
- * let y1 = 91;
25356
- * let isChanging = false;
25277
+ * ringInnerRadius = 25;
25278
+ * ringWidth = 5 * ringInnerRadius;
25357
25279
  *
25358
- * function setup() {
25359
- * createCanvas(100, 100);
25280
+ * offset = width;
25360
25281
  *
25361
25282
  * describe(
25362
- * 'A black U curve drawn upside down on a gray background. The curve passes from one red dot through two black dots and ends at another red dot.'
25283
+ * 'A white blob with a black outline changes its shape over time.'
25363
25284
  * );
25364
25285
  * }
25365
25286
  *
25366
25287
  * function draw() {
25367
- * background(200);
25288
+ * background(220);
25289
+ * strokeWeight(2);
25290
+ * translate(width / 2, height / 2);
25368
25291
  *
25369
- * // Style the shape.
25370
- * noFill();
25371
- * stroke(0);
25372
- * strokeWeight(1);
25292
+ * time = dTime * frameCount;
25373
25293
  *
25374
- * // Start drawing the shape.
25375
25294
  * beginShape();
25376
- *
25377
- * // Add the first control point and draw a segment to it.
25378
- * splineVertex(x1, y1);
25379
- * splineVertex(x1, y1);
25380
- *
25381
- * // Add the anchor points.
25382
- * splineVertex(21, 17);
25383
- * splineVertex(68, 19);
25384
- *
25385
- * // Add the second control point and draw a segment to it.
25386
- * splineVertex(84, 91);
25387
- * splineVertex(84, 91);
25388
- *
25389
- * // Stop drawing the shape.
25390
- * endShape();
25391
- *
25392
- * // Style the anchor and control points.
25393
- * strokeWeight(5);
25394
- *
25395
- * // Draw the anchor points in black.
25396
- * stroke(0);
25397
- * point(21, 17);
25398
- * point(68, 19);
25399
- *
25400
- * // Draw the control points in red.
25401
- * stroke(255, 0, 0);
25402
- * point(x1, y1);
25403
- * point(84, 91);
25404
- * }
25405
- *
25406
- * // Start changing the first control point if the user clicks near it.
25407
- * function mousePressed() {
25408
- * if (dist(mouseX, mouseY, x1, y1) < 20) {
25409
- * isChanging = true;
25295
+ * for (let i = 0; i < vertexCount; i++) {
25296
+ * unit.rotate(dTheta);
25297
+ * dRadius = noise(offset + unit.x, offset + unit.y, time) * ringWidth;
25298
+ * radius = ringInnerRadius + dRadius;
25299
+ * splineVertex(radius * unit.x, radius * unit.y);
25410
25300
  * }
25411
- * }
25412
- *
25413
- * // Stop changing the first control point when the user releases the mouse.
25414
- * function mouseReleased() {
25415
- * isChanging = false;
25416
- * }
25417
- *
25418
- * // Update the first control point while the user drags the mouse.
25419
- * function mouseDragged() {
25420
- * if (isChanging === true) {
25421
- * x1 = mouseX;
25422
- * y1 = mouseY;
25423
- * }
25424
- * }
25425
- * </code>
25426
- * </div>
25427
- *
25428
- * <div>
25429
- * <code>
25430
- * function setup() {
25431
- * createCanvas(100, 100);
25432
- *
25433
- * background(200);
25434
- *
25435
- * // Start drawing the shape.
25436
- * beginShape();
25437
- *
25438
- * // Add the first control point and draw a segment to it.
25439
- * splineVertex(32, 91);
25440
- * splineVertex(32, 91);
25441
- *
25442
- * // Add the anchor points.
25443
- * splineVertex(21, 17);
25444
- * splineVertex(68, 19);
25445
- *
25446
- * // Add the second control point.
25447
- * splineVertex(84, 91);
25448
- * splineVertex(84, 91);
25449
- *
25450
- * // Stop drawing the shape.
25451
- * endShape();
25452
- *
25453
- * describe('A ghost shape drawn in white on a gray background.');
25301
+ * endShape(CLOSE);
25454
25302
  * }
25455
25303
  * </code>
25456
25304
  * </div>
@@ -25539,25 +25387,83 @@ function customShapes(p5, fn) {
25539
25387
  };
25540
25388
 
25541
25389
  /**
25542
- * Sets the property of a curve.
25390
+ * Gets or sets a given spline property.
25391
+ *
25392
+ * Use `splineProperty()` to adjust the behavior of splines
25393
+ * created with `splineVertex()` or `spline()`. You can control
25394
+ * two key aspects of a spline: its end behavior (`ends`) and
25395
+ * its curvature (`tightness`).
25396
+ *
25397
+ * By default, the ends property is set to `INCLUDE`, which means
25398
+ * the spline passes through every point, including the endpoints.
25399
+ * You can also set it to `EXCLUDE` i.e. `splineProperty('ends', EXCLUDE)`,
25400
+ * which makes the spline pass through all points except the endpoints.
25401
+ *
25402
+ * `INCLUDE` case will have the spline passing through
25403
+ * all points, like this:
25404
+ *
25405
+ * ```js
25406
+ * splineProperty('ends', INCLUDE); // no need to set this, as it is the default
25407
+ * spline(25, 46, 93, 44, 93, 81, 35, 85);
25408
+ *
25409
+ * point(25, 46);
25410
+ * point(93, 44);
25411
+ * point(93, 81);
25412
+ * point(35, 85);
25413
+ * ```
25543
25414
  *
25544
- * For example, set tightness,
25545
- * use `splineProperty('tightness', t)`, with `t` between 0 and 1,
25546
- * at 0 as default.
25415
+ * <img src="assets/includeSpline.png"></img>
25547
25416
  *
25548
- * Spline curves are like cables that are attached to a set of points.
25549
- * Adjusting tightness adjusts how tightly the cable is
25550
- * attached to the points. The parameter, tightness, determines
25551
- * how the curve fits to the vertex points. By default,
25552
- * tightness is set to 0. Setting tightness to 1, as in
25553
- * `splineProperty('tightness', 1)`, connects the curve's points
25554
- * using straight lines. Values in the range from –5 to 5
25555
- * deform curves while leaving them recognizable.
25556
25417
  *
25557
- * This function can also be used to set 'ends' property
25558
- * (see also: the <a href="#/p5/curveDetail">curveDetail()</a> example),
25559
- * such as: `splineProperty('ends', EXCLUDE)` to exclude
25560
- * vertices, or `splineProperty('ends', INCLUDE)` to include them.
25418
+ * EXCLUDE case will have the spline passing through
25419
+ * the middle points, like this:
25420
+ *
25421
+ *
25422
+ * ```js
25423
+ * splineProperty('ends', INCLUDE);
25424
+ * spline(25, 46, 93, 44, 93, 81, 35, 85);
25425
+ *
25426
+ * point(25, 46);
25427
+ * point(93, 44);
25428
+ * point(93, 81);
25429
+ * point(35, 85);
25430
+ * ```
25431
+ *
25432
+ * <img src="assets/excludeSpline.png"></img>
25433
+ *
25434
+ * By default, the tightness property is set to `0`,
25435
+ * producing a smooth curve that passes evenly through
25436
+ * the vertices. Negative values make the curve looser,
25437
+ * while positive values make it tighter. Common values
25438
+ * range between -1 and 1, though values outside this
25439
+ * range can also be used for different effects.
25440
+ *
25441
+ * For example, To set tightness, use `splineProperty('tightness', t)`,
25442
+ * (default: t = 0).
25443
+ *
25444
+ * Here's the example showing negetive value of tightness,
25445
+ * which creates a rounder bulge:
25446
+ *
25447
+ * ```js
25448
+ * splineProperty('tightness', -5)
25449
+ * stroke(0);
25450
+ * strokeWeight(2);
25451
+ * spline(25, 46, 93, 44, 93, 81, 35, 85);
25452
+ * ```
25453
+ *
25454
+ * Here's the example showing positive value of tightness,
25455
+ * which makes the curve tighter and more angular:
25456
+ *
25457
+ * ```js
25458
+ * splineProperty('tightness', 5)
25459
+ * stroke(0);
25460
+ * strokeWeight(2);
25461
+ * spline(25, 46, 93, 44, 93, 81, 35, 85);
25462
+ * ```
25463
+ *
25464
+ * In all cases, the splines in p5.js are <a href = "https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline">cardinal splines</a>.
25465
+ * When tightness is 0, these splines are often known as
25466
+ * <a href="https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull%E2%80%93Rom_spline">Catmull-Rom splines</a>
25561
25467
  *
25562
25468
  * @method splineProperty
25563
25469
  * @param {String} property
@@ -25567,33 +25473,111 @@ function customShapes(p5, fn) {
25567
25473
  * <div>
25568
25474
  * <code>
25569
25475
  * // Move the mouse left and right to see the curve change.
25570
- *
25476
+ *
25477
+ * let t;
25478
+ *
25571
25479
  * function setup() {
25572
25480
  * createCanvas(100, 100);
25573
- * describe('A black curve forms a sideways U shape. The curve deforms as the user moves the mouse from left to right');
25481
+ *
25574
25482
  * }
25575
- *
25483
+ *
25576
25484
  * function draw() {
25577
- * background(200);
25578
- *
25579
- * // Set the curve's tightness using the mouse.
25580
- * let t = map(mouseX, 0, 100, -5, 5, true);
25485
+ * background(240);
25486
+ *
25487
+ * t = map(mouseX, 0, width, -5, 5, true);
25581
25488
  * splineProperty('tightness', t);
25582
- *
25583
- * // Draw the curve.
25489
+ *
25584
25490
  * noFill();
25491
+ * stroke(0);
25492
+ * strokeWeight(2);
25493
+ *
25585
25494
  * beginShape();
25586
25495
  * splineVertex(10, 26);
25587
- * splineVertex(10, 26);
25588
25496
  * splineVertex(83, 24);
25497
+ *
25589
25498
  * splineVertex(83, 61);
25590
25499
  * splineVertex(25, 65);
25591
- * splineVertex(25, 65);
25592
25500
  * endShape();
25501
+ *
25502
+ * push();
25503
+ * strokeWeight(5);
25504
+ * point(10, 26);
25505
+ * point(83, 24);
25506
+ * point(83, 61);
25507
+ * point(25, 65);
25508
+ * pop();
25509
+ *
25510
+ * fill(0);
25511
+ * noStroke();
25512
+ * textSize(10);
25513
+ * text(`tightness: ${round(t, 1)}`, 15, 90);
25514
+ * describe('A black spline forms a sideways U shape through four points. The spline passes through the points more loosely as the mouse moves left of center (negative tightness), and more tightly as it moves right of center (positive tightness). The tightness is displayed at the bottom.');
25515
+ * }
25516
+ * </code>
25517
+ * </div>
25518
+ *
25519
+ * @example
25520
+ * <div>
25521
+ * <code>
25522
+ * function setup() {
25523
+ * createCanvas(360, 140);
25524
+ * background(240);
25525
+ * noFill();
25526
+ *
25527
+ * // Right panel: ends = INCLUDE (all spans).
25528
+ * push();
25529
+ * translate(10, 10);
25530
+ * stroke(220);
25531
+ * rect(0, 0, 160, 120);
25532
+ * fill(30);
25533
+ * textSize(11);
25534
+ * text('ends: INCLUDE (all spans)', 8, 16);
25535
+ * noFill();
25536
+ *
25537
+ * splineProperty('ends', INCLUDE);
25538
+ * stroke(0);
25539
+ * strokeWeight(2);
25540
+ * spline(25, 46, 93, 44, 93, 81, 35, 85);
25541
+ *
25542
+ * // vertices
25543
+ * strokeWeight(5);
25544
+ * stroke(0);
25545
+ * point(25, 46);
25546
+ * point(93, 44);
25547
+ * point(93, 81);
25548
+ * point(35, 85);
25549
+ * pop();
25550
+ *
25551
+ * // Right panel: ends = EXCLUDE (middle only).
25552
+ * push();
25553
+ * translate(190, 10);
25554
+ * stroke(220);
25555
+ * rect(0, 0, 160, 120);
25556
+ * noStroke();
25557
+ * fill(30);
25558
+ * text('ends: EXCLUDE ', 18, 16);
25559
+ * noFill();
25560
+ *
25561
+ * splineProperty('ends', EXCLUDE);
25562
+ * stroke(0);
25563
+ * strokeWeight(2);
25564
+ * spline(25, 46, 93, 44, 93, 81, 35, 85);
25565
+ *
25566
+ * // vertices
25567
+ * strokeWeight(5);
25568
+ * stroke(0);
25569
+ * point(25, 46);
25570
+ * point(93, 44);
25571
+ * point(93, 81);
25572
+ * point(35, 85);
25573
+ * pop();
25574
+ *
25575
+ * describe('Left panel shows spline with ends INCLUDE (three spans). Right panel shows EXCLUDE (only the middle span). Four black points mark the vertices.');
25593
25576
  * }
25594
25577
  * </code>
25595
25578
  * </div>
25596
25579
  */
25580
+
25597
25581
  /**
25598
25582
  * @method splineProperty
25599
25583
  * @param {String} property
@@ -30443,7 +30427,7 @@ function curves(p5, fn){
30443
30427
  * Bézier curves can form shapes and curves that slope gently. They're defined
30444
30428
  * by two anchor points and two control points. Bézier curves provide more
30445
30429
  * control than the spline curves created with the
30446
- * <a href="#/p5/curve">curve()</a> function.
30430
+ * <a href="#/p5/spline">spline()</a> function.
30447
30431
  *
30448
30432
  * The first two parameters, `x1` and `y1`, set the first anchor point. The
30449
30433
  * first anchor point is where the curve starts.
@@ -30893,38 +30877,53 @@ function curves(p5, fn){
30893
30877
 
30894
30878
  /**
30895
30879
  * Draws a curve using a Catmull-Rom spline.
30896
- *
30880
+ *
30897
30881
  * Spline curves can form shapes and curves that slope gently. They’re like
30898
- * cables that are attached to a set of points. Splines are defined by two
30899
- * anchor points and two control points.
30900
- *
30901
- * The first two parameters, `x1` and `y1`, set the first control point. This
30902
- * point isn’t drawn and can be thought of as the curve’s starting point.
30903
- *
30904
- * The next four parameters, `x2`, `y2`, `x3`, and `y3`, set the two anchor
30905
- * points. The anchor points are the start and end points of the curve’s
30906
- * visible segment.
30907
- *
30908
- * The seventh and eighth parameters, `x4` and `y4`, set the last control
30909
- * point. This point isn’t drawn and can be thought of as the curve’s ending
30910
- * point.
30882
+ * cables that are attached to a set of points. By default (`ends: INCLUDE`),
30883
+ * the curve passes through all four points you provide, in order
30884
+ * `p0(x1,y1)` -> `p1(x2,y2)` -> `p2(x3,y3)` -> `p3(x4,y4)`. Think of them as
30885
+ * points on a curve. If you switch to `ends: EXCLUDE`, p0 and p3 act
30886
+ * like control points and only the middle span `p1->p2` is drawn.
30911
30887
  *
30912
30888
  * Spline curves can also be drawn in 3D using WebGL mode. The 3D version of
30913
30889
  * `spline()` has twelve arguments because each point has x-, y-, and
30914
30890
  * z-coordinates.
30915
30891
  *
30916
30892
  * @method spline
30917
- * @param {Number} x1 x-coordinate of the first control point.
30918
- * @param {Number} y1 y-coordinate of the first control point.
30919
- * @param {Number} x2 x-coordinate of the first anchor point.
30920
- * @param {Number} y2 y-coordinate of the first anchor point.
30921
- * @param {Number} x3 x-coordinate of the second anchor point.
30922
- * @param {Number} y3 y-coordinate of the second anchor point.
30923
- * @param {Number} x4 x-coordinate of the second control point.
30924
- * @param {Number} y4 y-coordinate of the second control point.
30893
+ * @param {Number} x1 x-coordinate of point p0.
30894
+ * @param {Number} y1 y-coordinate of point p0.
30895
+ * @param {Number} x2 x-coordinate of point p1.
30896
+ * @param {Number} y2 y-coordinate of point p1.
30897
+ * @param {Number} x3 x-coordinate of point p2.
30898
+ * @param {Number} y3 y-coordinate of point p2.
30899
+ * @param {Number} x4 x-coordinate of point p3.
30900
+ * @param {Number} y4 y-coordinate of point p3.
30925
30901
  * @chainable
30926
30902
  *
30927
30903
  * @example
30904
+ *
30905
+ * <div>
30906
+ * <code>
30907
+ * function setup() {
30908
+ * createCanvas(200, 200);
30909
+ * background(240);
30910
+ * noFill();
30911
+ *
30912
+ * stroke(0);
30913
+ * strokeWeight(2);
30914
+ * spline(40, 60, 100, 40, 120, 120, 60, 140);
30915
+ *
30916
+ * strokeWeight(5);
30917
+ * point(40, 60);
30918
+ * point(100, 40);
30919
+ * point(120, 120);
30920
+ * point(60, 140);
30921
+ *
30922
+ * describe('A black spline passes smoothly through four points');
30923
+ * }
30924
+ * </code>
30925
+ * </div>
30926
+ *
30928
30927
  * <div>
30929
30928
  * <code>
30930
30929
  * function setup() {
@@ -30932,24 +30931,27 @@ function curves(p5, fn){
30932
30931
  *
30933
30932
  * background(200);
30934
30933
  *
30934
+ * // Exclude the ends—skip the outer spans (p0→p1 and p2→p3) so only the middle span (p1→p2) is drawn.
30935
+ * splineProperty('ends', EXCLUDE);
30936
+ *
30935
30937
  * // Draw a black spline curve.
30936
30938
  * noFill();
30937
30939
  * strokeWeight(1);
30938
30940
  * stroke(0);
30939
30941
  * spline(5, 26, 73, 24, 73, 61, 15, 65);
30940
30942
  *
30941
- * // Draw red spline curves from the anchor points to the control points.
30943
+ * // Draw red spline curves from the points.
30942
30944
  * stroke(255, 0, 0);
30943
30945
  * spline(5, 26, 5, 26, 73, 24, 73, 61);
30944
30946
  * spline(73, 24, 73, 61, 15, 65, 15, 65);
30945
30947
  *
30946
- * // Draw the anchor points in black.
30948
+ * // Draw the points in black.
30947
30949
  * strokeWeight(5);
30948
30950
  * stroke(0);
30949
30951
  * point(73, 24);
30950
30952
  * point(73, 61);
30951
30953
  *
30952
- * // Draw the control points in red.
30954
+ * // Draw the points in red.
30953
30955
  * stroke(255, 0, 0);
30954
30956
  * point(5, 26);
30955
30957
  * point(15, 65);
@@ -30977,14 +30979,17 @@ function curves(p5, fn){
30977
30979
  *
30978
30980
  * function draw() {
30979
30981
  * background(200);
30980
- *
30982
+ *
30983
+ * // Exclude the ends—skip the outer spans (p0→p1 and p2→p3) so only the middle span (p1→p2) is drawn.
30984
+ * splineProperty('ends', EXCLUDE);
30985
+ *
30981
30986
  * // Draw a black spline curve.
30982
30987
  * noFill();
30983
30988
  * strokeWeight(1);
30984
30989
  * stroke(0);
30985
30990
  * spline(x1, y1, 73, 24, 73, 61, 15, 65);
30986
30991
  *
30987
- * // Draw red spline curves from the anchor points to the control points.
30992
+ * // Draw red spline curves from the points.
30988
30993
  * stroke(255, 0, 0);
30989
30994
  * spline(x1, y1, x1, y1, 73, 24, 73, 61);
30990
30995
  * spline(73, 24, 73, 61, 15, 65, 15, 65);
@@ -30995,25 +31000,25 @@ function curves(p5, fn){
30995
31000
  * point(73, 24);
30996
31001
  * point(73, 61);
30997
31002
  *
30998
- * // Draw the control points in red.
31003
+ * // Draw the points in red.
30999
31004
  * stroke(255, 0, 0);
31000
31005
  * point(x1, y1);
31001
31006
  * point(15, 65);
31002
31007
  * }
31003
31008
  *
31004
- * // Start changing the first control point if the user clicks near it.
31009
+ * // Start changing the first point if the user clicks near it.
31005
31010
  * function mousePressed() {
31006
31011
  * if (dist(mouseX, mouseY, x1, y1) < 20) {
31007
31012
  * isChanging = true;
31008
31013
  * }
31009
31014
  * }
31010
31015
  *
31011
- * // Stop changing the first control point when the user releases the mouse.
31016
+ * // Stop changing the first point when the user releases the mouse.
31012
31017
  * function mouseReleased() {
31013
31018
  * isChanging = false;
31014
31019
  * }
31015
31020
  *
31016
- * // Update the first control point while the user drags the mouse.
31021
+ * // Update the first point while the user drags the mouse.
31017
31022
  * function mouseDragged() {
31018
31023
  * if (isChanging === true) {
31019
31024
  * x1 = mouseX;
@@ -31029,7 +31034,10 @@ function curves(p5, fn){
31029
31034
  * createCanvas(100, 100);
31030
31035
  *
31031
31036
  * background('skyblue');
31032
- *
31037
+ *
31038
+ * // Exclude the ends—skip the outer spans (p0→p1 and p2→p3) so only the middle span (p1→p2) is drawn.
31039
+ * splineProperty('ends', EXCLUDE);
31040
+ *
31033
31041
  * // Draw the red balloon.
31034
31042
  * fill('red');
31035
31043
  * spline(-150, 275, 50, 60, 50, 60, 250, 275);
@@ -31052,7 +31060,10 @@ function curves(p5, fn){
31052
31060
  *
31053
31061
  * function draw() {
31054
31062
  * background('skyblue');
31055
- *
31063
+ *
31064
+ * // Exclude the ends—skip the outer spans (p0→p1 and p2→p3) so only the middle span (p1→p2) is drawn.
31065
+ * splineProperty('ends', EXCLUDE);
31066
+ *
31056
31067
  * // Rotate around the y-axis.
31057
31068
  * rotateY(frameCount * 0.01);
31058
31069
  *
@@ -31071,16 +31082,16 @@ function curves(p5, fn){
31071
31082
  * @method spline
31072
31083
  * @param {Number} x1
31073
31084
  * @param {Number} y1
31074
- * @param {Number} z1 z-coordinate of the first control point.
31085
+ * @param {Number} z1 z-coordinate of point p0.
31075
31086
  * @param {Number} x2
31076
31087
  * @param {Number} y2
31077
- * @param {Number} z2 z-coordinate of the first anchor point.
31088
+ * @param {Number} z2 z-coordinate of point p1.
31078
31089
  * @param {Number} x3
31079
31090
  * @param {Number} y3
31080
- * @param {Number} z3 z-coordinate of the second anchor point.
31091
+ * @param {Number} z3 z-coordinate of point p2.
31081
31092
  * @param {Number} x4
31082
31093
  * @param {Number} y4
31083
- * @param {Number} z4 z-coordinate of the second control point.
31094
+ * @param {Number} z4 z-coordinate of point p3.
31084
31095
  * @chainable
31085
31096
  */
31086
31097
  fn.spline = function(...args) {
@@ -31095,30 +31106,30 @@ function curves(p5, fn){
31095
31106
  /**
31096
31107
  * Calculates coordinates along a spline curve using interpolation.
31097
31108
  *
31098
- * `splinePoint()` calculates coordinates along a spline curve using the
31099
- * anchor and control points. It expects points in the same order as the
31109
+ * `splinePoint()` calculates coordinates along a spline curve using four
31110
+ * points p0, p1, p2, p3. It expects points in the same order as the
31100
31111
  * <a href="#/p5/spline">spline()</a> function. `splinePoint()` works one axis
31101
- * at a time. Passing the anchor and control points' x-coordinates will
31102
- * calculate the x-coordinate of a point on the curve. Passing the anchor and
31103
- * control points' y-coordinates will calculate the y-coordinate of a point on
31112
+ * at a time. Passing the points' x-coordinates will
31113
+ * calculate the x-coordinate of a point on the curve. Passing the
31114
+ * points' y-coordinates will calculate the y-coordinate of a point on
31104
31115
  * the curve.
31105
31116
  *
31106
- * The first parameter, `a`, is the coordinate of the first control point.
31117
+ * The first parameter, `a`, is the coordinate of point p0.
31107
31118
  *
31108
- * The second and third parameters, `b` and `c`, are the coordinates of the
31109
- * anchor points.
31119
+ * The second and third parameters, `b` and `c`, are the coordinates of
31120
+ * points p1 and p2.
31110
31121
  *
31111
- * The fourth parameter, `d`, is the coordinate of the last control point.
31122
+ * The fourth parameter, `d`, is the coordinate of point p3.
31112
31123
  *
31113
- * The fifth parameter, `t`, is the amount to interpolate along the curve. 0
31114
- * is the first anchor point, 1 is the second anchor point, and 0.5 is halfway
31124
+ * The fifth parameter, `t`, is the amount to interpolate along the span
31125
+ * from p1 to p2. `t = 0` is p1, `t = 1` is p2, and `t = 0.5` is halfway
31115
31126
  * between them.
31116
31127
  *
31117
31128
  * @method splinePoint
31118
- * @param {Number} a coordinate of first control point.
31119
- * @param {Number} b coordinate of first anchor point.
31120
- * @param {Number} c coordinate of second anchor point.
31121
- * @param {Number} d coordinate of second control point.
31129
+ * @param {Number} a coordinate of point p0.
31130
+ * @param {Number} b coordinate of point p1.
31131
+ * @param {Number} c coordinate of point p2.
31132
+ * @param {Number} d coordinate of point p3.
31122
31133
  * @param {Number} t amount to interpolate between 0 and 1.
31123
31134
  * @return {Number} coordinate of a point on the curve.
31124
31135
  *
@@ -31130,7 +31141,8 @@ function curves(p5, fn){
31130
31141
  *
31131
31142
  * background(200);
31132
31143
  *
31133
- * // Set the coordinates for the curve's anchor and control points.
31144
+ *
31145
+ * // Set the coordinates for the curve's four points (p0, p1, p2, p3).
31134
31146
  * let x1 = 5;
31135
31147
  * let y1 = 26;
31136
31148
  * let x2 = 73;
@@ -31178,7 +31190,7 @@ function curves(p5, fn){
31178
31190
  * function draw() {
31179
31191
  * background(200);
31180
31192
  *
31181
- * // Set the coordinates for the curve's anchor and control points.
31193
+ * // Set the coordinates for the curve's four points (p0, p1, p2, p3).
31182
31194
  * let x1 = 5;
31183
31195
  * let y1 = 26;
31184
31196
  * let x2 = 73;
@@ -31204,6 +31216,7 @@ function curves(p5, fn){
31204
31216
  * </code>
31205
31217
  * </div>
31206
31218
  */
31219
+
31207
31220
  fn.splinePoint = function(a, b, c, d, t) {
31208
31221
  const s = this._renderer.states.splineProperties.tightness,
31209
31222
  t3 = t * t * t,
@@ -31221,30 +31234,27 @@ function curves(p5, fn){
31221
31234
  * Tangent lines skim the surface of a curve. A tangent line's slope equals
31222
31235
  * the curve's slope at the point where it intersects.
31223
31236
  *
31224
- * `splineTangent()` calculates coordinates along a tangent line using the
31225
- * spline curve's anchor and control points. It expects points in the same
31226
- * order as the <a href="#/p5/spline">spline()</a> function. `splineTangent()`
31227
- * works one axis at a time. Passing the anchor and control points'
31228
- * x-coordinates will calculate the x-coordinate of a point on the tangent
31229
- * line. Passing the anchor and control points' y-coordinates will calculate
31230
- * the y-coordinate of a point on the tangent line.
31237
+ * `splineTangent()` calculates coordinates along a tangent line using four
31238
+ * points p0, p1, p2, p3. It expects points in the same order as the
31239
+ * <a href="#/p5/spline">spline()</a> function. `splineTangent()` works one
31240
+ * axis at a time. Passing the points' x-coordinates returns the x-component of
31241
+ * the tangent vector; passing the points' y-coordinates returns the y-component.
31242
+ * The first parameter, `a`, is the coordinate of point p0.
31231
31243
  *
31232
- * The first parameter, `a`, is the coordinate of the first control point.
31233
- *
31234
- * The second and third parameters, `b` and `c`, are the coordinates of the
31235
- * anchor points.
31244
+ * The second and third parameters, `b` and `c`, are the coordinates of
31245
+ * points p1 and p2.
31236
31246
  *
31237
- * The fourth parameter, `d`, is the coordinate of the last control point.
31247
+ * The fourth parameter, `d`, is the coordinate of point p3.
31238
31248
  *
31239
- * The fifth parameter, `t`, is the amount to interpolate along the curve. 0
31240
- * is the first anchor point, 1 is the second anchor point, and 0.5 is halfway
31249
+ * The fifth parameter, `t`, is the amount to interpolate along the span
31250
+ * from p1 to p2. `t = 0` is p1, `t = 1` is p2, and `t = 0.5` is halfway
31241
31251
  * between them.
31242
31252
  *
31243
31253
  * @method splineTangent
31244
- * @param {Number} a coordinate of first control point.
31245
- * @param {Number} b coordinate of first anchor point.
31246
- * @param {Number} c coordinate of second anchor point.
31247
- * @param {Number} d coordinate of second control point.
31254
+ * @param {Number} a coordinate of point p0.
31255
+ * @param {Number} b coordinate of point p1.
31256
+ * @param {Number} c coordinate of point p2.
31257
+ * @param {Number} d coordinate of point p3.
31248
31258
  * @param {Number} t amount to interpolate between 0 and 1.
31249
31259
  * @return {Number} coordinate of a point on the tangent line.
31250
31260
  *
@@ -31252,11 +31262,54 @@ function curves(p5, fn){
31252
31262
  * <div>
31253
31263
  * <code>
31254
31264
  * function setup() {
31265
+ * createCanvas(120, 120);
31266
+ * 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.');
31267
+ * }
31268
+ *
31269
+ * function draw() {
31270
+ * background(240);
31271
+ *
31272
+ * const x1 = 15, y1 = 40;
31273
+ * const x2 = 90, y2 = 25;
31274
+ * const x3 = 95, y3 = 95;
31275
+ * const x4 = 30, y4 = 110;
31276
+ *
31277
+ * noFill();
31278
+ * stroke(0);
31279
+ * strokeWeight(2);
31280
+ * spline(x1, y1, x2, y2, x3, y3, x4, y4);
31281
+ *
31282
+ * const t = 0.5 + 0.5 * sin(frameCount * 0.03);
31283
+ *
31284
+ * const px = splinePoint(x1, x2, x3, x4, t);
31285
+ * const py = splinePoint(y1, y2, y3, y4, t);
31286
+ *
31287
+ * let tx = splineTangent(x1, x2, x3, x4, t);
31288
+ * let ty = splineTangent(y1, y2, y3, y4, t);
31289
+ *
31290
+ * const m = Math.hypot(tx, ty) || 1;
31291
+ * tx = (tx / m) * 16;
31292
+ * ty = (ty / m) * 16;
31293
+ *
31294
+ * stroke(0);
31295
+ * strokeWeight(2);
31296
+ * line(px, py, px + tx, py + ty);
31297
+ *
31298
+ * noStroke();
31299
+ * fill('red');
31300
+ * circle(px, py, 7);
31301
+ * }
31302
+ * </code>
31303
+ * </div>
31304
+ *
31305
+ * <div>
31306
+ * <code>
31307
+ * function setup() {
31255
31308
  * createCanvas(100, 100);
31256
31309
  *
31257
31310
  * background(200);
31258
31311
  *
31259
- * // Set the coordinates for the curve's anchor and control points.
31312
+ * // Set the coordinates for the curve's four points (p0, p1, p2, p3).
31260
31313
  * let x1 = 5;
31261
31314
  * let y1 = 26;
31262
31315
  * let x2 = 73;
@@ -53767,7 +53820,7 @@ class RendererGL extends Renderer {
53767
53820
 
53768
53821
  _prepareUserAttributes(geometry, shader) {
53769
53822
  for (const buff of this.buffers.user) {
53770
- if (!this._pInst.constructor.disableFriendleErrors) {
53823
+ if (!this._pInst.constructor.disableFriendlyErrors) {
53771
53824
  // Check for the right data size
53772
53825
  const prop = geometry.userVertexProperties[buff.attr];
53773
53826
  if (prop) {
@@ -72268,7 +72321,7 @@ function outputs(p5, fn){
72268
72321
  if (!this.ingredients.shapes[f]) {
72269
72322
  this.ingredients.shapes[f] = [include];
72270
72323
  //if other shapes of this type have been created
72271
- } else if (this.ingredients.shapes[f] !== [include]) {
72324
+ } else {
72272
72325
  //for every shape of this type
72273
72326
  for (let y in this.ingredients.shapes[f]) {
72274
72327
  //compare it with current shape and if it already exists make add false
@@ -128181,7 +128234,11 @@ function shadergenerator(p5, fn) {
128181
128234
  const transpiledSource = escodegen.generate(ast);
128182
128235
  const scopeKeys = Object.keys(scope);
128183
128236
  const internalGeneratorFunction = new Function(
128184
- 'p5',
128237
+ // Create a parameter called __p5, not just p5, because users of instance mode
128238
+ // may pass in a variable called p5 as a scope variable. If we rely on a variable called
128239
+ // p5, then the scope variable called p5 might accidentally override internal function
128240
+ // calls to p5 static methods.
128241
+ '__p5',
128185
128242
  ...scopeKeys,
128186
128243
  transpiledSource
128187
128244
  .slice(
@@ -128246,7 +128303,7 @@ function shadergenerator(p5, fn) {
128246
128303
  node.type = 'CallExpression';
128247
128304
  node.callee = {
128248
128305
  type: 'Identifier',
128249
- name: 'p5.unaryNode',
128306
+ name: '__p5.unaryNode',
128250
128307
  };
128251
128308
  node.arguments = [node.argument, signNode];
128252
128309
  };
@@ -128269,7 +128326,7 @@ function shadergenerator(p5, fn) {
128269
128326
  type: 'CallExpression',
128270
128327
  callee: {
128271
128328
  type: 'Identifier',
128272
- name: 'p5.unaryNode'
128329
+ name: '__p5.unaryNode'
128273
128330
  },
128274
128331
  arguments: [node.argument.object, signNode],
128275
128332
  };
@@ -128334,7 +128391,7 @@ function shadergenerator(p5, fn) {
128334
128391
  node.type = 'CallExpression';
128335
128392
  node.callee = {
128336
128393
  type: 'Identifier',
128337
- name: 'p5.dynamicNode',
128394
+ name: '__p5.dynamicNode',
128338
128395
  };
128339
128396
  node.arguments = [original];
128340
128397
  },
@@ -128388,7 +128445,7 @@ function shadergenerator(p5, fn) {
128388
128445
  type: 'CallExpression',
128389
128446
  callee: {
128390
128447
  type: 'Identifier',
128391
- name: 'p5.dynamicNode',
128448
+ name: '__p5.dynamicNode',
128392
128449
  },
128393
128450
  arguments: [node.left]
128394
128451
  };
@@ -129750,7 +129807,6 @@ function shadergenerator(p5, fn) {
129750
129807
  ],
129751
129808
  'sqrt': { args: ['genType'], returnType: 'genType', isp5Function: true},
129752
129809
  'step': { args: ['genType', 'genType'], returnType: 'genType', isp5Function: false},
129753
- 'noise': { args: ['vec2'], returnType: 'float', isp5Function: false },
129754
129810
  'trunc': { args: ['genType'], returnType: 'genType', isp5Function: false},
129755
129811
 
129756
129812
  ////////// Vector //////////
@@ -129817,7 +129873,7 @@ function shadergenerator(p5, fn) {
129817
129873
  } else {
129818
129874
  nodeArgs = args;
129819
129875
  }
129820
-
129876
+
129821
129877
  return fnNodeConstructor('noise', nodeArgs, {
129822
129878
  args: ['vec2'],
129823
129879
  returnType: 'float'