p5 2.2.3 → 2.3.0-rc.1

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 (137) hide show
  1. package/dist/accessibility/color_namer.js +9 -11
  2. package/dist/accessibility/describe.js +0 -1
  3. package/dist/accessibility/gridOutput.js +0 -1
  4. package/dist/accessibility/index.js +9 -10
  5. package/dist/accessibility/outputs.js +0 -1
  6. package/dist/accessibility/textOutput.js +0 -1
  7. package/dist/app.js +11 -10
  8. package/dist/app.node.js +122 -0
  9. package/dist/color/color_conversion.js +9 -11
  10. package/dist/color/creating_reading.js +1 -1
  11. package/dist/color/index.js +2 -2
  12. package/dist/color/p5.Color.js +1 -1
  13. package/dist/color/setting.js +25 -12
  14. package/dist/{constants-BdTiYOQI.js → constants-0wkVUfqa.js} +2 -2
  15. package/dist/core/States.js +1 -1
  16. package/dist/core/constants.js +1 -1
  17. package/dist/core/environment.js +28 -29
  18. package/dist/core/filterShaders.js +1 -1
  19. package/dist/core/friendly_errors/fes_core.js +9 -8
  20. package/dist/core/friendly_errors/file_errors.js +1 -2
  21. package/dist/core/friendly_errors/index.js +1 -1
  22. package/dist/core/friendly_errors/param_validator.js +737 -640
  23. package/dist/core/friendly_errors/sketch_verifier.js +1 -1
  24. package/dist/core/friendly_errors/stacktrace.js +0 -1
  25. package/dist/core/helpers.js +3 -4
  26. package/dist/core/init.js +24 -21
  27. package/dist/core/internationalization.js +1 -1
  28. package/dist/core/legacy.js +9 -11
  29. package/dist/core/main.js +9 -10
  30. package/dist/core/p5.Graphics.js +5 -5
  31. package/dist/core/p5.Renderer.js +3 -3
  32. package/dist/core/p5.Renderer2D.js +9 -10
  33. package/dist/core/p5.Renderer3D.js +5 -5
  34. package/dist/core/rendering.js +5 -5
  35. package/dist/core/structure.js +0 -1
  36. package/dist/core/transform.js +7 -16
  37. package/dist/{creating_reading-C7hu6sg1.js → creating_reading-DLkHH80h.js} +11 -8
  38. package/dist/data/local_storage.js +0 -1
  39. package/dist/dom/dom.js +2 -3
  40. package/dist/dom/index.js +2 -2
  41. package/dist/dom/p5.Element.js +2 -2
  42. package/dist/dom/p5.MediaElement.js +2 -2
  43. package/dist/events/acceleration.js +5 -3
  44. package/dist/events/keyboard.js +0 -1
  45. package/dist/events/pointer.js +0 -2
  46. package/dist/image/const.js +1 -1
  47. package/dist/image/filterRenderer2D.js +19 -12
  48. package/dist/image/image.js +5 -5
  49. package/dist/image/index.js +5 -5
  50. package/dist/image/loading_displaying.js +5 -5
  51. package/dist/image/p5.Image.js +3 -3
  52. package/dist/image/pixels.js +0 -1
  53. package/dist/io/files.js +5 -5
  54. package/dist/io/index.js +5 -5
  55. package/dist/io/p5.Table.js +0 -1
  56. package/dist/io/p5.TableRow.js +0 -1
  57. package/dist/io/p5.XML.js +0 -1
  58. package/dist/{ir_builders-Cd6rU9Vm.js → ir_builders-C2ebb6Lu.js} +234 -1
  59. package/dist/{main-H_nu4eDs.js → main-D2kqeMXM.js} +107 -136
  60. package/dist/math/Matrices/Matrix.js +1 -1
  61. package/dist/math/Matrices/MatrixNumjs.js +1 -1
  62. package/dist/math/calculation.js +0 -1
  63. package/dist/math/index.js +3 -1
  64. package/dist/math/math.js +3 -17
  65. package/dist/math/noise.js +0 -1
  66. package/dist/math/p5.Matrix.js +1 -2
  67. package/dist/math/p5.Vector.js +237 -279
  68. package/dist/math/patch-vector.js +75 -0
  69. package/dist/math/random.js +0 -1
  70. package/dist/math/trigonometry.js +3 -4
  71. package/dist/{p5.Renderer-BmD2P6Wv.js → p5.Renderer-CQI8PO1F.js} +31 -24
  72. package/dist/{rendering-CC8JNTwG.js → rendering-ltTIxpF2.js} +732 -44
  73. package/dist/shape/2d_primitives.js +1 -4
  74. package/dist/shape/attributes.js +43 -8
  75. package/dist/shape/curves.js +0 -1
  76. package/dist/shape/custom_shapes.js +260 -5
  77. package/dist/shape/index.js +2 -2
  78. package/dist/shape/vertex.js +0 -2
  79. package/dist/strands/ir_builders.js +1 -1
  80. package/dist/strands/ir_types.js +5 -1
  81. package/dist/strands/p5.strands.js +286 -31
  82. package/dist/strands/strands_api.js +179 -8
  83. package/dist/strands/strands_codegen.js +26 -8
  84. package/dist/strands/strands_conditionals.js +1 -1
  85. package/dist/strands/strands_for.js +1 -1
  86. package/dist/strands/strands_node.js +1 -1
  87. package/dist/strands/strands_ternary.js +56 -0
  88. package/dist/strands/strands_transpiler.js +416 -251
  89. package/dist/strands_glslBackend-i-ReKgZo.js +423 -0
  90. package/dist/type/index.js +3 -3
  91. package/dist/type/lib/Typr.js +1 -1
  92. package/dist/type/p5.Font.js +3 -3
  93. package/dist/type/textCore.js +31 -24
  94. package/dist/utilities/conversion.js +0 -1
  95. package/dist/utilities/time_date.js +0 -1
  96. package/dist/utilities/utility_functions.js +0 -1
  97. package/dist/webgl/3d_primitives.js +5 -5
  98. package/dist/webgl/GeometryBuilder.js +1 -1
  99. package/dist/webgl/ShapeBuilder.js +26 -1
  100. package/dist/webgl/enums.js +1 -1
  101. package/dist/webgl/index.js +8 -9
  102. package/dist/webgl/interaction.js +8 -4
  103. package/dist/webgl/light.js +5 -5
  104. package/dist/webgl/loading.js +60 -21
  105. package/dist/webgl/material.js +5 -5
  106. package/dist/webgl/p5.Camera.js +5 -5
  107. package/dist/webgl/p5.Framebuffer.js +5 -5
  108. package/dist/webgl/p5.Geometry.js +3 -5
  109. package/dist/webgl/p5.Quat.js +1 -1
  110. package/dist/webgl/p5.RendererGL.js +17 -21
  111. package/dist/webgl/p5.Shader.js +129 -36
  112. package/dist/webgl/p5.Texture.js +5 -5
  113. package/dist/webgl/strands_glslBackend.js +5 -386
  114. package/dist/webgl/text.js +5 -5
  115. package/dist/webgl/utils.js +5 -5
  116. package/dist/webgl2Compatibility-DA7DLMuq.js +7 -0
  117. package/dist/webgpu/index.js +7 -3
  118. package/dist/webgpu/p5.RendererWebGPU.js +1146 -180
  119. package/dist/webgpu/shaders/color.js +1 -1
  120. package/dist/webgpu/shaders/compute.js +32 -0
  121. package/dist/webgpu/shaders/functions/randomComputeWGSL.js +31 -0
  122. package/dist/webgpu/shaders/functions/randomVertWGSL.js +30 -0
  123. package/dist/webgpu/shaders/functions/randomWGSL.js +30 -0
  124. package/dist/webgpu/shaders/line.js +1 -1
  125. package/dist/webgpu/shaders/material.js +3 -3
  126. package/dist/webgpu/strands_wgslBackend.js +137 -15
  127. package/lib/p5.esm.js +4092 -1950
  128. package/lib/p5.esm.min.js +1 -1
  129. package/lib/p5.js +4092 -1950
  130. package/lib/p5.min.js +1 -1
  131. package/lib/p5.webgpu.esm.js +1748 -306
  132. package/lib/p5.webgpu.js +1747 -305
  133. package/lib/p5.webgpu.min.js +1 -1
  134. package/package.json +6 -1
  135. package/types/global.d.ts +4182 -2441
  136. package/types/p5.d.ts +2776 -1675
  137. package/dist/noise3DGLSL-Bwrdi4gi.js +0 -9
@@ -1,23 +1,22 @@
1
- import { j as ARROW, k as CROSS, l as HAND, m as MOVE, n as TEXT, o as WAIT, P as P2D } from '../constants-BdTiYOQI.js';
1
+ import { h as ARROW, i as CROSS, j as HAND, k as MOVE, l as TEXT, m as WAIT, P as P2D } from '../constants-0wkVUfqa.js';
2
2
 
3
3
  /**
4
4
  * @module Environment
5
5
  * @submodule Environment
6
6
  * @for p5
7
- * @requires core
8
- * @requires constants
9
7
  */
10
8
 
11
9
  // import { Vector } from '../math/p5.Vector';
12
10
 
13
11
  function environment(p5, fn, lifecycles){
14
12
  const standardCursors = [ARROW, CROSS, HAND, MOVE, TEXT, WAIT];
13
+ const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
15
14
 
16
15
  fn._frameRate = 0;
17
- fn._lastFrameTime = window.performance.now();
16
+ fn._lastFrameTime = globalThis.performance.now();
18
17
  fn._targetFrameRate = 60;
19
18
 
20
- const _windowPrint = window.print;
19
+ const windowPrint = isBrowser ? window.print : null;
21
20
  let windowPrintDisabled = false;
22
21
 
23
22
  lifecycles.presetup = function(){
@@ -25,11 +24,13 @@ function environment(p5, fn, lifecycles){
25
24
  'resize'
26
25
  ];
27
26
 
28
- for(const event of events){
29
- window.addEventListener(event, this[`_on${event}`].bind(this), {
30
- passive: false,
31
- signal: this._removeSignal
32
- });
27
+ if(isBrowser){
28
+ for(const event of events){
29
+ window.addEventListener(event, this[`_on${event}`].bind(this), {
30
+ passive: false,
31
+ signal: this._removeSignal
32
+ });
33
+ }
33
34
  }
34
35
  };
35
36
 
@@ -60,9 +61,9 @@ function environment(p5, fn, lifecycles){
60
61
  * }
61
62
  */
62
63
  fn.print = function(...args) {
63
- if (!args.length) {
64
+ if (!args.length && windowPrint !== null) {
64
65
  if (!windowPrintDisabled) {
65
- _windowPrint();
66
+ windowPrint();
66
67
  if (
67
68
  window.confirm(
68
69
  'You just tried to print the webpage. Do you want to prevent this from running again?'
@@ -199,7 +200,7 @@ function environment(p5, fn, lifecycles){
199
200
  * }
200
201
  * }
201
202
  */
202
- fn.focused = document.hasFocus();
203
+ fn.focused = isBrowser ? document.hasFocus() : true;
203
204
 
204
205
  /**
205
206
  * Changes the cursor's appearance.
@@ -216,6 +217,8 @@ function environment(p5, fn, lifecycles){
216
217
  * cursor, `x` and `y` set the location pointed to within the image. They are
217
218
  * both 0 by default, so the cursor points to the image's top-left corner. `x`
218
219
  * and `y` must be less than the image's width and height, respectively.
220
+ *
221
+ * Calling `cursor()` without an argument returns the current cursor type as a string.
219
222
  *
220
223
  * @method cursor
221
224
  * @param {(ARROW|CROSS|HAND|MOVE|TEXT|WAIT|String)} type Built-in: either ARROW, CROSS, HAND, MOVE, TEXT, or WAIT.
@@ -282,9 +285,17 @@ function environment(p5, fn, lifecycles){
282
285
  * }
283
286
  * }
284
287
  */
288
+ /**
289
+ * @method cursor
290
+ * @return {(ARROW|CROSS|HAND|MOVE|TEXT|WAIT|String)} the current cursor type
291
+ */
285
292
  fn.cursor = function(type, x, y) {
286
293
  let cursor = 'auto';
287
294
  const canvas = this._curElement.elt;
295
+ if (typeof type === 'undefined') {
296
+ let curstr = canvas.style.cursor;
297
+ return curstr.length ? curstr : 'default';
298
+ }
288
299
  if (standardCursors.includes(type)) {
289
300
  // Standard css cursor
290
301
  cursor = type;
@@ -571,7 +582,7 @@ function environment(p5, fn, lifecycles){
571
582
  * @alt
572
583
  * This example does not render anything.
573
584
  */
574
- fn.displayWidth = screen.width;
585
+ fn.displayWidth = isBrowser ? window.screen.width : 0;
575
586
 
576
587
  /**
577
588
  * A `Number` variable that stores the height of the screen display.
@@ -599,7 +610,7 @@ function environment(p5, fn, lifecycles){
599
610
  * @alt
600
611
  * This example does not render anything.
601
612
  */
602
- fn.displayHeight = screen.height;
613
+ fn.displayHeight = isBrowser ? window.screen.height : 0;
603
614
 
604
615
  /**
605
616
  * A `Number` variable that stores the width of the browser's viewport.
@@ -725,21 +736,11 @@ function environment(p5, fn, lifecycles){
725
736
  };
726
737
 
727
738
  function getWindowWidth() {
728
- return (
729
- window.innerWidth ||
730
- (document.documentElement && document.documentElement.clientWidth) ||
731
- (document.body && document.body.clientWidth) ||
732
- 0
733
- );
739
+ return isBrowser ? document.documentElement.clientWidth : 0;
734
740
  }
735
741
 
736
742
  function getWindowHeight() {
737
- return (
738
- window.innerHeight ||
739
- (document.documentElement && document.documentElement.clientHeight) ||
740
- (document.body && document.body.clientHeight) ||
741
- 0
742
- );
743
+ return isBrowser ? document.documentElement.clientHeight : 0;
743
744
  }
744
745
 
745
746
  /**
@@ -799,7 +800,6 @@ function environment(p5, fn, lifecycles){
799
800
  * }
800
801
  */
801
802
  fn.fullscreen = function(val) {
802
- // p5._validateParameters('fullscreen', arguments);
803
803
  // no arguments, return fullscreen or not
804
804
  if (typeof val === 'undefined') {
805
805
  return (
@@ -870,7 +870,6 @@ function environment(p5, fn, lifecycles){
870
870
  * @returns {Number} current pixel density of the sketch.
871
871
  */
872
872
  fn.pixelDensity = function(val) {
873
- // p5._validateParameters('pixelDensity', arguments);
874
873
  let returnValue;
875
874
  if (typeof val === 'number') {
876
875
  if (val !== this._renderer._pixelDensity) {
@@ -1,4 +1,4 @@
1
- import { ag as OPAQUE, ah as DILATE, ai as ERODE, ab as BLUR, af as POSTERIZE, ae as THRESHOLD, aj as INVERT, ak as GRAY } from '../constants-BdTiYOQI.js';
1
+ import { ah as OPAQUE, ai as DILATE, aj as ERODE, ac as BLUR, ag as POSTERIZE, af as THRESHOLD, ak as INVERT, al as GRAY } from '../constants-0wkVUfqa.js';
2
2
 
3
3
  /*
4
4
  * Creates p5.strands filter shaders for cross-platform compatibility.
@@ -1,12 +1,11 @@
1
1
  import { translator } from '../internationalization.js';
2
2
  import strings from './browser_errors.js';
3
- import { a3 as constants } from '../../constants-BdTiYOQI.js';
3
+ import { am as constants } from '../../constants-0wkVUfqa.js';
4
4
  import 'i18next';
5
5
  import 'i18next-browser-languagedetector';
6
6
 
7
7
  /**
8
8
  * @for p5
9
- * @requires core
10
9
  *
11
10
  * This is the main file for the Friendly Error System (FES), containing
12
11
  * the core as well as miscellaneous functionality of the FES. Here is a
@@ -29,7 +28,7 @@ import 'i18next-browser-languagedetector';
29
28
  * https://github.com/processing/p5.js/blob/main/contributor_docs/fes_reference_dev_notes.md
30
29
  */
31
30
 
32
- function fesCore(p5, fn){
31
+ function fesCore(p5, fn, lifecycles){
33
32
  // p5.js blue, p5.js orange, auto dark green; fallback p5.js darkened magenta
34
33
  // See testColors below for all the color codes and names
35
34
  const typeColors = ['#2D7BB6', '#EE9900', '#4DB200', '#C83C00'];
@@ -942,9 +941,11 @@ function fesCore(p5, fn){
942
941
  p5._fesLogger = null;
943
942
  p5._fesLogCache = {};
944
943
 
945
- window.addEventListener('load', checkForUserDefinedFunctions, false);
946
- window.addEventListener('error', p5._fesErrorMonitor, false);
947
- window.addEventListener('unhandledrejection', p5._fesErrorMonitor, false);
944
+ lifecycles.presetup = function () {
945
+ window.addEventListener('load', checkForUserDefinedFunctions, false);
946
+ window.addEventListener('error', p5._fesErrorMonitor, false);
947
+ window.addEventListener('unhandledrejection', p5._fesErrorMonitor, false);
948
+ };
948
949
 
949
950
  /**
950
951
  * Prints out all the colors in the color pallete with white text.
@@ -1104,7 +1105,7 @@ function fesCore(p5, fn){
1104
1105
  // Exposing this primarily for unit testing.
1105
1106
  fn._helpForMisusedAtTopLevelCode = helpForMisusedAtTopLevelCode;
1106
1107
 
1107
- if (document.readyState !== 'complete') {
1108
+ if (typeof document !== 'undefined' && document.readyState !== 'complete') {
1108
1109
  window.addEventListener('error', helpForMisusedAtTopLevelCode, false);
1109
1110
 
1110
1111
  // Our job is only to catch ReferenceErrors that are thrown when
@@ -1118,7 +1119,7 @@ function fesCore(p5, fn){
1118
1119
  }
1119
1120
 
1120
1121
  if (typeof p5 !== 'undefined') {
1121
- fesCore(p5, p5.prototype);
1122
+ p5.registerAddon(fesCore);
1122
1123
  }
1123
1124
 
1124
1125
  export { fesCore as default };
@@ -1,11 +1,10 @@
1
1
  import { translator } from '../internationalization.js';
2
2
  import 'i18next';
3
3
  import 'i18next-browser-languagedetector';
4
- import '../../constants-BdTiYOQI.js';
4
+ import '../../constants-0wkVUfqa.js';
5
5
 
6
6
  /**
7
7
  * @for p5
8
- * @requires core
9
8
  */
10
9
 
11
10
  function fileErrors(p5, fn){
@@ -6,7 +6,7 @@ import fileErrors from './file_errors.js';
6
6
  import '../internationalization.js';
7
7
  import 'i18next';
8
8
  import 'i18next-browser-languagedetector';
9
- import '../../constants-BdTiYOQI.js';
9
+ import '../../constants-0wkVUfqa.js';
10
10
  import './browser_errors.js';
11
11
  import 'zod/v4';
12
12
  import 'acorn';