p5 2.2.3-rc.0 → 2.2.3

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 (97) hide show
  1. package/README.md +4 -5
  2. package/dist/accessibility/color_namer.js +5 -5
  3. package/dist/accessibility/index.js +5 -5
  4. package/dist/app.js +5 -5
  5. package/dist/color/color_conversion.js +5 -5
  6. package/dist/color/index.js +1 -1
  7. package/dist/color/setting.js +1 -1
  8. package/dist/{constants-D3ryGa0m.js → constants-BdTiYOQI.js} +1 -1
  9. package/dist/core/constants.js +1 -1
  10. package/dist/core/environment.js +1 -1
  11. package/dist/core/filterShaders.js +1 -1
  12. package/dist/core/friendly_errors/fes_core.js +1 -1
  13. package/dist/core/friendly_errors/file_errors.js +1 -1
  14. package/dist/core/friendly_errors/index.js +1 -1
  15. package/dist/core/friendly_errors/param_validator.js +1 -1
  16. package/dist/core/friendly_errors/sketch_verifier.js +1 -1
  17. package/dist/core/helpers.js +1 -1
  18. package/dist/core/init.js +5 -5
  19. package/dist/core/internationalization.js +1 -1
  20. package/dist/core/legacy.js +5 -5
  21. package/dist/core/main.js +5 -5
  22. package/dist/core/p5.Graphics.js +3 -3
  23. package/dist/core/p5.Renderer.js +2 -2
  24. package/dist/core/p5.Renderer2D.js +5 -5
  25. package/dist/core/p5.Renderer3D.js +3 -3
  26. package/dist/core/rendering.js +3 -3
  27. package/dist/data/local_storage.js +13 -9
  28. package/dist/dom/dom.js +30 -29
  29. package/dist/dom/index.js +1 -1
  30. package/dist/dom/p5.Element.js +3 -3
  31. package/dist/dom/p5.MediaElement.js +4 -5
  32. package/dist/events/pointer.js +1 -1
  33. package/dist/image/const.js +1 -1
  34. package/dist/image/filterRenderer2D.js +4 -4
  35. package/dist/image/image.js +3 -3
  36. package/dist/image/index.js +3 -3
  37. package/dist/image/loading_displaying.js +3 -3
  38. package/dist/image/p5.Image.js +2 -2
  39. package/dist/io/files.js +3 -3
  40. package/dist/io/index.js +3 -3
  41. package/dist/io/p5.XML.js +8 -8
  42. package/dist/{ir_builders-DMfaOLIL.js → ir_builders-Cd6rU9Vm.js} +0 -6
  43. package/dist/{main-CGwYa9-f.js → main-H_nu4eDs.js} +3 -3
  44. package/dist/math/Matrices/Matrix.js +1 -1
  45. package/dist/math/Matrices/MatrixNumjs.js +1 -1
  46. package/dist/math/index.js +1 -1
  47. package/dist/math/p5.Matrix.js +1 -1
  48. package/dist/math/p5.Vector.js +1 -1
  49. package/dist/math/trigonometry.js +1 -1
  50. package/dist/{p5.Renderer-C0e0XesC.js → p5.Renderer-BmD2P6Wv.js} +4 -3
  51. package/dist/{rendering-4Z2qdE_W.js → rendering-CC8JNTwG.js} +21 -58
  52. package/dist/shape/2d_primitives.js +1 -1
  53. package/dist/shape/attributes.js +1 -1
  54. package/dist/shape/custom_shapes.js +1 -1
  55. package/dist/shape/index.js +1 -1
  56. package/dist/strands/ir_builders.js +1 -1
  57. package/dist/strands/p5.strands.js +10 -34
  58. package/dist/strands/strands_api.js +1 -2
  59. package/dist/strands/strands_codegen.js +0 -12
  60. package/dist/strands/strands_conditionals.js +1 -1
  61. package/dist/strands/strands_for.js +1 -1
  62. package/dist/strands/strands_node.js +1 -1
  63. package/dist/type/index.js +2 -2
  64. package/dist/type/p5.Font.js +2 -2
  65. package/dist/type/textCore.js +2 -2
  66. package/dist/webgl/3d_primitives.js +3 -3
  67. package/dist/webgl/GeometryBuilder.js +1 -1
  68. package/dist/webgl/ShapeBuilder.js +1 -1
  69. package/dist/webgl/enums.js +1 -1
  70. package/dist/webgl/index.js +4 -4
  71. package/dist/webgl/interaction.js +1 -1
  72. package/dist/webgl/light.js +3 -3
  73. package/dist/webgl/loading.js +4 -6
  74. package/dist/webgl/material.js +3 -3
  75. package/dist/webgl/p5.Camera.js +3 -3
  76. package/dist/webgl/p5.Framebuffer.js +3 -3
  77. package/dist/webgl/p5.Geometry.js +1 -1
  78. package/dist/webgl/p5.Quat.js +1 -1
  79. package/dist/webgl/p5.RendererGL.js +4 -4
  80. package/dist/webgl/p5.Shader.js +14 -6
  81. package/dist/webgl/p5.Texture.js +3 -3
  82. package/dist/webgl/strands_glslBackend.js +1 -1
  83. package/dist/webgl/text.js +3 -3
  84. package/dist/webgl/utils.js +3 -3
  85. package/dist/webgpu/index.js +2 -2
  86. package/dist/webgpu/p5.RendererWebGPU.js +2 -2
  87. package/dist/webgpu/strands_wgslBackend.js +1 -1
  88. package/lib/p5.esm.js +104 -173
  89. package/lib/p5.esm.min.js +1 -1
  90. package/lib/p5.js +104 -173
  91. package/lib/p5.min.js +1 -1
  92. package/lib/p5.webgpu.esm.js +1 -7
  93. package/lib/p5.webgpu.js +1 -7
  94. package/lib/p5.webgpu.min.js +1 -1
  95. package/package.json +1 -1
  96. package/types/global.d.ts +1170 -1210
  97. package/types/p5.d.ts +645 -658
package/types/p5.d.ts CHANGED
@@ -1137,9 +1137,9 @@ declare const __BOTTOM: typeof BOTTOM;
1137
1137
 
1138
1138
  /**
1139
1139
  * A system variable that provides direct access to the sketch's
1140
- * `<canvas>` element.
1140
+ * `<canvas>` element.
1141
1141
  *
1142
- * The `&lt;canvas&gt;` element provides many specialized features that aren't
1142
+ * The `<canvas>` element provides many specialized features that aren't
1143
1143
  * included in the p5.js library. The `drawingContext` system variable
1144
1144
  * provides access to these features by exposing the sketch's
1145
1145
  * <a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D">CanvasRenderingContext2D</a>
@@ -3325,6 +3325,26 @@ declare class p5 {
3325
3325
  byte(n: string | boolean | number): number;
3326
3326
  byte(ns: any[]): number[];
3327
3327
 
3328
+ /**
3329
+ * Creates a custom <a href="#/p5.Geometry">p5.Geometry</a> object from
3330
+ * simpler 3D shapes.
3331
+ *
3332
+ * `buildGeometry()` helps with creating complex 3D shapes from simpler ones
3333
+ * such as <a href="#/p5/sphere">sphere()</a>. It can help to make sketches
3334
+ * more performant. For example, if a complex 3D shape doesn’t change while a
3335
+ * sketch runs, then it can be created with `buildGeometry()`. Creating a
3336
+ * <a href="#/p5.Geometry">p5.Geometry</a> object once and then drawing it
3337
+ * will run faster than repeatedly drawing the individual pieces.
3338
+ *
3339
+ * The parameter, `callback`, is a function with the drawing instructions for
3340
+ * the new <a href="#/p5.Geometry">p5.Geometry</a> object. It will be called
3341
+ * once to create the new 3D shape.
3342
+ * Note: `buildGeometry()` can only be used in WebGL mode.
3343
+ * @param callback function that draws the shape.
3344
+ * @returns new 3D shape.
3345
+ */
3346
+ buildGeometry(callback: Function): p5.Geometry;
3347
+
3328
3348
  /**
3329
3349
  * Calculates coordinates along a Bézier curve using interpolation.
3330
3350
  *
@@ -3355,31 +3375,6 @@ declare class p5 {
3355
3375
  */
3356
3376
  bezierPoint(a: number, b: number, c: number, d: number, t: number): number;
3357
3377
 
3358
- /**
3359
- * Creates a custom <a href="#/p5.Geometry">p5.Geometry</a> object from
3360
- * simpler 3D shapes.
3361
- *
3362
- * `buildGeometry()` helps with creating complex 3D shapes from simpler ones
3363
- * such as <a href="#/p5/sphere">sphere()</a>. It can help to make sketches
3364
- * more performant. For example, if a complex 3D shape doesn’t change while a
3365
- * sketch runs, then it can be created with `buildGeometry()`. Creating a
3366
- * <a href="#/p5.Geometry">p5.Geometry</a> object once and then drawing it
3367
- * will run faster than repeatedly drawing the individual pieces.
3368
- *
3369
- * The parameter, `callback`, is a function with the drawing instructions for
3370
- * the new <a href="#/p5.Geometry">p5.Geometry</a> object. It will be called
3371
- * once to create the new 3D shape.
3372
- *
3373
- * See <a href="#/p5/beginGeometry">beginGeometry()</a> and
3374
- * <a href="#/p5/endGeometry">endGeometry()</a> for another way to build 3D
3375
- * shapes.
3376
- *
3377
- * Note: `buildGeometry()` can only be used in WebGL mode.
3378
- * @param callback function that draws the shape.
3379
- * @returns new 3D shape.
3380
- */
3381
- buildGeometry(callback: Function): p5.Geometry;
3382
-
3383
3378
  /**
3384
3379
  * Loads a 3D model to create a
3385
3380
  * <a href="#/p5.Geometry">p5.Geometry</a> object.
@@ -3539,20 +3534,6 @@ declare class p5 {
3539
3534
  */
3540
3535
  smooth(): void;
3541
3536
 
3542
- /**
3543
- * Removes all items in the web browser's local storage.
3544
- *
3545
- * Web browsers can save small amounts of data using the built-in
3546
- * <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage" target="_blank">localStorage object</a>.
3547
- * Data stored in `localStorage` can be retrieved at any point, even after
3548
- * refreshing a page or restarting the browser. Data are stored as key-value
3549
- * pairs. Calling `clearStorage()` removes all data from `localStorage`.
3550
- *
3551
- * Note: Sensitive data such as passwords or personal information shouldn't be
3552
- * stored in `localStorage`.
3553
- */
3554
- clearStorage(): void;
3555
-
3556
3537
  /**
3557
3538
  * Converts a `Number` into a `String` with a plus or minus sign.
3558
3539
  *
@@ -3588,6 +3569,20 @@ declare class p5 {
3588
3569
  nfp(num: number, left?: number, right?: number): string;
3589
3570
  nfp(nums: number[], left?: number, right?: number): string[];
3590
3571
 
3572
+ /**
3573
+ * Removes all items in the web browser's local storage.
3574
+ *
3575
+ * Web browsers can save small amounts of data using the built-in
3576
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage" target="_blank">localStorage object</a>.
3577
+ * Data stored in `localStorage` can be retrieved at any point, even after
3578
+ * refreshing a page or restarting the browser. Data are stored as key-value
3579
+ * pairs. Calling `clearStorage()` removes all data from `localStorage`.
3580
+ *
3581
+ * Note: Sensitive data such as passwords or personal information shouldn't be
3582
+ * stored in `localStorage`.
3583
+ */
3584
+ clearStorage(): void;
3585
+
3591
3586
  /**
3592
3587
  * Removes all elements created by p5.js, including any event handlers.
3593
3588
  *
@@ -3830,6 +3825,29 @@ declare class p5 {
3830
3825
  frameRate(fps: number): number;
3831
3826
  frameRate(): number;
3832
3827
 
3828
+ /**
3829
+ * Clears a <a href="#/p5.Geometry">p5.Geometry</a> object from the graphics
3830
+ * processing unit (GPU) memory.
3831
+ *
3832
+ * <a href="#/p5.Geometry">p5.Geometry</a> objects can contain lots of data
3833
+ * about their vertices, surface normals, colors, and so on. Complex 3D shapes
3834
+ * can use lots of memory which is a limited resource in many GPUs. Calling
3835
+ * `freeGeometry()` works with <a href="#/p5.Geometry">p5.Geometry</a> objects
3836
+ * created with <a href="#/p5/buildGeometry">buildGeometry()</a> and
3837
+ * <a href="#/p5/loadModel">loadModel()</a>.
3838
+ *
3839
+ * The parameter, `geometry`, is the <a href="#/p5.Geometry">p5.Geometry</a>
3840
+ * object to be freed.
3841
+ *
3842
+ * Note: A <a href="#/p5.Geometry">p5.Geometry</a> object can still be drawn
3843
+ * after its resources are cleared from GPU memory. It may take longer to draw
3844
+ * the first time it’s redrawn.
3845
+ *
3846
+ * Note: `freeGeometry()` can only be used in WebGL mode.
3847
+ * @param geometry 3D shape whose resources should be freed.
3848
+ */
3849
+ freeGeometry(geometry: p5.Geometry): void;
3850
+
3833
3851
  /**
3834
3852
  * Calculates the cosine of an angle.
3835
3853
  *
@@ -3892,14 +3910,14 @@ declare class p5 {
3892
3910
  specularColor(color: p5.Color): void;
3893
3911
 
3894
3912
  /**
3895
- * Creates a `&lt;div&gt;&lt;/div&gt;` element.
3913
+ * Creates a `<div></div>` element.
3896
3914
  *
3897
- * `&lt;div&gt;&lt;/div&gt;` elements are commonly used as containers for
3915
+ * `<div></div>` elements are commonly used as containers for
3898
3916
  * other elements.
3899
3917
  *
3900
3918
  * The parameter `html` is optional. It accepts a string that sets the
3901
- * inner HTML of the new `&lt;div&gt;&lt;/div&gt;`.
3902
- * @param html inner HTML for the new `&lt;div&gt;&lt;/div&gt;` element.
3919
+ * inner HTML of the new `<div></div>`.
3920
+ * @param html inner HTML for the new `<div></div>` element.
3903
3921
  * @returns new <a href="#/p5.Element">p5.Element</a> object.
3904
3922
  */
3905
3923
  createDiv(html?: string): p5.Element;
@@ -3957,27 +3975,6 @@ declare class p5 {
3957
3975
  boolean(n: string | boolean | number): boolean;
3958
3976
  boolean(ns: any[]): boolean[];
3959
3977
 
3960
- /**
3961
- * Removes an item from the web browser's local storage.
3962
- *
3963
- * Web browsers can save small amounts of data using the built-in
3964
- * <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage" target="_blank">localStorage object</a>.
3965
- * Data stored in `localStorage` can be retrieved at any point, even after
3966
- * refreshing a page or restarting the browser. Data are stored as key-value
3967
- * pairs.
3968
- *
3969
- * <a href="#/p5/storeItem">storeItem()</a> makes it easy to store values in
3970
- * `localStorage` and `removeItem()` makes it easy to delete them.
3971
- *
3972
- * The parameter, `key`, is the name of the value to remove as a string. For
3973
- * example, calling `removeItem('size')` removes the item with the key `size`.
3974
- *
3975
- * Note: Sensitive data such as passwords or personal information shouldn't be
3976
- * stored in `localStorage`.
3977
- * @param key name of the value to remove.
3978
- */
3979
- removeItem(key: string): void;
3980
-
3981
3978
  /**
3982
3979
  * Rotates the coordinate system.
3983
3980
  *
@@ -4013,31 +4010,25 @@ declare class p5 {
4013
4010
  rotate(angle: number, axis?: p5.Vector | number[]): void;
4014
4011
 
4015
4012
  /**
4016
- * Clears a <a href="#/p5.Geometry">p5.Geometry</a> object from the graphics
4017
- * processing unit (GPU) memory.
4013
+ * Removes an item from the web browser's local storage.
4018
4014
  *
4019
- * <a href="#/p5.Geometry">p5.Geometry</a> objects can contain lots of data
4020
- * about their vertices, surface normals, colors, and so on. Complex 3D shapes
4021
- * can use lots of memory which is a limited resource in many GPUs. Calling
4022
- * `freeGeometry()` can improve performance by freeing a
4023
- * <a href="#/p5.Geometry">p5.Geometry</a> object’s resources from GPU memory.
4024
- * `freeGeometry()` works with <a href="#/p5.Geometry">p5.Geometry</a> objects
4025
- * created with <a href="#/p5/beginGeometry">beginGeometry()</a> and
4026
- * <a href="#/p5/endGeometry">endGeometry()</a>,
4027
- * <a href="#/p5/buildGeometry">buildGeometry()</a>, and
4028
- * <a href="#/p5/loadModel">loadModel()</a>.
4015
+ * Web browsers can save small amounts of data using the built-in
4016
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage" target="_blank">localStorage object</a>.
4017
+ * Data stored in `localStorage` can be retrieved at any point, even after
4018
+ * refreshing a page or restarting the browser. Data are stored as key-value
4019
+ * pairs.
4029
4020
  *
4030
- * The parameter, `geometry`, is the <a href="#/p5.Geometry">p5.Geometry</a>
4031
- * object to be freed.
4021
+ * <a href="#/p5/storeItem">storeItem()</a> makes it easy to store values in
4022
+ * `localStorage` and `removeItem()` makes it easy to delete them.
4032
4023
  *
4033
- * Note: A <a href="#/p5.Geometry">p5.Geometry</a> object can still be drawn
4034
- * after its resources are cleared from GPU memory. It may take longer to draw
4035
- * the first time it’s redrawn.
4024
+ * The parameter, `key`, is the name of the value to remove as a string. For
4025
+ * example, calling `removeItem('size')` removes the item with the key `size`.
4036
4026
  *
4037
- * Note: `freeGeometry()` can only be used in WebGL mode.
4038
- * @param geometry 3D shape whose resources should be freed.
4027
+ * Note: Sensitive data such as passwords or personal information shouldn't be
4028
+ * stored in `localStorage`.
4029
+ * @param key name of the value to remove.
4039
4030
  */
4040
- freeGeometry(geometry: p5.Geometry): void;
4031
+ removeItem(key: string): void;
4041
4032
 
4042
4033
  /**
4043
4034
  * The <a href="#/p5/setMoveThreshold">setMoveThreshold()</a> function is used to set the movement threshold for
@@ -4127,11 +4118,11 @@ declare class p5 {
4127
4118
  /**
4128
4119
  * Creates a paragraph element.
4129
4120
  *
4130
- * `&lt;p&gt;&lt;/p&gt;` elements are commonly used for paragraph-length text.
4121
+ * `<p></p>` elements are commonly used for paragraph-length text.
4131
4122
  *
4132
4123
  * The parameter `html` is optional. It accepts a string that sets the
4133
- * inner HTML of the new `&lt;p&gt;&lt;/p&gt;`.
4134
- * @param html inner HTML for the new `&lt;p&gt;&lt;/p&gt;` element.
4124
+ * inner HTML of the new `<p></p>`.
4125
+ * @param html inner HTML for the new `<p></p>` element.
4135
4126
  * @returns new <a href="#/p5.Element">p5.Element</a> object.
4136
4127
  */
4137
4128
  createP(html?: string): p5.Element;
@@ -4375,7 +4366,7 @@ declare class p5 {
4375
4366
  * // Make a version of the shader with a hook overridden
4376
4367
  * modifiedShader = myShader.modify(() => {
4377
4368
  * // Create new uniforms and override the getColor hook
4378
- * let t = uniformFloat(() => millis() / 1000);
4369
+ * let t = millis() / 1000;
4379
4370
  * getColor(() => {
4380
4371
  * return [0, 0.5 + 0.5 * sin(t), 1, 1];
4381
4372
  * });
@@ -4565,6 +4556,38 @@ declare class p5 {
4565
4556
  */
4566
4557
  loadTable(filename: string | Request, separator?: string, header?: string, callback?: Function, errorCallback?: Function): Promise<object>;
4567
4558
 
4559
+ /**
4560
+ * Draws a plane.
4561
+ *
4562
+ * A plane is a four-sided, flat shape with every angle measuring 90˚. It’s
4563
+ * similar to a rectangle and offers advanced drawing features in WebGL mode.
4564
+ *
4565
+ * The first parameter, `width`, is optional. If a `Number` is passed, as in
4566
+ * `plane(20)`, it sets the plane’s width and height. By default, `width` is
4567
+ * 50.
4568
+ *
4569
+ * The second parameter, `height`, is also optional. If a `Number` is passed,
4570
+ * as in `plane(20, 30)`, it sets the plane’s height. By default, `height` is
4571
+ * set to the plane’s `width`.
4572
+ *
4573
+ * The third parameter, `detailX`, is also optional. If a `Number` is passed,
4574
+ * as in `plane(20, 30, 5)` it sets the number of triangle subdivisions to use
4575
+ * along the x-axis. All 3D shapes are made by connecting triangles to form
4576
+ * their surfaces. By default, `detailX` is 1.
4577
+ *
4578
+ * The fourth parameter, `detailY`, is also optional. If a `Number` is passed,
4579
+ * as in `plane(20, 30, 5, 7)` it sets the number of triangle subdivisions to
4580
+ * use along the y-axis. All 3D shapes are made by connecting triangles to
4581
+ * form their surfaces. By default, `detailY` is 1.
4582
+ *
4583
+ * Note: `plane()` can only be used in WebGL mode.
4584
+ * @param width width of the plane.
4585
+ * @param height height of the plane.
4586
+ * @param detailX number of triangle subdivisions along the x-axis.
4587
+ * @param detailY number of triangle subdivisions along the y-axis.
4588
+ */
4589
+ plane(width?: number, height?: number, detailX?: number, detailY?: number): void;
4590
+
4568
4591
  /**
4569
4592
  * Gets the red value of a color.
4570
4593
  *
@@ -4650,16 +4673,16 @@ declare class p5 {
4650
4673
  tan(angle: number): number;
4651
4674
 
4652
4675
  /**
4653
- * Creates a `&lt;span&gt;&lt;/span&gt;` element.
4676
+ * Creates a `<span></span>` element.
4654
4677
  *
4655
- * `&lt;span&gt;&lt;/span&gt;` elements are commonly used as containers
4656
- * for inline elements. For example, a `&lt;span&gt;&lt;/span&gt;`
4678
+ * `<span></span>` elements are commonly used as containers
4679
+ * for inline elements. For example, a `<span></span>`
4657
4680
  * can hold part of a sentence that's a
4658
4681
  * <span style="color: deeppink;">different</span> style.
4659
4682
  *
4660
4683
  * The parameter `html` is optional. It accepts a string that sets the
4661
- * inner HTML of the new `&lt;span&gt;&lt;/span&gt;`.
4662
- * @param html inner HTML for the new `&lt;span&gt;&lt;/span&gt;` element.
4684
+ * inner HTML of the new `<span></span>`.
4685
+ * @param html inner HTML for the new `<span></span>` element.
4663
4686
  * @returns new <a href="#/p5.Element">p5.Element</a> object.
4664
4687
  */
4665
4688
  createSpan(html?: string): p5.Element;
@@ -4712,38 +4735,6 @@ declare class p5 {
4712
4735
  */
4713
4736
  loadFilterShader(filename: string, successCallback?: Function, failureCallback?: Function): Promise<p5.Shader>;
4714
4737
 
4715
- /**
4716
- * Draws a plane.
4717
- *
4718
- * A plane is a four-sided, flat shape with every angle measuring 90˚. It’s
4719
- * similar to a rectangle and offers advanced drawing features in WebGL mode.
4720
- *
4721
- * The first parameter, `width`, is optional. If a `Number` is passed, as in
4722
- * `plane(20)`, it sets the plane’s width and height. By default, `width` is
4723
- * 50.
4724
- *
4725
- * The second parameter, `height`, is also optional. If a `Number` is passed,
4726
- * as in `plane(20, 30)`, it sets the plane’s height. By default, `height` is
4727
- * set to the plane’s `width`.
4728
- *
4729
- * The third parameter, `detailX`, is also optional. If a `Number` is passed,
4730
- * as in `plane(20, 30, 5)` it sets the number of triangle subdivisions to use
4731
- * along the x-axis. All 3D shapes are made by connecting triangles to form
4732
- * their surfaces. By default, `detailX` is 1.
4733
- *
4734
- * The fourth parameter, `detailY`, is also optional. If a `Number` is passed,
4735
- * as in `plane(20, 30, 5, 7)` it sets the number of triangle subdivisions to
4736
- * use along the y-axis. All 3D shapes are made by connecting triangles to
4737
- * form their surfaces. By default, `detailY` is 1.
4738
- *
4739
- * Note: `plane()` can only be used in WebGL mode.
4740
- * @param width width of the plane.
4741
- * @param height height of the plane.
4742
- * @param detailX number of triangle subdivisions along the x-axis.
4743
- * @param detailY number of triangle subdivisions along the y-axis.
4744
- */
4745
- plane(width?: number, height?: number, detailX?: number, detailY?: number): void;
4746
-
4747
4738
  /**
4748
4739
  * Creates and a new <a href="#/p5.Framebuffer">p5.Framebuffer</a> object.
4749
4740
  *
@@ -4853,7 +4844,7 @@ declare class p5 {
4853
4844
  map(value: number, start1: number, stop1: number, start2: number, stop2: number, withinBounds?: boolean): number;
4854
4845
 
4855
4846
  /**
4856
- * Creates an `&lt;img&gt;` element that can appear outside of the canvas.
4847
+ * Creates an `<img>` element that can appear outside of the canvas.
4857
4848
  *
4858
4849
  * The first parameter, `src`, is a string with the path to the image file.
4859
4850
  * `src` should be a relative path, as in `'assets/image.png'`, or a URL, as
@@ -5111,6 +5102,42 @@ declare class p5 {
5111
5102
  */
5112
5103
  green(color: p5.Color | number[] | string): number;
5113
5104
 
5105
+ /**
5106
+ * Draws a box (rectangular prism).
5107
+ *
5108
+ * A box is a 3D shape with six faces. Each face makes a 90˚ with four
5109
+ * neighboring faces.
5110
+ *
5111
+ * The first parameter, `width`, is optional. If a `Number` is passed, as in
5112
+ * `box(20)`, it sets the box’s width and height. By default, `width` is 50.
5113
+ *
5114
+ * The second parameter, `height`, is also optional. If a `Number` is passed,
5115
+ * as in `box(20, 30)`, it sets the box’s height. By default, `height` is set
5116
+ * to the box’s `width`.
5117
+ *
5118
+ * The third parameter, `depth`, is also optional. If a `Number` is passed, as
5119
+ * in `box(20, 30, 40)`, it sets the box’s depth. By default, `depth` is set
5120
+ * to the box’s `height`.
5121
+ *
5122
+ * The fourth parameter, `detailX`, is also optional. If a `Number` is passed,
5123
+ * as in `box(20, 30, 40, 5)`, it sets the number of triangle subdivisions to
5124
+ * use along the x-axis. All 3D shapes are made by connecting triangles to
5125
+ * form their surfaces. By default, `detailX` is 1.
5126
+ *
5127
+ * The fifth parameter, `detailY`, is also optional. If a number is passed, as
5128
+ * in `box(20, 30, 40, 5, 7)`, it sets the number of triangle subdivisions to
5129
+ * use along the y-axis. All 3D shapes are made by connecting triangles to
5130
+ * form their surfaces. By default, `detailY` is 1.
5131
+ *
5132
+ * Note: `box()` can only be used in WebGL mode.
5133
+ * @param width width of the box.
5134
+ * @param height height of the box.
5135
+ * @param depth depth of the box.
5136
+ * @param detailX number of triangle subdivisions along the x-axis.
5137
+ * @param detailY number of triangle subdivisions along the y-axis.
5138
+ */
5139
+ box(width?: number, height?: number, depth?: number, detailX?: number, detailY?: number): void;
5140
+
5114
5141
  /**
5115
5142
  * Returns the largest value in a sequence of numbers.
5116
5143
  *
@@ -5161,7 +5188,7 @@ declare class p5 {
5161
5188
  bezierVertex(x: number, y: number, z: number, u?: number, v?: number): void;
5162
5189
 
5163
5190
  /**
5164
- * Creates an `&lt;a&gt;&lt;/a&gt;` element that links to another web page.
5191
+ * Creates an `<a></a>` element that links to another web page.
5165
5192
  *
5166
5193
  * The first parmeter, `href`, is a string that sets the URL of the linked
5167
5194
  * page.
@@ -5319,52 +5346,16 @@ declare class p5 {
5319
5346
  clear(): void;
5320
5347
 
5321
5348
  /**
5322
- * Draws a box (rectangular prism).
5349
+ * Converts a `Number` or `String` to a single-character `String`.
5323
5350
  *
5324
- * A box is a 3D shape with six faces. Each face makes a 90˚ with four
5325
- * neighboring faces.
5351
+ * `char()` converts numbers to their single-character string representations.
5326
5352
  *
5327
- * The first parameter, `width`, is optional. If a `Number` is passed, as in
5328
- * `box(20)`, it sets the box’s width and height. By default, `width` is 50.
5329
- *
5330
- * The second parameter, `height`, is also optional. If a `Number` is passed,
5331
- * as in `box(20, 30)`, it sets the box’s height. By default, `height` is set
5332
- * to the box’s `width`.
5333
- *
5334
- * The third parameter, `depth`, is also optional. If a `Number` is passed, as
5335
- * in `box(20, 30, 40)`, it sets the box’s depth. By default, `depth` is set
5336
- * to the box’s `height`.
5337
- *
5338
- * The fourth parameter, `detailX`, is also optional. If a `Number` is passed,
5339
- * as in `box(20, 30, 40, 5)`, it sets the number of triangle subdivisions to
5340
- * use along the x-axis. All 3D shapes are made by connecting triangles to
5341
- * form their surfaces. By default, `detailX` is 1.
5342
- *
5343
- * The fifth parameter, `detailY`, is also optional. If a number is passed, as
5344
- * in `box(20, 30, 40, 5, 7)`, it sets the number of triangle subdivisions to
5345
- * use along the y-axis. All 3D shapes are made by connecting triangles to
5346
- * form their surfaces. By default, `detailY` is 1.
5347
- *
5348
- * Note: `box()` can only be used in WebGL mode.
5349
- * @param width width of the box.
5350
- * @param height height of the box.
5351
- * @param depth depth of the box.
5352
- * @param detailX number of triangle subdivisions along the x-axis.
5353
- * @param detailY number of triangle subdivisions along the y-axis.
5354
- */
5355
- box(width?: number, height?: number, depth?: number, detailX?: number, detailY?: number): void;
5356
-
5357
- /**
5358
- * Converts a `Number` or `String` to a single-character `String`.
5359
- *
5360
- * `char()` converts numbers to their single-character string representations.
5361
- *
5362
- * The parameter, `n`, is the value to convert. If a number is passed, as in
5363
- * `char(65)`, the corresponding single-character string is returned. If a
5364
- * string is passed, as in `char('65')`, the string is converted to an integer
5365
- * (whole number) and the corresponding single-character string is returned.
5366
- * If an array is passed, as in `char([65, 66, 67])`, an array of
5367
- * single-character strings is returned.
5353
+ * The parameter, `n`, is the value to convert. If a number is passed, as in
5354
+ * `char(65)`, the corresponding single-character string is returned. If a
5355
+ * string is passed, as in `char('65')`, the string is converted to an integer
5356
+ * (whole number) and the corresponding single-character string is returned.
5357
+ * If an array is passed, as in `char([65, 66, 67])`, an array of
5358
+ * single-character strings is returned.
5368
5359
  *
5369
5360
  * See <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode" target="_blank">MDN</a>
5370
5361
  * for more information about conversions.
@@ -5498,7 +5489,7 @@ declare class p5 {
5498
5489
  * (<a href="https://developer.mozilla.org/en-US/docs/Web/XML/XML_introduction" target="_blank">XML</a>)
5499
5490
  * is a standard format for sending data between applications. Like HTML, the
5500
5491
  * XML format is based on tags and attributes, as in
5501
- * `&lt;time units="s"&gt;1234&lt;/time&gt;`.
5492
+ * `<time units="s">1234</time>`.
5502
5493
  *
5503
5494
  * The first parameter, `path`, is always a string with the path to the file.
5504
5495
  * Paths to local files should be relative, as in
@@ -5667,6 +5658,33 @@ declare class p5 {
5667
5658
  angleMode(mode: typeof p5.RADIANS | typeof p5.DEGREES): typeof p5.RADIANS | typeof p5.DEGREES;
5668
5659
  angleMode(): typeof p5.RADIANS | typeof p5.DEGREES;
5669
5660
 
5661
+ /**
5662
+ * Draws a sphere.
5663
+ *
5664
+ * A sphere is a 3D shape with triangular faces that connect to form a round
5665
+ * surface. Spheres with few faces look like crystals. Spheres with many faces
5666
+ * have smooth surfaces and look like balls.
5667
+ *
5668
+ * The first parameter, `radius`, is optional. If a `Number` is passed, as in
5669
+ * `sphere(20)`, it sets the radius of the sphere. By default, `radius` is 50.
5670
+ *
5671
+ * The second parameter, `detailX`, is also optional. If a `Number` is passed,
5672
+ * as in `sphere(20, 5)`, it sets the number of triangle subdivisions to use
5673
+ * along the x-axis. All 3D shapes are made by connecting triangles to form
5674
+ * their surfaces. By default, `detailX` is 24.
5675
+ *
5676
+ * The third parameter, `detailY`, is also optional. If a `Number` is passed,
5677
+ * as in `sphere(20, 5, 2)`, it sets the number of triangle subdivisions to
5678
+ * use along the y-axis. All 3D shapes are made by connecting triangles to
5679
+ * form their surfaces. By default, `detailY` is 16.
5680
+ *
5681
+ * Note: `sphere()` can only be used in WebGL mode.
5682
+ * @param radius radius of the sphere. Defaults to 50.
5683
+ * @param detailX number of triangle subdivisions along the x-axis. Defaults to 24.
5684
+ * @param detailY number of triangle subdivisions along the y-axis. Defaults to 16.
5685
+ */
5686
+ sphere(radius?: number, detailX?: number, detailY?: number): void;
5687
+
5670
5688
  /**
5671
5689
  * Loads the current value of each pixel on the canvas into the
5672
5690
  * <a href="#/p5/pixels">pixels</a> array.
@@ -5676,17 +5694,6 @@ declare class p5 {
5676
5694
  */
5677
5695
  loadPixels(): void;
5678
5696
 
5679
- /**
5680
- * This method is suitable for fetching files up to size of 64MB.
5681
- * @param file name of the file or URL to load
5682
- * @param callback function to be executed after <a href="#/p5/loadBytes">loadBytes()</a>
5683
- * completes
5684
- * @param errorCallback function to be executed if there
5685
- * is an error
5686
- * @returns a Uint8Array containing the loaded buffer
5687
- */
5688
- loadBytes(file: string | Request, callback?: Function, errorCallback?: Function): Promise<Uint8Array>;
5689
-
5690
5697
  /**
5691
5698
  * Creates a <a href="#/p5.Shader">p5.Shader</a> object to be used with the
5692
5699
  * <a href="#/p5/filter">filter()</a> function.
@@ -5783,7 +5790,7 @@ declare class p5 {
5783
5790
  * filterColor.texCoord.x // x coordinate, from 0 to 1
5784
5791
  * ));
5785
5792
  * filterColor.end();
5786
- * }`You can also animate your filters over time by passing the time into the shader with `uniformFloat`.
5793
+ * }`You can also animate your filters over time using the `millis()` function.
5787
5794
  *
5788
5795
  * `let myFilter;
5789
5796
  * function setup() {
@@ -5793,7 +5800,7 @@ declare class p5 {
5793
5800
  * }
5794
5801
  *
5795
5802
  * function gradient() {
5796
- * let time = uniformFloat();
5803
+ * let time = millis();
5797
5804
  * filterColor.begin();
5798
5805
  * filterColor.set(mix(
5799
5806
  * [1, 0, 0, 1], // Red
@@ -5804,9 +5811,8 @@ declare class p5 {
5804
5811
  * }
5805
5812
  *
5806
5813
  * function draw() {
5807
- * myFilter.setUniform('time', millis());
5808
5814
  * filter(myFilter);
5809
- * }`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.
5815
+ * }`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.
5810
5816
  *
5811
5817
  * `let myFilter;
5812
5818
  *
@@ -5817,7 +5823,7 @@ declare class p5 {
5817
5823
  * }
5818
5824
  *
5819
5825
  * function noiseShaderCallback() {
5820
- * let time = uniformFloat();
5826
+ * let time = millis();
5821
5827
  * filterColor.begin();
5822
5828
  * let coord = filterColor.texCoord;
5823
5829
  *
@@ -5834,7 +5840,6 @@ declare class p5 {
5834
5840
  * }
5835
5841
  *
5836
5842
  * function draw() {
5837
- * myFilter.setUniform("time", millis());
5838
5843
  * filter(myFilter);
5839
5844
  * }`Like the `modify()` method on shaders,
5840
5845
  * 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>
@@ -5853,7 +5858,18 @@ declare class p5 {
5853
5858
  buildFilterShader(hooks: object, scope?: object): p5.Shader;
5854
5859
 
5855
5860
  /**
5856
- * Creates a slider `&lt;input&gt;&lt;/input&gt;` element.
5861
+ * This method is suitable for fetching files up to size of 64MB.
5862
+ * @param file name of the file or URL to load
5863
+ * @param callback function to be executed after <a href="#/p5/loadBytes">loadBytes()</a>
5864
+ * completes
5865
+ * @param errorCallback function to be executed if there
5866
+ * is an error
5867
+ * @returns a Uint8Array containing the loaded buffer
5868
+ */
5869
+ loadBytes(file: string | Request, callback?: Function, errorCallback?: Function): Promise<Uint8Array>;
5870
+
5871
+ /**
5872
+ * Creates a slider `<input></input>` element.
5857
5873
  *
5858
5874
  * Range sliders are useful for quickly selecting numbers from a given range.
5859
5875
  *
@@ -5890,33 +5906,6 @@ declare class p5 {
5890
5906
  */
5891
5907
  norm(value: number, start: number, stop: number): number;
5892
5908
 
5893
- /**
5894
- * Draws a sphere.
5895
- *
5896
- * A sphere is a 3D shape with triangular faces that connect to form a round
5897
- * surface. Spheres with few faces look like crystals. Spheres with many faces
5898
- * have smooth surfaces and look like balls.
5899
- *
5900
- * The first parameter, `radius`, is optional. If a `Number` is passed, as in
5901
- * `sphere(20)`, it sets the radius of the sphere. By default, `radius` is 50.
5902
- *
5903
- * The second parameter, `detailX`, is also optional. If a `Number` is passed,
5904
- * as in `sphere(20, 5)`, it sets the number of triangle subdivisions to use
5905
- * along the x-axis. All 3D shapes are made by connecting triangles to form
5906
- * their surfaces. By default, `detailX` is 24.
5907
- *
5908
- * The third parameter, `detailY`, is also optional. If a `Number` is passed,
5909
- * as in `sphere(20, 5, 2)`, it sets the number of triangle subdivisions to
5910
- * use along the y-axis. All 3D shapes are made by connecting triangles to
5911
- * form their surfaces. By default, `detailY` is 16.
5912
- *
5913
- * Note: `sphere()` can only be used in WebGL mode.
5914
- * @param radius radius of the sphere. Defaults to 50.
5915
- * @param detailX number of triangle subdivisions along the x-axis. Defaults to 24.
5916
- * @param detailY number of triangle subdivisions along the y-axis. Defaults to 16.
5917
- */
5918
- sphere(radius?: number, detailX?: number, detailY?: number): void;
5919
-
5920
5909
  /**
5921
5910
  * A function that's called once when any key is released.
5922
5911
  *
@@ -6107,7 +6096,7 @@ declare class p5 {
6107
6096
  alpha(color: p5.Color | number[] | string): number;
6108
6097
 
6109
6098
  /**
6110
- * Creates a `&lt;button&gt;&lt;/button&gt;` element.
6099
+ * Creates a `<button></button>` element.
6111
6100
  *
6112
6101
  * The first parameter, `label`, is a string that sets the label displayed on
6113
6102
  * the button.
@@ -6398,7 +6387,7 @@ declare class p5 {
6398
6387
  panorama(img: p5.Image): void;
6399
6388
 
6400
6389
  /**
6401
- * Creates a checkbox `&lt;input&gt;&lt;/input&gt;` element.
6390
+ * Creates a checkbox `<input></input>` element.
6402
6391
  *
6403
6392
  * Checkboxes extend the <a href="#/p5.Element">p5.Element</a> class with a
6404
6393
  * `checked()` method. Calling `myBox.checked()` returns `true` if it the box
@@ -6474,6 +6463,50 @@ declare class p5 {
6474
6463
  */
6475
6464
  hue(color: p5.Color | number[] | string): number;
6476
6465
 
6466
+ /**
6467
+ * Draws a cylinder.
6468
+ *
6469
+ * A cylinder is a 3D shape with triangular faces that connect a flat bottom
6470
+ * to a flat top. Cylinders with few faces look like boxes. Cylinders with
6471
+ * many faces have smooth surfaces.
6472
+ *
6473
+ * The first parameter, `radius`, is optional. If a `Number` is passed, as in
6474
+ * `cylinder(20)`, it sets the radius of the cylinder’s base. By default,
6475
+ * `radius` is 50.
6476
+ *
6477
+ * The second parameter, `height`, is also optional. If a `Number` is passed,
6478
+ * as in `cylinder(20, 30)`, it sets the cylinder’s height. By default,
6479
+ * `height` is set to the cylinder’s `radius`.
6480
+ *
6481
+ * The third parameter, `detailX`, is also optional. If a `Number` is passed,
6482
+ * as in `cylinder(20, 30, 5)`, it sets the number of edges used to form the
6483
+ * cylinder's top and bottom. Using more edges makes the top and bottom look
6484
+ * more like circles. By default, `detailX` is 24.
6485
+ *
6486
+ * The fourth parameter, `detailY`, is also optional. If a `Number` is passed,
6487
+ * as in `cylinder(20, 30, 5, 2)`, it sets the number of triangle subdivisions
6488
+ * to use along the y-axis, between cylinder's the top and bottom. All 3D
6489
+ * shapes are made by connecting triangles to form their surfaces. By default,
6490
+ * `detailY` is 1.
6491
+ *
6492
+ * The fifth parameter, `bottomCap`, is also optional. If a `false` is passed,
6493
+ * as in `cylinder(20, 30, 5, 2, false)` the cylinder’s bottom won’t be drawn.
6494
+ * By default, `bottomCap` is `true`.
6495
+ *
6496
+ * The sixth parameter, `topCap`, is also optional. If a `false` is passed, as
6497
+ * in `cylinder(20, 30, 5, 2, false, false)` the cylinder’s top won’t be
6498
+ * drawn. By default, `topCap` is `true`.
6499
+ *
6500
+ * Note: `cylinder()` can only be used in WebGL mode.
6501
+ * @param radius radius of the cylinder. Defaults to 50.
6502
+ * @param height height of the cylinder. Defaults to the value of `radius`.
6503
+ * @param detailX number of edges along the top and bottom. Defaults to 24.
6504
+ * @param detailY number of triangle subdivisions along the y-axis. Defaults to 1.
6505
+ * @param bottomCap whether to draw the cylinder's bottom. Defaults to `true`.
6506
+ * @param topCap whether to draw the cylinder's top. Defaults to `true`.
6507
+ */
6508
+ cylinder(radius?: number, height?: number, detailX?: number, detailY?: number, bottomCap?: boolean, topCap?: boolean): void;
6509
+
6477
6510
  /**
6478
6511
  * Scales the coordinate system.
6479
6512
  *
@@ -6593,50 +6626,6 @@ declare class p5 {
6593
6626
  httpPost(path: string | Request, data: object | boolean, callback?: Function, errorCallback?: Function): Promise<any>;
6594
6627
  httpPost(path: string | Request, callback?: Function, errorCallback?: Function): Promise<any>;
6595
6628
 
6596
- /**
6597
- * Draws a cylinder.
6598
- *
6599
- * A cylinder is a 3D shape with triangular faces that connect a flat bottom
6600
- * to a flat top. Cylinders with few faces look like boxes. Cylinders with
6601
- * many faces have smooth surfaces.
6602
- *
6603
- * The first parameter, `radius`, is optional. If a `Number` is passed, as in
6604
- * `cylinder(20)`, it sets the radius of the cylinder’s base. By default,
6605
- * `radius` is 50.
6606
- *
6607
- * The second parameter, `height`, is also optional. If a `Number` is passed,
6608
- * as in `cylinder(20, 30)`, it sets the cylinder’s height. By default,
6609
- * `height` is set to the cylinder’s `radius`.
6610
- *
6611
- * The third parameter, `detailX`, is also optional. If a `Number` is passed,
6612
- * as in `cylinder(20, 30, 5)`, it sets the number of edges used to form the
6613
- * cylinder's top and bottom. Using more edges makes the top and bottom look
6614
- * more like circles. By default, `detailX` is 24.
6615
- *
6616
- * The fourth parameter, `detailY`, is also optional. If a `Number` is passed,
6617
- * as in `cylinder(20, 30, 5, 2)`, it sets the number of triangle subdivisions
6618
- * to use along the y-axis, between cylinder's the top and bottom. All 3D
6619
- * shapes are made by connecting triangles to form their surfaces. By default,
6620
- * `detailY` is 1.
6621
- *
6622
- * The fifth parameter, `bottomCap`, is also optional. If a `false` is passed,
6623
- * as in `cylinder(20, 30, 5, 2, false)` the cylinder’s bottom won’t be drawn.
6624
- * By default, `bottomCap` is `true`.
6625
- *
6626
- * The sixth parameter, `topCap`, is also optional. If a `false` is passed, as
6627
- * in `cylinder(20, 30, 5, 2, false, false)` the cylinder’s top won’t be
6628
- * drawn. By default, `topCap` is `true`.
6629
- *
6630
- * Note: `cylinder()` can only be used in WebGL mode.
6631
- * @param radius radius of the cylinder. Defaults to 50.
6632
- * @param height height of the cylinder. Defaults to the value of `radius`.
6633
- * @param detailX number of edges along the top and bottom. Defaults to 24.
6634
- * @param detailY number of triangle subdivisions along the y-axis. Defaults to 1.
6635
- * @param bottomCap whether to draw the cylinder's bottom. Defaults to `true`.
6636
- * @param topCap whether to draw the cylinder's top. Defaults to `true`.
6637
- */
6638
- cylinder(radius?: number, height?: number, detailX?: number, detailY?: number, bottomCap?: boolean, topCap?: boolean): void;
6639
-
6640
6629
  /**
6641
6630
  * Returns the sketch's current
6642
6631
  * <a href="https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Web_mechanics/What_is_a_URL" target="_blank">URL</a>
@@ -6970,104 +6959,6 @@ declare class p5 {
6970
6959
  */
6971
6960
  lightFalloff(constant: number, linear: number, quadratic: number): void;
6972
6961
 
6973
- /**
6974
- * A function that's called when the mouse moves.
6975
- *
6976
- * Declaring the function `mouseMoved()` sets a code block to run
6977
- * automatically when the user moves the mouse without clicking any mouse
6978
- * buttons:
6979
- *
6980
- * `function mouseMoved() {
6981
- * // Code to run.
6982
- * }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
6983
- * <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
6984
- * value when `mouseMoved()` is called by p5.js:
6985
- *
6986
- * `function mouseMoved() {
6987
- * if (mouseX < 50) {
6988
- * // Code to run if the mouse is on the left.
6989
- * }
6990
- *
6991
- * if (mouseY > 50) {
6992
- * // Code to run if the mouse is near the bottom.
6993
- * }
6994
- * }`The parameter, `event`, is optional. `mouseMoved()` is always passed a
6995
- * <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
6996
- * object with properties that describe the mouse move event:
6997
- *
6998
- * `function mouseMoved(event) {
6999
- * // Code to run that uses the event.
7000
- * console.log(event);
7001
- * }`Browsers may have default behaviors attached to various mouse events. For
7002
- * example, some browsers highlight text when the user moves the mouse while
7003
- * pressing a mouse button. To prevent any default behavior for this event,
7004
- * add `return false;` to the end of the function.
7005
- * @param event optional `MouseEvent` argument.
7006
- */
7007
- mouseMoved(event?: MouseEvent): void;
7008
-
7009
- /**
7010
- * A function that's called when the mouse moves while a button is pressed.
7011
- *
7012
- * Declaring the function `mouseDragged()` sets a code block to run
7013
- * automatically when the user clicks and drags the mouse:
7014
- *
7015
- * `function mouseDragged() {
7016
- * // Code to run.
7017
- * }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
7018
- * <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
7019
- * value when `mouseDragged()` is called by p5.js:
7020
- *
7021
- * `function mouseDragged() {
7022
- * if (mouseX < 50) {
7023
- * // Code to run if the mouse is on the left.
7024
- * }
7025
- *
7026
- * if (mouseY > 50) {
7027
- * // Code to run if the mouse is near the bottom.
7028
- * }
7029
- * }`The parameter, `event`, is optional. `mouseDragged()` is always passed a
7030
- * <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
7031
- * object with properties that describe the mouse drag event:
7032
- *
7033
- * `function mouseDragged(event) {
7034
- * // Code to run that uses the event.
7035
- * console.log(event);
7036
- * }`On touchscreen devices, `mouseDragged()` will run when a user moves a touch
7037
- * point.
7038
- *
7039
- * Browsers may have default behaviors attached to various mouse events. For
7040
- * example, some browsers highlight text when the user moves the mouse while
7041
- * pressing a mouse button. To prevent any default behavior for this event,
7042
- * add `return false;` to the end of the function.
7043
- * @param event optional `MouseEvent` argument.
7044
- */
7045
- mouseDragged(event?: MouseEvent): void;
7046
-
7047
- /**
7048
- * Returns `true` if the key it’s checking is pressed and `false` if not.
7049
- *
7050
- * `keyIsDown()` is helpful when checking for multiple different key presses.
7051
- * For example, `keyIsDown()` can be used to check if both `LEFT_ARROW` and
7052
- * `UP_ARROW` are pressed:
7053
- *
7054
- * `if (keyIsDown(LEFT_ARROW) && keyIsDown(UP_ARROW)) {
7055
- * // Move diagonally.
7056
- * }``keyIsDown()` can check for key presses using strings based on
7057
- * <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key" target="_blank">KeyboardEvent.key</a>
7058
- * or <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code" target="_blank">KeyboardEvent.code</a> values,
7059
- * such as `keyIsDown('x')` or `keyIsDown('ArrowLeft')`.
7060
- *
7061
- * Note: In p5.js 2.0 and newer, numeric keycodes (such as 88 for 'X') are no longer supported.
7062
- * This is a breaking change from previous versions.
7063
- *
7064
- * You can still use the p5 constants like `LEFT_ARROW` which now map to string values
7065
- * internally rather than numeric codes.
7066
- * @param code key to check.
7067
- * @returns whether the key is down or not.
7068
- */
7069
- keyIsDown(code: number | string): boolean;
7070
-
7071
6962
  /**
7072
6963
  * Sets the <a href="#/p5.Shader">p5.Shader</a> object to apply while drawing.
7073
6964
  *
@@ -7107,7 +6998,7 @@ declare class p5 {
7107
6998
  * }
7108
6999
  *
7109
7000
  * function material() {
7110
- * let time = uniformFloat();
7001
+ * let time = millis() / 1000;
7111
7002
  * finalColor.begin();
7112
7003
  * let r = 0.2 + 0.5 * abs(sin(time + 0));
7113
7004
  * let g = 0.2 + 0.5 * abs(sin(time + 1));
@@ -7118,7 +7009,6 @@ declare class p5 {
7118
7009
  *
7119
7010
  * function draw() {
7120
7011
  * background(245, 245, 220);
7121
- * myShader.setUniform('time', millis() / 1000);
7122
7012
  * shader(myShader);
7123
7013
  *
7124
7014
  * rectMode(CENTER);
@@ -7176,66 +7066,164 @@ declare class p5 {
7176
7066
  * torus(25, 10, 30, 30);
7177
7067
  * }``let fillShader;
7178
7068
  *
7179
- * let vertSrc = `
7180
- * precision highp float;
7181
- * attribute vec3 aPosition;
7182
- * uniform mat4 uProjectionMatrix;
7183
- * uniform mat4 uModelViewMatrix;
7184
- * varying vec3 vPosition;
7185
- * void main() {
7186
- * vPosition = aPosition;
7187
- * gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(aPosition, 1.0);
7188
- * }
7189
- * `;
7069
+ * let vertSrc = `
7070
+ * precision highp float;
7071
+ * attribute vec3 aPosition;
7072
+ * uniform mat4 uProjectionMatrix;
7073
+ * uniform mat4 uModelViewMatrix;
7074
+ * varying vec3 vPosition;
7075
+ * void main() {
7076
+ * vPosition = aPosition;
7077
+ * gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(aPosition, 1.0);
7078
+ * }
7079
+ * `;
7080
+ *
7081
+ * let fragSrc = `
7082
+ * precision highp float;
7083
+ * uniform vec3 uLightPos;
7084
+ * uniform vec3 uFillColor;
7085
+ * varying vec3 vPosition;
7086
+ * void main() {
7087
+ * float brightness = dot(normalize(uLightPos), normalize(vPosition));
7088
+ * brightness = clamp(brightness, 0.0, 1.0);
7089
+ * vec3 color = uFillColor * brightness;
7090
+ * gl_FragColor = vec4(color, 1.0);
7091
+ * }
7092
+ * `;
7093
+ *
7094
+ * function setup() {
7095
+ * createCanvas(200, 200, WEBGL);
7096
+ * fillShader = createShader(vertSrc, fragSrc);
7097
+ * shader(fillShader);
7098
+ * noStroke();
7099
+ * describe('A square affected by both fill color and lighting, with lights controlled by mouse.');
7100
+ * }
7101
+ *
7102
+ * function draw() {
7103
+ * let lightPos = [(mouseX - width / 2) / width,
7104
+ * (mouseY - height / 2) / height, 1.0];
7105
+ * fillShader.setUniform('uLightPos', lightPos);
7106
+ * let fillColor = [map(mouseX, 0, width, 0, 1),
7107
+ * map(mouseY, 0, height, 0, 1), 0.5];
7108
+ * fillShader.setUniform('uFillColor', fillColor);
7109
+ * plane(width, height);
7110
+ * }`<div>
7111
+ * <p>If you want to apply shaders to strokes or images, use the following methods:
7112
+ *
7113
+ * - <a href="#/p5/strokeShader">strokeShader()</a> : Applies a shader to the stroke (outline) of shapes, allowing independent control over the stroke rendering using shaders.
7114
+ *
7115
+ * - <a href="#/p5/imageShader">imageShader()</a> : Applies a shader to images or textures, controlling how the shader modifies their appearance during rendering.
7116
+ *
7117
+ * </p>
7118
+ * </div>
7119
+ * @param s <a href="#/p5.Shader">p5.Shader</a> object
7120
+ * to apply.
7121
+ */
7122
+ shader(s: p5.Shader): void;
7123
+
7124
+ /**
7125
+ * A function that's called when the mouse moves.
7126
+ *
7127
+ * Declaring the function `mouseMoved()` sets a code block to run
7128
+ * automatically when the user moves the mouse without clicking any mouse
7129
+ * buttons:
7130
+ *
7131
+ * `function mouseMoved() {
7132
+ * // Code to run.
7133
+ * }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
7134
+ * <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
7135
+ * value when `mouseMoved()` is called by p5.js:
7136
+ *
7137
+ * `function mouseMoved() {
7138
+ * if (mouseX < 50) {
7139
+ * // Code to run if the mouse is on the left.
7140
+ * }
7141
+ *
7142
+ * if (mouseY > 50) {
7143
+ * // Code to run if the mouse is near the bottom.
7144
+ * }
7145
+ * }`The parameter, `event`, is optional. `mouseMoved()` is always passed a
7146
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
7147
+ * object with properties that describe the mouse move event:
7148
+ *
7149
+ * `function mouseMoved(event) {
7150
+ * // Code to run that uses the event.
7151
+ * console.log(event);
7152
+ * }`Browsers may have default behaviors attached to various mouse events. For
7153
+ * example, some browsers highlight text when the user moves the mouse while
7154
+ * pressing a mouse button. To prevent any default behavior for this event,
7155
+ * add `return false;` to the end of the function.
7156
+ * @param event optional `MouseEvent` argument.
7157
+ */
7158
+ mouseMoved(event?: MouseEvent): void;
7159
+
7160
+ /**
7161
+ * A function that's called when the mouse moves while a button is pressed.
7162
+ *
7163
+ * Declaring the function `mouseDragged()` sets a code block to run
7164
+ * automatically when the user clicks and drags the mouse:
7165
+ *
7166
+ * `function mouseDragged() {
7167
+ * // Code to run.
7168
+ * }`The mouse system variables, such as <a href="#/p5/mouseX">mouseX</a> and
7169
+ * <a href="#/p5/mouseY">mouseY</a>, will be updated with their most recent
7170
+ * value when `mouseDragged()` is called by p5.js:
7190
7171
  *
7191
- * let fragSrc = `
7192
- * precision highp float;
7193
- * uniform vec3 uLightPos;
7194
- * uniform vec3 uFillColor;
7195
- * varying vec3 vPosition;
7196
- * void main() {
7197
- * float brightness = dot(normalize(uLightPos), normalize(vPosition));
7198
- * brightness = clamp(brightness, 0.0, 1.0);
7199
- * vec3 color = uFillColor * brightness;
7200
- * gl_FragColor = vec4(color, 1.0);
7172
+ * `function mouseDragged() {
7173
+ * if (mouseX < 50) {
7174
+ * // Code to run if the mouse is on the left.
7201
7175
  * }
7202
- * `;
7203
7176
  *
7204
- * function setup() {
7205
- * createCanvas(200, 200, WEBGL);
7206
- * fillShader = createShader(vertSrc, fragSrc);
7207
- * shader(fillShader);
7208
- * noStroke();
7209
- * describe('A square affected by both fill color and lighting, with lights controlled by mouse.');
7177
+ * if (mouseY > 50) {
7178
+ * // Code to run if the mouse is near the bottom.
7210
7179
  * }
7180
+ * }`The parameter, `event`, is optional. `mouseDragged()` is always passed a
7181
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent" target="_blank">MouseEvent</a>
7182
+ * object with properties that describe the mouse drag event:
7211
7183
  *
7212
- * function draw() {
7213
- * let lightPos = [(mouseX - width / 2) / width,
7214
- * (mouseY - height / 2) / height, 1.0];
7215
- * fillShader.setUniform('uLightPos', lightPos);
7216
- * let fillColor = [map(mouseX, 0, width, 0, 1),
7217
- * map(mouseY, 0, height, 0, 1), 0.5];
7218
- * fillShader.setUniform('uFillColor', fillColor);
7219
- * plane(width, height);
7220
- * }`<div>
7221
- * <p>If you want to apply shaders to strokes or images, use the following methods:
7184
+ * `function mouseDragged(event) {
7185
+ * // Code to run that uses the event.
7186
+ * console.log(event);
7187
+ * }`On touchscreen devices, `mouseDragged()` will run when a user moves a touch
7188
+ * point.
7222
7189
  *
7223
- * - <a href="#/p5/strokeShader">strokeShader()</a> : Applies a shader to the stroke (outline) of shapes, allowing independent control over the stroke rendering using shaders.
7190
+ * Browsers may have default behaviors attached to various mouse events. For
7191
+ * example, some browsers highlight text when the user moves the mouse while
7192
+ * pressing a mouse button. To prevent any default behavior for this event,
7193
+ * add `return false;` to the end of the function.
7194
+ * @param event optional `MouseEvent` argument.
7195
+ */
7196
+ mouseDragged(event?: MouseEvent): void;
7197
+
7198
+ /**
7199
+ * Returns `true` if the key it’s checking is pressed and `false` if not.
7224
7200
  *
7225
- * - <a href="#/p5/imageShader">imageShader()</a> : Applies a shader to images or textures, controlling how the shader modifies their appearance during rendering.
7201
+ * `keyIsDown()` is helpful when checking for multiple different key presses.
7202
+ * For example, `keyIsDown()` can be used to check if both `LEFT_ARROW` and
7203
+ * `UP_ARROW` are pressed:
7226
7204
  *
7227
- * </p>
7228
- * </div>
7229
- * @param s <a href="#/p5.Shader">p5.Shader</a> object
7230
- * to apply.
7205
+ * `if (keyIsDown(LEFT_ARROW) && keyIsDown(UP_ARROW)) {
7206
+ * // Move diagonally.
7207
+ * }``keyIsDown()` can check for key presses using strings based on
7208
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key" target="_blank">KeyboardEvent.key</a>
7209
+ * or <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code" target="_blank">KeyboardEvent.code</a> values,
7210
+ * such as `keyIsDown('x')` or `keyIsDown('ArrowLeft')`.
7211
+ *
7212
+ * Note: In p5.js 2.0 and newer, numeric keycodes (such as 88 for 'X') are no longer supported.
7213
+ * This is a breaking change from previous versions.
7214
+ *
7215
+ * You can still use the p5 constants like `LEFT_ARROW` which now map to string values
7216
+ * internally rather than numeric codes.
7217
+ * @param code key to check.
7218
+ * @returns whether the key is down or not.
7231
7219
  */
7232
- shader(s: p5.Shader): void;
7220
+ keyIsDown(code: number | string): boolean;
7233
7221
 
7234
7222
  /**
7235
7223
  * Sets the element's content.
7236
7224
  *
7237
7225
  * An element's content is the text between its tags. For example, the element
7238
- * `&lt;language&gt;JavaScript&lt;/language&gt;` has the content `JavaScript`.
7226
+ * `<language>JavaScript</language>` has the content `JavaScript`.
7239
7227
  *
7240
7228
  * The parameter, `content`, is a string with the element's new content.
7241
7229
  * @param content new content for the element.
@@ -7248,9 +7236,7 @@ declare class p5 {
7248
7236
  * The parameter, `model`, is the
7249
7237
  * <a href="#/p5.Geometry">p5.Geometry</a> object to draw.
7250
7238
  * <a href="#/p5.Geometry">p5.Geometry</a> objects can be built with
7251
- * <a href="#/p5/buildGeometry">buildGeometry()</a>, or
7252
- * <a href="#/p5/beginGeometry">beginGeometry()</a> and
7253
- * <a href="#/p5/endGeometry">endGeometry()</a>. They can also be loaded from
7239
+ * <a href="#/p5/buildGeometry">buildGeometry()</a>. They can also be loaded from
7254
7240
  * a file with <a href="#/p5/loadGeometry">loadGeometry()</a>.
7255
7241
  *
7256
7242
  * Note: `model()` can only be used in WebGL mode.
@@ -7358,11 +7344,11 @@ declare class p5 {
7358
7344
  saturation(color: p5.Color | number[] | string): number;
7359
7345
 
7360
7346
  /**
7361
- * Creates a dropdown menu `&lt;select&gt;&lt;/select&gt;` element.
7347
+ * Creates a dropdown menu `<select></select>` element.
7362
7348
  *
7363
7349
  * The parameter is optional. If `true` is passed, as in
7364
7350
  * `let mySelect = createSelect(true)`, then the dropdown will support
7365
- * multiple selections. If an existing `&lt;select&gt;&lt;/select&gt;` element
7351
+ * multiple selections. If an existing `<select></select>` element
7366
7352
  * is passed, as in `let mySelect = createSelect(otherSelect)`, the existing
7367
7353
  * element will be wrapped in a new <a href="#/p5.Element">p5.Element</a>
7368
7354
  * object.
@@ -7391,20 +7377,6 @@ declare class p5 {
7391
7377
  createSelect(multiple?: boolean): p5.Element;
7392
7378
  createSelect(existing: object): p5.Element;
7393
7379
 
7394
- /**
7395
- * Converts 3D world coordinates to 2D screen coordinates.
7396
- *
7397
- * This function takes a 3D vector and converts its coordinates
7398
- * from the world space to screen space. This can be useful for placing
7399
- * 2D elements in a 3D scene or for determining the screen position
7400
- * of 3D objects.
7401
- * @param x The x coordinate in world space. (Or a vector for all three coordinates.)
7402
- * @param y The y coordinate in world space.
7403
- * @param z The z coordinate in world space.
7404
- * @returns A vector containing the 2D screen coordinates.
7405
- */
7406
- worldToScreen(x: number | p5.Vector, y: number, z?: number): p5.Vector;
7407
-
7408
7380
  /**
7409
7381
  * Draws a cone.
7410
7382
  *
@@ -7443,6 +7415,20 @@ declare class p5 {
7443
7415
  */
7444
7416
  cone(radius?: number, height?: number, detailX?: number, detailY?: number, cap?: boolean): void;
7445
7417
 
7418
+ /**
7419
+ * Converts 3D world coordinates to 2D screen coordinates.
7420
+ *
7421
+ * This function takes a 3D vector and converts its coordinates
7422
+ * from the world space to screen space. This can be useful for placing
7423
+ * 2D elements in a 3D scene or for determining the screen position
7424
+ * of 3D objects.
7425
+ * @param x The x coordinate in world space. (Or a vector for all three coordinates.)
7426
+ * @param y The y coordinate in world space.
7427
+ * @param z The z coordinate in world space.
7428
+ * @returns A vector containing the 2D screen coordinates.
7429
+ */
7430
+ worldToScreen(x: number | p5.Vector, y: number, z?: number): p5.Vector;
7431
+
7446
7432
  /**
7447
7433
  * Load a 3d model from an OBJ or STL string.
7448
7434
  *
@@ -8244,6 +8230,25 @@ declare class p5 {
8244
8230
  */
8245
8231
  lightness(color: p5.Color | number[] | string): number;
8246
8232
 
8233
+ /**
8234
+ * Sets the <a href="#/p5.Shader">p5.Shader</a> object to apply for images.
8235
+ *
8236
+ * This method allows the user to apply a custom shader to images, enabling
8237
+ * advanced visual effects such as pixel manipulation, color adjustments,
8238
+ * or dynamic behavior. The shader will be applied to the image drawn using
8239
+ * the <a href="#/p5/image">image()</a> function.
8240
+ *
8241
+ * The shader will be used exclusively for:
8242
+ *
8243
+ * - `image()` calls, applying only when drawing 2D images.
8244
+ *
8245
+ * - This shader will NOT apply to images used in <a href="#/p5/texture">texture()</a> or other 3D contexts.
8246
+ * Any attempts to use the imageShader in these cases will be ignored.
8247
+ * @param s <a href="#/p5.Shader">p5.Shader</a> object
8248
+ * to apply for images.
8249
+ */
8250
+ imageShader(s: p5.Shader): void;
8251
+
8247
8252
  /**
8248
8253
  * Changes the location from which images are drawn when
8249
8254
  * <a href="#/p5/image">image()</a> is called.
@@ -8265,25 +8270,6 @@ declare class p5 {
8265
8270
  */
8266
8271
  imageMode(mode: typeof p5.CORNER | typeof p5.CORNERS | typeof p5.CENTER): void;
8267
8272
 
8268
- /**
8269
- * Sets the <a href="#/p5.Shader">p5.Shader</a> object to apply for images.
8270
- *
8271
- * This method allows the user to apply a custom shader to images, enabling
8272
- * advanced visual effects such as pixel manipulation, color adjustments,
8273
- * or dynamic behavior. The shader will be applied to the image drawn using
8274
- * the <a href="#/p5/image">image()</a> function.
8275
- *
8276
- * The shader will be used exclusively for:
8277
- *
8278
- * - `image()` calls, applying only when drawing 2D images.
8279
- *
8280
- * - This shader will NOT apply to images used in <a href="#/p5/texture">texture()</a> or other 3D contexts.
8281
- * Any attempts to use the imageShader in these cases will be ignored.
8282
- * @param s <a href="#/p5.Shader">p5.Shader</a> object
8283
- * to apply for images.
8284
- */
8285
- imageShader(s: p5.Shader): void;
8286
-
8287
8273
  /**
8288
8274
  * A function that's called once when a mouse button is released.
8289
8275
  *
@@ -8357,8 +8343,8 @@ declare class p5 {
8357
8343
  *
8358
8344
  * The parameter is optional. If a string is passed, as in
8359
8345
  * `let myRadio = createSelect('food')`, then each radio option will
8360
- * have `"food"` as its `name` parameter: `&lt;input name="food"&gt;&lt;/input&gt;`.
8361
- * If an existing `&lt;div&gt;&lt;/div&gt;` or `&lt;span&gt;&lt;/span&gt;`
8346
+ * have `"food"` as its `name` parameter: `<input name="food"></input>`.
8347
+ * If an existing `<div></div>` or `<span></span>`
8362
8348
  * element is passed, as in `let myRadio = createSelect(container)`, it will
8363
8349
  * become the radio button's parent element.
8364
8350
  *
@@ -8374,8 +8360,8 @@ declare class p5 {
8374
8360
  * - `myRadio.selected(value)` selects the given option and returns it as an <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement" target="_blank">`HTMLInputElement`</a>.
8375
8361
  *
8376
8362
  * - `myRadio.disable(shouldDisable)` enables the entire radio button if `true` is passed and disables it if `false` is passed.
8377
- * @param containerElement container HTML Element, either a `&lt;div&gt;&lt;/div&gt;`
8378
- * or `&lt;span&gt;&lt;/span&gt;`.
8363
+ * @param containerElement container HTML Element, either a `<div></div>`
8364
+ * or `<span></span>`.
8379
8365
  * @returns new <a href="#/p5.Element">p5.Element</a> object.
8380
8366
  */
8381
8367
  createRadio(containerElement?: object): p5.Element;
@@ -8383,7 +8369,7 @@ declare class p5 {
8383
8369
  createRadio(): p5.Element;
8384
8370
 
8385
8371
  /**
8386
- * Creates a `&lt;video&gt;` element for simple audio/video playback.
8372
+ * Creates a `<video>` element for simple audio/video playback.
8387
8373
  *
8388
8374
  * `createVideo()` returns a new
8389
8375
  * <a href="#/p5.MediaElement">p5.MediaElement</a> object. Videos are shown by
@@ -8472,7 +8458,7 @@ declare class p5 {
8472
8458
  lerpColor(c1: p5.Color, c2: p5.Color, amt: number): p5.Color;
8473
8459
 
8474
8460
  /**
8475
- * Creates a hidden `&lt;audio&gt;` element for simple audio playback.
8461
+ * Creates a hidden `<audio>` element for simple audio playback.
8476
8462
  *
8477
8463
  * `createAudio()` returns a new
8478
8464
  * <a href="#/p5.MediaElement">p5.MediaElement</a> object.
@@ -8495,22 +8481,6 @@ declare class p5 {
8495
8481
  */
8496
8482
  createAudio(src?: string | string[], callback?: (video: p5.MediaElement<HTMLAudioElement>) => any): p5.MediaElement<HTMLAudioElement>;
8497
8483
 
8498
- /**
8499
- * Blends multiple colors to find a color between them.
8500
- *
8501
- * The `amt` parameter specifies the amount to interpolate between the color
8502
- * stops which are colors at each `amt` value "location" with `amt` values
8503
- * that are between 2 color stops interpolating between them based on its relative
8504
- * distance to both.
8505
- *
8506
- * The way that colors are interpolated depends on the current
8507
- * <a href="/reference/p5/colorMode/">colorMode()</a>.
8508
- * @param colors_stops color stops to interpolate from
8509
- * @param amt number to use to interpolate relative to color stops
8510
- * @returns interpolated color.
8511
- */
8512
- paletteLerp(colors_stops: [p5.Color | string | number | number[], number][], amt: number): p5.Color;
8513
-
8514
8484
  /**
8515
8485
  * Draws a torus.
8516
8486
  *
@@ -8542,6 +8512,22 @@ declare class p5 {
8542
8512
  */
8543
8513
  torus(radius?: number, tubeRadius?: number, detailX?: number, detailY?: number): void;
8544
8514
 
8515
+ /**
8516
+ * Blends multiple colors to find a color between them.
8517
+ *
8518
+ * The `amt` parameter specifies the amount to interpolate between the color
8519
+ * stops which are colors at each `amt` value "location" with `amt` values
8520
+ * that are between 2 color stops interpolating between them based on its relative
8521
+ * distance to both.
8522
+ *
8523
+ * The way that colors are interpolated depends on the current
8524
+ * <a href="/reference/p5/colorMode/">colorMode()</a>.
8525
+ * @param colors_stops color stops to interpolate from
8526
+ * @param amt number to use to interpolate relative to color stops
8527
+ * @returns interpolated color.
8528
+ */
8529
+ paletteLerp(colors_stops: [p5.Color | string | number | number[], number][], amt: number): p5.Color;
8530
+
8545
8531
  /**
8546
8532
  * Saves the file and closes the print stream.
8547
8533
  */
@@ -8630,7 +8616,7 @@ declare class p5 {
8630
8616
  * }
8631
8617
  *
8632
8618
  * function material() {
8633
- * let time = uniformFloat();
8619
+ * let time = millis();
8634
8620
  * worldInputs.begin();
8635
8621
  * worldInputs.position.y +=
8636
8622
  * 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -8640,7 +8626,6 @@ declare class p5 {
8640
8626
  * function draw() {
8641
8627
  * background(255);
8642
8628
  * shader(myShader);
8643
- * myShader.setUniform('time', millis());
8644
8629
  * lights();
8645
8630
  * noStroke();
8646
8631
  * fill('red');
@@ -8766,7 +8751,7 @@ declare class p5 {
8766
8751
  buildMaterialShader(hooks: object, scope?: object): p5.Shader;
8767
8752
 
8768
8753
  /**
8769
- * Creates a `&lt;video&gt;` element that "captures" the audio/video stream from
8754
+ * Creates a `<video>` element that "captures" the audio/video stream from
8770
8755
  * the webcam and microphone.
8771
8756
  *
8772
8757
  * `createCapture()` returns a new
@@ -8826,73 +8811,37 @@ declare class p5 {
8826
8811
  * The version of `stroke()` with three parameters interprets them as RGB, HSB,
8827
8812
  * or HSL colors, depending on the current `colorMode()`.
8828
8813
  *
8829
- * The version of `stroke()` with four parameters interprets them as RGBA, HSBA,
8830
- * or HSLA colors, depending on the current `colorMode()`. The last parameter
8831
- * sets the alpha (transparency) value.
8832
- * @param v1 red value if color mode is RGB or hue value if color mode is HSB.
8833
- * @param v2 green value if color mode is RGB or saturation value if color mode is HSB.
8834
- * @param v3 blue value if color mode is RGB or brightness value if color mode is HSB.
8835
- * @param alpha alpha value, controls transparency (0 - transparent, 255 - opaque).
8836
- */
8837
- stroke(v1: number, v2: number, v3: number, alpha?: number): void;
8838
- stroke(value: string): void;
8839
- stroke(gray: number, alpha?: number): void;
8840
- stroke(values: number[]): void;
8841
- stroke(color: p5.Color): void;
8842
-
8843
- /**
8844
- * Creates a color picker element.
8845
- *
8846
- * The parameter, `value`, is optional. If a color string or
8847
- * <a href="#/p5.Color">p5.Color</a> object is passed, it will set the default
8848
- * color.
8849
- *
8850
- * Color pickers extend the <a href="#/p5.Element">p5.Element</a> class with a
8851
- * couple of helpful methods for managing colors:
8852
- *
8853
- * - `myPicker.value()` returns the current color as a hex string in the format `'#rrggbb'`.
8854
- *
8855
- * - `myPicker.color()` returns the current color as a <a href="#/p5.Color">p5.Color</a> object.
8856
- * @param value default color as a <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/color" target="_blank">CSS color string</a>.
8857
- * @returns new <a href="#/p5.Element">p5.Element</a> object.
8858
- */
8859
- createColorPicker(value?: string | p5.Color): p5.Element;
8860
-
8861
- /**
8862
- * Saves a given element(image, text, json, csv, wav, or html) to the client's
8863
- * computer. The first parameter can be a pointer to element we want to save.
8864
- * The element can be one of <a href="#/p5.Element">p5.Element</a>,an Array of
8865
- * Strings, an Array of JSON, a JSON object, a <a href="#/p5.Table">p5.Table
8866
- * </a>, a <a href="#/p5.Image">p5.Image</a>, or a p5.SoundFile (requires
8867
- * p5.sound). The second parameter is a filename (including extension).The
8868
- * third parameter is for options specific to this type of object. This method
8869
- * will save a file that fits the given parameters.
8870
- * If it is called without specifying an element, by default it will save the
8871
- * whole canvas as an image file. You can optionally specify a filename as
8872
- * the first parameter in such a case.
8873
- * Note that it is not recommended to
8874
- * call this method within draw, as it will open a new save dialog on every
8875
- * render.
8876
- * @param objectOrFilename If filename is provided, will
8877
- * save canvas as an image with
8878
- * either png or jpg extension
8879
- * depending on the filename.
8880
- * If object is provided, will
8881
- * save depending on the object
8882
- * and filename (see examples
8883
- * above).
8884
- * @param filename If an object is provided as the first
8885
- * parameter, then the second parameter
8886
- * indicates the filename,
8887
- * and should include an appropriate
8888
- * file extension (see examples above).
8889
- * @param options Additional options depend on
8890
- * filetype. For example, when saving JSON,
8891
- * <code>true</code> indicates that the
8892
- * output will be optimized for filesize,
8893
- * rather than readability.
8814
+ * The version of `stroke()` with four parameters interprets them as RGBA, HSBA,
8815
+ * or HSLA colors, depending on the current `colorMode()`. The last parameter
8816
+ * sets the alpha (transparency) value.
8817
+ * @param v1 red value if color mode is RGB or hue value if color mode is HSB.
8818
+ * @param v2 green value if color mode is RGB or saturation value if color mode is HSB.
8819
+ * @param v3 blue value if color mode is RGB or brightness value if color mode is HSB.
8820
+ * @param alpha alpha value, controls transparency (0 - transparent, 255 - opaque).
8894
8821
  */
8895
- save(objectOrFilename?: object | string, filename?: string, options?: boolean | string): void;
8822
+ stroke(v1: number, v2: number, v3: number, alpha?: number): void;
8823
+ stroke(value: string): void;
8824
+ stroke(gray: number, alpha?: number): void;
8825
+ stroke(values: number[]): void;
8826
+ stroke(color: p5.Color): void;
8827
+
8828
+ /**
8829
+ * Creates a color picker element.
8830
+ *
8831
+ * The parameter, `value`, is optional. If a color string or
8832
+ * <a href="#/p5.Color">p5.Color</a> object is passed, it will set the default
8833
+ * color.
8834
+ *
8835
+ * Color pickers extend the <a href="#/p5.Element">p5.Element</a> class with a
8836
+ * couple of helpful methods for managing colors:
8837
+ *
8838
+ * - `myPicker.value()` returns the current color as a hex string in the format `'#rrggbb'`.
8839
+ *
8840
+ * - `myPicker.color()` returns the current color as a <a href="#/p5.Color">p5.Color</a> object.
8841
+ * @param value default color as a <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/color" target="_blank">CSS color string</a>.
8842
+ * @returns new <a href="#/p5.Element">p5.Element</a> object.
8843
+ */
8844
+ createColorPicker(value?: string | p5.Color): p5.Element;
8896
8845
 
8897
8846
  /**
8898
8847
  * Loads a new shader from a file that can change how fills are drawn. Pass the resulting
@@ -8911,7 +8860,6 @@ declare class p5 {
8911
8860
  * function draw() {
8912
8861
  * background(255);
8913
8862
  * shader(myShader);
8914
- * myShader.setUniform('time', millis());
8915
8863
  * lights();
8916
8864
  * noStroke();
8917
8865
  * fill('red');
@@ -8921,7 +8869,7 @@ declare class p5 {
8921
8869
  * might use the `pixelInputs` hook to change each pixel on the surface of a shape.
8922
8870
  *
8923
8871
  * `// myMaterial.js
8924
- * let time = uniformFloat();
8872
+ * let time = millis();
8925
8873
  * worldInputs.begin();
8926
8874
  * worldInputs.position.y +=
8927
8875
  * 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -8941,6 +8889,42 @@ declare class p5 {
8941
8889
  */
8942
8890
  loadMaterialShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<p5.Shader>;
8943
8891
 
8892
+ /**
8893
+ * Saves a given element(image, text, json, csv, wav, or html) to the client's
8894
+ * computer. The first parameter can be a pointer to element we want to save.
8895
+ * The element can be one of <a href="#/p5.Element">p5.Element</a>,an Array of
8896
+ * Strings, an Array of JSON, a JSON object, a <a href="#/p5.Table">p5.Table
8897
+ * </a>, a <a href="#/p5.Image">p5.Image</a>, or a p5.SoundFile (requires
8898
+ * p5.sound). The second parameter is a filename (including extension).The
8899
+ * third parameter is for options specific to this type of object. This method
8900
+ * will save a file that fits the given parameters.
8901
+ * If it is called without specifying an element, by default it will save the
8902
+ * whole canvas as an image file. You can optionally specify a filename as
8903
+ * the first parameter in such a case.
8904
+ * Note that it is not recommended to
8905
+ * call this method within draw, as it will open a new save dialog on every
8906
+ * render.
8907
+ * @param objectOrFilename If filename is provided, will
8908
+ * save canvas as an image with
8909
+ * either png or jpg extension
8910
+ * depending on the filename.
8911
+ * If object is provided, will
8912
+ * save depending on the object
8913
+ * and filename (see examples
8914
+ * above).
8915
+ * @param filename If an object is provided as the first
8916
+ * parameter, then the second parameter
8917
+ * indicates the filename,
8918
+ * and should include an appropriate
8919
+ * file extension (see examples above).
8920
+ * @param options Additional options depend on
8921
+ * filetype. For example, when saving JSON,
8922
+ * <code>true</code> indicates that the
8923
+ * output will be optimized for filesize,
8924
+ * rather than readability.
8925
+ */
8926
+ save(objectOrFilename?: object | string, filename?: string, options?: boolean | string): void;
8927
+
8944
8928
  /**
8945
8929
  * Influences the shape of the Bézier curve segment in a custom shape.
8946
8930
  * By default, this is 3; the other possible parameter is 2. This
@@ -9023,6 +9007,19 @@ declare class p5 {
9023
9007
  */
9024
9008
  baseMaterialShader(): p5.Shader;
9025
9009
 
9010
+ /**
9011
+ * Returns the base shader used for filters.
9012
+ *
9013
+ * Calling <a href="#/p5/buildFilterShader">`buildFilterShader(shaderFunction)`</a>
9014
+ * is equivalent to calling `baseFilterShader().modify(shaderFunction)`.
9015
+ *
9016
+ * Read <a href="#/p5/buildFilterShader">the `buildFilterShader` reference</a> or
9017
+ * call `baseFilterShader().inspectHooks()` for more information on what you can do with
9018
+ * the base filter shader.
9019
+ * @returns The base filter shader.
9020
+ */
9021
+ baseFilterShader(): p5.Shader;
9022
+
9026
9023
  /**
9027
9024
  * Starts using shapes to erase parts of the canvas.
9028
9025
  *
@@ -9057,19 +9054,6 @@ declare class p5 {
9057
9054
  */
9058
9055
  erase(strengthFill?: number, strengthStroke?: number): void;
9059
9056
 
9060
- /**
9061
- * Returns the base shader used for filters.
9062
- *
9063
- * Calling <a href="#/p5/buildFilterShader">`buildFilterShader(shaderFunction)`</a>
9064
- * is equivalent to calling `baseFilterShader().modify(shaderFunction)`.
9065
- *
9066
- * Read <a href="#/p5/buildFilterShader">the `buildFilterShader` reference</a> or
9067
- * call `baseFilterShader().inspectHooks()` for more information on what you can do with
9068
- * the base filter shader.
9069
- * @returns The base filter shader.
9070
- */
9071
- baseFilterShader(): p5.Shader;
9072
-
9073
9057
  /**
9074
9058
  * Ends erasing that was started with <a href="#/p5/erase">erase()</a>.
9075
9059
  *
@@ -9080,7 +9064,7 @@ declare class p5 {
9080
9064
  noErase(): void;
9081
9065
 
9082
9066
  /**
9083
- * Creates a text `&lt;input&gt;&lt;/input&gt;` element.
9067
+ * Creates a text `<input></input>` element.
9084
9068
  *
9085
9069
  * Call `myInput.size()` to set the length of the text box.
9086
9070
  *
@@ -9130,7 +9114,7 @@ declare class p5 {
9130
9114
  * }
9131
9115
  *
9132
9116
  * function material() {
9133
- * let time = uniformFloat();
9117
+ * let time = millis();
9134
9118
  * worldInputs.begin();
9135
9119
  * worldInputs.position.y +=
9136
9120
  * 20. * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -9140,7 +9124,6 @@ declare class p5 {
9140
9124
  * function draw() {
9141
9125
  * background(255);
9142
9126
  * shader(myShader);
9143
- * myShader.setUniform('time', millis());
9144
9127
  * noStroke();
9145
9128
  * sphere(50);
9146
9129
  * }`You may also want to change the colors used. By default, the x, y, and z values of the orientation
@@ -9429,7 +9412,7 @@ declare class p5 {
9429
9412
  pop(): void;
9430
9413
 
9431
9414
  /**
9432
- * Creates an `&lt;input&gt;&lt;/input&gt;` element of type `'file'`.
9415
+ * Creates an `<input></input>` element of type `'file'`.
9433
9416
  *
9434
9417
  * `createFileInput()` allows users to select local files for use in a sketch.
9435
9418
  * It returns a <a href="#/p5.File">p5.File</a> object.
@@ -9465,7 +9448,6 @@ declare class p5 {
9465
9448
  * function draw() {
9466
9449
  * background(255);
9467
9450
  * shader(myShader);
9468
- * myShader.setUniform('time', millis());
9469
9451
  * lights();
9470
9452
  * noStroke();
9471
9453
  * fill('red');
@@ -9475,7 +9457,7 @@ declare class p5 {
9475
9457
  * might use the `finalColor` hook to change the color of each pixel on the surface of a shape.
9476
9458
  *
9477
9459
  * `// myMaterial.js
9478
- * let time = uniformFloat();
9460
+ * let time = millis();
9479
9461
  * worldInputs.begin();
9480
9462
  * worldInputs.position.y +=
9481
9463
  * 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -9606,7 +9588,7 @@ declare class p5 {
9606
9588
  * }
9607
9589
  *
9608
9590
  * function material() {
9609
- * let time = uniformFloat();
9591
+ * let time = millis();
9610
9592
  * worldInputs.begin();
9611
9593
  * worldInputs.position.y +=
9612
9594
  * 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -9616,7 +9598,6 @@ declare class p5 {
9616
9598
  * function draw() {
9617
9599
  * background(255);
9618
9600
  * shader(myShader);
9619
- * myShader.setUniform('time', millis());
9620
9601
  * noStroke();
9621
9602
  * fill('red');
9622
9603
  * circle(0, 0, 50);
@@ -9730,7 +9711,6 @@ declare class p5 {
9730
9711
  * function draw() {
9731
9712
  * background(255);
9732
9713
  * shader(myShader);
9733
- * myShader.setUniform('time', millis());
9734
9714
  * lights();
9735
9715
  * noStroke();
9736
9716
  * fill('red');
@@ -9740,7 +9720,7 @@ declare class p5 {
9740
9720
  * might use the `finalColor` hook to change the color of each pixel on the surface of a shape.
9741
9721
  *
9742
9722
  * `// myMaterial.js
9743
- * let time = uniformFloat();
9723
+ * let time = millis();
9744
9724
  * worldInputs.begin();
9745
9725
  * worldInputs.position.y +=
9746
9726
  * 20 * sin(time * 0.001 + worldInputs.position.x * 0.05);
@@ -10025,7 +10005,7 @@ declare class p5 {
10025
10005
  * }
10026
10006
  *
10027
10007
  * function material() {
10028
- * let time = uniformFloat();
10008
+ * let time = millis();
10029
10009
  * worldInputs.begin();
10030
10010
  * // Add a somewhat random offset to the weight
10031
10011
  * // that varies based on position and time
@@ -10041,7 +10021,6 @@ declare class p5 {
10041
10021
  * function draw() {
10042
10022
  * background(255);
10043
10023
  * strokeShader(myShader);
10044
- * myShader.setUniform('time', millis());
10045
10024
  * strokeWeight(10);
10046
10025
  * beginShape();
10047
10026
  * for (let i = 0; i <= 50; i++) {
@@ -10132,6 +10111,58 @@ declare class p5 {
10132
10111
  splineProperty(property: string, value: any): void;
10133
10112
  splineProperty(property: string): void;
10134
10113
 
10114
+ /**
10115
+ * Loads a new shader from a file that can change how strokes are drawn. Pass the resulting
10116
+ * shader into the <a href="#/p5/strokeShader">`strokeShader()`</a> function to apply it
10117
+ * to any strokes you draw.
10118
+ *
10119
+ * Since this function loads data from another file, it returns a `Promise`.
10120
+ * Use it in an `async function setup`, and `await` its result.
10121
+ *
10122
+ * `let myShader;
10123
+ * async function setup() {
10124
+ * createCanvas(200, 200, WEBGL);
10125
+ * myShader = await loadStrokeShader('myMaterial.js');
10126
+ * }
10127
+ *
10128
+ * function draw() {
10129
+ * background(255);
10130
+ * strokeShader(myShader);
10131
+ * strokeWeight(30);
10132
+ * line(
10133
+ * -width/3,
10134
+ * sin(millis()*0.001) * height/4,
10135
+ * width/3,
10136
+ * sin(millis()*0.001 + 1) * height/4
10137
+ * );
10138
+ * }`Inside your shader file, you can call p5.strands hooks to change parts of the shader. For
10139
+ * example, you might use the `worldInputs` hook to change each vertex, or you
10140
+ * might use the `pixelInputs` hook to change each pixel on the surface of a stroke.
10141
+ *
10142
+ * `// myMaterial.js
10143
+ * pixelInputs.begin();
10144
+ * let opacity = 1 - smoothstep(
10145
+ * 0,
10146
+ * 15,
10147
+ * length(pixelInputs.position - pixelInputs.center)
10148
+ * );
10149
+ * pixelInputs.color.a *= opacity;
10150
+ * pixelInputs.end();`Read the reference for <a href="#/p5/buildStrokeShader">`buildStrokeShader`</a>,
10151
+ * the version of `loadStrokeShader` that takes in a function instead of a separate file,
10152
+ * for a full list of hooks you can use and examples for each.
10153
+ *
10154
+ * The second parameter, `successCallback`, is optional. If a function is passed, as in
10155
+ * `loadStrokeShader('myShader.js', onLoaded)`, then the `onLoaded()` function will be called
10156
+ * once the shader loads. The shader will be passed to `onLoaded()` as its only argument.
10157
+ * The return value of `handleData()`, if present, will be used as the final return value of
10158
+ * `loadStrokeShader('myShader.js', onLoaded)`.
10159
+ * @param url The URL of your p5.strands JavaScript file.
10160
+ * @param onSuccess A callback function to run when loading completes.
10161
+ * @param onFailure A callback function to run when loading fails.
10162
+ * @returns The stroke shader.
10163
+ */
10164
+ loadStrokeShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<p5.Shader>;
10165
+
10135
10166
  /**
10136
10167
  * Sets a perspective projection for the current camera in a 3D sketch.
10137
10168
  *
@@ -10186,58 +10217,6 @@ declare class p5 {
10186
10217
  */
10187
10218
  perspective(fovy?: number, aspect?: number, near?: number, far?: number): void;
10188
10219
 
10189
- /**
10190
- * Loads a new shader from a file that can change how strokes are drawn. Pass the resulting
10191
- * shader into the <a href="#/p5/strokeShader">`strokeShader()`</a> function to apply it
10192
- * to any strokes you draw.
10193
- *
10194
- * Since this function loads data from another file, it returns a `Promise`.
10195
- * Use it in an `async function setup`, and `await` its result.
10196
- *
10197
- * `let myShader;
10198
- * async function setup() {
10199
- * createCanvas(200, 200, WEBGL);
10200
- * myShader = await loadStrokeShader('myMaterial.js');
10201
- * }
10202
- *
10203
- * function draw() {
10204
- * background(255);
10205
- * strokeShader(myShader);
10206
- * strokeWeight(30);
10207
- * line(
10208
- * -width/3,
10209
- * sin(millis()*0.001) * height/4,
10210
- * width/3,
10211
- * sin(millis()*0.001 + 1) * height/4
10212
- * );
10213
- * }`Inside your shader file, you can call p5.strands hooks to change parts of the shader. For
10214
- * example, you might use the `worldInputs` hook to change each vertex, or you
10215
- * might use the `pixelInputs` hook to change each pixel on the surface of a stroke.
10216
- *
10217
- * `// myMaterial.js
10218
- * pixelInputs.begin();
10219
- * let opacity = 1 - smoothstep(
10220
- * 0,
10221
- * 15,
10222
- * length(pixelInputs.position - pixelInputs.center)
10223
- * );
10224
- * pixelInputs.color.a *= opacity;
10225
- * pixelInputs.end();`Read the reference for <a href="#/p5/buildStrokeShader">`buildStrokeShader`</a>,
10226
- * the version of `loadStrokeShader` that takes in a function instead of a separate file,
10227
- * for a full list of hooks you can use and examples for each.
10228
- *
10229
- * The second parameter, `successCallback`, is optional. If a function is passed, as in
10230
- * `loadStrokeShader('myShader.js', onLoaded)`, then the `onLoaded()` function will be called
10231
- * once the shader loads. The shader will be passed to `onLoaded()` as its only argument.
10232
- * The return value of `handleData()`, if present, will be used as the final return value of
10233
- * `loadStrokeShader('myShader.js', onLoaded)`.
10234
- * @param url The URL of your p5.strands JavaScript file.
10235
- * @param onSuccess A callback function to run when loading completes.
10236
- * @param onFailure A callback function to run when loading fails.
10237
- * @returns The stroke shader.
10238
- */
10239
- loadStrokeShader(url: string, onSuccess?: Function, onFailure?: Function): Promise<p5.Shader>;
10240
-
10241
10220
  /**
10242
10221
  * Returns the default shader used for strokes.
10243
10222
  *
@@ -10282,6 +10261,17 @@ declare class p5 {
10282
10261
  */
10283
10262
  splineProperties(values: object): object;
10284
10263
 
10264
+ /**
10265
+ * Restores the default shaders.
10266
+ *
10267
+ * `resetShader()` deactivates any shaders previously applied by
10268
+ * <a href="#/p5/shader">shader()</a>, <a href="#/p5/strokeShader">strokeShader()</a>,
10269
+ * or <a href="#/p5/imageShader">imageShader()</a>.
10270
+ *
10271
+ * Note: Shaders can only be used in WebGL mode.
10272
+ */
10273
+ resetShader(): void;
10274
+
10285
10275
  /**
10286
10276
  * Enables or disables perspective for lines in 3D sketches.
10287
10277
  *
@@ -10319,17 +10309,6 @@ declare class p5 {
10319
10309
  linePerspective(enable: boolean): boolean;
10320
10310
  linePerspective(): boolean;
10321
10311
 
10322
- /**
10323
- * Restores the default shaders.
10324
- *
10325
- * `resetShader()` deactivates any shaders previously applied by
10326
- * <a href="#/p5/shader">shader()</a>, <a href="#/p5/strokeShader">strokeShader()</a>,
10327
- * or <a href="#/p5/imageShader">imageShader()</a>.
10328
- *
10329
- * Note: Shaders can only be used in WebGL mode.
10330
- */
10331
- resetShader(): void;
10332
-
10333
10312
  /**
10334
10313
  * Sets an orthographic projection for the current camera in a 3D sketch.
10335
10314
  *
@@ -10413,6 +10392,20 @@ declare class p5 {
10413
10392
  vertex(x: number, y: number, u?: number, v?: number): void;
10414
10393
  vertex(x: number, y: number, z: number, u?: number, v?: number): void;
10415
10394
 
10395
+ /**
10396
+ * Sets the number of segments used to draw spline curves in WebGL mode.
10397
+ *
10398
+ * In WebGL mode, smooth shapes are drawn using many flat segments. Adding
10399
+ * more flat segments makes shapes appear smoother.
10400
+ *
10401
+ * The parameter, `detail`, is the density of segments to use while drawing a
10402
+ * spline curve.
10403
+ *
10404
+ * Note: `curveDetail()` has no effect in 2D mode.
10405
+ * @param resolution number of segments to use. Default is 1/4
10406
+ */
10407
+ curveDetail(resolution: number): void;
10408
+
10416
10409
  /**
10417
10410
  * Sets the frustum of the current camera in a 3D sketch.
10418
10411
  *
@@ -10452,20 +10445,6 @@ declare class p5 {
10452
10445
  */
10453
10446
  frustum(left?: number, right?: number, bottom?: number, top?: number, near?: number, far?: number): void;
10454
10447
 
10455
- /**
10456
- * Sets the number of segments used to draw spline curves in WebGL mode.
10457
- *
10458
- * In WebGL mode, smooth shapes are drawn using many flat segments. Adding
10459
- * more flat segments makes shapes appear smoother.
10460
- *
10461
- * The parameter, `detail`, is the density of segments to use while drawing a
10462
- * spline curve.
10463
- *
10464
- * Note: `curveDetail()` has no effect in 2D mode.
10465
- * @param resolution number of segments to use. Default is 1/4
10466
- */
10467
- curveDetail(resolution: number): void;
10468
-
10469
10448
  /**
10470
10449
  * Creates a new <a href="#/p5.Camera">p5.Camera</a> object.
10471
10450
  *
@@ -12218,7 +12197,7 @@ const EXCLUDE: typeof __EXCLUDE;
12218
12197
  * Removes the graphics buffer from the web page.
12219
12198
  *
12220
12199
  * Calling `myGraphics.remove()` removes the graphics buffer's
12221
- * `&lt;canvas&gt;` element from the web page. The graphics buffer also uses
12200
+ * `<canvas>` element from the web page. The graphics buffer also uses
12222
12201
  * a bit of memory on the CPU that can be freed like so:
12223
12202
  *
12224
12203
  * `// Remove the graphics buffer from the web page.
@@ -12682,7 +12661,7 @@ const EXCLUDE: typeof __EXCLUDE;
12682
12661
  * (<a href="https://developer.mozilla.org/en-US/docs/Web/XML/XML_introduction" target="_blank">XML</a>)
12683
12662
  * is a standard format for sending data between applications. Like HTML, the
12684
12663
  * XML format is based on tags and attributes, as in
12685
- * `&lt;time units="s"&gt;1234&lt;/time&gt;`.
12664
+ * `<time units="s">1234</time>`.
12686
12665
  *
12687
12666
  * Note: Use <a href="#/p5/loadXML">loadXML()</a> to load external XML files.
12688
12667
  */
@@ -12698,7 +12677,7 @@ const EXCLUDE: typeof __EXCLUDE;
12698
12677
  * Returns the element's name as a `String`.
12699
12678
  *
12700
12679
  * An XML element's name is given by its tag. For example, the element
12701
- * `&lt;language&gt;JavaScript&lt;/language&gt;` has the name `language`.
12680
+ * `<language>JavaScript</language>` has the name `language`.
12702
12681
  * @returns name of the element.
12703
12682
  */
12704
12683
  getName(): string;
@@ -12707,11 +12686,11 @@ const EXCLUDE: typeof __EXCLUDE;
12707
12686
  * Sets the element's tag name.
12708
12687
  *
12709
12688
  * An XML element's name is given by its tag. For example, the element
12710
- * `&lt;language&gt;JavaScript&lt;/language&gt;` has the name `language`.
12689
+ * `<language>JavaScript</language>` has the name `language`.
12711
12690
  *
12712
12691
  * The parameter, `name`, is the element's new name as a string. For example,
12713
12692
  * calling `myXML.setName('planet')` will make the element's new tag name
12714
- * `&lt;planet&gt;&lt;/planet&gt;`.
12693
+ * `<planet></planet>`.
12715
12694
  * @param name new tag name of the element.
12716
12695
  */
12717
12696
  setName(name: string): void;
@@ -12735,7 +12714,7 @@ const EXCLUDE: typeof __EXCLUDE;
12735
12714
  *
12736
12715
  * The parameter, `name`, is optional. If a string is passed, as in
12737
12716
  * `myXML.getChildren('cat')`, then the method will only return child elements
12738
- * with the tag `&lt;cat&gt;`.
12717
+ * with the tag `<cat>`.
12739
12718
  * @param name name of the elements to return.
12740
12719
  * @returns child elements.
12741
12720
  */
@@ -12747,7 +12726,7 @@ const EXCLUDE: typeof __EXCLUDE;
12747
12726
  *
12748
12727
  * The parameter, `name`, is optional. If a string is passed, as in
12749
12728
  * `myXML.getChild('cat')`, then the first child element with the tag
12750
- * `&lt;cat&gt;` will be returned. If a number is passed, as in
12729
+ * `<cat>` will be returned. If a number is passed, as in
12751
12730
  * `myXML.getChild(1)`, then the child element at that index will be returned.
12752
12731
  * @param name element name or index.
12753
12732
  * @returns child element.
@@ -12770,7 +12749,7 @@ const EXCLUDE: typeof __EXCLUDE;
12770
12749
  *
12771
12750
  * The parameter, `name`, is the child element to remove. If a string is
12772
12751
  * passed, as in `myXML.removeChild('cat')`, then the first child element
12773
- * with the tag `&lt;cat&gt;` will be removed. If a number is passed, as in
12752
+ * with the tag `<cat>` will be removed. If a number is passed, as in
12774
12753
  * `myXML.removeChild(1)`, then the child element at that index will be
12775
12754
  * removed.
12776
12755
  * @param name name or index of the child element to remove.
@@ -13020,23 +12999,27 @@ const EXCLUDE: typeof __EXCLUDE;
13020
12999
  * plane(width, height); // Draw a plane with the shader applied
13021
13000
  * }`In addition to calling hooks, you can create uniforms, which are special variables
13022
13001
  * used to pass data from p5.js into the shader. They can be created by calling `uniform` + the
13023
- * type of the data, such as `uniformFloat` for a number of `uniformVector2` for a two-component vector.
13002
+ * type of the data, such as `uniformFloat` for a number or `uniformVector2` for a two-component vector.
13024
13003
  * They take in a function that returns the data for the variable. You can then reference these
13025
13004
  * variables in your hooks, and their values will update every time you apply
13026
13005
  * the shader with the result of your function.
13027
13006
  *
13007
+ * Move the mouse over this sketch to increase the moveCounter which will be passed to the shader as a uniform.
13008
+ *
13028
13009
  * `let myShader;
13010
+ * //count of frames in which mouse has been moved
13011
+ * let moveCounter = 0;
13029
13012
  *
13030
13013
  * function setup() {
13031
13014
  * createCanvas(200, 200, WEBGL);
13032
13015
  * myShader = baseMaterialShader().modify(() => {
13033
- * // Get the current time from p5.js
13034
- * let t = uniformFloat(() => millis());
13016
+ * // Get the move counter from our sketch
13017
+ * let count = uniformFloat(() => moveCounter);
13035
13018
  *
13036
13019
  * getPixelInputs((inputs) => {
13037
13020
  * inputs.color = [
13038
13021
  * inputs.texCoord,
13039
- * sin(t * 0.01) / 2 + 0.5,
13022
+ * sin(count/100) / 2 + 0.5,
13040
13023
  * 1,
13041
13024
  * ];
13042
13025
  * return inputs;
@@ -13044,6 +13027,10 @@ const EXCLUDE: typeof __EXCLUDE;
13044
13027
  * });
13045
13028
  * }
13046
13029
  *
13030
+ * function mouseDragged(){
13031
+ * moveCounter += 1;
13032
+ * }
13033
+ *
13047
13034
  * function draw() {
13048
13035
  * background(255);
13049
13036
  * noStroke(255);
@@ -14640,9 +14627,9 @@ const EXCLUDE: typeof __EXCLUDE;
14640
14627
  /**
14641
14628
  * Attaches the element to a parent element.
14642
14629
  *
14643
- * For example, a `&lt;div&gt;&lt;/div&gt;` element may be used as a box to
14630
+ * For example, a `<div></div>` element may be used as a box to
14644
14631
  * hold two pieces of text, a header and a paragraph. The
14645
- * `&lt;div&gt;&lt;/div&gt;` is the parent element of both the header and
14632
+ * `<div></div>` is the parent element of both the header and
14646
14633
  * paragraph.
14647
14634
  *
14648
14635
  * The parameter `parent` can have one of three types. `parent` can be a