p5 2.3.0-rc.5 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +7 -11
  2. package/dist/accessibility/color_namer.js +4 -4
  3. package/dist/accessibility/index.js +4 -4
  4. package/dist/app.js +4 -4
  5. package/dist/app.node.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-CdA3y5zC.js → constants-Dv6ZqA6s.js} +1 -1
  10. package/dist/core/constants.js +1 -1
  11. package/dist/core/environment.js +1 -1
  12. package/dist/core/filterShaders.js +1 -1
  13. package/dist/core/friendly_errors/fes_core.js +1 -1
  14. package/dist/core/friendly_errors/file_errors.js +1 -1
  15. package/dist/core/friendly_errors/index.js +1 -1
  16. package/dist/core/friendly_errors/param_validator.js +1 -1
  17. package/dist/core/friendly_errors/sketch_verifier.js +1 -1
  18. package/dist/core/helpers.js +1 -1
  19. package/dist/core/init.js +4 -4
  20. package/dist/core/internationalization.js +1 -1
  21. package/dist/core/legacy.js +4 -4
  22. package/dist/core/main.js +4 -4
  23. package/dist/core/p5.Graphics.js +3 -3
  24. package/dist/core/p5.Renderer.js +2 -2
  25. package/dist/core/p5.Renderer2D.js +4 -4
  26. package/dist/core/p5.Renderer3D.js +3 -3
  27. package/dist/core/rendering.js +3 -3
  28. package/dist/dom/dom.js +1 -1
  29. package/dist/dom/index.js +1 -1
  30. package/dist/dom/p5.Element.js +1 -1
  31. package/dist/dom/p5.MediaElement.js +1 -1
  32. package/dist/image/const.js +1 -1
  33. package/dist/image/filterRenderer2D.js +3 -3
  34. package/dist/image/image.js +3 -3
  35. package/dist/image/index.js +3 -3
  36. package/dist/image/loading_displaying.js +3 -3
  37. package/dist/image/p5.Image.js +2 -2
  38. package/dist/io/files.js +3 -3
  39. package/dist/io/index.js +3 -3
  40. package/dist/{main-BNYJV9Kd.js → main-BR2ALC_6.js} +3 -3
  41. package/dist/math/Matrices/Matrix.js +1 -1
  42. package/dist/math/Matrices/MatrixNumjs.js +1 -1
  43. package/dist/math/index.js +1 -1
  44. package/dist/math/p5.Matrix.js +1 -1
  45. package/dist/math/p5.Vector.js +76 -51
  46. package/dist/math/patch-vector.js +20 -8
  47. package/dist/math/trigonometry.js +1 -1
  48. package/dist/{p5.Renderer-BfhR0QHl.js → p5.Renderer-XOvhEbJn.js} +1 -1
  49. package/dist/{rendering-mbOOQwHM.js → rendering-C5lX6zKm.js} +2 -2
  50. package/dist/shape/2d_primitives.js +1 -1
  51. package/dist/shape/attributes.js +1 -1
  52. package/dist/shape/custom_shapes.js +1 -1
  53. package/dist/shape/index.js +1 -1
  54. package/dist/type/index.js +2 -2
  55. package/dist/type/p5.Font.js +2 -2
  56. package/dist/type/textCore.js +2 -2
  57. package/dist/webgl/3d_primitives.js +3 -3
  58. package/dist/webgl/GeometryBuilder.js +1 -1
  59. package/dist/webgl/ShapeBuilder.js +1 -1
  60. package/dist/webgl/enums.js +1 -1
  61. package/dist/webgl/index.js +3 -3
  62. package/dist/webgl/interaction.js +1 -1
  63. package/dist/webgl/light.js +3 -3
  64. package/dist/webgl/loading.js +3 -3
  65. package/dist/webgl/material.js +3 -3
  66. package/dist/webgl/p5.Camera.js +3 -3
  67. package/dist/webgl/p5.Framebuffer.js +3 -3
  68. package/dist/webgl/p5.Geometry.js +1 -1
  69. package/dist/webgl/p5.Quat.js +1 -1
  70. package/dist/webgl/p5.RendererGL.js +3 -3
  71. package/dist/webgl/p5.Texture.js +3 -3
  72. package/dist/webgl/text.js +3 -3
  73. package/dist/webgl/utils.js +3 -3
  74. package/dist/webgpu/index.js +1 -1
  75. package/dist/webgpu/p5.RendererWebGPU.js +1 -1
  76. package/lib/p5.esm.js +96 -59
  77. package/lib/p5.esm.min.js +1 -1
  78. package/lib/p5.js +96 -59
  79. package/lib/p5.min.js +1 -1
  80. package/lib/p5.webgpu.esm.js +1 -1
  81. package/lib/p5.webgpu.js +1 -1
  82. package/lib/p5.webgpu.min.js +1 -1
  83. package/package.json +1 -1
  84. package/types/global.d.ts +14 -14
  85. package/types/p5.d.ts +24 -31
package/lib/p5.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! p5.js v2.3.0-rc.5 May 21, 2026 */
1
+ /*! p5.js v2.3.0 May 28, 2026 */
2
2
  var p5 = (function () {
3
3
  'use strict';
4
4
 
@@ -15,7 +15,7 @@ var p5 = (function () {
15
15
  * @property {String} VERSION
16
16
  * @final
17
17
  */
18
- const VERSION = '2.3.0-rc.5';
18
+ const VERSION = '2.3.0';
19
19
 
20
20
  // GRAPHICS RENDERER
21
21
  /**
@@ -19794,8 +19794,14 @@ var p5 = (function () {
19794
19794
  * This function is used by binary vector operations to prioritize shorter vectors,
19795
19795
  * and to emit a warning when lengths do not match.
19796
19796
  */
19797
- const prioritizeSmallerDimension = function(currentVectorDimension, args) {
19798
- return Math.min(currentVectorDimension, args.length);
19797
+ const prioritizeSmallerDimension = function (currentVectorDimension, args) {
19798
+ const resultDimension = Math.min(currentVectorDimension, args.length);
19799
+ if (Array.isArray(args) && currentVectorDimension !== args.length) {
19800
+ console.warn(
19801
+ 'When working with two vectors of different sizes, the smaller dimension is used. In this operation, both vector will be treated as ' + resultDimension + 'D vectors, and any additional values of the linger vector will be ignored.'
19802
+ );
19803
+ }
19804
+ return resultDimension;
19799
19805
  };
19800
19806
 
19801
19807
  /**
@@ -20089,17 +20095,12 @@ var p5 = (function () {
20089
20095
  }
20090
20096
 
20091
20097
  /**
20092
- * Sets the vector's `x`, `y`, and `z` components.
20098
+ * Sets the the vector to a new value.
20093
20099
  *
20094
20100
  * `set()` can use separate numbers, as in `v.set(1, 2, 3)`, a
20095
20101
  * <a href="#/p5.Vector">p5.Vector</a> object, as in `v.set(v2)`, or an
20096
20102
  * array of numbers, as in `v.set([1, 2, 3])`.
20097
20103
  *
20098
- * If a value isn't provided for a component, it will be set to 0. For
20099
- * example, `v.set(4, 5)` sets `v.x` to 4, `v.y` to 5, and `v.z` to 0.
20100
- * Calling `set()` with no arguments, as in `v.set()`, sets all the vector's
20101
- * components to 0.
20102
- *
20103
20104
  * @param {Number} [x] x component of the vector.
20104
20105
  * @param {Number} [y] y component of the vector.
20105
20106
  * @param {Number} [z] z component of the vector.
@@ -20184,8 +20185,6 @@ var p5 = (function () {
20184
20185
  }
20185
20186
  }
20186
20187
 
20187
-
20188
-
20189
20188
  /**
20190
20189
  * Adds to a vector's components.
20191
20190
  *
@@ -20193,11 +20192,10 @@ var p5 = (function () {
20193
20192
  * another <a href="#/p5.Vector">p5.Vector</a> object, as in `v.add(v2)`, or
20194
20193
  * an array of numbers, as in `v.add([1, 2, 3])`.
20195
20194
  *
20196
- * Add vectors only when they are the same size: both 2-dimensional, or
20197
- * both 3-dimensional. When two vectors of different sizes are added, the
20198
- * smaller dimension will be used, any additional values of the longer
20199
- * vector will be ignored.
20200
- * For example, adding `[1, 2, 3]` and `[4, 5]` will result in `[5, 7]`.
20195
+ * You should add vectors only when they are the same size. When two vectors
20196
+ * of different sizes are added, the smaller dimension will be used, any
20197
+ * additional values of the longer vector will be ignored. For example,
20198
+ * adding `[1, 2, 3]` and `[4, 5]` will result in `[5, 7]`.
20201
20199
  *
20202
20200
  * Calling `add()` with no arguments, as in `v.add()`, has no effect.
20203
20201
  *
@@ -20314,7 +20312,7 @@ var p5 = (function () {
20314
20312
  * @param {p5.Vector|Number[]} value The vector to add
20315
20313
  * @chainable
20316
20314
  */
20317
- add(...args) {
20315
+ add(args) {
20318
20316
  const minDimension = prioritizeSmallerDimension(this.dimensions, args);
20319
20317
  shrinkToDimension(this.values, minDimension);
20320
20318
 
@@ -20325,11 +20323,8 @@ var p5 = (function () {
20325
20323
  return this;
20326
20324
  }
20327
20325
 
20328
-
20329
-
20330
20326
  /**
20331
- * Performs modulo (remainder) division with a vector's `x`, `y`, and `z`
20332
- * components.
20327
+ * Performs modulo (remainder) division with a vector's components.
20333
20328
  *
20334
20329
  * `rem()` can use separate numbers, as in `v.rem(1, 2, 3)`,
20335
20330
  * another <a href="#/p5.Vector">p5.Vector</a> object, as in `v.rem(v2)`, or
@@ -20339,8 +20334,8 @@ var p5 = (function () {
20339
20334
  * will be set to their values modulo 2. Calling `rem()` with no
20340
20335
  * arguments, as in `v.rem()`, has no effect.
20341
20336
  *
20342
- * Modulo vectors only when they are the same size: both 2D, or both 3D.
20343
- * When two vectors of different sizes are used, the smaller dimension will be
20337
+ * You should modulo vectors only when they are the same size. When two
20338
+ * vectors of different sizes are used, the smaller dimension will be
20344
20339
  * used, any additional values of the longer vector will be ignored.
20345
20340
  * For example, taking `[3, 6, 9]` modulo `[2, 4]` will result in `[1, 2]`.
20346
20341
  *
@@ -20438,13 +20433,20 @@ var p5 = (function () {
20438
20433
  * @param {p5.Vector | Number[]} value divisor vector.
20439
20434
  * @chainable
20440
20435
  */
20441
- rem(...args) {
20436
+ rem(args) {
20442
20437
  const minDimension = prioritizeSmallerDimension(this.dimensions, args);
20443
20438
 
20444
20439
  shrinkToDimension(this.values, minDimension);
20445
- for (let i = 0; i < this.values.length; i++) {
20446
- if (args[i] > 0) {
20447
- this.values[i] = this.values[i] % args[i];
20440
+
20441
+ if(Array.isArray(args)){
20442
+ for (let i = 0; i < this.values.length; i++) {
20443
+ if (args[i] > 0) {
20444
+ this.values[i] = this.values[i] % args[i];
20445
+ }
20446
+ }
20447
+ } else if(args > 0) {
20448
+ for (let i = 0; i < this.values.length; i++) {
20449
+ this.values[i] = this.values[i] % args;
20448
20450
  }
20449
20451
  }
20450
20452
 
@@ -20452,7 +20454,7 @@ var p5 = (function () {
20452
20454
  }
20453
20455
 
20454
20456
  /**
20455
- * Subtracts from a vector's `x`, `y`, and `z` components.
20457
+ * Subtracts from a vector's components.
20456
20458
  *
20457
20459
  * `sub()` can use separate numbers, as in `v.sub(1, 2, 3)`, another
20458
20460
  * <a href="#/p5.Vector">p5.Vector</a> object, as in `v.sub(v2)`, or an array
@@ -20460,8 +20462,8 @@ var p5 = (function () {
20460
20462
  *
20461
20463
  * Calling `sub()` with no arguments, as in `v.sub()`, has no effect.
20462
20464
  *
20463
- * Subtract vectors only when they are the same size: both 2D, or both 3D.
20464
- * When two vectors of different sizes are used, the smaller dimension will be
20465
+ * You should subtract vectors only when they are the same size. When two
20466
+ * vectors of different sizes are used, the smaller dimension will be
20465
20467
  * used, any additional values of the longer vector will be ignored.
20466
20468
  * For example, subtracting `[1, 2]` from `[3, 5, 7]` will result in `[2, 3]`.
20467
20469
  *
@@ -20573,7 +20575,7 @@ var p5 = (function () {
20573
20575
  * @param {p5.Vector|Number[]} value the vector to subtract
20574
20576
  * @chainable
20575
20577
  */
20576
- sub(...args) {
20578
+ sub(args) {
20577
20579
  const minDimension = prioritizeSmallerDimension(this.dimensions, args);
20578
20580
  shrinkToDimension(this.values, minDimension);
20579
20581
 
@@ -20585,7 +20587,7 @@ var p5 = (function () {
20585
20587
  }
20586
20588
 
20587
20589
  /**
20588
- * Multiplies a vector's `x`, `y`, and `z` components.
20590
+ * Multiplies a vector's components.
20589
20591
  *
20590
20592
  * `mult()` can use separate numbers, as in `v.mult(1, 2, 3)`, another
20591
20593
  * <a href="#/p5.Vector">p5.Vector</a> object, as in `v.mult(v2)`, or an array
@@ -20595,8 +20597,8 @@ var p5 = (function () {
20595
20597
  * will be multiplied by 2. Calling `mult()` with no arguments, as in `v.mult()`, has
20596
20598
  * no effect.
20597
20599
  *
20598
- * Multiply vectors only when they are the same size: both 2D, or both 3D.
20599
- * When two vectors of different sizes are multiplied, the smaller dimension will be
20600
+ * You should multiply vectors only when they are the same size. When two
20601
+ * vectors of different sizes are multiplied, the smaller dimension will be
20600
20602
  * used, any additional values of the longer vector will be ignored.
20601
20603
  * For example, multiplying `[1, 2, 3]` by `[4, 5]` will result in `[4, 10]`.
20602
20604
  *
@@ -20761,19 +20763,25 @@ var p5 = (function () {
20761
20763
  * @param {p5.Vector} v vector to multiply with the components of the original vector.
20762
20764
  * @chainable
20763
20765
  */
20764
- mult(...args) {
20766
+ mult(args) {
20765
20767
  const minDimension = prioritizeSmallerDimension(this.dimensions, args);
20766
20768
  shrinkToDimension(this.values, minDimension);
20767
20769
 
20768
- for (let i = 0; i < this.values.length; i++) {
20769
- this.values[i] *= args[i];
20770
+ if(Array.isArray(args)){
20771
+ for (let i = 0; i < this.values.length; i++) {
20772
+ this.values[i] *= args[i];
20773
+ }
20774
+ } else {
20775
+ for (let i = 0; i < this.values.length; i++) {
20776
+ this.values[i] *= args;
20777
+ }
20770
20778
  }
20771
20779
 
20772
20780
  return this;
20773
20781
  }
20774
20782
 
20775
20783
  /**
20776
- * Divides a vector's `x`, `y`, and `z` components.
20784
+ * Divides a vector's components.
20777
20785
  *
20778
20786
  * `div()` can use separate numbers, as in `v.div(1, 2, 3)`, another
20779
20787
  * <a href="#/p5.Vector">p5.Vector</a> object, as in `v.div(v2)`, or an array
@@ -20783,8 +20791,8 @@ var p5 = (function () {
20783
20791
  * will be divided by 2. Calling `div()` with no arguments, as in `v.div()`, has
20784
20792
  * no effect.
20785
20793
  *
20786
- * Divide vectors only when they are the same size: both 2D, or both 3D.
20787
- * When two vectors of different sizes are divided, the smaller dimension will be
20794
+ * You should divide vectors only when they are the same size. When two
20795
+ * vectors of different sizes are divided, the smaller dimension will be
20788
20796
  * used, any additional values of the longer vector will be ignored.
20789
20797
  * For example, dividing `[8, 12, 21]` by `[2, 3]` will result in `[4, 4]`.
20790
20798
  *
@@ -20950,24 +20958,41 @@ var p5 = (function () {
20950
20958
  * @param {p5.Vector} v vector to divide the components of the original vector by.
20951
20959
  * @chainable
20952
20960
  */
20953
- div(...args) {
20961
+ div(args) {
20954
20962
  const minDimension = prioritizeSmallerDimension(this.dimensions, args);
20955
20963
 
20956
- for (let i = 0; i < minDimension; i++) {
20957
- if (typeof args[i] !== 'number' || args[i] === 0) {
20958
- if (!this.friendlyErrorsDisabled()) {
20959
- console.warn(
20960
- 'p5.Vector.prototype.div',
20961
- 'Arguments contain components that are 0'
20962
- );
20964
+ if (Array.isArray(args)) {
20965
+ for (let i = 0; i < minDimension; i++) {
20966
+ if ((typeof args[i] !== 'number' || args[i] === 0)) {
20967
+ if (!this.friendlyErrorsDisabled()) {
20968
+ console.warn(
20969
+ 'p5.Vector.prototype.div',
20970
+ 'Arguments contain components that are 0'
20971
+ );
20972
+ }
20973
+ return this;
20963
20974
  }
20964
- return this;
20965
20975
  }
20976
+ } else if(typeof args !== 'number' || args === 0) {
20977
+ if (!this.friendlyErrorsDisabled()) {
20978
+ console.warn(
20979
+ 'p5.Vector.prototype.div',
20980
+ 'Arguments contain components that are 0'
20981
+ );
20982
+ }
20983
+ return this;
20966
20984
  }
20967
20985
 
20968
20986
  shrinkToDimension(this.values, minDimension);
20969
- for (let i = 0; i < this.values.length; i++) {
20970
- this.values[i] /= args[i];
20987
+
20988
+ if(Array.isArray(args)){
20989
+ for (let i = 0; i < this.values.length; i++) {
20990
+ this.values[i] /= args[i];
20991
+ }
20992
+ } else {
20993
+ for (let i = 0; i < this.values.length; i++) {
20994
+ this.values[i] /= args;
20995
+ }
20971
20996
  }
20972
20997
 
20973
20998
  return this;
@@ -108361,7 +108386,7 @@ var p5 = (function () {
108361
108386
  function _defaultEmptyVector(target){
108362
108387
  return function(...args){
108363
108388
  if(args.length === 0){
108364
- this._friendlyError(
108389
+ this.constructor._friendlyError(
108365
108390
  'In 1.x, createVector() was a shortcut for createVector(0, 0, 0). In 2.x, p5.js has vectors of any dimension, so you must provide your desired number of zeros. Use createVector(0, 0) for a 2D vector and createVector(0, 0, 0) for a 3D vector.',
108366
108391
  'p5.createVector'
108367
108392
  );
@@ -108382,7 +108407,7 @@ var p5 = (function () {
108382
108407
  */
108383
108408
  function _validatedVectorOperation(expectsSoloNumberArgument){
108384
108409
  return function(target){
108385
- return function(...args){
108410
+ return function (...args) {
108386
108411
  if (args.length === 0) {
108387
108412
  // No arguments? No action
108388
108413
  return this;
@@ -108392,16 +108417,18 @@ var p5 = (function () {
108392
108417
  } else if (Array.isArray(args[0])) {
108393
108418
  // First argument is an array? Great, keep it!
108394
108419
  args = args[0];
108395
- } else if (expectsSoloNumberArgument && args.length === 1){
108420
+ } else if (args.length === 1){
108396
108421
  // Special case for a solo numeric arguments only applies sometimes
108397
- args = new Array(3).fill(args[0]);
108422
+ if (expectsSoloNumberArgument) {
108423
+ args = args[0];
108424
+ }
108398
108425
  }
108399
108426
 
108400
- if (Array.isArray(args)) {
108427
+ if(Array.isArray(args)){
108401
108428
  for (let i = 0; i < args.length; i++) {
108402
108429
  const v = args[i];
108403
108430
  if (typeof v !== 'number' || !Number.isFinite(v)) {
108404
- if (!Vector.friendlyErrorsDisabled()) {
108431
+ if (!this.friendlyErrorsDisabled()) {
108405
108432
  this._friendlyError(
108406
108433
  'Arguments contain non-finite numbers',
108407
108434
  'p5.Vector'
@@ -108410,9 +108437,19 @@ var p5 = (function () {
108410
108437
  return this;
108411
108438
  }
108412
108439
  }
108440
+ } else {
108441
+ if (typeof args !== 'number' || !Number.isFinite(args)) {
108442
+ if (!this.friendlyErrorsDisabled()) {
108443
+ this._friendlyError(
108444
+ 'Arguments contain non-finite numbers',
108445
+ 'p5.Vector'
108446
+ );
108447
+ }
108448
+ return this;
108449
+ }
108413
108450
  }
108414
108451
 
108415
- return target.call(this, ...args);
108452
+ return target.call(this, args);
108416
108453
  };
108417
108454
  };
108418
108455
  }