p5 2.2.2 → 2.2.3-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 (98) hide show
  1. package/dist/accessibility/color_namer.js +5 -5
  2. package/dist/accessibility/index.js +5 -5
  3. package/dist/app.js +5 -5
  4. package/dist/color/color_conversion.js +5 -5
  5. package/dist/color/index.js +1 -1
  6. package/dist/color/setting.js +1 -1
  7. package/dist/{constants-BxjhKpTv.js → constants-BUwWryrh.js} +1 -1
  8. package/dist/core/constants.js +1 -1
  9. package/dist/core/environment.js +7 -3
  10. package/dist/core/filterShaders.js +1 -1
  11. package/dist/core/friendly_errors/fes_core.js +1 -1
  12. package/dist/core/friendly_errors/file_errors.js +1 -1
  13. package/dist/core/friendly_errors/index.js +1 -1
  14. package/dist/core/friendly_errors/param_validator.js +2063 -2014
  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 +5 -5
  18. package/dist/core/internationalization.js +1 -1
  19. package/dist/core/legacy.js +5 -5
  20. package/dist/core/main.js +5 -5
  21. package/dist/core/p5.Graphics.js +3 -3
  22. package/dist/core/p5.Renderer.js +2 -2
  23. package/dist/core/p5.Renderer2D.js +5 -5
  24. package/dist/core/p5.Renderer3D.js +3 -3
  25. package/dist/core/rendering.js +3 -3
  26. package/dist/dom/dom.js +1 -1
  27. package/dist/dom/index.js +1 -1
  28. package/dist/dom/p5.Element.js +1 -1
  29. package/dist/dom/p5.MediaElement.js +11 -4
  30. package/dist/events/pointer.js +4 -0
  31. package/dist/image/const.js +1 -1
  32. package/dist/image/filterRenderer2D.js +4 -4
  33. package/dist/image/image.js +3 -3
  34. package/dist/image/index.js +3 -3
  35. package/dist/image/loading_displaying.js +3 -3
  36. package/dist/image/p5.Image.js +2 -2
  37. package/dist/io/files.js +3 -3
  38. package/dist/io/index.js +3 -3
  39. package/dist/{ir_builders-w12-GSxu.js → ir_builders-Cd6rU9Vm.js} +48 -14
  40. package/dist/{main-DDs4QOnh.js → main-DFpoFdvM.js} +126 -36
  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 +1 -1
  46. package/dist/math/trigonometry.js +1 -1
  47. package/dist/{p5.Renderer-BSGddFv7.js → p5.Renderer-D-EuAodU.js} +9 -2
  48. package/dist/{rendering-C9g7uSQ5.js → rendering-DE9-Hl7Y.js} +103 -78
  49. package/dist/shape/2d_primitives.js +1 -1
  50. package/dist/shape/attributes.js +1 -1
  51. package/dist/shape/custom_shapes.js +1 -1
  52. package/dist/shape/index.js +1 -1
  53. package/dist/strands/ir_builders.js +1 -1
  54. package/dist/strands/ir_dag.js +32 -2
  55. package/dist/strands/ir_types.js +18 -11
  56. package/dist/strands/p5.strands.js +24 -35
  57. package/dist/strands/strands_api.js +86 -41
  58. package/dist/strands/strands_codegen.js +0 -12
  59. package/dist/strands/strands_conditionals.js +1 -1
  60. package/dist/strands/strands_for.js +1 -1
  61. package/dist/strands/strands_node.js +1 -1
  62. package/dist/strands/strands_phi_utils.js +27 -9
  63. package/dist/strands/strands_transpiler.js +1237 -831
  64. package/dist/type/index.js +2 -2
  65. package/dist/type/p5.Font.js +7 -5
  66. package/dist/type/textCore.js +2 -2
  67. package/dist/webgl/3d_primitives.js +3 -3
  68. package/dist/webgl/GeometryBuilder.js +1 -1
  69. package/dist/webgl/ShapeBuilder.js +1 -1
  70. package/dist/webgl/enums.js +1 -1
  71. package/dist/webgl/index.js +4 -4
  72. package/dist/webgl/interaction.js +1 -1
  73. package/dist/webgl/light.js +3 -3
  74. package/dist/webgl/loading.js +41 -35
  75. package/dist/webgl/material.js +3 -3
  76. package/dist/webgl/p5.Camera.js +3 -3
  77. package/dist/webgl/p5.Framebuffer.js +3 -3
  78. package/dist/webgl/p5.Geometry.js +1 -1
  79. package/dist/webgl/p5.Quat.js +1 -1
  80. package/dist/webgl/p5.RendererGL.js +4 -4
  81. package/dist/webgl/p5.Shader.js +14 -6
  82. package/dist/webgl/p5.Texture.js +3 -3
  83. package/dist/webgl/strands_glslBackend.js +1 -1
  84. package/dist/webgl/text.js +3 -3
  85. package/dist/webgl/utils.js +3 -3
  86. package/dist/webgpu/index.js +2 -2
  87. package/dist/webgpu/p5.RendererWebGPU.js +2 -2
  88. package/dist/webgpu/strands_wgslBackend.js +13 -4
  89. package/lib/p5.esm.js +3670 -2951
  90. package/lib/p5.esm.min.js +1 -1
  91. package/lib/p5.js +3670 -2951
  92. package/lib/p5.min.js +1 -1
  93. package/lib/p5.webgpu.esm.js +43 -21
  94. package/lib/p5.webgpu.js +43 -21
  95. package/lib/p5.webgpu.min.js +1 -1
  96. package/package.json +1 -1
  97. package/types/global.d.ts +1283 -1301
  98. package/types/p5.d.ts +655 -657
package/types/global.d.ts CHANGED
@@ -48,6 +48,12 @@ deviceOrientation: typeof P5.deviceOrientation;
48
48
  */
49
49
  accelerationX: typeof P5.accelerationX;
50
50
 
51
+ /**
52
+ * The system variable accelerationY always contains the acceleration of the
53
+ * device along the y axis. Value is represented as meters per second squared.
54
+ */
55
+ accelerationY: typeof P5.accelerationY;
56
+
51
57
  /**
52
58
  * A `Number` system variable that tracks the mouse's horizontal movement.
53
59
  *
@@ -61,12 +67,6 @@ accelerationX: typeof P5.accelerationX;
61
67
  */
62
68
  movedX: typeof P5.movedX;
63
69
 
64
- /**
65
- * The system variable accelerationY always contains the acceleration of the
66
- * device along the y axis. Value is represented as meters per second squared.
67
- */
68
- accelerationY: typeof P5.accelerationY;
69
-
70
70
  /**
71
71
  * The system variable accelerationZ always contains the acceleration of the
72
72
  * device along the z axis. Value is represented as meters per second squared.
@@ -217,18 +217,6 @@ rotationZ: typeof P5.rotationZ;
217
217
  */
218
218
  pRotationX: typeof P5.pRotationX;
219
219
 
220
- /**
221
- * A `Number` system variable that tracks the mouse's vertical position.
222
- *
223
- * `mouseY` keeps track of the mouse's position relative to the
224
- * top-left corner of the canvas. For example, if the mouse is 50 pixels from
225
- * the top edge of the canvas, then `mouseY` will be 50.
226
- *
227
- * If touch is used instead of the mouse, then `mouseY` will hold the
228
- * y-coordinate of the most recent touch point.
229
- */
230
- mouseY: typeof P5.mouseY;
231
-
232
220
  /**
233
221
  * The system variable pRotationY always contains the rotation of the
234
222
  * device along the y axis in the frame previous to the current frame.
@@ -241,6 +229,18 @@ mouseY: typeof P5.mouseY;
241
229
  */
242
230
  pRotationY: typeof P5.pRotationY;
243
231
 
232
+ /**
233
+ * A `Number` system variable that tracks the mouse's vertical position.
234
+ *
235
+ * `mouseY` keeps track of the mouse's position relative to the
236
+ * top-left corner of the canvas. For example, if the mouse is 50 pixels from
237
+ * the top edge of the canvas, then `mouseY` will be 50.
238
+ *
239
+ * If touch is used instead of the mouse, then `mouseY` will hold the
240
+ * y-coordinate of the most recent touch point.
241
+ */
242
+ mouseY: typeof P5.mouseY;
243
+
244
244
  /**
245
245
  * The system variable pRotationZ always contains the rotation of the
246
246
  * device along the z axis in the frame previous to the current frame.
@@ -945,17 +945,6 @@ TWO_PI: typeof P5.TWO_PI;
945
945
 
946
946
  DEG_TO_RAD: typeof P5.DEG_TO_RAD;
947
947
 
948
- /**
949
- * Turns off the parts of the Friendly Error System (FES) that impact performance.
950
- *
951
- * The <a href="https://github.com/processing/p5.js/blob/main/contributor_docs/friendly_error_system.md" target="_blank">FES</a>
952
- * can cause sketches to draw slowly because it does extra work behind the
953
- * scenes. For example, the FES checks the arguments passed to functions,
954
- * which takes time to process. Disabling the FES can significantly improve
955
- * performance by turning off these checks.
956
- */
957
- disableFriendlyErrors: typeof P5.disableFriendlyErrors;
958
-
959
948
  RAD_TO_DEG: typeof P5.RAD_TO_DEG;
960
949
 
961
950
  CORNER: typeof P5.CORNER;
@@ -998,6 +987,17 @@ LINE_LOOP: typeof P5.LINE_LOOP;
998
987
 
999
988
  TRIANGLES: typeof P5.TRIANGLES;
1000
989
 
990
+ /**
991
+ * Turns off the parts of the Friendly Error System (FES) that impact performance.
992
+ *
993
+ * The <a href="https://github.com/processing/p5.js/blob/main/contributor_docs/friendly_error_system.md" target="_blank">FES</a>
994
+ * can cause sketches to draw slowly because it does extra work behind the
995
+ * scenes. For example, the FES checks the arguments passed to functions,
996
+ * which takes time to process. Disabling the FES can significantly improve
997
+ * performance by turning off these checks.
998
+ */
999
+ disableFriendlyErrors: typeof P5.disableFriendlyErrors;
1000
+
1001
1001
  TRIANGLE_FAN: typeof P5.TRIANGLE_FAN;
1002
1002
 
1003
1003
  TRIANGLE_STRIP: typeof P5.TRIANGLE_STRIP;
@@ -1883,6 +1883,65 @@ EXCLUDE: typeof P5.EXCLUDE;
1883
1883
  */
1884
1884
  beginClip(options?: { invert?: boolean }): void;
1885
1885
 
1886
+ /**
1887
+ * Creates a light that shines from all directions.
1888
+ *
1889
+ * Ambient light does not come from one direction. Instead, 3D shapes are
1890
+ * lit evenly from all sides. Ambient lights are almost always used in
1891
+ * combination with other types of lights.
1892
+ *
1893
+ * There are three ways to call `ambientLight()` with optional parameters to
1894
+ * set the light’s color.
1895
+ *
1896
+ * The first way to call `ambientLight()` has two parameters, `gray` and
1897
+ * `alpha`. `alpha` is optional. Grayscale and alpha values between 0 and 255
1898
+ * can be passed to set the ambient light’s color, as in `ambientLight(50)` or
1899
+ * `ambientLight(50, 30)`.
1900
+ *
1901
+ * The second way to call `ambientLight()` has one parameter, color. A
1902
+ * <a href="#/p5.Color">p5.Color</a> object, an array of color values, or a
1903
+ * CSS color string, as in `ambientLight('magenta')`, can be passed to set the
1904
+ * ambient light’s color.
1905
+ *
1906
+ * The third way to call `ambientLight()` has four parameters, `v1`, `v2`,
1907
+ * `v3`, and `alpha`. `alpha` is optional. RGBA, HSBA, or HSLA values can be
1908
+ * passed to set the ambient light’s colors, as in `ambientLight(255, 0, 0)`
1909
+ * or `ambientLight(255, 0, 0, 30)`. Color values will be interpreted using
1910
+ * the current <a href="#/p5/colorMode">colorMode()</a>.
1911
+ * @param v1 red or hue value in the current
1912
+ * <a href="#/p5/colorMode">colorMode()</a>.
1913
+ * @param v2 green or saturation value in the current
1914
+ * <a href="#/p5/colorMode">colorMode()</a>.
1915
+ * @param v3 blue, brightness, or lightness value in the current
1916
+ * <a href="#/p5/colorMode">colorMode()</a>.
1917
+ * @param alpha alpha (transparency) value in the current
1918
+ * <a href="#/p5/colorMode">colorMode()</a>.
1919
+ */
1920
+ ambientLight(v1: number, v2: number, v3: number, alpha?: number): void;
1921
+ ambientLight(gray: number, alpha?: number): void;
1922
+ ambientLight(value: string): void;
1923
+ ambientLight(values: number[]): void;
1924
+ ambientLight(color: P5.Color): void;
1925
+
1926
+ /**
1927
+ * Searches the page for all elements that matches the given
1928
+ * <a href="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/CSS_basics#different_types_of_selectors" target="_blank">CSS selector string</a>.
1929
+ *
1930
+ * The selector string can be an ID, class, tag name, or a combination.
1931
+ * `selectAll()` returns an array of <a href="#/p5.Element">p5.Element</a>
1932
+ * objects if it finds any matches and an empty array if none are found.
1933
+ *
1934
+ * The second parameter, `container`, is optional. It specifies a container to
1935
+ * search within. `container` can be CSS selector string, a
1936
+ * <a href="#/p5.Element">p5.Element</a> object, or an
1937
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement" target="_blank">HTMLElement</a> object.
1938
+ * @param selectors CSS selector string of element to search for.
1939
+ * @param container CSS selector string, <a href="#/p5.Element">p5.Element</a>, or
1940
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement" target="_blank">HTMLElement</a> to search within.
1941
+ * @returns array of <a href="#/p5.Element">p5.Element</a>s containing any elements found.
1942
+ */
1943
+ selectAll(selectors: string, container?: string | P5.Element | HTMLElement): P5.Element[];
1944
+
1886
1945
  /**
1887
1946
  * A shader function that performs smooth Hermite interpolation between `0.0`
1888
1947
  * and `1.0`.
@@ -1955,65 +2014,6 @@ EXCLUDE: typeof P5.EXCLUDE;
1955
2014
 
1956
2015
  getCameraInputs(callback: Function): void;
1957
2016
 
1958
- /**
1959
- * Creates a light that shines from all directions.
1960
- *
1961
- * Ambient light does not come from one direction. Instead, 3D shapes are
1962
- * lit evenly from all sides. Ambient lights are almost always used in
1963
- * combination with other types of lights.
1964
- *
1965
- * There are three ways to call `ambientLight()` with optional parameters to
1966
- * set the light’s color.
1967
- *
1968
- * The first way to call `ambientLight()` has two parameters, `gray` and
1969
- * `alpha`. `alpha` is optional. Grayscale and alpha values between 0 and 255
1970
- * can be passed to set the ambient light’s color, as in `ambientLight(50)` or
1971
- * `ambientLight(50, 30)`.
1972
- *
1973
- * The second way to call `ambientLight()` has one parameter, color. A
1974
- * <a href="#/p5.Color">p5.Color</a> object, an array of color values, or a
1975
- * CSS color string, as in `ambientLight('magenta')`, can be passed to set the
1976
- * ambient light’s color.
1977
- *
1978
- * The third way to call `ambientLight()` has four parameters, `v1`, `v2`,
1979
- * `v3`, and `alpha`. `alpha` is optional. RGBA, HSBA, or HSLA values can be
1980
- * passed to set the ambient light’s colors, as in `ambientLight(255, 0, 0)`
1981
- * or `ambientLight(255, 0, 0, 30)`. Color values will be interpreted using
1982
- * the current <a href="#/p5/colorMode">colorMode()</a>.
1983
- * @param v1 red or hue value in the current
1984
- * <a href="#/p5/colorMode">colorMode()</a>.
1985
- * @param v2 green or saturation value in the current
1986
- * <a href="#/p5/colorMode">colorMode()</a>.
1987
- * @param v3 blue, brightness, or lightness value in the current
1988
- * <a href="#/p5/colorMode">colorMode()</a>.
1989
- * @param alpha alpha (transparency) value in the current
1990
- * <a href="#/p5/colorMode">colorMode()</a>.
1991
- */
1992
- ambientLight(v1: number, v2: number, v3: number, alpha?: number): void;
1993
- ambientLight(gray: number, alpha?: number): void;
1994
- ambientLight(value: string): void;
1995
- ambientLight(values: number[]): void;
1996
- ambientLight(color: P5.Color): void;
1997
-
1998
- /**
1999
- * Searches the page for all elements that matches the given
2000
- * <a href="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/CSS_basics#different_types_of_selectors" target="_blank">CSS selector string</a>.
2001
- *
2002
- * The selector string can be an ID, class, tag name, or a combination.
2003
- * `selectAll()` returns an array of <a href="#/p5.Element">p5.Element</a>
2004
- * objects if it finds any matches and an empty array if none are found.
2005
- *
2006
- * The second parameter, `container`, is optional. It specifies a container to
2007
- * search within. `container` can be CSS selector string, a
2008
- * <a href="#/p5.Element">p5.Element</a> object, or an
2009
- * <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement" target="_blank">HTMLElement</a> object.
2010
- * @param selectors CSS selector string of element to search for.
2011
- * @param container CSS selector string, <a href="#/p5.Element">p5.Element</a>, or
2012
- * <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement" target="_blank">HTMLElement</a> to search within.
2013
- * @returns array of <a href="#/p5.Element">p5.Element</a>s containing any elements found.
2014
- */
2015
- selectAll(selectors: string, container?: string | P5.Element | HTMLElement): P5.Element[];
2016
-
2017
2017
  /**
2018
2018
  * Draws a Bézier curve.
2019
2019
  *
@@ -3947,7 +3947,7 @@ EXCLUDE: typeof P5.EXCLUDE;
3947
3947
  * // Make a version of the shader with a hook overridden
3948
3948
  * modifiedShader = myShader.modify(() => {
3949
3949
  * // Create new uniforms and override the getColor hook
3950
- * let t = uniformFloat(() => millis() / 1000);
3950
+ * let t = millis() / 1000;
3951
3951
  * getColor(() => {
3952
3952
  * return [0, 0.5 + 0.5 * sin(t), 1, 1];
3953
3953
  * });
@@ -4400,55 +4400,6 @@ EXCLUDE: typeof P5.EXCLUDE;
4400
4400
  */
4401
4401
  rotateX(angle: number): void;
4402
4402
 
4403
- /**
4404
- * A function that's called once when the sketch begins running.
4405
- *
4406
- * Declaring the function `setup()` sets a code block to run once
4407
- * automatically when the sketch starts running. It's used to perform
4408
- * setup tasks such as creating the canvas and initializing variables:
4409
- *
4410
- * `function setup() {
4411
- * // Code to run once at the start of the sketch.
4412
- * }`Code placed in `setup()` will run once before code placed in
4413
- * <a href="#/p5/draw">draw()</a> begins looping.
4414
- * If `setup()` is declared `async` (e.g. `async function setup()`),
4415
- * execution pauses at each `await` until its promise resolves.
4416
- * For example, `font = await loadFont(...)` waits for the font asset
4417
- * to load because `loadFont()` function returns a promise, and the await
4418
- * keyword means the program will wait for the promise to resolve.
4419
- * This ensures that all assets are fully loaded before the sketch continues.
4420
- *
4421
- * loading assets.
4422
- *
4423
- * Note: `setup()` doesn’t have to be declared, but it’s common practice to do so.
4424
- */
4425
- setup(): void;
4426
-
4427
- /**
4428
- * A function that's called repeatedly while the sketch runs.
4429
- *
4430
- * Declaring the function `draw()` sets a code block to run repeatedly
4431
- * once the sketch starts. It’s used to create animations and respond to
4432
- * user inputs:
4433
- *
4434
- * `function draw() {
4435
- * // Code to run repeatedly.
4436
- * }`This is often called the "draw loop" because p5.js calls the code in
4437
- * `draw()` in a loop behind the scenes. By default, `draw()` tries to run
4438
- * 60 times per second. The actual rate depends on many factors. The
4439
- * drawing rate, called the "frame rate", can be controlled by calling
4440
- * <a href="#/p5/frameRate">frameRate()</a>. The number of times `draw()`
4441
- * has run is stored in the system variable
4442
- * <a href="#/p5/frameCount">frameCount()</a>.
4443
- *
4444
- * Code placed within `draw()` begins looping after
4445
- * <a href="#/p5/setup">setup()</a> runs. `draw()` will run until the user
4446
- * closes the sketch. `draw()` can be stopped by calling the
4447
- * <a href="#/p5/noLoop">noLoop()</a> function. `draw()` can be resumed by
4448
- * calling the <a href="#/p5/loop">loop()</a> function.
4449
- */
4450
- draw(): void;
4451
-
4452
4403
  /**
4453
4404
  * Re-maps a number from one range to another.
4454
4405
  *
@@ -4869,35 +4820,84 @@ EXCLUDE: typeof P5.EXCLUDE;
4869
4820
  line(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number): void;
4870
4821
 
4871
4822
  /**
4872
- * Clears the pixels on the canvas.
4873
- *
4874
- * `clear()` makes every pixel 100% transparent. Calling `clear()` doesn't
4875
- * clear objects created by `createX()` functions such as
4876
- * <a href="#/p5/createGraphics">createGraphics()</a>,
4877
- * <a href="#/p5/createVideo">createVideo()</a>, and
4878
- * <a href="#/p5/createImg">createImg()</a>. These objects will remain
4879
- * unchanged after calling `clear()` and can be redrawn.
4880
- *
4881
- * In WebGL mode, this function can clear the screen to a specific color. It
4882
- * interprets four numeric parameters as normalized RGBA color values. It also
4883
- * clears the depth buffer. If you are not using the WebGL renderer, these
4884
- * parameters will have no effect.
4885
- * @param r normalized red value.
4886
- * @param g normalized green value.
4887
- * @param b normalized blue value.
4888
- * @param a normalized alpha value.
4889
- */
4890
- clear(r?: number, g?: number, b?: number, a?: number): void;
4891
- clear(): void;
4892
-
4893
- /**
4894
- * Draws a box (rectangular prism).
4823
+ * A function that's called once when the sketch begins running.
4895
4824
  *
4896
- * A box is a 3D shape with six faces. Each face makes a 90˚ with four
4897
- * neighboring faces.
4825
+ * Declaring the function `setup()` sets a code block to run once
4826
+ * automatically when the sketch starts running. It's used to perform
4827
+ * setup tasks such as creating the canvas and initializing variables:
4898
4828
  *
4899
- * The first parameter, `width`, is optional. If a `Number` is passed, as in
4900
- * `box(20)`, it sets the box’s width and height. By default, `width` is 50.
4829
+ * `function setup() {
4830
+ * // Code to run once at the start of the sketch.
4831
+ * }`Code placed in `setup()` will run once before code placed in
4832
+ * <a href="#/p5/draw">draw()</a> begins looping.
4833
+ * If `setup()` is declared `async` (e.g. `async function setup()`),
4834
+ * execution pauses at each `await` until its promise resolves.
4835
+ * For example, `font = await loadFont(...)` waits for the font asset
4836
+ * to load because `loadFont()` function returns a promise, and the await
4837
+ * keyword means the program will wait for the promise to resolve.
4838
+ * This ensures that all assets are fully loaded before the sketch continues.
4839
+ *
4840
+ * loading assets.
4841
+ *
4842
+ * Note: `setup()` doesn’t have to be declared, but it’s common practice to do so.
4843
+ */
4844
+ setup(): void;
4845
+
4846
+ /**
4847
+ * A function that's called repeatedly while the sketch runs.
4848
+ *
4849
+ * Declaring the function `draw()` sets a code block to run repeatedly
4850
+ * once the sketch starts. It’s used to create animations and respond to
4851
+ * user inputs:
4852
+ *
4853
+ * `function draw() {
4854
+ * // Code to run repeatedly.
4855
+ * }`This is often called the "draw loop" because p5.js calls the code in
4856
+ * `draw()` in a loop behind the scenes. By default, `draw()` tries to run
4857
+ * 60 times per second. The actual rate depends on many factors. The
4858
+ * drawing rate, called the "frame rate", can be controlled by calling
4859
+ * <a href="#/p5/frameRate">frameRate()</a>. The number of times `draw()`
4860
+ * has run is stored in the system variable
4861
+ * <a href="#/p5/frameCount">frameCount()</a>.
4862
+ *
4863
+ * Code placed within `draw()` begins looping after
4864
+ * <a href="#/p5/setup">setup()</a> runs. `draw()` will run until the user
4865
+ * closes the sketch. `draw()` can be stopped by calling the
4866
+ * <a href="#/p5/noLoop">noLoop()</a> function. `draw()` can be resumed by
4867
+ * calling the <a href="#/p5/loop">loop()</a> function.
4868
+ */
4869
+ draw(): void;
4870
+
4871
+ /**
4872
+ * Clears the pixels on the canvas.
4873
+ *
4874
+ * `clear()` makes every pixel 100% transparent. Calling `clear()` doesn't
4875
+ * clear objects created by `createX()` functions such as
4876
+ * <a href="#/p5/createGraphics">createGraphics()</a>,
4877
+ * <a href="#/p5/createVideo">createVideo()</a>, and
4878
+ * <a href="#/p5/createImg">createImg()</a>. These objects will remain
4879
+ * unchanged after calling `clear()` and can be redrawn.
4880
+ *
4881
+ * In WebGL mode, this function can clear the screen to a specific color. It
4882
+ * interprets four numeric parameters as normalized RGBA color values. It also
4883
+ * clears the depth buffer. If you are not using the WebGL renderer, these
4884
+ * parameters will have no effect.
4885
+ * @param r normalized red value.
4886
+ * @param g normalized green value.
4887
+ * @param b normalized blue value.
4888
+ * @param a normalized alpha value.
4889
+ */
4890
+ clear(r?: number, g?: number, b?: number, a?: number): void;
4891
+ clear(): void;
4892
+
4893
+ /**
4894
+ * Draws a box (rectangular prism).
4895
+ *
4896
+ * A box is a 3D shape with six faces. Each face makes a 90˚ with four
4897
+ * neighboring faces.
4898
+ *
4899
+ * The first parameter, `width`, is optional. If a `Number` is passed, as in
4900
+ * `box(20)`, it sets the box’s width and height. By default, `width` is 50.
4901
4901
  *
4902
4902
  * The second parameter, `height`, is also optional. If a `Number` is passed,
4903
4903
  * as in `box(20, 30)`, it sets the box’s height. By default, `height` is set
@@ -5184,17 +5184,6 @@ EXCLUDE: typeof P5.EXCLUDE;
5184
5184
  */
5185
5185
  shuffle<T>(array: T[], modify?: boolean): T[];
5186
5186
 
5187
- /**
5188
- * This method is suitable for fetching files up to size of 64MB.
5189
- * @param file name of the file or URL to load
5190
- * @param callback function to be executed after <a href="#/p5/loadBytes">loadBytes()</a>
5191
- * completes
5192
- * @param errorCallback function to be executed if there
5193
- * is an error
5194
- * @returns a Uint8Array containing the loaded buffer
5195
- */
5196
- loadBytes(file: string | Request, callback?: Function, errorCallback?: Function): Promise<Uint8Array>;
5197
-
5198
5187
  /**
5199
5188
  * Turns off <a href="#/p5/debugMode">debugMode()</a> in a 3D sketch.
5200
5189
  */
@@ -5355,7 +5344,7 @@ EXCLUDE: typeof P5.EXCLUDE;
5355
5344
  * filterColor.texCoord.x // x coordinate, from 0 to 1
5356
5345
  * ));
5357
5346
  * filterColor.end();
5358
- * }`You can also animate your filters over time by passing the time into the shader with `uniformFloat`.
5347
+ * }`You can also animate your filters over time using the `millis()` function.
5359
5348
  *
5360
5349
  * `let myFilter;
5361
5350
  * function setup() {
@@ -5365,7 +5354,7 @@ EXCLUDE: typeof P5.EXCLUDE;
5365
5354
  * }
5366
5355
  *
5367
5356
  * function gradient() {
5368
- * let time = uniformFloat();
5357
+ * let time = millis();
5369
5358
  * filterColor.begin();
5370
5359
  * filterColor.set(mix(
5371
5360
  * [1, 0, 0, 1], // Red
@@ -5376,9 +5365,8 @@ EXCLUDE: typeof P5.EXCLUDE;
5376
5365
  * }
5377
5366
  *
5378
5367
  * function draw() {
5379
- * myFilter.setUniform('time', millis());
5380
5368
  * filter(myFilter);
5381
- * }`We can use the `noise()` function built into strands to generate a color for each pixel. (Again no need here for underlying content for the filter to operate on.) Again we'll animate by passing in an announced uniform variable `time` with `setUniform()`, each frame.
5369
+ * }`We can use the `noise()` function built into strands to generate a color for each pixel. (Again no need here for underlying content for the filter to operate on.) Again we'll animate by using the millis() function to get an up-to-date time value.
5382
5370
  *
5383
5371
  * `let myFilter;
5384
5372
  *
@@ -5389,7 +5377,7 @@ EXCLUDE: typeof P5.EXCLUDE;
5389
5377
  * }
5390
5378
  *
5391
5379
  * function noiseShaderCallback() {
5392
- * let time = uniformFloat();
5380
+ * let time = millis();
5393
5381
  * filterColor.begin();
5394
5382
  * let coord = filterColor.texCoord;
5395
5383
  *
@@ -5406,7 +5394,6 @@ EXCLUDE: typeof P5.EXCLUDE;
5406
5394
  * }
5407
5395
  *
5408
5396
  * function draw() {
5409
- * myFilter.setUniform("time", millis());
5410
5397
  * filter(myFilter);
5411
5398
  * }`Like the `modify()` method on shaders,
5412
5399
  * advanced users can also fill in `filterColor` using <a href="https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_on_the_web/GLSL_Shaders" target="_blank">GLSL</a>
@@ -5424,6 +5411,17 @@ EXCLUDE: typeof P5.EXCLUDE;
5424
5411
  buildFilterShader(callback: Function, scope?: object): P5.Shader;
5425
5412
  buildFilterShader(hooks: object, scope?: object): P5.Shader;
5426
5413
 
5414
+ /**
5415
+ * This method is suitable for fetching files up to size of 64MB.
5416
+ * @param file name of the file or URL to load
5417
+ * @param callback function to be executed after <a href="#/p5/loadBytes">loadBytes()</a>
5418
+ * completes
5419
+ * @param errorCallback function to be executed if there
5420
+ * is an error
5421
+ * @returns a Uint8Array containing the loaded buffer
5422
+ */
5423
+ loadBytes(file: string | Request, callback?: Function, errorCallback?: Function): Promise<Uint8Array>;
5424
+
5427
5425
  /**
5428
5426
  * Creates a slider `&lt;input&gt;&lt;/input&gt;` element.
5429
5427
  *
@@ -5543,22 +5541,6 @@ EXCLUDE: typeof P5.EXCLUDE;
5543
5541
  */
5544
5542
  rotateZ(angle: number): void;
5545
5543
 
5546
- /**
5547
- * Loads a file at the given path as a Blob, then returns the resulting data or
5548
- * passes it to a success callback function, if provided. On load, this function
5549
- * returns a `Promise` that resolves to a Blob containing the file data.
5550
- * @param path The path or Request object pointing to the file
5551
- * you want to load.
5552
- * @param successCallback Optional. A function to be called if the
5553
- * file successfully loads, receiving the
5554
- * resulting Blob as its only argument.
5555
- * @param errorCallback Optional. A function to be called if an
5556
- * error occurs during loading; receives the
5557
- * error object as its only argument.
5558
- * @returns A promise that resolves with the loaded Blob.
5559
- */
5560
- loadBlob(path: string | Request, successCallback?: Function, errorCallback?: Function): Promise<Blob>;
5561
-
5562
5544
  /**
5563
5545
  * Calculates exponential expressions such as <var>2<sup>3</sup></var>.
5564
5546
  *
@@ -5587,6 +5569,22 @@ EXCLUDE: typeof P5.EXCLUDE;
5587
5569
  */
5588
5570
  fullscreen(val?: boolean): boolean;
5589
5571
 
5572
+ /**
5573
+ * Loads a file at the given path as a Blob, then returns the resulting data or
5574
+ * passes it to a success callback function, if provided. On load, this function
5575
+ * returns a `Promise` that resolves to a Blob containing the file data.
5576
+ * @param path The path or Request object pointing to the file
5577
+ * you want to load.
5578
+ * @param successCallback Optional. A function to be called if the
5579
+ * file successfully loads, receiving the
5580
+ * resulting Blob as its only argument.
5581
+ * @param errorCallback Optional. A function to be called if an
5582
+ * error occurs during loading; receives the
5583
+ * error object as its only argument.
5584
+ * @returns A promise that resolves with the loaded Blob.
5585
+ */
5586
+ loadBlob(path: string | Request, successCallback?: Function, errorCallback?: Function): Promise<Blob>;
5587
+
5590
5588
  /**
5591
5589
  * Creates a light that shines from a point in all directions.
5592
5590
  *
@@ -5864,26 +5862,20 @@ EXCLUDE: typeof P5.EXCLUDE;
5864
5862
  splinePoint(a: number, b: number, c: number, d: number, t: number): number;
5865
5863
 
5866
5864
  /**
5867
- * Method for executing an HTTP GET request. If data type is not specified,
5868
- * it will default to `'text'`. This is equivalent to
5869
- * calling <code>httpDo(path, 'GET')</code>. The 'binary' datatype will return
5870
- * a Blob object, and the 'arrayBuffer' datatype will return an ArrayBuffer
5871
- * which can be used to initialize typed arrays (such as Uint8Array).
5872
- * @param path name of the file or url to load
5873
- * @param datatype "json", "jsonp", "binary", "arrayBuffer",
5874
- * "xml", or "text"
5875
- * @param callback function to be executed after
5876
- * <a href="#/p5/httpGet">httpGet()</a> completes, data is passed in
5877
- * as first argument
5878
- * @param errorCallback function to be executed if
5879
- * there is an error, response is passed
5880
- * in as first argument
5881
- * @returns A promise that resolves with the data when the operation
5882
- * completes successfully or rejects with the error after
5883
- * one occurs.
5865
+ * Creates an ambient light from an image.
5866
+ *
5867
+ * `imageLight()` simulates a light shining from all directions. The effect is
5868
+ * like placing the sketch at the center of a giant sphere that uses the image
5869
+ * as its texture. The image's diffuse light will be affected by
5870
+ * <a href="#/p5/fill">fill()</a> and the specular reflections will be
5871
+ * affected by <a href="#/p5/specularMaterial">specularMaterial()</a> and
5872
+ * <a href="#/p5/shininess">shininess()</a>.
5873
+ *
5874
+ * The parameter, `img`, is the <a href="#/p5.Image">p5.Image</a> object to
5875
+ * use as the light source.
5876
+ * @param img image to use as the light source.
5884
5877
  */
5885
- httpGet(path: string | Request, datatype?: string, callback?: Function, errorCallback?: Function): Promise<any>;
5886
- httpGet(path: string | Request, callback: Function, errorCallback?: Function): Promise<any>;
5878
+ imageLight(img: P5.Image): void;
5887
5879
 
5888
5880
  /**
5889
5881
  * Sets the pixel density or returns the current density.
@@ -5906,20 +5898,26 @@ EXCLUDE: typeof P5.EXCLUDE;
5906
5898
  pixelDensity(): number;
5907
5899
 
5908
5900
  /**
5909
- * Creates an ambient light from an image.
5910
- *
5911
- * `imageLight()` simulates a light shining from all directions. The effect is
5912
- * like placing the sketch at the center of a giant sphere that uses the image
5913
- * as its texture. The image's diffuse light will be affected by
5914
- * <a href="#/p5/fill">fill()</a> and the specular reflections will be
5915
- * affected by <a href="#/p5/specularMaterial">specularMaterial()</a> and
5916
- * <a href="#/p5/shininess">shininess()</a>.
5917
- *
5918
- * The parameter, `img`, is the <a href="#/p5.Image">p5.Image</a> object to
5919
- * use as the light source.
5920
- * @param img image to use as the light source.
5901
+ * Method for executing an HTTP GET request. If data type is not specified,
5902
+ * it will default to `'text'`. This is equivalent to
5903
+ * calling <code>httpDo(path, 'GET')</code>. The 'binary' datatype will return
5904
+ * a Blob object, and the 'arrayBuffer' datatype will return an ArrayBuffer
5905
+ * which can be used to initialize typed arrays (such as Uint8Array).
5906
+ * @param path name of the file or url to load
5907
+ * @param datatype "json", "jsonp", "binary", "arrayBuffer",
5908
+ * "xml", or "text"
5909
+ * @param callback function to be executed after
5910
+ * <a href="#/p5/httpGet">httpGet()</a> completes, data is passed in
5911
+ * as first argument
5912
+ * @param errorCallback function to be executed if
5913
+ * there is an error, response is passed
5914
+ * in as first argument
5915
+ * @returns A promise that resolves with the data when the operation
5916
+ * completes successfully or rejects with the error after
5917
+ * one occurs.
5921
5918
  */
5922
- imageLight(img: P5.Image): void;
5919
+ httpGet(path: string | Request, datatype?: string, callback?: Function, errorCallback?: Function): Promise<any>;
5920
+ httpGet(path: string | Request, callback: Function, errorCallback?: Function): Promise<any>;
5923
5921
 
5924
5922
  /**
5925
5923
  * Updates the canvas with the RGBA values in the
@@ -6084,28 +6082,6 @@ EXCLUDE: typeof P5.EXCLUDE;
6084
6082
  scale(s: number | P5.Vector | number[], y?: number, z?: number): void;
6085
6083
  scale(scales: P5.Vector | number[]): void;
6086
6084
 
6087
- /**
6088
- * Method for executing an HTTP POST request. If data type is not specified,
6089
- * it will default to `'text'`. This is equivalent to
6090
- * calling <code>httpDo(path, 'POST')</code>.
6091
- * @param path name of the file or url to load
6092
- * @param data param data passed sent with request
6093
- * @param datatype "json", "jsonp", "xml", or "text".
6094
- * If omitted, <a href="#/p5/httpPost">httpPost()</a> will guess.
6095
- * @param callback function to be executed after
6096
- * <a href="#/p5/httpPost">httpPost()</a> completes, data is passed in
6097
- * as first argument
6098
- * @param errorCallback function to be executed if
6099
- * there is an error, response is passed
6100
- * in as first argument
6101
- * @returns A promise that resolves with the data when the operation
6102
- * completes successfully or rejects with the error after
6103
- * one occurs.
6104
- */
6105
- httpPost(path: string | Request, data?: object | boolean, datatype?: string, callback?: Function, errorCallback?: Function): Promise<any>;
6106
- httpPost(path: string | Request, data: object | boolean, callback?: Function, errorCallback?: Function): Promise<any>;
6107
- httpPost(path: string | Request, callback?: Function, errorCallback?: Function): Promise<any>;
6108
-
6109
6085
  /**
6110
6086
  * Converts a `String` with a hexadecimal value to a `Number`.
6111
6087
  *
@@ -6165,6 +6141,28 @@ EXCLUDE: typeof P5.EXCLUDE;
6165
6141
  */
6166
6142
  sqrt(n: number): number;
6167
6143
 
6144
+ /**
6145
+ * Method for executing an HTTP POST request. If data type is not specified,
6146
+ * it will default to `'text'`. This is equivalent to
6147
+ * calling <code>httpDo(path, 'POST')</code>.
6148
+ * @param path name of the file or url to load
6149
+ * @param data param data passed sent with request
6150
+ * @param datatype "json", "jsonp", "xml", or "text".
6151
+ * If omitted, <a href="#/p5/httpPost">httpPost()</a> will guess.
6152
+ * @param callback function to be executed after
6153
+ * <a href="#/p5/httpPost">httpPost()</a> completes, data is passed in
6154
+ * as first argument
6155
+ * @param errorCallback function to be executed if
6156
+ * there is an error, response is passed
6157
+ * in as first argument
6158
+ * @returns A promise that resolves with the data when the operation
6159
+ * completes successfully or rejects with the error after
6160
+ * one occurs.
6161
+ */
6162
+ httpPost(path: string | Request, data?: object | boolean, datatype?: string, callback?: Function, errorCallback?: Function): Promise<any>;
6163
+ httpPost(path: string | Request, data: object | boolean, callback?: Function, errorCallback?: Function): Promise<any>;
6164
+ httpPost(path: string | Request, callback?: Function, errorCallback?: Function): Promise<any>;
6165
+
6168
6166
  /**
6169
6167
  * Draws a cylinder.
6170
6168
  *
@@ -6410,18 +6408,6 @@ EXCLUDE: typeof P5.EXCLUDE;
6410
6408
  image(img: P5.Image | P5.Element | P5.Texture | P5.Framebuffer | P5.FramebufferTexture | P5.Renderer | P5.Graphics, x: number, y: number, width?: number, height?: number): void;
6411
6409
  image(img: P5.Image | P5.Element | P5.Texture | P5.Framebuffer | P5.FramebufferTexture, dx: number, dy: number, dWidth: number, dHeight: number, sx: number, sy: number, sWidth?: number, sHeight?: number, fit?: typeof P5.CONTAIN | typeof P5.COVER, xAlign?: typeof P5.LEFT | typeof P5.RIGHT | typeof P5.CENTER, yAlign?: typeof P5.TOP | typeof P5.BOTTOM | typeof P5.CENTER): void;
6412
6410
 
6413
- /**
6414
- * Returns the current
6415
- * <a href="https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Web_mechanics/What_is_a_URL#parameters" target="_blank">URL parameters</a>
6416
- * in an `Object`.
6417
- *
6418
- * For example, calling `getURLParams()` in a sketch hosted at the URL
6419
- * `https://p5js.org?year=2014&month=May&day=15` returns
6420
- * `{ year: 2014, month: 'May', day: 15 }`.
6421
- * @returns URL params
6422
- */
6423
- getURLParams(): object;
6424
-
6425
6411
  /**
6426
6412
  * Changes the way color values are interpreted.
6427
6413
  *
@@ -6496,14 +6482,26 @@ EXCLUDE: typeof P5.EXCLUDE;
6496
6482
  colorMode(): typeof P5.RGB | typeof P5.HSB | typeof P5.HSL | typeof P5.RGBHDR | typeof P5.HWB | typeof P5.LAB | typeof P5.LCH | typeof P5.OKLAB | typeof P5.OKLCH;
6497
6483
 
6498
6484
  /**
6499
- * Shears the x-axis so that shapes appear skewed.
6500
- *
6501
- * By default, the x- and y-axes are perpendicular. The `shearX()` function
6502
- * transforms the coordinate system so that x-coordinates are translated while
6503
- * y-coordinates are fixed.
6485
+ * Returns the current
6486
+ * <a href="https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Web_mechanics/What_is_a_URL#parameters" target="_blank">URL parameters</a>
6487
+ * in an `Object`.
6504
6488
  *
6505
- * The first parameter, `angle`, is the amount to shear. For example, calling
6506
- * `shearX(1)` transforms all x-coordinates using the formula
6489
+ * For example, calling `getURLParams()` in a sketch hosted at the URL
6490
+ * `https://p5js.org?year=2014&month=May&day=15` returns
6491
+ * `{ year: 2014, month: 'May', day: 15 }`.
6492
+ * @returns URL params
6493
+ */
6494
+ getURLParams(): object;
6495
+
6496
+ /**
6497
+ * Shears the x-axis so that shapes appear skewed.
6498
+ *
6499
+ * By default, the x- and y-axes are perpendicular. The `shearX()` function
6500
+ * transforms the coordinate system so that x-coordinates are translated while
6501
+ * y-coordinates are fixed.
6502
+ *
6503
+ * The first parameter, `angle`, is the amount to shear. For example, calling
6504
+ * `shearX(1)` transforms all x-coordinates using the formula
6507
6505
  * `x = x + y * tan(angle)`. `shearX()` interprets angle values using the
6508
6506
  * current <a href="#/p5/angleMode">angleMode()</a>.
6509
6507
  *
@@ -6542,104 +6540,6 @@ EXCLUDE: typeof P5.EXCLUDE;
6542
6540
  */
6543
6541
  lightFalloff(constant: number, linear: number, quadratic: number): void;
6544
6542
 
6545
- /**
6546
- * A function that's called when the mouse moves.
6547
- *
6548
- * Declaring the function `mouseMoved()` sets a code block to run
6549
- * automatically when the user moves the mouse without clicking any mouse
6550
- * buttons:
6551
- *
6552
- * `function mouseMoved() {
6553
- * // Code to run.
6554
- * }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
6555
- * <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
6556
- * value when `mouseMoved()` is called by p5.js:
6557
- *
6558
- * `function mouseMoved() {
6559
- * if (mouseX < 50) {
6560
- * // Code to run if the mouse is on the left.
6561
- * }
6562
- *
6563
- * if (mouseY > 50) {
6564
- * // Code to run if the mouse is near the bottom.
6565
- * }
6566
- * }`The parameter, `event`, is optional. `mouseMoved()` is always passed a
6567
- * <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
6568
- * object with properties that describe the mouse move event:
6569
- *
6570
- * `function mouseMoved(event) {
6571
- * // Code to run that uses the event.
6572
- * console.log(event);
6573
- * }`Browsers may have default behaviors attached to various mouse events. For
6574
- * example, some browsers highlight text when the user moves the mouse while
6575
- * pressing a mouse button. To prevent any default behavior for this event,
6576
- * add `return false;` to the end of the function.
6577
- * @param event optional `MouseEvent` argument.
6578
- */
6579
- mouseMoved(event?: MouseEvent): void;
6580
-
6581
- /**
6582
- * A function that's called when the mouse moves while a button is pressed.
6583
- *
6584
- * Declaring the function `mouseDragged()` sets a code block to run
6585
- * automatically when the user clicks and drags the mouse:
6586
- *
6587
- * `function mouseDragged() {
6588
- * // Code to run.
6589
- * }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
6590
- * <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
6591
- * value when `mouseDragged()` is called by p5.js:
6592
- *
6593
- * `function mouseDragged() {
6594
- * if (mouseX < 50) {
6595
- * // Code to run if the mouse is on the left.
6596
- * }
6597
- *
6598
- * if (mouseY > 50) {
6599
- * // Code to run if the mouse is near the bottom.
6600
- * }
6601
- * }`The parameter, `event`, is optional. `mouseDragged()` is always passed a
6602
- * <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
6603
- * object with properties that describe the mouse drag event:
6604
- *
6605
- * `function mouseDragged(event) {
6606
- * // Code to run that uses the event.
6607
- * console.log(event);
6608
- * }`On touchscreen devices, `mouseDragged()` will run when a user moves a touch
6609
- * point.
6610
- *
6611
- * Browsers may have default behaviors attached to various mouse events. For
6612
- * example, some browsers highlight text when the user moves the mouse while
6613
- * pressing a mouse button. To prevent any default behavior for this event,
6614
- * add `return false;` to the end of the function.
6615
- * @param event optional `MouseEvent` argument.
6616
- */
6617
- mouseDragged(event?: MouseEvent): void;
6618
-
6619
- /**
6620
- * Returns `true` if the key it’s checking is pressed and `false` if not.
6621
- *
6622
- * `keyIsDown()` is helpful when checking for multiple different key presses.
6623
- * For example, `keyIsDown()` can be used to check if both `LEFT_ARROW` and
6624
- * `UP_ARROW` are pressed:
6625
- *
6626
- * `if (keyIsDown(LEFT_ARROW) && keyIsDown(UP_ARROW)) {
6627
- * // Move diagonally.
6628
- * }``keyIsDown()` can check for key presses using strings based on
6629
- * <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key" target="_blank">KeyboardEvent.key</a>
6630
- * or <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code" target="_blank">KeyboardEvent.code</a> values,
6631
- * such as `keyIsDown('x')` or `keyIsDown('ArrowLeft')`.
6632
- *
6633
- * Note: In p5.js 2.0 and newer, numeric keycodes (such as 88 for 'X') are no longer supported.
6634
- * This is a breaking change from previous versions.
6635
- *
6636
- * You can still use the p5 constants like `LEFT_ARROW` which now map to string values
6637
- * internally rather than numeric codes.
6638
- * @param code key to check.
6639
- * @returns whether the key is down or not.
6640
- */
6641
- keyIsDown(code: number | string): boolean;
6642
-
6643
6543
  /**
6644
6544
  * Sets the <a href="#/p5.Shader">p5.Shader</a> object to apply while drawing.
6645
6545
  *
@@ -6679,7 +6579,7 @@ EXCLUDE: typeof P5.EXCLUDE;
6679
6579
  * }
6680
6580
  *
6681
6581
  * function material() {
6682
- * let time = uniformFloat();
6582
+ * let time = millis() / 1000;
6683
6583
  * finalColor.begin();
6684
6584
  * let r = 0.2 + 0.5 * abs(sin(time + 0));
6685
6585
  * let g = 0.2 + 0.5 * abs(sin(time + 1));
@@ -6690,7 +6590,6 @@ EXCLUDE: typeof P5.EXCLUDE;
6690
6590
  *
6691
6591
  * function draw() {
6692
6592
  * background(245, 245, 220);
6693
- * myShader.setUniform('time', millis() / 1000);
6694
6593
  * shader(myShader);
6695
6594
  *
6696
6595
  * rectMode(CENTER);
@@ -6804,21 +6703,102 @@ EXCLUDE: typeof P5.EXCLUDE;
6804
6703
  shader(s: P5.Shader): void;
6805
6704
 
6806
6705
  /**
6807
- * Draws a <a href="#/p5.Geometry">p5.Geometry</a> object to the canvas.
6706
+ * A function that's called when the mouse moves.
6808
6707
  *
6809
- * The parameter, `model`, is the
6810
- * <a href="#/p5.Geometry">p5.Geometry</a> object to draw.
6811
- * <a href="#/p5.Geometry">p5.Geometry</a> objects can be built with
6812
- * <a href="#/p5/buildGeometry">buildGeometry()</a>, or
6813
- * <a href="#/p5/beginGeometry">beginGeometry()</a> and
6814
- * <a href="#/p5/endGeometry">endGeometry()</a>. They can also be loaded from
6815
- * a file with <a href="#/p5/loadGeometry">loadGeometry()</a>.
6708
+ * Declaring the function `mouseMoved()` sets a code block to run
6709
+ * automatically when the user moves the mouse without clicking any mouse
6710
+ * buttons:
6816
6711
  *
6817
- * Note: `model()` can only be used in WebGL mode.
6818
- * @param model 3D shape to be drawn.
6819
- * @param count number of instances to draw.
6712
+ * `function mouseMoved() {
6713
+ * // Code to run.
6714
+ * }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
6715
+ * <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
6716
+ * value when `mouseMoved()` is called by p5.js:
6717
+ *
6718
+ * `function mouseMoved() {
6719
+ * if (mouseX < 50) {
6720
+ * // Code to run if the mouse is on the left.
6721
+ * }
6722
+ *
6723
+ * if (mouseY > 50) {
6724
+ * // Code to run if the mouse is near the bottom.
6725
+ * }
6726
+ * }`The parameter, `event`, is optional. `mouseMoved()` is always passed a
6727
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
6728
+ * object with properties that describe the mouse move event:
6729
+ *
6730
+ * `function mouseMoved(event) {
6731
+ * // Code to run that uses the event.
6732
+ * console.log(event);
6733
+ * }`Browsers may have default behaviors attached to various mouse events. For
6734
+ * example, some browsers highlight text when the user moves the mouse while
6735
+ * pressing a mouse button. To prevent any default behavior for this event,
6736
+ * add `return false;` to the end of the function.
6737
+ * @param event optional `MouseEvent` argument.
6820
6738
  */
6821
- model(model: P5.Geometry, count?: number): void;
6739
+ mouseMoved(event?: MouseEvent): void;
6740
+
6741
+ /**
6742
+ * A function that's called when the mouse moves while a button is pressed.
6743
+ *
6744
+ * Declaring the function `mouseDragged()` sets a code block to run
6745
+ * automatically when the user clicks and drags the mouse:
6746
+ *
6747
+ * `function mouseDragged() {
6748
+ * // Code to run.
6749
+ * }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
6750
+ * <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
6751
+ * value when `mouseDragged()` is called by p5.js:
6752
+ *
6753
+ * `function mouseDragged() {
6754
+ * if (mouseX < 50) {
6755
+ * // Code to run if the mouse is on the left.
6756
+ * }
6757
+ *
6758
+ * if (mouseY > 50) {
6759
+ * // Code to run if the mouse is near the bottom.
6760
+ * }
6761
+ * }`The parameter, `event`, is optional. `mouseDragged()` is always passed a
6762
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
6763
+ * object with properties that describe the mouse drag event:
6764
+ *
6765
+ * `function mouseDragged(event) {
6766
+ * // Code to run that uses the event.
6767
+ * console.log(event);
6768
+ * }`On touchscreen devices, `mouseDragged()` will run when a user moves a touch
6769
+ * point.
6770
+ *
6771
+ * Browsers may have default behaviors attached to various mouse events. For
6772
+ * example, some browsers highlight text when the user moves the mouse while
6773
+ * pressing a mouse button. To prevent any default behavior for this event,
6774
+ * add `return false;` to the end of the function.
6775
+ * @param event optional `MouseEvent` argument.
6776
+ */
6777
+ mouseDragged(event?: MouseEvent): void;
6778
+
6779
+ /**
6780
+ * Returns `true` if the key it’s checking is pressed and `false` if not.
6781
+ *
6782
+ * `keyIsDown()` is helpful when checking for multiple different key presses.
6783
+ * For example, `keyIsDown()` can be used to check if both `LEFT_ARROW` and
6784
+ * `UP_ARROW` are pressed:
6785
+ *
6786
+ * `if (keyIsDown(LEFT_ARROW) && keyIsDown(UP_ARROW)) {
6787
+ * // Move diagonally.
6788
+ * }``keyIsDown()` can check for key presses using strings based on
6789
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key" target="_blank">KeyboardEvent.key</a>
6790
+ * or <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code" target="_blank">KeyboardEvent.code</a> values,
6791
+ * such as `keyIsDown('x')` or `keyIsDown('ArrowLeft')`.
6792
+ *
6793
+ * Note: In p5.js 2.0 and newer, numeric keycodes (such as 88 for 'X') are no longer supported.
6794
+ * This is a breaking change from previous versions.
6795
+ *
6796
+ * You can still use the p5 constants like `LEFT_ARROW` which now map to string values
6797
+ * internally rather than numeric codes.
6798
+ * @param code key to check.
6799
+ * @returns whether the key is down or not.
6800
+ */
6801
+ keyIsDown(code: number | string): boolean;
6822
6802
 
6823
6803
  /**
6824
6804
  * Sets the element's content.
@@ -6832,31 +6812,21 @@ EXCLUDE: typeof P5.EXCLUDE;
6832
6812
  setContent(content: string): void;
6833
6813
 
6834
6814
  /**
6835
- * Method for executing an HTTP request. If data type is not specified,
6836
- * it will default to `'text'`.
6815
+ * Draws a <a href="#/p5.Geometry">p5.Geometry</a> object to the canvas.
6837
6816
  *
6838
- * This function is meant for more advanced usage of HTTP requests in p5.js. It is
6839
- * best used when a `Request`
6840
- * object is passed to the `path` parameter.
6817
+ * The parameter, `model`, is the
6818
+ * <a href="#/p5.Geometry">p5.Geometry</a> object to draw.
6819
+ * <a href="#/p5.Geometry">p5.Geometry</a> objects can be built with
6820
+ * <a href="#/p5/buildGeometry">buildGeometry()</a>, or
6821
+ * <a href="#/p5/beginGeometry">beginGeometry()</a> and
6822
+ * <a href="#/p5/endGeometry">endGeometry()</a>. They can also be loaded from
6823
+ * a file with <a href="#/p5/loadGeometry">loadGeometry()</a>.
6841
6824
  *
6842
- * This method is suitable for fetching files up to size of 64MB when "GET" is used.
6843
- * @param path name of the file or url to load
6844
- * @param method either "GET", "POST", "PUT", "DELETE",
6845
- * or other HTTP request methods
6846
- * @param datatype "json", "jsonp", "xml", or "text"
6847
- * @param data param data passed sent with request
6848
- * @param callback function to be executed after
6849
- * <a href="#/p5/httpGet">httpGet()</a> completes, data is passed in
6850
- * as first argument
6851
- * @param errorCallback function to be executed if
6852
- * there is an error, response is passed
6853
- * in as first argument
6854
- * @returns A promise that resolves with the data when the operation
6855
- * completes successfully or rejects with the error after
6856
- * one occurs.
6825
+ * Note: `model()` can only be used in WebGL mode.
6826
+ * @param model 3D shape to be drawn.
6827
+ * @param count number of instances to draw.
6857
6828
  */
6858
- httpDo(path: string | Request, method?: string, datatype?: string, data?: object, callback?: Function, errorCallback?: Function): Promise<any>;
6859
- httpDo(path: string | Request, callback?: Function, errorCallback?: Function): Promise<any>;
6829
+ model(model: P5.Geometry, count?: number): void;
6860
6830
 
6861
6831
  /**
6862
6832
  * Draws a rectangle.
@@ -6887,6 +6857,33 @@ EXCLUDE: typeof P5.EXCLUDE;
6887
6857
  rect(x: number, y: number, w: number, h?: number, tl?: number, tr?: number, br?: number, bl?: number): void;
6888
6858
  rect(x: number, y: number, w: number, h: number, detailX?: number, detailY?: number): void;
6889
6859
 
6860
+ /**
6861
+ * Method for executing an HTTP request. If data type is not specified,
6862
+ * it will default to `'text'`.
6863
+ *
6864
+ * This function is meant for more advanced usage of HTTP requests in p5.js. It is
6865
+ * best used when a `Request`
6866
+ * object is passed to the `path` parameter.
6867
+ *
6868
+ * This method is suitable for fetching files up to size of 64MB when "GET" is used.
6869
+ * @param path name of the file or url to load
6870
+ * @param method either "GET", "POST", "PUT", "DELETE",
6871
+ * or other HTTP request methods
6872
+ * @param datatype "json", "jsonp", "xml", or "text"
6873
+ * @param data param data passed sent with request
6874
+ * @param callback function to be executed after
6875
+ * <a href="#/p5/httpGet">httpGet()</a> completes, data is passed in
6876
+ * as first argument
6877
+ * @param errorCallback function to be executed if
6878
+ * there is an error, response is passed
6879
+ * in as first argument
6880
+ * @returns A promise that resolves with the data when the operation
6881
+ * completes successfully or rejects with the error after
6882
+ * one occurs.
6883
+ */
6884
+ httpDo(path: string | Request, method?: string, datatype?: string, data?: object, callback?: Function, errorCallback?: Function): Promise<any>;
6885
+ httpDo(path: string | Request, callback?: Function, errorCallback?: Function): Promise<any>;
6886
+
6890
6887
  /**
6891
6888
  * Shears the y-axis so that shapes appear skewed.
6892
6889
  *
@@ -7191,6 +7188,22 @@ EXCLUDE: typeof P5.EXCLUDE;
7191
7188
  */
7192
7189
  strokeShader(s: P5.Shader): void;
7193
7190
 
7191
+ /**
7192
+ * Gets the brightness value of a color.
7193
+ *
7194
+ * `brightness()` extracts the HSB brightness value from a
7195
+ * <a href="/reference/p5/p5.Color/">p5.Color</a> object, an array of color components, or
7196
+ * a CSS color string.
7197
+ *
7198
+ * By default, `brightness()` returns a color's HSB brightness in the range 0
7199
+ * to 100. If the <a href="/reference/p5/colorMode/">colorMode()</a> is set to HSB, it
7200
+ * returns the brightness value in the given range.
7201
+ * @param color <a href="/reference/p5/p5.Color/">p5.Color</a> object, array of
7202
+ * color components, or CSS color string.
7203
+ * @returns the brightness value.
7204
+ */
7205
+ brightness(color: P5.Color | number[] | string): number;
7206
+
7194
7207
  /**
7195
7208
  * Tints images using a color.
7196
7209
  *
@@ -7219,47 +7232,6 @@ EXCLUDE: typeof P5.EXCLUDE;
7219
7232
  tint(values: number[]): void;
7220
7233
  tint(color: P5.Color): void;
7221
7234
 
7222
- /**
7223
- * Gets the brightness value of a color.
7224
- *
7225
- * `brightness()` extracts the HSB brightness value from a
7226
- * <a href="/reference/p5/p5.Color/">p5.Color</a> object, an array of color components, or
7227
- * a CSS color string.
7228
- *
7229
- * By default, `brightness()` returns a color's HSB brightness in the range 0
7230
- * to 100. If the <a href="/reference/p5/colorMode/">colorMode()</a> is set to HSB, it
7231
- * returns the brightness value in the given range.
7232
- * @param color <a href="/reference/p5/p5.Color/">p5.Color</a> object, array of
7233
- * color components, or CSS color string.
7234
- * @returns the brightness value.
7235
- */
7236
- brightness(color: P5.Color | number[] | string): number;
7237
-
7238
- /**
7239
- * Creates a new <a href="#/p5.PrintWriter">p5.PrintWriter</a> object.
7240
- *
7241
- * <a href="#/p5.PrintWriter">p5.PrintWriter</a> objects provide a way to
7242
- * save a sequence of text data, called the print stream, to the user's
7243
- * computer. They're low-level objects that enable precise control of text
7244
- * output. Functions such as
7245
- * <a href="#/p5/saveStrings">saveStrings()</a> and
7246
- * <a href="#/p5/saveJSON">saveJSON()</a> are easier to use for simple file
7247
- * saving.
7248
- *
7249
- * The first parameter, `filename`, is the name of the file to be written. If
7250
- * a string is passed, as in `createWriter('words.txt')`, a new
7251
- * <a href="#/p5.PrintWriter">p5.PrintWriter</a> object will be created that
7252
- * writes to a file named `words.txt`.
7253
- *
7254
- * The second parameter, `extension`, is optional. If a string is passed, as
7255
- * in `createWriter('words', 'csv')`, the first parameter will be interpreted
7256
- * as the file name and the second parameter as the extension.
7257
- * @param name name of the file to create.
7258
- * @param extension format to use for the file.
7259
- * @returns stream for writing data.
7260
- */
7261
- createWriter(name: string, extension?: string): P5.PrintWriter;
7262
-
7263
7235
  /**
7264
7236
  * Creates a light that shines from a point in one direction.
7265
7237
  *
@@ -7308,6 +7280,31 @@ EXCLUDE: typeof P5.EXCLUDE;
7308
7280
  spotLight(v1: number, v2: number, v3: number, position: P5.Vector, rx: number, ry: number, rz: number, angle?: number, concentration?: number): void;
7309
7281
  spotLight(color: P5.Color | number[] | string, x: number, y: number, z: number, rx: number, ry: number, rz: number, angle?: number, concentration?: number): void;
7310
7282
 
7283
+ /**
7284
+ * Creates a new <a href="#/p5.PrintWriter">p5.PrintWriter</a> object.
7285
+ *
7286
+ * <a href="#/p5.PrintWriter">p5.PrintWriter</a> objects provide a way to
7287
+ * save a sequence of text data, called the print stream, to the user's
7288
+ * computer. They're low-level objects that enable precise control of text
7289
+ * output. Functions such as
7290
+ * <a href="#/p5/saveStrings">saveStrings()</a> and
7291
+ * <a href="#/p5/saveJSON">saveJSON()</a> are easier to use for simple file
7292
+ * saving.
7293
+ *
7294
+ * The first parameter, `filename`, is the name of the file to be written. If
7295
+ * a string is passed, as in `createWriter('words.txt')`, a new
7296
+ * <a href="#/p5.PrintWriter">p5.PrintWriter</a> object will be created that
7297
+ * writes to a file named `words.txt`.
7298
+ *
7299
+ * The second parameter, `extension`, is optional. If a string is passed, as
7300
+ * in `createWriter('words', 'csv')`, the first parameter will be interpreted
7301
+ * as the file name and the second parameter as the extension.
7302
+ * @param name name of the file to create.
7303
+ * @param extension format to use for the file.
7304
+ * @returns stream for writing data.
7305
+ */
7306
+ createWriter(name: string, extension?: string): P5.PrintWriter;
7307
+
7311
7308
  /**
7312
7309
  * Translates the coordinate system.
7313
7310
  *
@@ -7800,18 +7797,6 @@ EXCLUDE: typeof P5.EXCLUDE;
7800
7797
  */
7801
7798
  noLights(): void;
7802
7799
 
7803
- /**
7804
- * Writes data to the print stream without adding new lines.
7805
- *
7806
- * The parameter, `data`, is the data to write. `data` can be a number or
7807
- * string, as in `myWriter.write('hi')`, or an array of numbers and strings,
7808
- * as in `myWriter.write([1, 2, 3])`. A comma will be inserted between array
7809
- * array elements when they're added to the print stream.
7810
- * @param data data to be written as a string, number,
7811
- * or array of strings and numbers.
7812
- */
7813
- write(data: string | number | any[]): void;
7814
-
7815
7800
  /**
7816
7801
  * Gets the lightness value of a color.
7817
7802
  *
@@ -7828,6 +7813,25 @@ EXCLUDE: typeof P5.EXCLUDE;
7828
7813
  */
7829
7814
  lightness(color: P5.Color | number[] | string): number;
7830
7815
 
7816
+ /**
7817
+ * Sets the <a href="#/p5.Shader">p5.Shader</a> object to apply for images.
7818
+ *
7819
+ * This method allows the user to apply a custom shader to images, enabling
7820
+ * advanced visual effects such as pixel manipulation, color adjustments,
7821
+ * or dynamic behavior. The shader will be applied to the image drawn using
7822
+ * the <a href="#/p5/image">image()</a> function.
7823
+ *
7824
+ * The shader will be used exclusively for:
7825
+ *
7826
+ * - `image()` calls, applying only when drawing 2D images.
7827
+ *
7828
+ * - This shader will NOT apply to images used in <a href="#/p5/texture">texture()</a> or other 3D contexts.
7829
+ * Any attempts to use the imageShader in these cases will be ignored.
7830
+ * @param s <a href="#/p5.Shader">p5.Shader</a> object
7831
+ * to apply for images.
7832
+ */
7833
+ imageShader(s: P5.Shader): void;
7834
+
7831
7835
  /**
7832
7836
  * Changes the location from which images are drawn when
7833
7837
  * <a href="#/p5/image">image()</a> is called.
@@ -7896,23 +7900,16 @@ EXCLUDE: typeof P5.EXCLUDE;
7896
7900
  mouseReleased(event?: MouseEvent): void;
7897
7901
 
7898
7902
  /**
7899
- * Sets the <a href="#/p5.Shader">p5.Shader</a> object to apply for images.
7900
- *
7901
- * This method allows the user to apply a custom shader to images, enabling
7902
- * advanced visual effects such as pixel manipulation, color adjustments,
7903
- * or dynamic behavior. The shader will be applied to the image drawn using
7904
- * the <a href="#/p5/image">image()</a> function.
7905
- *
7906
- * The shader will be used exclusively for:
7907
- *
7908
- * - `image()` calls, applying only when drawing 2D images.
7903
+ * Writes data to the print stream without adding new lines.
7909
7904
  *
7910
- * - This shader will NOT apply to images used in <a href="#/p5/texture">texture()</a> or other 3D contexts.
7911
- * Any attempts to use the imageShader in these cases will be ignored.
7912
- * @param s <a href="#/p5.Shader">p5.Shader</a> object
7913
- * to apply for images.
7905
+ * The parameter, `data`, is the data to write. `data` can be a number or
7906
+ * string, as in `myWriter.write('hi')`, or an array of numbers and strings,
7907
+ * as in `myWriter.write([1, 2, 3])`. A comma will be inserted between array
7908
+ * array elements when they're added to the print stream.
7909
+ * @param data data to be written as a string, number,
7910
+ * or array of strings and numbers.
7914
7911
  */
7915
- imageShader(s: P5.Shader): void;
7912
+ write(data: string | number | any[]): void;
7916
7913
 
7917
7914
  /**
7918
7915
  * Disables drawing points, lines, and the outlines of shapes.
@@ -8202,7 +8199,7 @@ EXCLUDE: typeof P5.EXCLUDE;
8202
8199
  * }
8203
8200
  *
8204
8201
  * function material() {
8205
- * let time = uniformFloat();
8202
+ * let time = millis();
8206
8203
  * worldInputs.begin();
8207
8204
  * worldInputs.position.y +=
8208
8205
  * 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -8212,7 +8209,6 @@ EXCLUDE: typeof P5.EXCLUDE;
8212
8209
  * function draw() {
8213
8210
  * background(255);
8214
8211
  * shader(myShader);
8215
- * myShader.setUniform('time', millis());
8216
8212
  * lights();
8217
8213
  * noStroke();
8218
8214
  * fill('red');
@@ -8430,42 +8426,6 @@ EXCLUDE: typeof P5.EXCLUDE;
8430
8426
  */
8431
8427
  createColorPicker(value?: string | P5.Color): P5.Element;
8432
8428
 
8433
- /**
8434
- * Saves a given element(image, text, json, csv, wav, or html) to the client's
8435
- * computer. The first parameter can be a pointer to element we want to save.
8436
- * The element can be one of <a href="#/p5.Element">p5.Element</a>,an Array of
8437
- * Strings, an Array of JSON, a JSON object, a <a href="#/p5.Table">p5.Table
8438
- * </a>, a <a href="#/p5.Image">p5.Image</a>, or a p5.SoundFile (requires
8439
- * p5.sound). The second parameter is a filename (including extension).The
8440
- * third parameter is for options specific to this type of object. This method
8441
- * will save a file that fits the given parameters.
8442
- * If it is called without specifying an element, by default it will save the
8443
- * whole canvas as an image file. You can optionally specify a filename as
8444
- * the first parameter in such a case.
8445
- * Note that it is not recommended to
8446
- * call this method within draw, as it will open a new save dialog on every
8447
- * render.
8448
- * @param objectOrFilename If filename is provided, will
8449
- * save canvas as an image with
8450
- * either png or jpg extension
8451
- * depending on the filename.
8452
- * If object is provided, will
8453
- * save depending on the object
8454
- * and filename (see examples
8455
- * above).
8456
- * @param filename If an object is provided as the first
8457
- * parameter, then the second parameter
8458
- * indicates the filename,
8459
- * and should include an appropriate
8460
- * file extension (see examples above).
8461
- * @param options Additional options depend on
8462
- * filetype. For example, when saving JSON,
8463
- * <code>true</code> indicates that the
8464
- * output will be optimized for filesize,
8465
- * rather than readability.
8466
- */
8467
- save(objectOrFilename?: object | string, filename?: string, options?: boolean | string): void;
8468
-
8469
8429
  /**
8470
8430
  * Loads a new shader from a file that can change how fills are drawn. Pass the resulting
8471
8431
  * shader into the <a href="#/p5/shader">`shader()`</a> function to apply it
@@ -8483,7 +8443,6 @@ EXCLUDE: typeof P5.EXCLUDE;
8483
8443
  * function draw() {
8484
8444
  * background(255);
8485
8445
  * shader(myShader);
8486
- * myShader.setUniform('time', millis());
8487
8446
  * lights();
8488
8447
  * noStroke();
8489
8448
  * fill('red');
@@ -8493,7 +8452,7 @@ EXCLUDE: typeof P5.EXCLUDE;
8493
8452
  * might use the `pixelInputs` hook to change each pixel on the surface of a shape.
8494
8453
  *
8495
8454
  * `// myMaterial.js
8496
- * let time = uniformFloat();
8455
+ * let time = millis();
8497
8456
  * worldInputs.begin();
8498
8457
  * worldInputs.position.y +=
8499
8458
  * 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -8511,7 +8470,43 @@ EXCLUDE: typeof P5.EXCLUDE;
8511
8470
  * @param onFailure A callback function to run when loading fails.
8512
8471
  * @returns The material shader.
8513
8472
  */
8514
- loadMaterialShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
8473
+ loadMaterialShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
8474
+
8475
+ /**
8476
+ * Saves a given element(image, text, json, csv, wav, or html) to the client's
8477
+ * computer. The first parameter can be a pointer to element we want to save.
8478
+ * The element can be one of <a href="#/p5.Element">p5.Element</a>,an Array of
8479
+ * Strings, an Array of JSON, a JSON object, a <a href="#/p5.Table">p5.Table
8480
+ * </a>, a <a href="#/p5.Image">p5.Image</a>, or a p5.SoundFile (requires
8481
+ * p5.sound). The second parameter is a filename (including extension).The
8482
+ * third parameter is for options specific to this type of object. This method
8483
+ * will save a file that fits the given parameters.
8484
+ * If it is called without specifying an element, by default it will save the
8485
+ * whole canvas as an image file. You can optionally specify a filename as
8486
+ * the first parameter in such a case.
8487
+ * Note that it is not recommended to
8488
+ * call this method within draw, as it will open a new save dialog on every
8489
+ * render.
8490
+ * @param objectOrFilename If filename is provided, will
8491
+ * save canvas as an image with
8492
+ * either png or jpg extension
8493
+ * depending on the filename.
8494
+ * If object is provided, will
8495
+ * save depending on the object
8496
+ * and filename (see examples
8497
+ * above).
8498
+ * @param filename If an object is provided as the first
8499
+ * parameter, then the second parameter
8500
+ * indicates the filename,
8501
+ * and should include an appropriate
8502
+ * file extension (see examples above).
8503
+ * @param options Additional options depend on
8504
+ * filetype. For example, when saving JSON,
8505
+ * <code>true</code> indicates that the
8506
+ * output will be optimized for filesize,
8507
+ * rather than readability.
8508
+ */
8509
+ save(objectOrFilename?: object | string, filename?: string, options?: boolean | string): void;
8515
8510
 
8516
8511
  /**
8517
8512
  * Influences the shape of the Bézier curve segment in a custom shape.
@@ -8595,6 +8590,19 @@ EXCLUDE: typeof P5.EXCLUDE;
8595
8590
  */
8596
8591
  baseMaterialShader(): P5.Shader;
8597
8592
 
8593
+ /**
8594
+ * Returns the base shader used for filters.
8595
+ *
8596
+ * Calling <a href="#/p5/buildFilterShader">`buildFilterShader(shaderFunction)`</a>
8597
+ * is equivalent to calling `baseFilterShader().modify(shaderFunction)`.
8598
+ *
8599
+ * Read <a href="#/p5/buildFilterShader">the `buildFilterShader` reference</a> or
8600
+ * call `baseFilterShader().inspectHooks()` for more information on what you can do with
8601
+ * the base filter shader.
8602
+ * @returns The base filter shader.
8603
+ */
8604
+ baseFilterShader(): P5.Shader;
8605
+
8598
8606
  /**
8599
8607
  * Starts using shapes to erase parts of the canvas.
8600
8608
  *
@@ -8629,19 +8637,6 @@ EXCLUDE: typeof P5.EXCLUDE;
8629
8637
  */
8630
8638
  erase(strengthFill?: number, strengthStroke?: number): void;
8631
8639
 
8632
- /**
8633
- * Returns the base shader used for filters.
8634
- *
8635
- * Calling <a href="#/p5/buildFilterShader">`buildFilterShader(shaderFunction)`</a>
8636
- * is equivalent to calling `baseFilterShader().modify(shaderFunction)`.
8637
- *
8638
- * Read <a href="#/p5/buildFilterShader">the `buildFilterShader` reference</a> or
8639
- * call `baseFilterShader().inspectHooks()` for more information on what you can do with
8640
- * the base filter shader.
8641
- * @returns The base filter shader.
8642
- */
8643
- baseFilterShader(): P5.Shader;
8644
-
8645
8640
  /**
8646
8641
  * Ends erasing that was started with <a href="#/p5/erase">erase()</a>.
8647
8642
  *
@@ -8670,37 +8665,6 @@ EXCLUDE: typeof P5.EXCLUDE;
8670
8665
  createInput(value?: string, type?: string): P5.Element;
8671
8666
  createInput(value?: string): P5.Element;
8672
8667
 
8673
- /**
8674
- * Saves an `Object` or `Array` to a JSON file.
8675
- *
8676
- * JavaScript Object Notation
8677
- * (<a href="https://developer.mozilla.org/en-US/docs/Glossary/JSON" target="_blank">JSON</a>)
8678
- * is a standard format for sending data between applications. The format is
8679
- * based on JavaScript objects which have keys and values. JSON files store
8680
- * data in an object with strings as keys. Values can be strings, numbers,
8681
- * Booleans, arrays, `null`, or other objects.
8682
- *
8683
- * The first parameter, `json`, is the data to save. The data can be an array,
8684
- * as in `[1, 2, 3]`, or an object, as in
8685
- * `{ x: 50, y: 50, color: 'deeppink' }`.
8686
- *
8687
- * The second parameter, `filename`, is a string that sets the file's name.
8688
- * For example, calling `saveJSON([1, 2, 3], 'data.json')` saves the array
8689
- * `[1, 2, 3]` to a file called `data.json` on the user's computer.
8690
- *
8691
- * The third parameter, `optimize`, is optional. If `true` is passed, as in
8692
- * `saveJSON([1, 2, 3], 'data.json', true)`, then all unneeded whitespace will
8693
- * be removed to reduce the file size.
8694
- *
8695
- * Note: The browser will either save the file immediately or prompt the user
8696
- * with a dialogue window.
8697
- * @param json data to save.
8698
- * @param filename name of the file to be saved.
8699
- * @param optimize whether to trim unneeded whitespace. Defaults
8700
- * to `true`.
8701
- */
8702
- saveJSON(json: any[] | object, filename: string, optimize?: boolean): void;
8703
-
8704
8668
  /**
8705
8669
  * Create a new shader that can change how fills are drawn, based on the material used
8706
8670
  * when <a href="#/p5/normalMaterial">`normalMaterial()`</a> is active. Pass the resulting
@@ -8733,7 +8697,7 @@ EXCLUDE: typeof P5.EXCLUDE;
8733
8697
  * }
8734
8698
  *
8735
8699
  * function material() {
8736
- * let time = uniformFloat();
8700
+ * let time = millis();
8737
8701
  * worldInputs.begin();
8738
8702
  * worldInputs.position.y +=
8739
8703
  * 20. * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -8743,7 +8707,6 @@ EXCLUDE: typeof P5.EXCLUDE;
8743
8707
  * function draw() {
8744
8708
  * background(255);
8745
8709
  * shader(myShader);
8746
- * myShader.setUniform('time', millis());
8747
8710
  * noStroke();
8748
8711
  * sphere(50);
8749
8712
  * }`You may also want to change the colors used. By default, the x, y, and z values of the orientation
@@ -8836,6 +8799,37 @@ EXCLUDE: typeof P5.EXCLUDE;
8836
8799
  */
8837
8800
  mouseWheel(event?: WheelEvent): void;
8838
8801
 
8802
+ /**
8803
+ * Saves an `Object` or `Array` to a JSON file.
8804
+ *
8805
+ * JavaScript Object Notation
8806
+ * (<a href="https://developer.mozilla.org/en-US/docs/Glossary/JSON" target="_blank">JSON</a>)
8807
+ * is a standard format for sending data between applications. The format is
8808
+ * based on JavaScript objects which have keys and values. JSON files store
8809
+ * data in an object with strings as keys. Values can be strings, numbers,
8810
+ * Booleans, arrays, `null`, or other objects.
8811
+ *
8812
+ * The first parameter, `json`, is the data to save. The data can be an array,
8813
+ * as in `[1, 2, 3]`, or an object, as in
8814
+ * `{ x: 50, y: 50, color: 'deeppink' }`.
8815
+ *
8816
+ * The second parameter, `filename`, is a string that sets the file's name.
8817
+ * For example, calling `saveJSON([1, 2, 3], 'data.json')` saves the array
8818
+ * `[1, 2, 3]` to a file called `data.json` on the user's computer.
8819
+ *
8820
+ * The third parameter, `optimize`, is optional. If `true` is passed, as in
8821
+ * `saveJSON([1, 2, 3], 'data.json', true)`, then all unneeded whitespace will
8822
+ * be removed to reduce the file size.
8823
+ *
8824
+ * Note: The browser will either save the file immediately or prompt the user
8825
+ * with a dialogue window.
8826
+ * @param json data to save.
8827
+ * @param filename name of the file to be saved.
8828
+ * @param optimize whether to trim unneeded whitespace. Defaults
8829
+ * to `true`.
8830
+ */
8831
+ saveJSON(json: any[] | object, filename: string, optimize?: boolean): void;
8832
+
8839
8833
  /**
8840
8834
  * Ends a drawing group that contains its own styles and transformations.
8841
8835
  *
@@ -9019,25 +9013,6 @@ EXCLUDE: typeof P5.EXCLUDE;
9019
9013
  */
9020
9014
  createFileInput(callback: (input: P5.File) => any, multiple?: boolean): P5.Element;
9021
9015
 
9022
- /**
9023
- * Locks the mouse pointer to its current position and makes it invisible.
9024
- *
9025
- * `requestPointerLock()` allows the mouse to move forever without leaving the
9026
- * screen. Calling `requestPointerLock()` locks the values of
9027
- * <a href="#/p5/mouseX">mouseX</a>, <a href="#/p5/mouseY">mouseY</a>,
9028
- * <a href="#/p5/pmouseX">pmouseX</a>, and <a href="#/p5/pmouseY">pmouseY</a>.
9029
- * <a href="#/p5/movedX">movedX</a> and <a href="#/p5/movedY">movedY</a>
9030
- * continue updating and can be used to get the distance the mouse moved since
9031
- * the last frame was drawn. Calling
9032
- * <a href="#/p5/exitPointerLock">exitPointerLock()</a> resumes updating the
9033
- * mouse system variables.
9034
- *
9035
- * Note: Most browsers require an input, such as a click, before calling
9036
- * `requestPointerLock()`. It’s recommended to call `requestPointerLock()` in
9037
- * an event function such as <a href="#/p5/doubleClicked">doubleClicked()</a>.
9038
- */
9039
- requestPointerLock(): void;
9040
-
9041
9016
  /**
9042
9017
  * Loads a new shader from a file that can change how fills are drawn, based on the material used
9043
9018
  * when <a href="#/p5/normalMaterial">`normalMaterial()`</a> is active. Pass the resulting
@@ -9056,7 +9031,6 @@ EXCLUDE: typeof P5.EXCLUDE;
9056
9031
  * function draw() {
9057
9032
  * background(255);
9058
9033
  * shader(myShader);
9059
- * myShader.setUniform('time', millis());
9060
9034
  * lights();
9061
9035
  * noStroke();
9062
9036
  * fill('red');
@@ -9066,7 +9040,7 @@ EXCLUDE: typeof P5.EXCLUDE;
9066
9040
  * might use the `finalColor` hook to change the color of each pixel on the surface of a shape.
9067
9041
  *
9068
9042
  * `// myMaterial.js
9069
- * let time = uniformFloat();
9043
+ * let time = millis();
9070
9044
  * worldInputs.begin();
9071
9045
  * worldInputs.position.y +=
9072
9046
  * 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -9086,6 +9060,25 @@ EXCLUDE: typeof P5.EXCLUDE;
9086
9060
  */
9087
9061
  loadNormalShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
9088
9062
 
9063
+ /**
9064
+ * Locks the mouse pointer to its current position and makes it invisible.
9065
+ *
9066
+ * `requestPointerLock()` allows the mouse to move forever without leaving the
9067
+ * screen. Calling `requestPointerLock()` locks the values of
9068
+ * <a href="#/p5/mouseX">mouseX</a>, <a href="#/p5/mouseY">mouseY</a>,
9069
+ * <a href="#/p5/pmouseX">pmouseX</a>, and <a href="#/p5/pmouseY">pmouseY</a>.
9070
+ * <a href="#/p5/movedX">movedX</a> and <a href="#/p5/movedY">movedY</a>
9071
+ * continue updating and can be used to get the distance the mouse moved since
9072
+ * the last frame was drawn. Calling
9073
+ * <a href="#/p5/exitPointerLock">exitPointerLock()</a> resumes updating the
9074
+ * mouse system variables.
9075
+ *
9076
+ * Note: Most browsers require an input, such as a click, before calling
9077
+ * `requestPointerLock()`. It’s recommended to call `requestPointerLock()` in
9078
+ * an event function such as <a href="#/p5/doubleClicked">doubleClicked()</a>.
9079
+ */
9080
+ requestPointerLock(): void;
9081
+
9089
9082
  /**
9090
9083
  * Returns the default shader used for fills when
9091
9084
  * <a href="#/p5/normalMaterial">`normalMaterial()`</a> is activated.
@@ -9178,7 +9171,7 @@ EXCLUDE: typeof P5.EXCLUDE;
9178
9171
  * }
9179
9172
  *
9180
9173
  * function material() {
9181
- * let time = uniformFloat();
9174
+ * let time = millis();
9182
9175
  * worldInputs.begin();
9183
9176
  * worldInputs.position.y +=
9184
9177
  * 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -9188,7 +9181,6 @@ EXCLUDE: typeof P5.EXCLUDE;
9188
9181
  * function draw() {
9189
9182
  * background(255);
9190
9183
  * shader(myShader);
9191
- * myShader.setUniform('time', millis());
9192
9184
  * noStroke();
9193
9185
  * fill('red');
9194
9186
  * circle(0, 0, 50);
@@ -9302,7 +9294,6 @@ EXCLUDE: typeof P5.EXCLUDE;
9302
9294
  * function draw() {
9303
9295
  * background(255);
9304
9296
  * shader(myShader);
9305
- * myShader.setUniform('time', millis());
9306
9297
  * lights();
9307
9298
  * noStroke();
9308
9299
  * fill('red');
@@ -9312,7 +9303,7 @@ EXCLUDE: typeof P5.EXCLUDE;
9312
9303
  * might use the `finalColor` hook to change the color of each pixel on the surface of a shape.
9313
9304
  *
9314
9305
  * `// myMaterial.js
9315
- * let time = uniformFloat();
9306
+ * let time = millis();
9316
9307
  * worldInputs.begin();
9317
9308
  * worldInputs.position.y +=
9318
9309
  * 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -9597,7 +9588,7 @@ EXCLUDE: typeof P5.EXCLUDE;
9597
9588
  * }
9598
9589
  *
9599
9590
  * function material() {
9600
- * let time = uniformFloat();
9591
+ * let time = millis();
9601
9592
  * worldInputs.begin();
9602
9593
  * // Add a somewhat random offset to the weight
9603
9594
  * // that varies based on position and time
@@ -9613,7 +9604,6 @@ EXCLUDE: typeof P5.EXCLUDE;
9613
9604
  * function draw() {
9614
9605
  * background(255);
9615
9606
  * strokeShader(myShader);
9616
- * myShader.setUniform('time', millis());
9617
9607
  * strokeWeight(10);
9618
9608
  * beginShape();
9619
9609
  * for (let i = 0; i <= 50; i++) {
@@ -9704,6 +9694,58 @@ EXCLUDE: typeof P5.EXCLUDE;
9704
9694
  splineProperty(property: string, value: any): void;
9705
9695
  splineProperty(property: string): void;
9706
9696
 
9697
+ /**
9698
+ * Loads a new shader from a file that can change how strokes are drawn. Pass the resulting
9699
+ * shader into the <a href="#/p5/strokeShader">`strokeShader()`</a> function to apply it
9700
+ * to any strokes you draw.
9701
+ *
9702
+ * Since this function loads data from another file, it returns a `Promise`.
9703
+ * Use it in an `async function setup`, and `await` its result.
9704
+ *
9705
+ * `let myShader;
9706
+ * async function setup() {
9707
+ * createCanvas(200, 200, WEBGL);
9708
+ * myShader = await loadStrokeShader('myMaterial.js');
9709
+ * }
9710
+ *
9711
+ * function draw() {
9712
+ * background(255);
9713
+ * strokeShader(myShader);
9714
+ * strokeWeight(30);
9715
+ * line(
9716
+ * -width/3,
9717
+ * sin(millis()*0.001) * height/4,
9718
+ * width/3,
9719
+ * sin(millis()*0.001 + 1) * height/4
9720
+ * );
9721
+ * }`Inside your shader file, you can call p5.strands hooks to change parts of the shader. For
9722
+ * example, you might use the `worldInputs` hook to change each vertex, or you
9723
+ * might use the `pixelInputs` hook to change each pixel on the surface of a stroke.
9724
+ *
9725
+ * `// myMaterial.js
9726
+ * pixelInputs.begin();
9727
+ * let opacity = 1 - smoothstep(
9728
+ * 0,
9729
+ * 15,
9730
+ * length(pixelInputs.position - pixelInputs.center)
9731
+ * );
9732
+ * pixelInputs.color.a *= opacity;
9733
+ * pixelInputs.end();`Read the reference for <a href="#/p5/buildStrokeShader">`buildStrokeShader`</a>,
9734
+ * the version of `loadStrokeShader` that takes in a function instead of a separate file,
9735
+ * for a full list of hooks you can use and examples for each.
9736
+ *
9737
+ * The second parameter, `successCallback`, is optional. If a function is passed, as in
9738
+ * `loadStrokeShader('myShader.js', onLoaded)`, then the `onLoaded()` function will be called
9739
+ * once the shader loads. The shader will be passed to `onLoaded()` as its only argument.
9740
+ * The return value of `handleData()`, if present, will be used as the final return value of
9741
+ * `loadStrokeShader('myShader.js', onLoaded)`.
9742
+ * @param url The URL of your p5.strands JavaScript file.
9743
+ * @param onSuccess A callback function to run when loading completes.
9744
+ * @param onFailure A callback function to run when loading fails.
9745
+ * @returns The stroke shader.
9746
+ */
9747
+ loadStrokeShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
9748
+
9707
9749
  /**
9708
9750
  * Sets a perspective projection for the current camera in a 3D sketch.
9709
9751
  *
@@ -9734,81 +9776,29 @@ EXCLUDE: typeof P5.EXCLUDE;
9734
9776
  * The third parameter, `near`, is the distance from the camera to the near
9735
9777
  * plane. For example, calling `perspective(0.5, 1.5, 100)` sets the camera’s
9736
9778
  * field of view to 0.5 radians, its aspect ratio to 1.5, and places the near
9737
- * plane 100 pixels from the camera. Any shapes drawn less than 100 pixels
9738
- * from the camera won’t be visible. By default, near is set to `0.1 * 800`,
9739
- * which is 1/10th the default distance between the camera and the origin.
9740
- *
9741
- * The fourth parameter, `far`, is the distance from the camera to the far
9742
- * plane. For example, calling `perspective(0.5, 1.5, 100, 10000)` sets the
9743
- * camera’s field of view to 0.5 radians, its aspect ratio to 1.5, places the
9744
- * near plane 100 pixels from the camera, and places the far plane 10,000
9745
- * pixels from the camera. Any shapes drawn more than 10,000 pixels from the
9746
- * camera won’t be visible. By default, far is set to `10 * 800`, which is 10
9747
- * times the default distance between the camera and the origin.
9748
- *
9749
- * Note: `perspective()` can only be used in WebGL mode.
9750
- * @param fovy camera frustum vertical field of view. Defaults to
9751
- * `2 * atan(height / 2 / 800)`.
9752
- * @param aspect camera frustum aspect ratio. Defaults to
9753
- * `width / height`.
9754
- * @param near distance from the camera to the near clipping plane.
9755
- * Defaults to `0.1 * 800`.
9756
- * @param far distance from the camera to the far clipping plane.
9757
- * Defaults to `10 * 800`.
9758
- */
9759
- perspective(fovy?: number, aspect?: number, near?: number, far?: number): void;
9760
-
9761
- /**
9762
- * Loads a new shader from a file that can change how strokes are drawn. Pass the resulting
9763
- * shader into the <a href="#/p5/strokeShader">`strokeShader()`</a> function to apply it
9764
- * to any strokes you draw.
9765
- *
9766
- * Since this function loads data from another file, it returns a `Promise`.
9767
- * Use it in an `async function setup`, and `await` its result.
9768
- *
9769
- * `let myShader;
9770
- * async function setup() {
9771
- * createCanvas(200, 200, WEBGL);
9772
- * myShader = await loadStrokeShader('myMaterial.js');
9773
- * }
9774
- *
9775
- * function draw() {
9776
- * background(255);
9777
- * strokeShader(myShader);
9778
- * strokeWeight(30);
9779
- * line(
9780
- * -width/3,
9781
- * sin(millis()*0.001) * height/4,
9782
- * width/3,
9783
- * sin(millis()*0.001 + 1) * height/4
9784
- * );
9785
- * }`Inside your shader file, you can call p5.strands hooks to change parts of the shader. For
9786
- * example, you might use the `worldInputs` hook to change each vertex, or you
9787
- * might use the `pixelInputs` hook to change each pixel on the surface of a stroke.
9779
+ * plane 100 pixels from the camera. Any shapes drawn less than 100 pixels
9780
+ * from the camera won’t be visible. By default, near is set to `0.1 * 800`,
9781
+ * which is 1/10th the default distance between the camera and the origin.
9788
9782
  *
9789
- * `// myMaterial.js
9790
- * pixelInputs.begin();
9791
- * let opacity = 1 - smoothstep(
9792
- * 0,
9793
- * 15,
9794
- * length(pixelInputs.position - pixelInputs.center)
9795
- * );
9796
- * pixelInputs.color.a *= opacity;
9797
- * pixelInputs.end();`Read the reference for <a href="#/p5/buildStrokeShader">`buildStrokeShader`</a>,
9798
- * the version of `loadStrokeShader` that takes in a function instead of a separate file,
9799
- * for a full list of hooks you can use and examples for each.
9783
+ * The fourth parameter, `far`, is the distance from the camera to the far
9784
+ * plane. For example, calling `perspective(0.5, 1.5, 100, 10000)` sets the
9785
+ * camera’s field of view to 0.5 radians, its aspect ratio to 1.5, places the
9786
+ * near plane 100 pixels from the camera, and places the far plane 10,000
9787
+ * pixels from the camera. Any shapes drawn more than 10,000 pixels from the
9788
+ * camera won’t be visible. By default, far is set to `10 * 800`, which is 10
9789
+ * times the default distance between the camera and the origin.
9800
9790
  *
9801
- * The second parameter, `successCallback`, is optional. If a function is passed, as in
9802
- * `loadStrokeShader('myShader.js', onLoaded)`, then the `onLoaded()` function will be called
9803
- * once the shader loads. The shader will be passed to `onLoaded()` as its only argument.
9804
- * The return value of `handleData()`, if present, will be used as the final return value of
9805
- * `loadStrokeShader('myShader.js', onLoaded)`.
9806
- * @param url The URL of your p5.strands JavaScript file.
9807
- * @param onSuccess A callback function to run when loading completes.
9808
- * @param onFailure A callback function to run when loading fails.
9809
- * @returns The stroke shader.
9791
+ * Note: `perspective()` can only be used in WebGL mode.
9792
+ * @param fovy camera frustum vertical field of view. Defaults to
9793
+ * `2 * atan(height / 2 / 800)`.
9794
+ * @param aspect camera frustum aspect ratio. Defaults to
9795
+ * `width / height`.
9796
+ * @param near distance from the camera to the near clipping plane.
9797
+ * Defaults to `0.1 * 800`.
9798
+ * @param far distance from the camera to the far clipping plane.
9799
+ * Defaults to `10 * 800`.
9810
9800
  */
9811
- loadStrokeShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
9801
+ perspective(fovy?: number, aspect?: number, near?: number, far?: number): void;
9812
9802
 
9813
9803
  /**
9814
9804
  * Returns the default shader used for strokes.
@@ -9854,6 +9844,17 @@ EXCLUDE: typeof P5.EXCLUDE;
9854
9844
  */
9855
9845
  splineProperties(values: object): object;
9856
9846
 
9847
+ /**
9848
+ * Restores the default shaders.
9849
+ *
9850
+ * `resetShader()` deactivates any shaders previously applied by
9851
+ * <a href="#/p5/shader">shader()</a>, <a href="#/p5/strokeShader">strokeShader()</a>,
9852
+ * or <a href="#/p5/imageShader">imageShader()</a>.
9853
+ *
9854
+ * Note: Shaders can only be used in WebGL mode.
9855
+ */
9856
+ resetShader(): void;
9857
+
9857
9858
  /**
9858
9859
  * Enables or disables perspective for lines in 3D sketches.
9859
9860
  *
@@ -9891,17 +9892,6 @@ EXCLUDE: typeof P5.EXCLUDE;
9891
9892
  linePerspective(enable: boolean): boolean;
9892
9893
  linePerspective(): boolean;
9893
9894
 
9894
- /**
9895
- * Restores the default shaders.
9896
- *
9897
- * `resetShader()` deactivates any shaders previously applied by
9898
- * <a href="#/p5/shader">shader()</a>, <a href="#/p5/strokeShader">strokeShader()</a>,
9899
- * or <a href="#/p5/imageShader">imageShader()</a>.
9900
- *
9901
- * Note: Shaders can only be used in WebGL mode.
9902
- */
9903
- resetShader(): void;
9904
-
9905
9895
  /**
9906
9896
  * Sets an orthographic projection for the current camera in a 3D sketch.
9907
9897
  *
@@ -11249,8 +11239,8 @@ namespace p5 {
11249
11239
  const HSB: typeof P5.HSB;
11250
11240
  const deviceOrientation: typeof P5.deviceOrientation;
11251
11241
  const accelerationX: typeof P5.accelerationX;
11252
- const movedX: typeof P5.movedX;
11253
11242
  const accelerationY: typeof P5.accelerationY;
11243
+ const movedX: typeof P5.movedX;
11254
11244
  const accelerationZ: typeof P5.accelerationZ;
11255
11245
  const pAccelerationX: typeof P5.pAccelerationX;
11256
11246
  const pAccelerationY: typeof P5.pAccelerationY;
@@ -11266,8 +11256,8 @@ namespace p5 {
11266
11256
  const mouseX: typeof P5.mouseX;
11267
11257
  const rotationZ: typeof P5.rotationZ;
11268
11258
  const pRotationX: typeof P5.pRotationX;
11269
- const mouseY: typeof P5.mouseY;
11270
11259
  const pRotationY: typeof P5.pRotationY;
11260
+ const mouseY: typeof P5.mouseY;
11271
11261
  const pRotationZ: typeof P5.pRotationZ;
11272
11262
  const pmouseX: typeof P5.pmouseX;
11273
11263
  const code: typeof P5.code;
@@ -11320,7 +11310,6 @@ namespace p5 {
11320
11310
  const TAU: typeof P5.TAU;
11321
11311
  const TWO_PI: typeof P5.TWO_PI;
11322
11312
  const DEG_TO_RAD: typeof P5.DEG_TO_RAD;
11323
- let disableFriendlyErrors: typeof P5.disableFriendlyErrors;
11324
11313
  const RAD_TO_DEG: typeof P5.RAD_TO_DEG;
11325
11314
  const CORNER: typeof P5.CORNER;
11326
11315
  const CORNERS: typeof P5.CORNERS;
@@ -11337,6 +11326,7 @@ namespace p5 {
11337
11326
  const LINE_STRIP: typeof P5.LINE_STRIP;
11338
11327
  const LINE_LOOP: typeof P5.LINE_LOOP;
11339
11328
  const TRIANGLES: typeof P5.TRIANGLES;
11329
+ let disableFriendlyErrors: typeof P5.disableFriendlyErrors;
11340
11330
  const TRIANGLE_FAN: typeof P5.TRIANGLE_FAN;
11341
11331
  const TRIANGLE_STRIP: typeof P5.TRIANGLE_STRIP;
11342
11332
  const QUADS: typeof P5.QUADS;
@@ -11519,6 +11509,12 @@ const deviceOrientation: typeof P5.deviceOrientation;
11519
11509
  */
11520
11510
  const accelerationX: typeof P5.accelerationX;
11521
11511
 
11512
+ /**
11513
+ * The system variable accelerationY always contains the acceleration of the
11514
+ * device along the y axis. Value is represented as meters per second squared.
11515
+ */
11516
+ const accelerationY: typeof P5.accelerationY;
11517
+
11522
11518
  /**
11523
11519
  * A `Number` system variable that tracks the mouse's horizontal movement.
11524
11520
  *
@@ -11532,12 +11528,6 @@ const accelerationX: typeof P5.accelerationX;
11532
11528
  */
11533
11529
  const movedX: typeof P5.movedX;
11534
11530
 
11535
- /**
11536
- * The system variable accelerationY always contains the acceleration of the
11537
- * device along the y axis. Value is represented as meters per second squared.
11538
- */
11539
- const accelerationY: typeof P5.accelerationY;
11540
-
11541
11531
  /**
11542
11532
  * The system variable accelerationZ always contains the acceleration of the
11543
11533
  * device along the z axis. Value is represented as meters per second squared.
@@ -11688,18 +11678,6 @@ const rotationZ: typeof P5.rotationZ;
11688
11678
  */
11689
11679
  const pRotationX: typeof P5.pRotationX;
11690
11680
 
11691
- /**
11692
- * A `Number` system variable that tracks the mouse's vertical position.
11693
- *
11694
- * `mouseY` keeps track of the mouse's position relative to the
11695
- * top-left corner of the canvas. For example, if the mouse is 50 pixels from
11696
- * the top edge of the canvas, then `mouseY` will be 50.
11697
- *
11698
- * If touch is used instead of the mouse, then `mouseY` will hold the
11699
- * y-coordinate of the most recent touch point.
11700
- */
11701
- const mouseY: typeof P5.mouseY;
11702
-
11703
11681
  /**
11704
11682
  * The system variable pRotationY always contains the rotation of the
11705
11683
  * device along the y axis in the frame previous to the current frame.
@@ -11712,6 +11690,18 @@ const mouseY: typeof P5.mouseY;
11712
11690
  */
11713
11691
  const pRotationY: typeof P5.pRotationY;
11714
11692
 
11693
+ /**
11694
+ * A `Number` system variable that tracks the mouse's vertical position.
11695
+ *
11696
+ * `mouseY` keeps track of the mouse's position relative to the
11697
+ * top-left corner of the canvas. For example, if the mouse is 50 pixels from
11698
+ * the top edge of the canvas, then `mouseY` will be 50.
11699
+ *
11700
+ * If touch is used instead of the mouse, then `mouseY` will hold the
11701
+ * y-coordinate of the most recent touch point.
11702
+ */
11703
+ const mouseY: typeof P5.mouseY;
11704
+
11715
11705
  /**
11716
11706
  * The system variable pRotationZ always contains the rotation of the
11717
11707
  * device along the z axis in the frame previous to the current frame.
@@ -12416,17 +12406,6 @@ const TWO_PI: typeof P5.TWO_PI;
12416
12406
 
12417
12407
  const DEG_TO_RAD: typeof P5.DEG_TO_RAD;
12418
12408
 
12419
- /**
12420
- * Turns off the parts of the Friendly Error System (FES) that impact performance.
12421
- *
12422
- * The <a href="https://github.com/processing/p5.js/blob/main/contributor_docs/friendly_error_system.md" target="_blank">FES</a>
12423
- * can cause sketches to draw slowly because it does extra work behind the
12424
- * scenes. For example, the FES checks the arguments passed to functions,
12425
- * which takes time to process. Disabling the FES can significantly improve
12426
- * performance by turning off these checks.
12427
- */
12428
- const disableFriendlyErrors: typeof P5.disableFriendlyErrors;
12429
-
12430
12409
  const RAD_TO_DEG: typeof P5.RAD_TO_DEG;
12431
12410
 
12432
12411
  const CORNER: typeof P5.CORNER;
@@ -12469,6 +12448,17 @@ const LINE_LOOP: typeof P5.LINE_LOOP;
12469
12448
 
12470
12449
  const TRIANGLES: typeof P5.TRIANGLES;
12471
12450
 
12451
+ /**
12452
+ * Turns off the parts of the Friendly Error System (FES) that impact performance.
12453
+ *
12454
+ * The <a href="https://github.com/processing/p5.js/blob/main/contributor_docs/friendly_error_system.md" target="_blank">FES</a>
12455
+ * can cause sketches to draw slowly because it does extra work behind the
12456
+ * scenes. For example, the FES checks the arguments passed to functions,
12457
+ * which takes time to process. Disabling the FES can significantly improve
12458
+ * performance by turning off these checks.
12459
+ */
12460
+ const disableFriendlyErrors: typeof P5.disableFriendlyErrors;
12461
+
12472
12462
  const TRIANGLE_FAN: typeof P5.TRIANGLE_FAN;
12473
12463
 
12474
12464
  const TRIANGLE_STRIP: typeof P5.TRIANGLE_STRIP;
@@ -13354,6 +13344,65 @@ function orbitControl(sensitivityX?: number, sensitivityY?: number, sensitivityZ
13354
13344
  */
13355
13345
  function beginClip(options?: { invert?: boolean }): void;
13356
13346
 
13347
+ /**
13348
+ * Creates a light that shines from all directions.
13349
+ *
13350
+ * Ambient light does not come from one direction. Instead, 3D shapes are
13351
+ * lit evenly from all sides. Ambient lights are almost always used in
13352
+ * combination with other types of lights.
13353
+ *
13354
+ * There are three ways to call `ambientLight()` with optional parameters to
13355
+ * set the light’s color.
13356
+ *
13357
+ * The first way to call `ambientLight()` has two parameters, `gray` and
13358
+ * `alpha`. `alpha` is optional. Grayscale and alpha values between 0 and 255
13359
+ * can be passed to set the ambient light’s color, as in `ambientLight(50)` or
13360
+ * `ambientLight(50, 30)`.
13361
+ *
13362
+ * The second way to call `ambientLight()` has one parameter, color. A
13363
+ * <a href="#/p5.Color">p5.Color</a> object, an array of color values, or a
13364
+ * CSS color string, as in `ambientLight('magenta')`, can be passed to set the
13365
+ * ambient light’s color.
13366
+ *
13367
+ * The third way to call `ambientLight()` has four parameters, `v1`, `v2`,
13368
+ * `v3`, and `alpha`. `alpha` is optional. RGBA, HSBA, or HSLA values can be
13369
+ * passed to set the ambient light’s colors, as in `ambientLight(255, 0, 0)`
13370
+ * or `ambientLight(255, 0, 0, 30)`. Color values will be interpreted using
13371
+ * the current <a href="#/p5/colorMode">colorMode()</a>.
13372
+ * @param v1 red or hue value in the current
13373
+ * <a href="#/p5/colorMode">colorMode()</a>.
13374
+ * @param v2 green or saturation value in the current
13375
+ * <a href="#/p5/colorMode">colorMode()</a>.
13376
+ * @param v3 blue, brightness, or lightness value in the current
13377
+ * <a href="#/p5/colorMode">colorMode()</a>.
13378
+ * @param alpha alpha (transparency) value in the current
13379
+ * <a href="#/p5/colorMode">colorMode()</a>.
13380
+ */
13381
+ function ambientLight(v1: number, v2: number, v3: number, alpha?: number): void;
13382
+ function ambientLight(gray: number, alpha?: number): void;
13383
+ function ambientLight(value: string): void;
13384
+ function ambientLight(values: number[]): void;
13385
+ function ambientLight(color: P5.Color): void;
13386
+
13387
+ /**
13388
+ * Searches the page for all elements that matches the given
13389
+ * <a href="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/CSS_basics#different_types_of_selectors" target="_blank">CSS selector string</a>.
13390
+ *
13391
+ * The selector string can be an ID, class, tag name, or a combination.
13392
+ * `selectAll()` returns an array of <a href="#/p5.Element">p5.Element</a>
13393
+ * objects if it finds any matches and an empty array if none are found.
13394
+ *
13395
+ * The second parameter, `container`, is optional. It specifies a container to
13396
+ * search within. `container` can be CSS selector string, a
13397
+ * <a href="#/p5.Element">p5.Element</a> object, or an
13398
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement" target="_blank">HTMLElement</a> object.
13399
+ * @param selectors CSS selector string of element to search for.
13400
+ * @param container CSS selector string, <a href="#/p5.Element">p5.Element</a>, or
13401
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement" target="_blank">HTMLElement</a> to search within.
13402
+ * @returns array of <a href="#/p5.Element">p5.Element</a>s containing any elements found.
13403
+ */
13404
+ function selectAll(selectors: string, container?: string | P5.Element | HTMLElement): P5.Element[];
13405
+
13357
13406
  /**
13358
13407
  * A shader function that performs smooth Hermite interpolation between `0.0`
13359
13408
  * and `1.0`.
@@ -13414,76 +13463,17 @@ function smoothstep(edge0: number, edge1: number, x: number): number;
13414
13463
  */
13415
13464
  function getTexture(texture: any, coords: any): any;
13416
13465
 
13417
- function getWorldInputs(callback: Function): void;
13418
-
13419
- function getPixelInputs(callback: Function): void;
13420
-
13421
- function getFinalColor(callback: Function): void;
13422
-
13423
- function getColor(callback: Function): void;
13424
-
13425
- function getObjectInputs(callback: Function): void;
13426
-
13427
- function getCameraInputs(callback: Function): void;
13428
-
13429
- /**
13430
- * Creates a light that shines from all directions.
13431
- *
13432
- * Ambient light does not come from one direction. Instead, 3D shapes are
13433
- * lit evenly from all sides. Ambient lights are almost always used in
13434
- * combination with other types of lights.
13435
- *
13436
- * There are three ways to call `ambientLight()` with optional parameters to
13437
- * set the light’s color.
13438
- *
13439
- * The first way to call `ambientLight()` has two parameters, `gray` and
13440
- * `alpha`. `alpha` is optional. Grayscale and alpha values between 0 and 255
13441
- * can be passed to set the ambient light’s color, as in `ambientLight(50)` or
13442
- * `ambientLight(50, 30)`.
13443
- *
13444
- * The second way to call `ambientLight()` has one parameter, color. A
13445
- * <a href="#/p5.Color">p5.Color</a> object, an array of color values, or a
13446
- * CSS color string, as in `ambientLight('magenta')`, can be passed to set the
13447
- * ambient light’s color.
13448
- *
13449
- * The third way to call `ambientLight()` has four parameters, `v1`, `v2`,
13450
- * `v3`, and `alpha`. `alpha` is optional. RGBA, HSBA, or HSLA values can be
13451
- * passed to set the ambient light’s colors, as in `ambientLight(255, 0, 0)`
13452
- * or `ambientLight(255, 0, 0, 30)`. Color values will be interpreted using
13453
- * the current <a href="#/p5/colorMode">colorMode()</a>.
13454
- * @param v1 red or hue value in the current
13455
- * <a href="#/p5/colorMode">colorMode()</a>.
13456
- * @param v2 green or saturation value in the current
13457
- * <a href="#/p5/colorMode">colorMode()</a>.
13458
- * @param v3 blue, brightness, or lightness value in the current
13459
- * <a href="#/p5/colorMode">colorMode()</a>.
13460
- * @param alpha alpha (transparency) value in the current
13461
- * <a href="#/p5/colorMode">colorMode()</a>.
13462
- */
13463
- function ambientLight(v1: number, v2: number, v3: number, alpha?: number): void;
13464
- function ambientLight(gray: number, alpha?: number): void;
13465
- function ambientLight(value: string): void;
13466
- function ambientLight(values: number[]): void;
13467
- function ambientLight(color: P5.Color): void;
13468
-
13469
- /**
13470
- * Searches the page for all elements that matches the given
13471
- * <a href="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/CSS_basics#different_types_of_selectors" target="_blank">CSS selector string</a>.
13472
- *
13473
- * The selector string can be an ID, class, tag name, or a combination.
13474
- * `selectAll()` returns an array of <a href="#/p5.Element">p5.Element</a>
13475
- * objects if it finds any matches and an empty array if none are found.
13476
- *
13477
- * The second parameter, `container`, is optional. It specifies a container to
13478
- * search within. `container` can be CSS selector string, a
13479
- * <a href="#/p5.Element">p5.Element</a> object, or an
13480
- * <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement" target="_blank">HTMLElement</a> object.
13481
- * @param selectors CSS selector string of element to search for.
13482
- * @param container CSS selector string, <a href="#/p5.Element">p5.Element</a>, or
13483
- * <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement" target="_blank">HTMLElement</a> to search within.
13484
- * @returns array of <a href="#/p5.Element">p5.Element</a>s containing any elements found.
13485
- */
13486
- function selectAll(selectors: string, container?: string | P5.Element | HTMLElement): P5.Element[];
13466
+ function getWorldInputs(callback: Function): void;
13467
+
13468
+ function getPixelInputs(callback: Function): void;
13469
+
13470
+ function getFinalColor(callback: Function): void;
13471
+
13472
+ function getColor(callback: Function): void;
13473
+
13474
+ function getObjectInputs(callback: Function): void;
13475
+
13476
+ function getCameraInputs(callback: Function): void;
13487
13477
 
13488
13478
  /**
13489
13479
  * Draws a Bézier curve.
@@ -15418,7 +15408,7 @@ function createP(html?: string): P5.Element;
15418
15408
  * // Make a version of the shader with a hook overridden
15419
15409
  * modifiedShader = myShader.modify(() => {
15420
15410
  * // Create new uniforms and override the getColor hook
15421
- * let t = uniformFloat(() => millis() / 1000);
15411
+ * let t = millis() / 1000;
15422
15412
  * getColor(() => {
15423
15413
  * return [0, 0.5 + 0.5 * sin(t), 1, 1];
15424
15414
  * });
@@ -15871,55 +15861,6 @@ function degrees(radians: number): number;
15871
15861
  */
15872
15862
  function rotateX(angle: number): void;
15873
15863
 
15874
- /**
15875
- * A function that's called once when the sketch begins running.
15876
- *
15877
- * Declaring the function `setup()` sets a code block to run once
15878
- * automatically when the sketch starts running. It's used to perform
15879
- * setup tasks such as creating the canvas and initializing variables:
15880
- *
15881
- * `function setup() {
15882
- * // Code to run once at the start of the sketch.
15883
- * }`Code placed in `setup()` will run once before code placed in
15884
- * <a href="#/p5/draw">draw()</a> begins looping.
15885
- * If `setup()` is declared `async` (e.g. `async function setup()`),
15886
- * execution pauses at each `await` until its promise resolves.
15887
- * For example, `font = await loadFont(...)` waits for the font asset
15888
- * to load because `loadFont()` function returns a promise, and the await
15889
- * keyword means the program will wait for the promise to resolve.
15890
- * This ensures that all assets are fully loaded before the sketch continues.
15891
- *
15892
- * loading assets.
15893
- *
15894
- * Note: `setup()` doesn’t have to be declared, but it’s common practice to do so.
15895
- */
15896
- function setup(): void;
15897
-
15898
- /**
15899
- * A function that's called repeatedly while the sketch runs.
15900
- *
15901
- * Declaring the function `draw()` sets a code block to run repeatedly
15902
- * once the sketch starts. It’s used to create animations and respond to
15903
- * user inputs:
15904
- *
15905
- * `function draw() {
15906
- * // Code to run repeatedly.
15907
- * }`This is often called the "draw loop" because p5.js calls the code in
15908
- * `draw()` in a loop behind the scenes. By default, `draw()` tries to run
15909
- * 60 times per second. The actual rate depends on many factors. The
15910
- * drawing rate, called the "frame rate", can be controlled by calling
15911
- * <a href="#/p5/frameRate">frameRate()</a>. The number of times `draw()`
15912
- * has run is stored in the system variable
15913
- * <a href="#/p5/frameCount">frameCount()</a>.
15914
- *
15915
- * Code placed within `draw()` begins looping after
15916
- * <a href="#/p5/setup">setup()</a> runs. `draw()` will run until the user
15917
- * closes the sketch. `draw()` can be stopped by calling the
15918
- * <a href="#/p5/noLoop">noLoop()</a> function. `draw()` can be resumed by
15919
- * calling the <a href="#/p5/loop">loop()</a> function.
15920
- */
15921
- function draw(): void;
15922
-
15923
15864
  /**
15924
15865
  * Re-maps a number from one range to another.
15925
15866
  *
@@ -16339,6 +16280,55 @@ function saveFrames(filename: string, extension: string, duration: number, frame
16339
16280
  function line(x1: number, y1: number, x2: number, y2: number): void;
16340
16281
  function line(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number): void;
16341
16282
 
16283
+ /**
16284
+ * A function that's called once when the sketch begins running.
16285
+ *
16286
+ * Declaring the function `setup()` sets a code block to run once
16287
+ * automatically when the sketch starts running. It's used to perform
16288
+ * setup tasks such as creating the canvas and initializing variables:
16289
+ *
16290
+ * `function setup() {
16291
+ * // Code to run once at the start of the sketch.
16292
+ * }`Code placed in `setup()` will run once before code placed in
16293
+ * <a href="#/p5/draw">draw()</a> begins looping.
16294
+ * If `setup()` is declared `async` (e.g. `async function setup()`),
16295
+ * execution pauses at each `await` until its promise resolves.
16296
+ * For example, `font = await loadFont(...)` waits for the font asset
16297
+ * to load because `loadFont()` function returns a promise, and the await
16298
+ * keyword means the program will wait for the promise to resolve.
16299
+ * This ensures that all assets are fully loaded before the sketch continues.
16300
+ *
16301
+ * loading assets.
16302
+ *
16303
+ * Note: `setup()` doesn’t have to be declared, but it’s common practice to do so.
16304
+ */
16305
+ function setup(): void;
16306
+
16307
+ /**
16308
+ * A function that's called repeatedly while the sketch runs.
16309
+ *
16310
+ * Declaring the function `draw()` sets a code block to run repeatedly
16311
+ * once the sketch starts. It’s used to create animations and respond to
16312
+ * user inputs:
16313
+ *
16314
+ * `function draw() {
16315
+ * // Code to run repeatedly.
16316
+ * }`This is often called the "draw loop" because p5.js calls the code in
16317
+ * `draw()` in a loop behind the scenes. By default, `draw()` tries to run
16318
+ * 60 times per second. The actual rate depends on many factors. The
16319
+ * drawing rate, called the "frame rate", can be controlled by calling
16320
+ * <a href="#/p5/frameRate">frameRate()</a>. The number of times `draw()`
16321
+ * has run is stored in the system variable
16322
+ * <a href="#/p5/frameCount">frameCount()</a>.
16323
+ *
16324
+ * Code placed within `draw()` begins looping after
16325
+ * <a href="#/p5/setup">setup()</a> runs. `draw()` will run until the user
16326
+ * closes the sketch. `draw()` can be stopped by calling the
16327
+ * <a href="#/p5/noLoop">noLoop()</a> function. `draw()` can be resumed by
16328
+ * calling the <a href="#/p5/loop">loop()</a> function.
16329
+ */
16330
+ function draw(): void;
16331
+
16342
16332
  /**
16343
16333
  * Clears the pixels on the canvas.
16344
16334
  *
@@ -16655,17 +16645,6 @@ function windowResized(event?: Event): void;
16655
16645
  */
16656
16646
  function shuffle<T>(array: T[], modify?: boolean): T[];
16657
16647
 
16658
- /**
16659
- * This method is suitable for fetching files up to size of 64MB.
16660
- * @param file name of the file or URL to load
16661
- * @param callback function to be executed after <a href="#/p5/loadBytes">loadBytes()</a>
16662
- * completes
16663
- * @param errorCallback function to be executed if there
16664
- * is an error
16665
- * @returns a Uint8Array containing the loaded buffer
16666
- */
16667
- function loadBytes(file: string | Request, callback?: Function, errorCallback?: Function): Promise<Uint8Array>;
16668
-
16669
16648
  /**
16670
16649
  * Turns off <a href="#/p5/debugMode">debugMode()</a> in a 3D sketch.
16671
16650
  */
@@ -16826,7 +16805,7 @@ function loadPixels(): void;
16826
16805
  * filterColor.texCoord.x // x coordinate, from 0 to 1
16827
16806
  * ));
16828
16807
  * filterColor.end();
16829
- * }`You can also animate your filters over time by passing the time into the shader with `uniformFloat`.
16808
+ * }`You can also animate your filters over time using the `millis()` function.
16830
16809
  *
16831
16810
  * `let myFilter;
16832
16811
  * function setup() {
@@ -16836,7 +16815,7 @@ function loadPixels(): void;
16836
16815
  * }
16837
16816
  *
16838
16817
  * function gradient() {
16839
- * let time = uniformFloat();
16818
+ * let time = millis();
16840
16819
  * filterColor.begin();
16841
16820
  * filterColor.set(mix(
16842
16821
  * [1, 0, 0, 1], // Red
@@ -16847,9 +16826,8 @@ function loadPixels(): void;
16847
16826
  * }
16848
16827
  *
16849
16828
  * function draw() {
16850
- * myFilter.setUniform('time', millis());
16851
16829
  * filter(myFilter);
16852
- * }`We can use the `noise()` function built into strands to generate a color for each pixel. (Again no need here for underlying content for the filter to operate on.) Again we'll animate by passing in an announced uniform variable `time` with `setUniform()`, each frame.
16830
+ * }`We can use the `noise()` function built into strands to generate a color for each pixel. (Again no need here for underlying content for the filter to operate on.) Again we'll animate by using the millis() function to get an up-to-date time value.
16853
16831
  *
16854
16832
  * `let myFilter;
16855
16833
  *
@@ -16860,7 +16838,7 @@ function loadPixels(): void;
16860
16838
  * }
16861
16839
  *
16862
16840
  * function noiseShaderCallback() {
16863
- * let time = uniformFloat();
16841
+ * let time = millis();
16864
16842
  * filterColor.begin();
16865
16843
  * let coord = filterColor.texCoord;
16866
16844
  *
@@ -16877,7 +16855,6 @@ function loadPixels(): void;
16877
16855
  * }
16878
16856
  *
16879
16857
  * function draw() {
16880
- * myFilter.setUniform("time", millis());
16881
16858
  * filter(myFilter);
16882
16859
  * }`Like the `modify()` method on shaders,
16883
16860
  * advanced users can also fill in `filterColor` using <a href="https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_on_the_web/GLSL_Shaders" target="_blank">GLSL</a>
@@ -16895,6 +16872,17 @@ function loadPixels(): void;
16895
16872
  function buildFilterShader(callback: Function, scope?: object): P5.Shader;
16896
16873
  function buildFilterShader(hooks: object, scope?: object): P5.Shader;
16897
16874
 
16875
+ /**
16876
+ * This method is suitable for fetching files up to size of 64MB.
16877
+ * @param file name of the file or URL to load
16878
+ * @param callback function to be executed after <a href="#/p5/loadBytes">loadBytes()</a>
16879
+ * completes
16880
+ * @param errorCallback function to be executed if there
16881
+ * is an error
16882
+ * @returns a Uint8Array containing the loaded buffer
16883
+ */
16884
+ function loadBytes(file: string | Request, callback?: Function, errorCallback?: Function): Promise<Uint8Array>;
16885
+
16898
16886
  /**
16899
16887
  * Creates a slider `&lt;input&gt;&lt;/input&gt;` element.
16900
16888
  *
@@ -17014,22 +17002,6 @@ function keyReleased(event?: KeyboardEvent): void;
17014
17002
  */
17015
17003
  function rotateZ(angle: number): void;
17016
17004
 
17017
- /**
17018
- * Loads a file at the given path as a Blob, then returns the resulting data or
17019
- * passes it to a success callback function, if provided. On load, this function
17020
- * returns a `Promise` that resolves to a Blob containing the file data.
17021
- * @param path The path or Request object pointing to the file
17022
- * you want to load.
17023
- * @param successCallback Optional. A function to be called if the
17024
- * file successfully loads, receiving the
17025
- * resulting Blob as its only argument.
17026
- * @param errorCallback Optional. A function to be called if an
17027
- * error occurs during loading; receives the
17028
- * error object as its only argument.
17029
- * @returns A promise that resolves with the loaded Blob.
17030
- */
17031
- function loadBlob(path: string | Request, successCallback?: Function, errorCallback?: Function): Promise<Blob>;
17032
-
17033
17005
  /**
17034
17006
  * Calculates exponential expressions such as <var>2<sup>3</sup></var>.
17035
17007
  *
@@ -17058,6 +17030,22 @@ function pow(n: number, e: number): number;
17058
17030
  */
17059
17031
  function fullscreen(val?: boolean): boolean;
17060
17032
 
17033
+ /**
17034
+ * Loads a file at the given path as a Blob, then returns the resulting data or
17035
+ * passes it to a success callback function, if provided. On load, this function
17036
+ * returns a `Promise` that resolves to a Blob containing the file data.
17037
+ * @param path The path or Request object pointing to the file
17038
+ * you want to load.
17039
+ * @param successCallback Optional. A function to be called if the
17040
+ * file successfully loads, receiving the
17041
+ * resulting Blob as its only argument.
17042
+ * @param errorCallback Optional. A function to be called if an
17043
+ * error occurs during loading; receives the
17044
+ * error object as its only argument.
17045
+ * @returns A promise that resolves with the loaded Blob.
17046
+ */
17047
+ function loadBlob(path: string | Request, successCallback?: Function, errorCallback?: Function): Promise<Blob>;
17048
+
17061
17049
  /**
17062
17050
  * Creates a light that shines from a point in all directions.
17063
17051
  *
@@ -17335,26 +17323,20 @@ function hex(ns: number[], digits?: number): string[];
17335
17323
  function splinePoint(a: number, b: number, c: number, d: number, t: number): number;
17336
17324
 
17337
17325
  /**
17338
- * Method for executing an HTTP GET request. If data type is not specified,
17339
- * it will default to `'text'`. This is equivalent to
17340
- * calling <code>httpDo(path, 'GET')</code>. The 'binary' datatype will return
17341
- * a Blob object, and the 'arrayBuffer' datatype will return an ArrayBuffer
17342
- * which can be used to initialize typed arrays (such as Uint8Array).
17343
- * @param path name of the file or url to load
17344
- * @param datatype "json", "jsonp", "binary", "arrayBuffer",
17345
- * "xml", or "text"
17346
- * @param callback function to be executed after
17347
- * <a href="#/p5/httpGet">httpGet()</a> completes, data is passed in
17348
- * as first argument
17349
- * @param errorCallback function to be executed if
17350
- * there is an error, response is passed
17351
- * in as first argument
17352
- * @returns A promise that resolves with the data when the operation
17353
- * completes successfully or rejects with the error after
17354
- * one occurs.
17326
+ * Creates an ambient light from an image.
17327
+ *
17328
+ * `imageLight()` simulates a light shining from all directions. The effect is
17329
+ * like placing the sketch at the center of a giant sphere that uses the image
17330
+ * as its texture. The image's diffuse light will be affected by
17331
+ * <a href="#/p5/fill">fill()</a> and the specular reflections will be
17332
+ * affected by <a href="#/p5/specularMaterial">specularMaterial()</a> and
17333
+ * <a href="#/p5/shininess">shininess()</a>.
17334
+ *
17335
+ * The parameter, `img`, is the <a href="#/p5.Image">p5.Image</a> object to
17336
+ * use as the light source.
17337
+ * @param img image to use as the light source.
17355
17338
  */
17356
- function httpGet(path: string | Request, datatype?: string, callback?: Function, errorCallback?: Function): Promise<any>;
17357
- function httpGet(path: string | Request, callback: Function, errorCallback?: Function): Promise<any>;
17339
+ function imageLight(img: P5.Image): void;
17358
17340
 
17359
17341
  /**
17360
17342
  * Sets the pixel density or returns the current density.
@@ -17377,20 +17359,26 @@ function pixelDensity(val?: number): number;
17377
17359
  function pixelDensity(): number;
17378
17360
 
17379
17361
  /**
17380
- * Creates an ambient light from an image.
17381
- *
17382
- * `imageLight()` simulates a light shining from all directions. The effect is
17383
- * like placing the sketch at the center of a giant sphere that uses the image
17384
- * as its texture. The image's diffuse light will be affected by
17385
- * <a href="#/p5/fill">fill()</a> and the specular reflections will be
17386
- * affected by <a href="#/p5/specularMaterial">specularMaterial()</a> and
17387
- * <a href="#/p5/shininess">shininess()</a>.
17388
- *
17389
- * The parameter, `img`, is the <a href="#/p5.Image">p5.Image</a> object to
17390
- * use as the light source.
17391
- * @param img image to use as the light source.
17362
+ * Method for executing an HTTP GET request. If data type is not specified,
17363
+ * it will default to `'text'`. This is equivalent to
17364
+ * calling <code>httpDo(path, 'GET')</code>. The 'binary' datatype will return
17365
+ * a Blob object, and the 'arrayBuffer' datatype will return an ArrayBuffer
17366
+ * which can be used to initialize typed arrays (such as Uint8Array).
17367
+ * @param path name of the file or url to load
17368
+ * @param datatype "json", "jsonp", "binary", "arrayBuffer",
17369
+ * "xml", or "text"
17370
+ * @param callback function to be executed after
17371
+ * <a href="#/p5/httpGet">httpGet()</a> completes, data is passed in
17372
+ * as first argument
17373
+ * @param errorCallback function to be executed if
17374
+ * there is an error, response is passed
17375
+ * in as first argument
17376
+ * @returns A promise that resolves with the data when the operation
17377
+ * completes successfully or rejects with the error after
17378
+ * one occurs.
17392
17379
  */
17393
- function imageLight(img: P5.Image): void;
17380
+ function httpGet(path: string | Request, datatype?: string, callback?: Function, errorCallback?: Function): Promise<any>;
17381
+ function httpGet(path: string | Request, callback: Function, errorCallback?: Function): Promise<any>;
17394
17382
 
17395
17383
  /**
17396
17384
  * Updates the canvas with the RGBA values in the
@@ -17555,28 +17543,6 @@ function hue(color: P5.Color | number[] | string): number;
17555
17543
  function scale(s: number | P5.Vector | number[], y?: number, z?: number): void;
17556
17544
  function scale(scales: P5.Vector | number[]): void;
17557
17545
 
17558
- /**
17559
- * Method for executing an HTTP POST request. If data type is not specified,
17560
- * it will default to `'text'`. This is equivalent to
17561
- * calling <code>httpDo(path, 'POST')</code>.
17562
- * @param path name of the file or url to load
17563
- * @param data param data passed sent with request
17564
- * @param datatype "json", "jsonp", "xml", or "text".
17565
- * If omitted, <a href="#/p5/httpPost">httpPost()</a> will guess.
17566
- * @param callback function to be executed after
17567
- * <a href="#/p5/httpPost">httpPost()</a> completes, data is passed in
17568
- * as first argument
17569
- * @param errorCallback function to be executed if
17570
- * there is an error, response is passed
17571
- * in as first argument
17572
- * @returns A promise that resolves with the data when the operation
17573
- * completes successfully or rejects with the error after
17574
- * one occurs.
17575
- */
17576
- function httpPost(path: string | Request, data?: object | boolean, datatype?: string, callback?: Function, errorCallback?: Function): Promise<any>;
17577
- function httpPost(path: string | Request, data: object | boolean, callback?: Function, errorCallback?: Function): Promise<any>;
17578
- function httpPost(path: string | Request, callback?: Function, errorCallback?: Function): Promise<any>;
17579
-
17580
17546
  /**
17581
17547
  * Converts a `String` with a hexadecimal value to a `Number`.
17582
17548
  *
@@ -17634,7 +17600,29 @@ function quad(x1: number, y1: number, z1: number, x2: number, y2: number, z2: nu
17634
17600
  * @param n non-negative number to square root.
17635
17601
  * @returns square root of number.
17636
17602
  */
17637
- function sqrt(n: number): number;
17603
+ function sqrt(n: number): number;
17604
+
17605
+ /**
17606
+ * Method for executing an HTTP POST request. If data type is not specified,
17607
+ * it will default to `'text'`. This is equivalent to
17608
+ * calling <code>httpDo(path, 'POST')</code>.
17609
+ * @param path name of the file or url to load
17610
+ * @param data param data passed sent with request
17611
+ * @param datatype "json", "jsonp", "xml", or "text".
17612
+ * If omitted, <a href="#/p5/httpPost">httpPost()</a> will guess.
17613
+ * @param callback function to be executed after
17614
+ * <a href="#/p5/httpPost">httpPost()</a> completes, data is passed in
17615
+ * as first argument
17616
+ * @param errorCallback function to be executed if
17617
+ * there is an error, response is passed
17618
+ * in as first argument
17619
+ * @returns A promise that resolves with the data when the operation
17620
+ * completes successfully or rejects with the error after
17621
+ * one occurs.
17622
+ */
17623
+ function httpPost(path: string | Request, data?: object | boolean, datatype?: string, callback?: Function, errorCallback?: Function): Promise<any>;
17624
+ function httpPost(path: string | Request, data: object | boolean, callback?: Function, errorCallback?: Function): Promise<any>;
17625
+ function httpPost(path: string | Request, callback?: Function, errorCallback?: Function): Promise<any>;
17638
17626
 
17639
17627
  /**
17640
17628
  * Draws a cylinder.
@@ -17881,18 +17869,6 @@ function normal(x: number, y: number, z: number): void;
17881
17869
  function image(img: P5.Image | P5.Element | P5.Texture | P5.Framebuffer | P5.FramebufferTexture | P5.Renderer | P5.Graphics, x: number, y: number, width?: number, height?: number): void;
17882
17870
  function image(img: P5.Image | P5.Element | P5.Texture | P5.Framebuffer | P5.FramebufferTexture, dx: number, dy: number, dWidth: number, dHeight: number, sx: number, sy: number, sWidth?: number, sHeight?: number, fit?: typeof P5.CONTAIN | typeof P5.COVER, xAlign?: typeof P5.LEFT | typeof P5.RIGHT | typeof P5.CENTER, yAlign?: typeof P5.TOP | typeof P5.BOTTOM | typeof P5.CENTER): void;
17883
17871
 
17884
- /**
17885
- * Returns the current
17886
- * <a href="https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Web_mechanics/What_is_a_URL#parameters" target="_blank">URL parameters</a>
17887
- * in an `Object`.
17888
- *
17889
- * For example, calling `getURLParams()` in a sketch hosted at the URL
17890
- * `https://p5js.org?year=2014&month=May&day=15` returns
17891
- * `{ year: 2014, month: 'May', day: 15 }`.
17892
- * @returns URL params
17893
- */
17894
- function getURLParams(): object;
17895
-
17896
17872
  /**
17897
17873
  * Changes the way color values are interpreted.
17898
17874
  *
@@ -17966,6 +17942,18 @@ function colorMode(mode: typeof P5.RGB | typeof P5.HSB | typeof P5.HSL | typeof
17966
17942
  function colorMode(mode: typeof P5.RGB | typeof P5.HSB | typeof P5.HSL | typeof P5.RGBHDR | typeof P5.HWB | typeof P5.LAB | typeof P5.LCH | typeof P5.OKLAB | typeof P5.OKLCH, max1: number, max2: number, max3: number, maxA?: number): typeof P5.RGB | typeof P5.HSB | typeof P5.HSL | typeof P5.RGBHDR | typeof P5.HWB | typeof P5.LAB | typeof P5.LCH | typeof P5.OKLAB | typeof P5.OKLCH;
17967
17943
  function colorMode(): typeof P5.RGB | typeof P5.HSB | typeof P5.HSL | typeof P5.RGBHDR | typeof P5.HWB | typeof P5.LAB | typeof P5.LCH | typeof P5.OKLAB | typeof P5.OKLCH;
17968
17944
 
17945
+ /**
17946
+ * Returns the current
17947
+ * <a href="https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Web_mechanics/What_is_a_URL#parameters" target="_blank">URL parameters</a>
17948
+ * in an `Object`.
17949
+ *
17950
+ * For example, calling `getURLParams()` in a sketch hosted at the URL
17951
+ * `https://p5js.org?year=2014&month=May&day=15` returns
17952
+ * `{ year: 2014, month: 'May', day: 15 }`.
17953
+ * @returns URL params
17954
+ */
17955
+ function getURLParams(): object;
17956
+
17969
17957
  /**
17970
17958
  * Shears the x-axis so that shapes appear skewed.
17971
17959
  *
@@ -18013,104 +18001,6 @@ function shearX(angle: number): void;
18013
18001
  */
18014
18002
  function lightFalloff(constant: number, linear: number, quadratic: number): void;
18015
18003
 
18016
- /**
18017
- * A function that's called when the mouse moves.
18018
- *
18019
- * Declaring the function `mouseMoved()` sets a code block to run
18020
- * automatically when the user moves the mouse without clicking any mouse
18021
- * buttons:
18022
- *
18023
- * `function mouseMoved() {
18024
- * // Code to run.
18025
- * }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
18026
- * <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
18027
- * value when `mouseMoved()` is called by p5.js:
18028
- *
18029
- * `function mouseMoved() {
18030
- * if (mouseX < 50) {
18031
- * // Code to run if the mouse is on the left.
18032
- * }
18033
- *
18034
- * if (mouseY > 50) {
18035
- * // Code to run if the mouse is near the bottom.
18036
- * }
18037
- * }`The parameter, `event`, is optional. `mouseMoved()` is always passed a
18038
- * <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
18039
- * object with properties that describe the mouse move event:
18040
- *
18041
- * `function mouseMoved(event) {
18042
- * // Code to run that uses the event.
18043
- * console.log(event);
18044
- * }`Browsers may have default behaviors attached to various mouse events. For
18045
- * example, some browsers highlight text when the user moves the mouse while
18046
- * pressing a mouse button. To prevent any default behavior for this event,
18047
- * add `return false;` to the end of the function.
18048
- * @param event optional `MouseEvent` argument.
18049
- */
18050
- function mouseMoved(event?: MouseEvent): void;
18051
-
18052
- /**
18053
- * A function that's called when the mouse moves while a button is pressed.
18054
- *
18055
- * Declaring the function `mouseDragged()` sets a code block to run
18056
- * automatically when the user clicks and drags the mouse:
18057
- *
18058
- * `function mouseDragged() {
18059
- * // Code to run.
18060
- * }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
18061
- * <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
18062
- * value when `mouseDragged()` is called by p5.js:
18063
- *
18064
- * `function mouseDragged() {
18065
- * if (mouseX < 50) {
18066
- * // Code to run if the mouse is on the left.
18067
- * }
18068
- *
18069
- * if (mouseY > 50) {
18070
- * // Code to run if the mouse is near the bottom.
18071
- * }
18072
- * }`The parameter, `event`, is optional. `mouseDragged()` is always passed a
18073
- * <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
18074
- * object with properties that describe the mouse drag event:
18075
- *
18076
- * `function mouseDragged(event) {
18077
- * // Code to run that uses the event.
18078
- * console.log(event);
18079
- * }`On touchscreen devices, `mouseDragged()` will run when a user moves a touch
18080
- * point.
18081
- *
18082
- * Browsers may have default behaviors attached to various mouse events. For
18083
- * example, some browsers highlight text when the user moves the mouse while
18084
- * pressing a mouse button. To prevent any default behavior for this event,
18085
- * add `return false;` to the end of the function.
18086
- * @param event optional `MouseEvent` argument.
18087
- */
18088
- function mouseDragged(event?: MouseEvent): void;
18089
-
18090
- /**
18091
- * Returns `true` if the key it’s checking is pressed and `false` if not.
18092
- *
18093
- * `keyIsDown()` is helpful when checking for multiple different key presses.
18094
- * For example, `keyIsDown()` can be used to check if both `LEFT_ARROW` and
18095
- * `UP_ARROW` are pressed:
18096
- *
18097
- * `if (keyIsDown(LEFT_ARROW) && keyIsDown(UP_ARROW)) {
18098
- * // Move diagonally.
18099
- * }``keyIsDown()` can check for key presses using strings based on
18100
- * <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key" target="_blank">KeyboardEvent.key</a>
18101
- * or <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code" target="_blank">KeyboardEvent.code</a> values,
18102
- * such as `keyIsDown('x')` or `keyIsDown('ArrowLeft')`.
18103
- *
18104
- * Note: In p5.js 2.0 and newer, numeric keycodes (such as 88 for 'X') are no longer supported.
18105
- * This is a breaking change from previous versions.
18106
- *
18107
- * You can still use the p5 constants like `LEFT_ARROW` which now map to string values
18108
- * internally rather than numeric codes.
18109
- * @param code key to check.
18110
- * @returns whether the key is down or not.
18111
- */
18112
- function keyIsDown(code: number | string): boolean;
18113
-
18114
18004
  /**
18115
18005
  * Sets the <a href="#/p5.Shader">p5.Shader</a> object to apply while drawing.
18116
18006
  *
@@ -18150,7 +18040,7 @@ function keyIsDown(code: number | string): boolean;
18150
18040
  * }
18151
18041
  *
18152
18042
  * function material() {
18153
- * let time = uniformFloat();
18043
+ * let time = millis() / 1000;
18154
18044
  * finalColor.begin();
18155
18045
  * let r = 0.2 + 0.5 * abs(sin(time + 0));
18156
18046
  * let g = 0.2 + 0.5 * abs(sin(time + 1));
@@ -18161,7 +18051,6 @@ function keyIsDown(code: number | string): boolean;
18161
18051
  *
18162
18052
  * function draw() {
18163
18053
  * background(245, 245, 220);
18164
- * myShader.setUniform('time', millis() / 1000);
18165
18054
  * shader(myShader);
18166
18055
  *
18167
18056
  * rectMode(CENTER);
@@ -18275,21 +18164,102 @@ function keyIsDown(code: number | string): boolean;
18275
18164
  function shader(s: P5.Shader): void;
18276
18165
 
18277
18166
  /**
18278
- * Draws a <a href="#/p5.Geometry">p5.Geometry</a> object to the canvas.
18167
+ * A function that's called when the mouse moves.
18279
18168
  *
18280
- * The parameter, `model`, is the
18281
- * <a href="#/p5.Geometry">p5.Geometry</a> object to draw.
18282
- * <a href="#/p5.Geometry">p5.Geometry</a> objects can be built with
18283
- * <a href="#/p5/buildGeometry">buildGeometry()</a>, or
18284
- * <a href="#/p5/beginGeometry">beginGeometry()</a> and
18285
- * <a href="#/p5/endGeometry">endGeometry()</a>. They can also be loaded from
18286
- * a file with <a href="#/p5/loadGeometry">loadGeometry()</a>.
18169
+ * Declaring the function `mouseMoved()` sets a code block to run
18170
+ * automatically when the user moves the mouse without clicking any mouse
18171
+ * buttons:
18287
18172
  *
18288
- * Note: `model()` can only be used in WebGL mode.
18289
- * @param model 3D shape to be drawn.
18290
- * @param count number of instances to draw.
18173
+ * `function mouseMoved() {
18174
+ * // Code to run.
18175
+ * }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
18176
+ * <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
18177
+ * value when `mouseMoved()` is called by p5.js:
18178
+ *
18179
+ * `function mouseMoved() {
18180
+ * if (mouseX < 50) {
18181
+ * // Code to run if the mouse is on the left.
18182
+ * }
18183
+ *
18184
+ * if (mouseY > 50) {
18185
+ * // Code to run if the mouse is near the bottom.
18186
+ * }
18187
+ * }`The parameter, `event`, is optional. `mouseMoved()` is always passed a
18188
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
18189
+ * object with properties that describe the mouse move event:
18190
+ *
18191
+ * `function mouseMoved(event) {
18192
+ * // Code to run that uses the event.
18193
+ * console.log(event);
18194
+ * }`Browsers may have default behaviors attached to various mouse events. For
18195
+ * example, some browsers highlight text when the user moves the mouse while
18196
+ * pressing a mouse button. To prevent any default behavior for this event,
18197
+ * add `return false;` to the end of the function.
18198
+ * @param event optional `MouseEvent` argument.
18291
18199
  */
18292
- function model(model: P5.Geometry, count?: number): void;
18200
+ function mouseMoved(event?: MouseEvent): void;
18201
+
18202
+ /**
18203
+ * A function that's called when the mouse moves while a button is pressed.
18204
+ *
18205
+ * Declaring the function `mouseDragged()` sets a code block to run
18206
+ * automatically when the user clicks and drags the mouse:
18207
+ *
18208
+ * `function mouseDragged() {
18209
+ * // Code to run.
18210
+ * }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
18211
+ * <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
18212
+ * value when `mouseDragged()` is called by p5.js:
18213
+ *
18214
+ * `function mouseDragged() {
18215
+ * if (mouseX < 50) {
18216
+ * // Code to run if the mouse is on the left.
18217
+ * }
18218
+ *
18219
+ * if (mouseY > 50) {
18220
+ * // Code to run if the mouse is near the bottom.
18221
+ * }
18222
+ * }`The parameter, `event`, is optional. `mouseDragged()` is always passed a
18223
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
18224
+ * object with properties that describe the mouse drag event:
18225
+ *
18226
+ * `function mouseDragged(event) {
18227
+ * // Code to run that uses the event.
18228
+ * console.log(event);
18229
+ * }`On touchscreen devices, `mouseDragged()` will run when a user moves a touch
18230
+ * point.
18231
+ *
18232
+ * Browsers may have default behaviors attached to various mouse events. For
18233
+ * example, some browsers highlight text when the user moves the mouse while
18234
+ * pressing a mouse button. To prevent any default behavior for this event,
18235
+ * add `return false;` to the end of the function.
18236
+ * @param event optional `MouseEvent` argument.
18237
+ */
18238
+ function mouseDragged(event?: MouseEvent): void;
18239
+
18240
+ /**
18241
+ * Returns `true` if the key it’s checking is pressed and `false` if not.
18242
+ *
18243
+ * `keyIsDown()` is helpful when checking for multiple different key presses.
18244
+ * For example, `keyIsDown()` can be used to check if both `LEFT_ARROW` and
18245
+ * `UP_ARROW` are pressed:
18246
+ *
18247
+ * `if (keyIsDown(LEFT_ARROW) && keyIsDown(UP_ARROW)) {
18248
+ * // Move diagonally.
18249
+ * }``keyIsDown()` can check for key presses using strings based on
18250
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key" target="_blank">KeyboardEvent.key</a>
18251
+ * or <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code" target="_blank">KeyboardEvent.code</a> values,
18252
+ * such as `keyIsDown('x')` or `keyIsDown('ArrowLeft')`.
18253
+ *
18254
+ * Note: In p5.js 2.0 and newer, numeric keycodes (such as 88 for 'X') are no longer supported.
18255
+ * This is a breaking change from previous versions.
18256
+ *
18257
+ * You can still use the p5 constants like `LEFT_ARROW` which now map to string values
18258
+ * internally rather than numeric codes.
18259
+ * @param code key to check.
18260
+ * @returns whether the key is down or not.
18261
+ */
18262
+ function keyIsDown(code: number | string): boolean;
18293
18263
 
18294
18264
  /**
18295
18265
  * Sets the element's content.
@@ -18303,31 +18273,21 @@ function model(model: P5.Geometry, count?: number): void;
18303
18273
  function setContent(content: string): void;
18304
18274
 
18305
18275
  /**
18306
- * Method for executing an HTTP request. If data type is not specified,
18307
- * it will default to `'text'`.
18276
+ * Draws a <a href="#/p5.Geometry">p5.Geometry</a> object to the canvas.
18308
18277
  *
18309
- * This function is meant for more advanced usage of HTTP requests in p5.js. It is
18310
- * best used when a `Request`
18311
- * object is passed to the `path` parameter.
18278
+ * The parameter, `model`, is the
18279
+ * <a href="#/p5.Geometry">p5.Geometry</a> object to draw.
18280
+ * <a href="#/p5.Geometry">p5.Geometry</a> objects can be built with
18281
+ * <a href="#/p5/buildGeometry">buildGeometry()</a>, or
18282
+ * <a href="#/p5/beginGeometry">beginGeometry()</a> and
18283
+ * <a href="#/p5/endGeometry">endGeometry()</a>. They can also be loaded from
18284
+ * a file with <a href="#/p5/loadGeometry">loadGeometry()</a>.
18312
18285
  *
18313
- * This method is suitable for fetching files up to size of 64MB when "GET" is used.
18314
- * @param path name of the file or url to load
18315
- * @param method either "GET", "POST", "PUT", "DELETE",
18316
- * or other HTTP request methods
18317
- * @param datatype "json", "jsonp", "xml", or "text"
18318
- * @param data param data passed sent with request
18319
- * @param callback function to be executed after
18320
- * <a href="#/p5/httpGet">httpGet()</a> completes, data is passed in
18321
- * as first argument
18322
- * @param errorCallback function to be executed if
18323
- * there is an error, response is passed
18324
- * in as first argument
18325
- * @returns A promise that resolves with the data when the operation
18326
- * completes successfully or rejects with the error after
18327
- * one occurs.
18286
+ * Note: `model()` can only be used in WebGL mode.
18287
+ * @param model 3D shape to be drawn.
18288
+ * @param count number of instances to draw.
18328
18289
  */
18329
- function httpDo(path: string | Request, method?: string, datatype?: string, data?: object, callback?: Function, errorCallback?: Function): Promise<any>;
18330
- function httpDo(path: string | Request, callback?: Function, errorCallback?: Function): Promise<any>;
18290
+ function model(model: P5.Geometry, count?: number): void;
18331
18291
 
18332
18292
  /**
18333
18293
  * Draws a rectangle.
@@ -18358,6 +18318,33 @@ function httpDo(path: string | Request, callback?: Function, errorCallback?: Fun
18358
18318
  function rect(x: number, y: number, w: number, h?: number, tl?: number, tr?: number, br?: number, bl?: number): void;
18359
18319
  function rect(x: number, y: number, w: number, h: number, detailX?: number, detailY?: number): void;
18360
18320
 
18321
+ /**
18322
+ * Method for executing an HTTP request. If data type is not specified,
18323
+ * it will default to `'text'`.
18324
+ *
18325
+ * This function is meant for more advanced usage of HTTP requests in p5.js. It is
18326
+ * best used when a `Request`
18327
+ * object is passed to the `path` parameter.
18328
+ *
18329
+ * This method is suitable for fetching files up to size of 64MB when "GET" is used.
18330
+ * @param path name of the file or url to load
18331
+ * @param method either "GET", "POST", "PUT", "DELETE",
18332
+ * or other HTTP request methods
18333
+ * @param datatype "json", "jsonp", "xml", or "text"
18334
+ * @param data param data passed sent with request
18335
+ * @param callback function to be executed after
18336
+ * <a href="#/p5/httpGet">httpGet()</a> completes, data is passed in
18337
+ * as first argument
18338
+ * @param errorCallback function to be executed if
18339
+ * there is an error, response is passed
18340
+ * in as first argument
18341
+ * @returns A promise that resolves with the data when the operation
18342
+ * completes successfully or rejects with the error after
18343
+ * one occurs.
18344
+ */
18345
+ function httpDo(path: string | Request, method?: string, datatype?: string, data?: object, callback?: Function, errorCallback?: Function): Promise<any>;
18346
+ function httpDo(path: string | Request, callback?: Function, errorCallback?: Function): Promise<any>;
18347
+
18361
18348
  /**
18362
18349
  * Shears the y-axis so that shapes appear skewed.
18363
18350
  *
@@ -18662,6 +18649,22 @@ function mousePressed(event?: MouseEvent): void;
18662
18649
  */
18663
18650
  function strokeShader(s: P5.Shader): void;
18664
18651
 
18652
+ /**
18653
+ * Gets the brightness value of a color.
18654
+ *
18655
+ * `brightness()` extracts the HSB brightness value from a
18656
+ * <a href="/reference/p5/p5.Color/">p5.Color</a> object, an array of color components, or
18657
+ * a CSS color string.
18658
+ *
18659
+ * By default, `brightness()` returns a color's HSB brightness in the range 0
18660
+ * to 100. If the <a href="/reference/p5/colorMode/">colorMode()</a> is set to HSB, it
18661
+ * returns the brightness value in the given range.
18662
+ * @param color <a href="/reference/p5/p5.Color/">p5.Color</a> object, array of
18663
+ * color components, or CSS color string.
18664
+ * @returns the brightness value.
18665
+ */
18666
+ function brightness(color: P5.Color | number[] | string): number;
18667
+
18665
18668
  /**
18666
18669
  * Tints images using a color.
18667
18670
  *
@@ -18690,47 +18693,6 @@ function tint(gray: number, alpha?: number): void;
18690
18693
  function tint(values: number[]): void;
18691
18694
  function tint(color: P5.Color): void;
18692
18695
 
18693
- /**
18694
- * Gets the brightness value of a color.
18695
- *
18696
- * `brightness()` extracts the HSB brightness value from a
18697
- * <a href="/reference/p5/p5.Color/">p5.Color</a> object, an array of color components, or
18698
- * a CSS color string.
18699
- *
18700
- * By default, `brightness()` returns a color's HSB brightness in the range 0
18701
- * to 100. If the <a href="/reference/p5/colorMode/">colorMode()</a> is set to HSB, it
18702
- * returns the brightness value in the given range.
18703
- * @param color <a href="/reference/p5/p5.Color/">p5.Color</a> object, array of
18704
- * color components, or CSS color string.
18705
- * @returns the brightness value.
18706
- */
18707
- function brightness(color: P5.Color | number[] | string): number;
18708
-
18709
- /**
18710
- * Creates a new <a href="#/p5.PrintWriter">p5.PrintWriter</a> object.
18711
- *
18712
- * <a href="#/p5.PrintWriter">p5.PrintWriter</a> objects provide a way to
18713
- * save a sequence of text data, called the print stream, to the user's
18714
- * computer. They're low-level objects that enable precise control of text
18715
- * output. Functions such as
18716
- * <a href="#/p5/saveStrings">saveStrings()</a> and
18717
- * <a href="#/p5/saveJSON">saveJSON()</a> are easier to use for simple file
18718
- * saving.
18719
- *
18720
- * The first parameter, `filename`, is the name of the file to be written. If
18721
- * a string is passed, as in `createWriter('words.txt')`, a new
18722
- * <a href="#/p5.PrintWriter">p5.PrintWriter</a> object will be created that
18723
- * writes to a file named `words.txt`.
18724
- *
18725
- * The second parameter, `extension`, is optional. If a string is passed, as
18726
- * in `createWriter('words', 'csv')`, the first parameter will be interpreted
18727
- * as the file name and the second parameter as the extension.
18728
- * @param name name of the file to create.
18729
- * @param extension format to use for the file.
18730
- * @returns stream for writing data.
18731
- */
18732
- function createWriter(name: string, extension?: string): P5.PrintWriter;
18733
-
18734
18696
  /**
18735
18697
  * Creates a light that shines from a point in one direction.
18736
18698
  *
@@ -18779,6 +18741,31 @@ function spotLight(v1: number, v2: number, v3: number, x: number, y: number, z:
18779
18741
  function spotLight(v1: number, v2: number, v3: number, position: P5.Vector, rx: number, ry: number, rz: number, angle?: number, concentration?: number): void;
18780
18742
  function spotLight(color: P5.Color | number[] | string, x: number, y: number, z: number, rx: number, ry: number, rz: number, angle?: number, concentration?: number): void;
18781
18743
 
18744
+ /**
18745
+ * Creates a new <a href="#/p5.PrintWriter">p5.PrintWriter</a> object.
18746
+ *
18747
+ * <a href="#/p5.PrintWriter">p5.PrintWriter</a> objects provide a way to
18748
+ * save a sequence of text data, called the print stream, to the user's
18749
+ * computer. They're low-level objects that enable precise control of text
18750
+ * output. Functions such as
18751
+ * <a href="#/p5/saveStrings">saveStrings()</a> and
18752
+ * <a href="#/p5/saveJSON">saveJSON()</a> are easier to use for simple file
18753
+ * saving.
18754
+ *
18755
+ * The first parameter, `filename`, is the name of the file to be written. If
18756
+ * a string is passed, as in `createWriter('words.txt')`, a new
18757
+ * <a href="#/p5.PrintWriter">p5.PrintWriter</a> object will be created that
18758
+ * writes to a file named `words.txt`.
18759
+ *
18760
+ * The second parameter, `extension`, is optional. If a string is passed, as
18761
+ * in `createWriter('words', 'csv')`, the first parameter will be interpreted
18762
+ * as the file name and the second parameter as the extension.
18763
+ * @param name name of the file to create.
18764
+ * @param extension format to use for the file.
18765
+ * @returns stream for writing data.
18766
+ */
18767
+ function createWriter(name: string, extension?: string): P5.PrintWriter;
18768
+
18782
18769
  /**
18783
18770
  * Translates the coordinate system.
18784
18771
  *
@@ -19271,18 +19258,6 @@ function noFill(): void;
19271
19258
  */
19272
19259
  function noLights(): void;
19273
19260
 
19274
- /**
19275
- * Writes data to the print stream without adding new lines.
19276
- *
19277
- * The parameter, `data`, is the data to write. `data` can be a number or
19278
- * string, as in `myWriter.write('hi')`, or an array of numbers and strings,
19279
- * as in `myWriter.write([1, 2, 3])`. A comma will be inserted between array
19280
- * array elements when they're added to the print stream.
19281
- * @param data data to be written as a string, number,
19282
- * or array of strings and numbers.
19283
- */
19284
- function write(data: string | number | any[]): void;
19285
-
19286
19261
  /**
19287
19262
  * Gets the lightness value of a color.
19288
19263
  *
@@ -19299,6 +19274,25 @@ function write(data: string | number | any[]): void;
19299
19274
  */
19300
19275
  function lightness(color: P5.Color | number[] | string): number;
19301
19276
 
19277
+ /**
19278
+ * Sets the <a href="#/p5.Shader">p5.Shader</a> object to apply for images.
19279
+ *
19280
+ * This method allows the user to apply a custom shader to images, enabling
19281
+ * advanced visual effects such as pixel manipulation, color adjustments,
19282
+ * or dynamic behavior. The shader will be applied to the image drawn using
19283
+ * the <a href="#/p5/image">image()</a> function.
19284
+ *
19285
+ * The shader will be used exclusively for:
19286
+ *
19287
+ * - `image()` calls, applying only when drawing 2D images.
19288
+ *
19289
+ * - This shader will NOT apply to images used in <a href="#/p5/texture">texture()</a> or other 3D contexts.
19290
+ * Any attempts to use the imageShader in these cases will be ignored.
19291
+ * @param s <a href="#/p5.Shader">p5.Shader</a> object
19292
+ * to apply for images.
19293
+ */
19294
+ function imageShader(s: P5.Shader): void;
19295
+
19302
19296
  /**
19303
19297
  * Changes the location from which images are drawn when
19304
19298
  * <a href="#/p5/image">image()</a> is called.
@@ -19367,23 +19361,16 @@ function imageMode(mode: typeof P5.CORNER | typeof P5.CORNERS | typeof P5.CENTER
19367
19361
  function mouseReleased(event?: MouseEvent): void;
19368
19362
 
19369
19363
  /**
19370
- * Sets the <a href="#/p5.Shader">p5.Shader</a> object to apply for images.
19371
- *
19372
- * This method allows the user to apply a custom shader to images, enabling
19373
- * advanced visual effects such as pixel manipulation, color adjustments,
19374
- * or dynamic behavior. The shader will be applied to the image drawn using
19375
- * the <a href="#/p5/image">image()</a> function.
19376
- *
19377
- * The shader will be used exclusively for:
19378
- *
19379
- * - `image()` calls, applying only when drawing 2D images.
19364
+ * Writes data to the print stream without adding new lines.
19380
19365
  *
19381
- * - This shader will NOT apply to images used in <a href="#/p5/texture">texture()</a> or other 3D contexts.
19382
- * Any attempts to use the imageShader in these cases will be ignored.
19383
- * @param s <a href="#/p5.Shader">p5.Shader</a> object
19384
- * to apply for images.
19366
+ * The parameter, `data`, is the data to write. `data` can be a number or
19367
+ * string, as in `myWriter.write('hi')`, or an array of numbers and strings,
19368
+ * as in `myWriter.write([1, 2, 3])`. A comma will be inserted between array
19369
+ * array elements when they're added to the print stream.
19370
+ * @param data data to be written as a string, number,
19371
+ * or array of strings and numbers.
19385
19372
  */
19386
- function imageShader(s: P5.Shader): void;
19373
+ function write(data: string | number | any[]): void;
19387
19374
 
19388
19375
  /**
19389
19376
  * Disables drawing points, lines, and the outlines of shapes.
@@ -19673,7 +19660,7 @@ function mouseClicked(event?: MouseEvent): void;
19673
19660
  * }
19674
19661
  *
19675
19662
  * function material() {
19676
- * let time = uniformFloat();
19663
+ * let time = millis();
19677
19664
  * worldInputs.begin();
19678
19665
  * worldInputs.position.y +=
19679
19666
  * 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -19683,7 +19670,6 @@ function mouseClicked(event?: MouseEvent): void;
19683
19670
  * function draw() {
19684
19671
  * background(255);
19685
19672
  * shader(myShader);
19686
- * myShader.setUniform('time', millis());
19687
19673
  * lights();
19688
19674
  * noStroke();
19689
19675
  * fill('red');
@@ -19901,42 +19887,6 @@ function stroke(color: P5.Color): void;
19901
19887
  */
19902
19888
  function createColorPicker(value?: string | P5.Color): P5.Element;
19903
19889
 
19904
- /**
19905
- * Saves a given element(image, text, json, csv, wav, or html) to the client's
19906
- * computer. The first parameter can be a pointer to element we want to save.
19907
- * The element can be one of <a href="#/p5.Element">p5.Element</a>,an Array of
19908
- * Strings, an Array of JSON, a JSON object, a <a href="#/p5.Table">p5.Table
19909
- * </a>, a <a href="#/p5.Image">p5.Image</a>, or a p5.SoundFile (requires
19910
- * p5.sound). The second parameter is a filename (including extension).The
19911
- * third parameter is for options specific to this type of object. This method
19912
- * will save a file that fits the given parameters.
19913
- * If it is called without specifying an element, by default it will save the
19914
- * whole canvas as an image file. You can optionally specify a filename as
19915
- * the first parameter in such a case.
19916
- * Note that it is not recommended to
19917
- * call this method within draw, as it will open a new save dialog on every
19918
- * render.
19919
- * @param objectOrFilename If filename is provided, will
19920
- * save canvas as an image with
19921
- * either png or jpg extension
19922
- * depending on the filename.
19923
- * If object is provided, will
19924
- * save depending on the object
19925
- * and filename (see examples
19926
- * above).
19927
- * @param filename If an object is provided as the first
19928
- * parameter, then the second parameter
19929
- * indicates the filename,
19930
- * and should include an appropriate
19931
- * file extension (see examples above).
19932
- * @param options Additional options depend on
19933
- * filetype. For example, when saving JSON,
19934
- * <code>true</code> indicates that the
19935
- * output will be optimized for filesize,
19936
- * rather than readability.
19937
- */
19938
- function save(objectOrFilename?: object | string, filename?: string, options?: boolean | string): void;
19939
-
19940
19890
  /**
19941
19891
  * Loads a new shader from a file that can change how fills are drawn. Pass the resulting
19942
19892
  * shader into the <a href="#/p5/shader">`shader()`</a> function to apply it
@@ -19954,7 +19904,6 @@ function save(objectOrFilename?: object | string, filename?: string, options?: b
19954
19904
  * function draw() {
19955
19905
  * background(255);
19956
19906
  * shader(myShader);
19957
- * myShader.setUniform('time', millis());
19958
19907
  * lights();
19959
19908
  * noStroke();
19960
19909
  * fill('red');
@@ -19964,7 +19913,7 @@ function save(objectOrFilename?: object | string, filename?: string, options?: b
19964
19913
  * might use the `pixelInputs` hook to change each pixel on the surface of a shape.
19965
19914
  *
19966
19915
  * `// myMaterial.js
19967
- * let time = uniformFloat();
19916
+ * let time = millis();
19968
19917
  * worldInputs.begin();
19969
19918
  * worldInputs.position.y +=
19970
19919
  * 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -19982,7 +19931,43 @@ function save(objectOrFilename?: object | string, filename?: string, options?: b
19982
19931
  * @param onFailure A callback function to run when loading fails.
19983
19932
  * @returns The material shader.
19984
19933
  */
19985
- function loadMaterialShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
19934
+ function loadMaterialShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
19935
+
19936
+ /**
19937
+ * Saves a given element(image, text, json, csv, wav, or html) to the client's
19938
+ * computer. The first parameter can be a pointer to element we want to save.
19939
+ * The element can be one of <a href="#/p5.Element">p5.Element</a>,an Array of
19940
+ * Strings, an Array of JSON, a JSON object, a <a href="#/p5.Table">p5.Table
19941
+ * </a>, a <a href="#/p5.Image">p5.Image</a>, or a p5.SoundFile (requires
19942
+ * p5.sound). The second parameter is a filename (including extension).The
19943
+ * third parameter is for options specific to this type of object. This method
19944
+ * will save a file that fits the given parameters.
19945
+ * If it is called without specifying an element, by default it will save the
19946
+ * whole canvas as an image file. You can optionally specify a filename as
19947
+ * the first parameter in such a case.
19948
+ * Note that it is not recommended to
19949
+ * call this method within draw, as it will open a new save dialog on every
19950
+ * render.
19951
+ * @param objectOrFilename If filename is provided, will
19952
+ * save canvas as an image with
19953
+ * either png or jpg extension
19954
+ * depending on the filename.
19955
+ * If object is provided, will
19956
+ * save depending on the object
19957
+ * and filename (see examples
19958
+ * above).
19959
+ * @param filename If an object is provided as the first
19960
+ * parameter, then the second parameter
19961
+ * indicates the filename,
19962
+ * and should include an appropriate
19963
+ * file extension (see examples above).
19964
+ * @param options Additional options depend on
19965
+ * filetype. For example, when saving JSON,
19966
+ * <code>true</code> indicates that the
19967
+ * output will be optimized for filesize,
19968
+ * rather than readability.
19969
+ */
19970
+ function save(objectOrFilename?: object | string, filename?: string, options?: boolean | string): void;
19986
19971
 
19987
19972
  /**
19988
19973
  * Influences the shape of the Bézier curve segment in a custom shape.
@@ -20066,6 +20051,19 @@ function doubleClicked(event?: MouseEvent): void;
20066
20051
  */
20067
20052
  function baseMaterialShader(): P5.Shader;
20068
20053
 
20054
+ /**
20055
+ * Returns the base shader used for filters.
20056
+ *
20057
+ * Calling <a href="#/p5/buildFilterShader">`buildFilterShader(shaderFunction)`</a>
20058
+ * is equivalent to calling `baseFilterShader().modify(shaderFunction)`.
20059
+ *
20060
+ * Read <a href="#/p5/buildFilterShader">the `buildFilterShader` reference</a> or
20061
+ * call `baseFilterShader().inspectHooks()` for more information on what you can do with
20062
+ * the base filter shader.
20063
+ * @returns The base filter shader.
20064
+ */
20065
+ function baseFilterShader(): P5.Shader;
20066
+
20069
20067
  /**
20070
20068
  * Starts using shapes to erase parts of the canvas.
20071
20069
  *
@@ -20100,19 +20098,6 @@ function baseMaterialShader(): P5.Shader;
20100
20098
  */
20101
20099
  function erase(strengthFill?: number, strengthStroke?: number): void;
20102
20100
 
20103
- /**
20104
- * Returns the base shader used for filters.
20105
- *
20106
- * Calling <a href="#/p5/buildFilterShader">`buildFilterShader(shaderFunction)`</a>
20107
- * is equivalent to calling `baseFilterShader().modify(shaderFunction)`.
20108
- *
20109
- * Read <a href="#/p5/buildFilterShader">the `buildFilterShader` reference</a> or
20110
- * call `baseFilterShader().inspectHooks()` for more information on what you can do with
20111
- * the base filter shader.
20112
- * @returns The base filter shader.
20113
- */
20114
- function baseFilterShader(): P5.Shader;
20115
-
20116
20101
  /**
20117
20102
  * Ends erasing that was started with <a href="#/p5/erase">erase()</a>.
20118
20103
  *
@@ -20141,37 +20126,6 @@ function noErase(): void;
20141
20126
  function createInput(value?: string, type?: string): P5.Element;
20142
20127
  function createInput(value?: string): P5.Element;
20143
20128
 
20144
- /**
20145
- * Saves an `Object` or `Array` to a JSON file.
20146
- *
20147
- * JavaScript Object Notation
20148
- * (<a href="https://developer.mozilla.org/en-US/docs/Glossary/JSON" target="_blank">JSON</a>)
20149
- * is a standard format for sending data between applications. The format is
20150
- * based on JavaScript objects which have keys and values. JSON files store
20151
- * data in an object with strings as keys. Values can be strings, numbers,
20152
- * Booleans, arrays, `null`, or other objects.
20153
- *
20154
- * The first parameter, `json`, is the data to save. The data can be an array,
20155
- * as in `[1, 2, 3]`, or an object, as in
20156
- * `{ x: 50, y: 50, color: 'deeppink' }`.
20157
- *
20158
- * The second parameter, `filename`, is a string that sets the file's name.
20159
- * For example, calling `saveJSON([1, 2, 3], 'data.json')` saves the array
20160
- * `[1, 2, 3]` to a file called `data.json` on the user's computer.
20161
- *
20162
- * The third parameter, `optimize`, is optional. If `true` is passed, as in
20163
- * `saveJSON([1, 2, 3], 'data.json', true)`, then all unneeded whitespace will
20164
- * be removed to reduce the file size.
20165
- *
20166
- * Note: The browser will either save the file immediately or prompt the user
20167
- * with a dialogue window.
20168
- * @param json data to save.
20169
- * @param filename name of the file to be saved.
20170
- * @param optimize whether to trim unneeded whitespace. Defaults
20171
- * to `true`.
20172
- */
20173
- function saveJSON(json: any[] | object, filename: string, optimize?: boolean): void;
20174
-
20175
20129
  /**
20176
20130
  * Create a new shader that can change how fills are drawn, based on the material used
20177
20131
  * when <a href="#/p5/normalMaterial">`normalMaterial()`</a> is active. Pass the resulting
@@ -20204,7 +20158,7 @@ function saveJSON(json: any[] | object, filename: string, optimize?: boolean): v
20204
20158
  * }
20205
20159
  *
20206
20160
  * function material() {
20207
- * let time = uniformFloat();
20161
+ * let time = millis();
20208
20162
  * worldInputs.begin();
20209
20163
  * worldInputs.position.y +=
20210
20164
  * 20. * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -20214,7 +20168,6 @@ function saveJSON(json: any[] | object, filename: string, optimize?: boolean): v
20214
20168
  * function draw() {
20215
20169
  * background(255);
20216
20170
  * shader(myShader);
20217
- * myShader.setUniform('time', millis());
20218
20171
  * noStroke();
20219
20172
  * sphere(50);
20220
20173
  * }`You may also want to change the colors used. By default, the x, y, and z values of the orientation
@@ -20307,6 +20260,37 @@ function buildNormalShader(hooks: object, scope?: object): P5.Shader;
20307
20260
  */
20308
20261
  function mouseWheel(event?: WheelEvent): void;
20309
20262
 
20263
+ /**
20264
+ * Saves an `Object` or `Array` to a JSON file.
20265
+ *
20266
+ * JavaScript Object Notation
20267
+ * (<a href="https://developer.mozilla.org/en-US/docs/Glossary/JSON" target="_blank">JSON</a>)
20268
+ * is a standard format for sending data between applications. The format is
20269
+ * based on JavaScript objects which have keys and values. JSON files store
20270
+ * data in an object with strings as keys. Values can be strings, numbers,
20271
+ * Booleans, arrays, `null`, or other objects.
20272
+ *
20273
+ * The first parameter, `json`, is the data to save. The data can be an array,
20274
+ * as in `[1, 2, 3]`, or an object, as in
20275
+ * `{ x: 50, y: 50, color: 'deeppink' }`.
20276
+ *
20277
+ * The second parameter, `filename`, is a string that sets the file's name.
20278
+ * For example, calling `saveJSON([1, 2, 3], 'data.json')` saves the array
20279
+ * `[1, 2, 3]` to a file called `data.json` on the user's computer.
20280
+ *
20281
+ * The third parameter, `optimize`, is optional. If `true` is passed, as in
20282
+ * `saveJSON([1, 2, 3], 'data.json', true)`, then all unneeded whitespace will
20283
+ * be removed to reduce the file size.
20284
+ *
20285
+ * Note: The browser will either save the file immediately or prompt the user
20286
+ * with a dialogue window.
20287
+ * @param json data to save.
20288
+ * @param filename name of the file to be saved.
20289
+ * @param optimize whether to trim unneeded whitespace. Defaults
20290
+ * to `true`.
20291
+ */
20292
+ function saveJSON(json: any[] | object, filename: string, optimize?: boolean): void;
20293
+
20310
20294
  /**
20311
20295
  * Ends a drawing group that contains its own styles and transformations.
20312
20296
  *
@@ -20490,25 +20474,6 @@ function pop(): void;
20490
20474
  */
20491
20475
  function createFileInput(callback: (input: P5.File) => any, multiple?: boolean): P5.Element;
20492
20476
 
20493
- /**
20494
- * Locks the mouse pointer to its current position and makes it invisible.
20495
- *
20496
- * `requestPointerLock()` allows the mouse to move forever without leaving the
20497
- * screen. Calling `requestPointerLock()` locks the values of
20498
- * <a href="#/p5/mouseX">mouseX</a>, <a href="#/p5/mouseY">mouseY</a>,
20499
- * <a href="#/p5/pmouseX">pmouseX</a>, and <a href="#/p5/pmouseY">pmouseY</a>.
20500
- * <a href="#/p5/movedX">movedX</a> and <a href="#/p5/movedY">movedY</a>
20501
- * continue updating and can be used to get the distance the mouse moved since
20502
- * the last frame was drawn. Calling
20503
- * <a href="#/p5/exitPointerLock">exitPointerLock()</a> resumes updating the
20504
- * mouse system variables.
20505
- *
20506
- * Note: Most browsers require an input, such as a click, before calling
20507
- * `requestPointerLock()`. It’s recommended to call `requestPointerLock()` in
20508
- * an event function such as <a href="#/p5/doubleClicked">doubleClicked()</a>.
20509
- */
20510
- function requestPointerLock(): void;
20511
-
20512
20477
  /**
20513
20478
  * Loads a new shader from a file that can change how fills are drawn, based on the material used
20514
20479
  * when <a href="#/p5/normalMaterial">`normalMaterial()`</a> is active. Pass the resulting
@@ -20527,7 +20492,6 @@ function requestPointerLock(): void;
20527
20492
  * function draw() {
20528
20493
  * background(255);
20529
20494
  * shader(myShader);
20530
- * myShader.setUniform('time', millis());
20531
20495
  * lights();
20532
20496
  * noStroke();
20533
20497
  * fill('red');
@@ -20537,7 +20501,7 @@ function requestPointerLock(): void;
20537
20501
  * might use the `finalColor` hook to change the color of each pixel on the surface of a shape.
20538
20502
  *
20539
20503
  * `// myMaterial.js
20540
- * let time = uniformFloat();
20504
+ * let time = millis();
20541
20505
  * worldInputs.begin();
20542
20506
  * worldInputs.position.y +=
20543
20507
  * 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -20557,6 +20521,25 @@ function requestPointerLock(): void;
20557
20521
  */
20558
20522
  function loadNormalShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
20559
20523
 
20524
+ /**
20525
+ * Locks the mouse pointer to its current position and makes it invisible.
20526
+ *
20527
+ * `requestPointerLock()` allows the mouse to move forever without leaving the
20528
+ * screen. Calling `requestPointerLock()` locks the values of
20529
+ * <a href="#/p5/mouseX">mouseX</a>, <a href="#/p5/mouseY">mouseY</a>,
20530
+ * <a href="#/p5/pmouseX">pmouseX</a>, and <a href="#/p5/pmouseY">pmouseY</a>.
20531
+ * <a href="#/p5/movedX">movedX</a> and <a href="#/p5/movedY">movedY</a>
20532
+ * continue updating and can be used to get the distance the mouse moved since
20533
+ * the last frame was drawn. Calling
20534
+ * <a href="#/p5/exitPointerLock">exitPointerLock()</a> resumes updating the
20535
+ * mouse system variables.
20536
+ *
20537
+ * Note: Most browsers require an input, such as a click, before calling
20538
+ * `requestPointerLock()`. It’s recommended to call `requestPointerLock()` in
20539
+ * an event function such as <a href="#/p5/doubleClicked">doubleClicked()</a>.
20540
+ */
20541
+ function requestPointerLock(): void;
20542
+
20560
20543
  /**
20561
20544
  * Returns the default shader used for fills when
20562
20545
  * <a href="#/p5/normalMaterial">`normalMaterial()`</a> is activated.
@@ -20649,7 +20632,7 @@ function saveStrings(list: string[], filename: string, extension?: string, isCRL
20649
20632
  * }
20650
20633
  *
20651
20634
  * function material() {
20652
- * let time = uniformFloat();
20635
+ * let time = millis();
20653
20636
  * worldInputs.begin();
20654
20637
  * worldInputs.position.y +=
20655
20638
  * 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -20659,7 +20642,6 @@ function saveStrings(list: string[], filename: string, extension?: string, isCRL
20659
20642
  * function draw() {
20660
20643
  * background(255);
20661
20644
  * shader(myShader);
20662
- * myShader.setUniform('time', millis());
20663
20645
  * noStroke();
20664
20646
  * fill('red');
20665
20647
  * circle(0, 0, 50);
@@ -20773,7 +20755,6 @@ function saveTable(Table: P5.Table, filename: string, options?: string): void;
20773
20755
  * function draw() {
20774
20756
  * background(255);
20775
20757
  * shader(myShader);
20776
- * myShader.setUniform('time', millis());
20777
20758
  * lights();
20778
20759
  * noStroke();
20779
20760
  * fill('red');
@@ -20783,7 +20764,7 @@ function saveTable(Table: P5.Table, filename: string, options?: string): void;
20783
20764
  * might use the `finalColor` hook to change the color of each pixel on the surface of a shape.
20784
20765
  *
20785
20766
  * `// myMaterial.js
20786
- * let time = uniformFloat();
20767
+ * let time = millis();
20787
20768
  * worldInputs.begin();
20788
20769
  * worldInputs.position.y +=
20789
20770
  * 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -21068,7 +21049,7 @@ function camera(x?: number, y?: number, z?: number, centerX?: number, centerY?:
21068
21049
  * }
21069
21050
  *
21070
21051
  * function material() {
21071
- * let time = uniformFloat();
21052
+ * let time = millis();
21072
21053
  * worldInputs.begin();
21073
21054
  * // Add a somewhat random offset to the weight
21074
21055
  * // that varies based on position and time
@@ -21084,7 +21065,6 @@ function camera(x?: number, y?: number, z?: number, centerX?: number, centerY?:
21084
21065
  * function draw() {
21085
21066
  * background(255);
21086
21067
  * strokeShader(myShader);
21087
- * myShader.setUniform('time', millis());
21088
21068
  * strokeWeight(10);
21089
21069
  * beginShape();
21090
21070
  * for (let i = 0; i <= 50; i++) {
@@ -21175,6 +21155,58 @@ function buildStrokeShader(hooks: object, scope?: object): P5.Shader;
21175
21155
  function splineProperty(property: string, value: any): void;
21176
21156
  function splineProperty(property: string): void;
21177
21157
 
21158
+ /**
21159
+ * Loads a new shader from a file that can change how strokes are drawn. Pass the resulting
21160
+ * shader into the <a href="#/p5/strokeShader">`strokeShader()`</a> function to apply it
21161
+ * to any strokes you draw.
21162
+ *
21163
+ * Since this function loads data from another file, it returns a `Promise`.
21164
+ * Use it in an `async function setup`, and `await` its result.
21165
+ *
21166
+ * `let myShader;
21167
+ * async function setup() {
21168
+ * createCanvas(200, 200, WEBGL);
21169
+ * myShader = await loadStrokeShader('myMaterial.js');
21170
+ * }
21171
+ *
21172
+ * function draw() {
21173
+ * background(255);
21174
+ * strokeShader(myShader);
21175
+ * strokeWeight(30);
21176
+ * line(
21177
+ * -width/3,
21178
+ * sin(millis()*0.001) * height/4,
21179
+ * width/3,
21180
+ * sin(millis()*0.001 + 1) * height/4
21181
+ * );
21182
+ * }`Inside your shader file, you can call p5.strands hooks to change parts of the shader. For
21183
+ * example, you might use the `worldInputs` hook to change each vertex, or you
21184
+ * might use the `pixelInputs` hook to change each pixel on the surface of a stroke.
21185
+ *
21186
+ * `// myMaterial.js
21187
+ * pixelInputs.begin();
21188
+ * let opacity = 1 - smoothstep(
21189
+ * 0,
21190
+ * 15,
21191
+ * length(pixelInputs.position - pixelInputs.center)
21192
+ * );
21193
+ * pixelInputs.color.a *= opacity;
21194
+ * pixelInputs.end();`Read the reference for <a href="#/p5/buildStrokeShader">`buildStrokeShader`</a>,
21195
+ * the version of `loadStrokeShader` that takes in a function instead of a separate file,
21196
+ * for a full list of hooks you can use and examples for each.
21197
+ *
21198
+ * The second parameter, `successCallback`, is optional. If a function is passed, as in
21199
+ * `loadStrokeShader('myShader.js', onLoaded)`, then the `onLoaded()` function will be called
21200
+ * once the shader loads. The shader will be passed to `onLoaded()` as its only argument.
21201
+ * The return value of `handleData()`, if present, will be used as the final return value of
21202
+ * `loadStrokeShader('myShader.js', onLoaded)`.
21203
+ * @param url The URL of your p5.strands JavaScript file.
21204
+ * @param onSuccess A callback function to run when loading completes.
21205
+ * @param onFailure A callback function to run when loading fails.
21206
+ * @returns The stroke shader.
21207
+ */
21208
+ function loadStrokeShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
21209
+
21178
21210
  /**
21179
21211
  * Sets a perspective projection for the current camera in a 3D sketch.
21180
21212
  *
@@ -21229,58 +21261,6 @@ function splineProperty(property: string): void;
21229
21261
  */
21230
21262
  function perspective(fovy?: number, aspect?: number, near?: number, far?: number): void;
21231
21263
 
21232
- /**
21233
- * Loads a new shader from a file that can change how strokes are drawn. Pass the resulting
21234
- * shader into the <a href="#/p5/strokeShader">`strokeShader()`</a> function to apply it
21235
- * to any strokes you draw.
21236
- *
21237
- * Since this function loads data from another file, it returns a `Promise`.
21238
- * Use it in an `async function setup`, and `await` its result.
21239
- *
21240
- * `let myShader;
21241
- * async function setup() {
21242
- * createCanvas(200, 200, WEBGL);
21243
- * myShader = await loadStrokeShader('myMaterial.js');
21244
- * }
21245
- *
21246
- * function draw() {
21247
- * background(255);
21248
- * strokeShader(myShader);
21249
- * strokeWeight(30);
21250
- * line(
21251
- * -width/3,
21252
- * sin(millis()*0.001) * height/4,
21253
- * width/3,
21254
- * sin(millis()*0.001 + 1) * height/4
21255
- * );
21256
- * }`Inside your shader file, you can call p5.strands hooks to change parts of the shader. For
21257
- * example, you might use the `worldInputs` hook to change each vertex, or you
21258
- * might use the `pixelInputs` hook to change each pixel on the surface of a stroke.
21259
- *
21260
- * `// myMaterial.js
21261
- * pixelInputs.begin();
21262
- * let opacity = 1 - smoothstep(
21263
- * 0,
21264
- * 15,
21265
- * length(pixelInputs.position - pixelInputs.center)
21266
- * );
21267
- * pixelInputs.color.a *= opacity;
21268
- * pixelInputs.end();`Read the reference for <a href="#/p5/buildStrokeShader">`buildStrokeShader`</a>,
21269
- * the version of `loadStrokeShader` that takes in a function instead of a separate file,
21270
- * for a full list of hooks you can use and examples for each.
21271
- *
21272
- * The second parameter, `successCallback`, is optional. If a function is passed, as in
21273
- * `loadStrokeShader('myShader.js', onLoaded)`, then the `onLoaded()` function will be called
21274
- * once the shader loads. The shader will be passed to `onLoaded()` as its only argument.
21275
- * The return value of `handleData()`, if present, will be used as the final return value of
21276
- * `loadStrokeShader('myShader.js', onLoaded)`.
21277
- * @param url The URL of your p5.strands JavaScript file.
21278
- * @param onSuccess A callback function to run when loading completes.
21279
- * @param onFailure A callback function to run when loading fails.
21280
- * @returns The stroke shader.
21281
- */
21282
- function loadStrokeShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<P5.Shader>;
21283
-
21284
21264
  /**
21285
21265
  * Returns the default shader used for strokes.
21286
21266
  *
@@ -21325,6 +21305,17 @@ function baseStrokeShader(): P5.Shader;
21325
21305
  */
21326
21306
  function splineProperties(values: object): object;
21327
21307
 
21308
+ /**
21309
+ * Restores the default shaders.
21310
+ *
21311
+ * `resetShader()` deactivates any shaders previously applied by
21312
+ * <a href="#/p5/shader">shader()</a>, <a href="#/p5/strokeShader">strokeShader()</a>,
21313
+ * or <a href="#/p5/imageShader">imageShader()</a>.
21314
+ *
21315
+ * Note: Shaders can only be used in WebGL mode.
21316
+ */
21317
+ function resetShader(): void;
21318
+
21328
21319
  /**
21329
21320
  * Enables or disables perspective for lines in 3D sketches.
21330
21321
  *
@@ -21362,17 +21353,6 @@ function splineProperties(values: object): object;
21362
21353
  function linePerspective(enable: boolean): boolean;
21363
21354
  function linePerspective(): boolean;
21364
21355
 
21365
- /**
21366
- * Restores the default shaders.
21367
- *
21368
- * `resetShader()` deactivates any shaders previously applied by
21369
- * <a href="#/p5/shader">shader()</a>, <a href="#/p5/strokeShader">strokeShader()</a>,
21370
- * or <a href="#/p5/imageShader">imageShader()</a>.
21371
- *
21372
- * Note: Shaders can only be used in WebGL mode.
21373
- */
21374
- function resetShader(): void;
21375
-
21376
21356
  /**
21377
21357
  * Sets an orthographic projection for the current camera in a 3D sketch.
21378
21358
  *
@@ -22710,3 +22690,5 @@ function sampler(value: any): any;
22710
22690
 
22711
22691
  }
22712
22692
 
22693
+ export default p5;
22694
+