p5 2.0.1 → 2.0.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 (160) hide show
  1. package/dist/accessibility/color_namer.js +5 -5
  2. package/dist/accessibility/describe.js +10 -0
  3. package/dist/accessibility/index.js +5 -5
  4. package/dist/accessibility/outputs.js +21 -0
  5. package/dist/app.js +5 -5
  6. package/dist/color/color_conversion.js +5 -5
  7. package/dist/color/creating_reading.js +1 -1
  8. package/dist/color/index.js +2 -2
  9. package/dist/color/p5.Color.js +1 -1
  10. package/dist/color/setting.js +2 -2
  11. package/dist/{constants-C-g_eAdC.js → constants-BRcElHU3.js} +19 -3
  12. package/dist/core/constants.js +1 -1
  13. package/dist/core/environment.js +6 -5
  14. package/dist/core/friendly_errors/fes_core.js +1 -1
  15. package/dist/core/friendly_errors/index.js +1 -1
  16. package/dist/core/friendly_errors/param_validator.js +46 -93
  17. package/dist/core/friendly_errors/sketch_reader.js +5 -5
  18. package/dist/core/friendly_errors/sketch_verifier.js +1 -1
  19. package/dist/core/friendly_errors/validate_params.js +5 -5
  20. package/dist/core/helpers.js +1 -1
  21. package/dist/core/init.js +5 -5
  22. package/dist/core/legacy.js +5 -5
  23. package/dist/core/main.js +5 -5
  24. package/dist/core/p5.Graphics.js +4 -4
  25. package/dist/core/p5.Renderer.js +3 -3
  26. package/dist/core/p5.Renderer2D.js +5 -5
  27. package/dist/core/rendering.js +4 -4
  28. package/dist/{creating_reading-D4AAKRbx.js → creating_reading-Cr8L2Jnm.js} +2 -2
  29. package/dist/dom/dom.js +10 -10
  30. package/dist/dom/index.js +2 -2
  31. package/dist/dom/p5.Element.js +2 -2
  32. package/dist/dom/p5.MediaElement.js +2 -2
  33. package/dist/events/acceleration.js +24 -24
  34. package/dist/events/keyboard.js +11 -6
  35. package/dist/image/const.js +1 -1
  36. package/dist/image/filterRenderer2D.js +4 -4
  37. package/dist/image/image.js +4 -4
  38. package/dist/image/index.js +4 -4
  39. package/dist/image/loading_displaying.js +4 -4
  40. package/dist/image/p5.Image.js +3 -3
  41. package/dist/image/pixels.js +1 -0
  42. package/dist/io/files.js +4 -4
  43. package/dist/io/index.js +4 -4
  44. package/dist/io/p5.TableRow.js +2 -2
  45. package/dist/{main-s72KWcUy.js → main-BKN5yFoS.js} +12 -9
  46. package/dist/math/Matrices/Matrix.js +1 -1
  47. package/dist/math/Matrices/MatrixNumjs.js +1 -1
  48. package/dist/math/index.js +1 -1
  49. package/dist/math/math.js +1 -1
  50. package/dist/math/p5.Matrix.js +1 -1
  51. package/dist/math/p5.Vector.js +1 -1
  52. package/dist/math/trigonometry.js +1 -1
  53. package/dist/{p5.Renderer-CwAYZOC2.js → p5.Renderer-R23xoC7s.js} +5 -5
  54. package/dist/{rendering--aAe5aq3.js → rendering-CvUVN-Vb.js} +101 -66
  55. package/dist/shape/2d_primitives.js +1 -1
  56. package/dist/shape/attributes.js +1 -1
  57. package/dist/shape/custom_shapes.js +2 -2
  58. package/dist/shape/index.js +2 -2
  59. package/dist/type/index.js +3 -3
  60. package/dist/type/p5.Font.js +3 -5
  61. package/dist/type/textCore.js +4 -4
  62. package/dist/webgl/3d_primitives.js +4 -4
  63. package/dist/webgl/GeometryBuilder.js +1 -1
  64. package/dist/webgl/ShapeBuilder.js +1 -1
  65. package/dist/webgl/index.js +4 -4
  66. package/dist/webgl/interaction.js +1 -1
  67. package/dist/webgl/light.js +4 -4
  68. package/dist/webgl/loading.js +5 -4
  69. package/dist/webgl/material.js +4 -4
  70. package/dist/webgl/p5.Camera.js +4 -4
  71. package/dist/webgl/p5.Framebuffer.js +4 -4
  72. package/dist/webgl/p5.Geometry.js +1 -1
  73. package/dist/webgl/p5.Quat.js +1 -1
  74. package/dist/webgl/p5.RendererGL.js +4 -4
  75. package/dist/webgl/p5.Shader.js +4 -4
  76. package/dist/webgl/p5.Texture.js +4 -4
  77. package/dist/webgl/text.js +32 -34
  78. package/lib/p5.esm.js +289 -247
  79. package/lib/p5.js +289 -247
  80. package/lib/p5.min.js +1 -1
  81. package/package.json +1 -2
  82. package/types/accessibility/color_namer.d.ts +8 -0
  83. package/types/accessibility/describe.d.ts +184 -0
  84. package/types/accessibility/gridOutput.d.ts +8 -0
  85. package/types/accessibility/outputs.d.ts +235 -0
  86. package/types/accessibility/textOutput.d.ts +8 -0
  87. package/types/color/color_conversion.d.ts +47 -0
  88. package/types/color/creating_reading.d.ts +1348 -0
  89. package/types/color/p5.Color.d.ts +1070 -0
  90. package/types/color/setting.d.ts +2085 -0
  91. package/types/core/constants.d.ts +341 -0
  92. package/types/core/environment.d.ts +668 -0
  93. package/types/core/friendly_errors/fes_core.d.ts +8 -0
  94. package/types/core/friendly_errors/file_errors.d.ts +8 -0
  95. package/types/core/friendly_errors/param_validator.d.ts +30 -0
  96. package/types/core/friendly_errors/sketch_reader.d.ts +8 -0
  97. package/types/core/friendly_errors/stacktrace.d.ts +11 -0
  98. package/types/core/friendly_errors/validate_params.d.ts +8 -0
  99. package/types/core/helpers.d.ts +8 -0
  100. package/types/core/legacy.d.ts +8 -0
  101. package/types/core/main.d.ts +5999 -0
  102. package/types/core/p5.Graphics.d.ts +484 -0
  103. package/types/core/p5.Renderer.d.ts +14 -0
  104. package/types/core/reference.d.ts +8 -0
  105. package/types/core/rendering.d.ts +481 -0
  106. package/types/core/structure.d.ts +492 -0
  107. package/types/core/transform.d.ts +1638 -0
  108. package/types/data/local_storage.d.ts +323 -0
  109. package/types/dom/dom.d.ts +1295 -0
  110. package/types/dom/p5.Element.d.ts +2011 -0
  111. package/types/dom/p5.File.d.ts +13 -0
  112. package/types/dom/p5.MediaElement.d.ts +1249 -0
  113. package/types/events/acceleration.d.ts +193 -0
  114. package/types/events/keyboard.d.ts +501 -0
  115. package/types/events/pointer.d.ts +782 -0
  116. package/types/global.d.ts +5544 -0
  117. package/types/image/filterRenderer2D.d.ts +54 -0
  118. package/types/image/image.d.ts +326 -0
  119. package/types/image/loading_displaying.d.ts +580 -0
  120. package/types/image/p5.Image.d.ts +5882 -0
  121. package/types/image/pixels.d.ts +832 -0
  122. package/types/io/files.d.ts +1447 -0
  123. package/types/io/p5.Table.d.ts +1247 -0
  124. package/types/io/p5.TableRow.d.ts +343 -0
  125. package/types/io/p5.XML.d.ts +1188 -0
  126. package/types/math/Matrices/Matrix.d.ts +1029 -0
  127. package/types/math/Matrices/MatrixNumjs.d.ts +8 -0
  128. package/types/math/calculation.d.ts +923 -0
  129. package/types/math/math.d.ts +90 -0
  130. package/types/math/noise.d.ts +311 -0
  131. package/types/math/p5.Matrix.d.ts +8 -0
  132. package/types/math/p5.Vector.d.ts +3416 -0
  133. package/types/math/random.d.ts +267 -0
  134. package/types/math/trigonometry.d.ts +663 -0
  135. package/types/p5.d.ts +6666 -0
  136. package/types/shape/2d_primitives.d.ts +1033 -0
  137. package/types/shape/attributes.d.ts +466 -0
  138. package/types/shape/curves.d.ts +740 -0
  139. package/types/shape/custom_shapes.d.ts +888 -0
  140. package/types/shape/vertex.d.ts +1141 -0
  141. package/types/type/p5.Font.d.ts +575 -0
  142. package/types/type/textCore.d.ts +1198 -0
  143. package/types/utilities/conversion.d.ts +894 -0
  144. package/types/utilities/time_date.d.ts +295 -0
  145. package/types/utilities/utility_functions.d.ts +587 -0
  146. package/types/webgl/3d_primitives.d.ts +1432 -0
  147. package/types/webgl/ShaderGenerator.d.ts +8 -0
  148. package/types/webgl/interaction.d.ts +371 -0
  149. package/types/webgl/light.d.ts +1184 -0
  150. package/types/webgl/loading.d.ts +482 -0
  151. package/types/webgl/material.d.ts +2656 -0
  152. package/types/webgl/p5.Camera.d.ts +3023 -0
  153. package/types/webgl/p5.DataArray.d.ts +61 -0
  154. package/types/webgl/p5.Framebuffer.d.ts +760 -0
  155. package/types/webgl/p5.Geometry.d.ts +1191 -0
  156. package/types/webgl/p5.Quat.d.ts +45 -0
  157. package/types/webgl/p5.RendererGL.d.ts +234 -0
  158. package/types/webgl/p5.Shader.d.ts +660 -0
  159. package/types/webgl/p5.Texture.d.ts +61 -0
  160. package/types/webgl/text.d.ts +74 -0
@@ -0,0 +1,782 @@
1
+ // This file is auto-generated from JSDoc documentation
2
+
3
+ import p5 from 'p5';
4
+
5
+ declare module 'p5' {
6
+ /**
7
+ * A function that's called when the mouse moves.Declaring the function `mouseMoved()` sets a code block to run
8
+ * automatically when the user moves the mouse without clicking any mouse
9
+ * buttons:`function mouseMoved() {
10
+ * // Code to run.
11
+ * }`The mouse system variables, such as mouseX and
12
+ * mouseY, will be updated with their most recent
13
+ * value when `mouseMoved()` is called by p5.js:`function mouseMoved() {
14
+ * if (mouseX < 50) {
15
+ * // Code to run if the mouse is on the left.
16
+ * }
17
+ *
18
+ * if (mouseY > 50) {
19
+ * // Code to run if the mouse is near the bottom.
20
+ * }
21
+ * }`The parameter, `event`, is optional. `mouseMoved()` is always passed a
22
+ * MouseEvent
23
+ * object with properties that describe the mouse move event:`function mouseMoved(event) {
24
+ * // Code to run that uses the event.
25
+ * console.log(event);
26
+ * }`Browsers may have default behaviors attached to various mouse events. For
27
+ * example, some browsers highlight text when the user moves the mouse while
28
+ * pressing a mouse button. To prevent any default behavior for this event,
29
+ * add `return false;` to the end of the function.
30
+ *
31
+ * @param optional `MouseEvent` argument.
32
+ * @example <div>
33
+ * <code>
34
+ * let value = 0;
35
+ *
36
+ * function setup() {
37
+ * createCanvas(100, 100);
38
+ *
39
+ * describe(
40
+ * 'A gray square with a black square at its center. The inner square becomes lighter as the mouse moves.'
41
+ * );
42
+ * }
43
+ *
44
+ * function draw() {
45
+ * background(200);
46
+ *
47
+ * // Style the square.
48
+ * fill(value);
49
+ *
50
+ * // Draw the square.
51
+ * square(25, 25, 50);
52
+ * }
53
+ *
54
+ * function mouseMoved() {
55
+ * // Update the grayscale value.
56
+ * value += 5;
57
+ *
58
+ * // Reset the grayscale value.
59
+ * if (value > 255) {
60
+ * value = 0;
61
+ * }
62
+ * // Uncomment to prevent any default behavior.
63
+ * // return false;
64
+ * }
65
+ * </code>
66
+ * </div>
67
+ */
68
+ function mouseMoved(event?: MouseEvent): void;
69
+
70
+ /**
71
+ * A function that's called when the mouse moves while a button is pressed.Declaring the function `mouseDragged()` sets a code block to run
72
+ * automatically when the user clicks and drags the mouse:`function mouseDragged() {
73
+ * // Code to run.
74
+ * }`The mouse system variables, such as mouseX and
75
+ * mouseY, will be updated with their most recent
76
+ * value when `mouseDragged()` is called by p5.js:`function mouseDragged() {
77
+ * if (mouseX < 50) {
78
+ * // Code to run if the mouse is on the left.
79
+ * }
80
+ *
81
+ * if (mouseY > 50) {
82
+ * // Code to run if the mouse is near the bottom.
83
+ * }
84
+ * }`The parameter, `event`, is optional. `mouseDragged()` is always passed a
85
+ * MouseEvent
86
+ * object with properties that describe the mouse drag event:`function mouseDragged(event) {
87
+ * // Code to run that uses the event.
88
+ * console.log(event);
89
+ * }`On touchscreen devices, `mouseDragged()` will run when a user moves a touch
90
+ * point.Browsers may have default behaviors attached to various mouse events. For
91
+ * example, some browsers highlight text when the user moves the mouse while
92
+ * pressing a mouse button. To prevent any default behavior for this event,
93
+ * add `return false;` to the end of the function.
94
+ *
95
+ * @param optional `MouseEvent` argument.
96
+ * @example <div>
97
+ * <code>
98
+ * let value = 0;
99
+ *
100
+ * function setup() {
101
+ * createCanvas(100, 100);
102
+ *
103
+ * describe(
104
+ * 'A gray square with a black square at its center. The inner square becomes lighter as the user drags the mouse.'
105
+ * );
106
+ * }
107
+ *
108
+ * function draw() {
109
+ * background(200);
110
+ *
111
+ * // Style the square.
112
+ * fill(value);
113
+ *
114
+ * // Draw the square.
115
+ * square(25, 25, 50);
116
+ * }
117
+ *
118
+ * function mouseDragged() {
119
+ * // Update the grayscale value.
120
+ * value += 5;
121
+ *
122
+ * // Reset the grayscale value.
123
+ * if (value > 255) {
124
+ * value = 0;
125
+ * }
126
+ * // Uncomment to prevent any default behavior.
127
+ * // return false;
128
+ * }
129
+ * </code>
130
+ * </div>
131
+ */
132
+ function mouseDragged(event?: MouseEvent): void;
133
+
134
+ /**
135
+ * A function that's called once when a mouse button is pressed.Declaring the function `mousePressed()` sets a code block to run
136
+ * automatically when the user presses a mouse button:`function mousePressed() {
137
+ * // Code to run.
138
+ * }`The mouse system variables, such as mouseX and
139
+ * mouseY, will be updated with their most recent
140
+ * value when `mousePressed()` is called by p5.js:`function mousePressed() {
141
+ * if (mouseX < 50) {
142
+ * // Code to run if the mouse is on the left.
143
+ * }
144
+ *
145
+ * if (mouseY > 50) {
146
+ * // Code to run if the mouse is near the bottom.
147
+ * }
148
+ * }`The parameter, `event`, is optional. `mousePressed()` is always passed a
149
+ * MouseEvent
150
+ * object with properties that describe the mouse press event:`function mousePressed(event) {
151
+ * // Code to run that uses the event.
152
+ * console.log(event);
153
+ * }`On touchscreen devices, `mousePressed()` will run when a user’s touch
154
+ * begins.Browsers may have default behaviors attached to various mouse events. For
155
+ * example, some browsers highlight text when the user moves the mouse while
156
+ * pressing a mouse button. To prevent any default behavior for this event,
157
+ * add `return false;` to the end of the function.Note: `mousePressed()`, mouseReleased(),
158
+ * and mouseClicked() are all related.
159
+ * `mousePressed()` runs as soon as the user clicks the mouse.
160
+ * mouseReleased() runs as soon as the user
161
+ * releases the mouse click. mouseClicked()
162
+ * runs immediately after mouseReleased().
163
+ *
164
+ * @param optional `MouseEvent` argument.
165
+ * @example <div>
166
+ * <code>
167
+ * let value = 0;
168
+ *
169
+ * function setup() {
170
+ * createCanvas(100, 100);
171
+ *
172
+ * describe(
173
+ * 'A gray square with a black square at its center. The inner square becomes lighter when the user presses a mouse button.'
174
+ * );
175
+ * }
176
+ *
177
+ * function draw() {
178
+ * background(200);
179
+ *
180
+ * // Style the square.
181
+ * fill(value);
182
+ *
183
+ * // Draw the square.
184
+ * square(25, 25, 50);
185
+ * }
186
+ *
187
+ * function mousePressed() {
188
+ * // Update the grayscale value.
189
+ * value += 5;
190
+ *
191
+ * // Reset the grayscale value.
192
+ * if (value > 255) {
193
+ * value = 0;
194
+ * }
195
+ * // Uncomment to prevent any default behavior.
196
+ * // return false;
197
+ * }
198
+ * </code>
199
+ * </div>
200
+ *
201
+ * <div>
202
+ * <code>
203
+ * function setup() {
204
+ * createCanvas(100, 100);
205
+ *
206
+ * // Style the circle.
207
+ * fill('orange');
208
+ * stroke('royalblue');
209
+ * strokeWeight(10);
210
+ *
211
+ * describe(
212
+ * 'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.'
213
+ * );
214
+ * }
215
+ *
216
+ * function draw() {
217
+ * background(220);
218
+ *
219
+ * // Draw the circle.
220
+ * circle(50, 50, 20);
221
+ * }
222
+ *
223
+ * // Set the stroke color and weight as soon as the user clicks.
224
+ * function mousePressed() {
225
+ * stroke('deeppink');
226
+ * strokeWeight(3);
227
+ * }
228
+ *
229
+ * // Set the stroke and fill colors as soon as the user releases
230
+ * // the mouse.
231
+ * function mouseReleased() {
232
+ * stroke('royalblue');
233
+ *
234
+ * // This is never visible because fill() is called
235
+ * // in mouseClicked() which runs immediately after
236
+ * // mouseReleased();
237
+ * fill('limegreen');
238
+ * }
239
+ *
240
+ * // Set the fill color and stroke weight after
241
+ * // mousePressed() and mouseReleased() are called.
242
+ * function mouseClicked() {
243
+ * fill('orange');
244
+ * strokeWeight(10);
245
+ * }
246
+ * </code>
247
+ * </div>
248
+ */
249
+ function mousePressed(event?: MouseEvent): void;
250
+
251
+ /**
252
+ * A function that's called once when a mouse button is released.Declaring the function `mouseReleased()` sets a code block to run
253
+ * automatically when the user releases a mouse button after having pressed
254
+ * it:`function mouseReleased() {
255
+ * // Code to run.
256
+ * }`The mouse system variables, such as mouseX and
257
+ * mouseY, will be updated with their most recent
258
+ * value when `mouseReleased()` is called by p5.js:`function mouseReleased() {
259
+ * if (mouseX < 50) {
260
+ * // Code to run if the mouse is on the left.
261
+ * }
262
+ *
263
+ * if (mouseY > 50) {
264
+ * // Code to run if the mouse is near the bottom.
265
+ * }
266
+ * }`The parameter, `event`, is optional. `mouseReleased()` is always passed a
267
+ * MouseEvent
268
+ * object with properties that describe the mouse release event:`function mouseReleased(event) {
269
+ * // Code to run that uses the event.
270
+ * console.log(event);
271
+ * }`On touchscreen devices, `mouseReleased()` will run when a user’s touch
272
+ * ends.Browsers may have default behaviors attached to various mouse events. For
273
+ * example, some browsers highlight text when the user moves the mouse while
274
+ * pressing a mouse button. To prevent any default behavior for this event,
275
+ * add `return false;` to the end of the function.Note: mousePressed(), `mouseReleased()`,
276
+ * and mouseClicked() are all related.
277
+ * mousePressed() runs as soon as the user
278
+ * clicks the mouse. `mouseReleased()` runs as soon as the user releases the
279
+ * mouse click. mouseClicked() runs
280
+ * immediately after `mouseReleased()`.
281
+ *
282
+ * @param optional `MouseEvent` argument.
283
+ * @example <div>
284
+ * <code>
285
+ * let value = 0;
286
+ *
287
+ * function setup() {
288
+ * createCanvas(100, 100);
289
+ *
290
+ * describe(
291
+ * 'A gray square with a black square at its center. The inner square becomes lighter when the user presses and releases a mouse button.'
292
+ * );
293
+ * }
294
+ *
295
+ * function draw() {
296
+ * background(200);
297
+ *
298
+ * // Style the square.
299
+ * fill(value);
300
+ *
301
+ * // Draw the square.
302
+ * square(25, 25, 50);
303
+ * }
304
+ *
305
+ * function mouseReleased() {
306
+ * // Update the grayscale value.
307
+ * value += 5;
308
+ *
309
+ * // Reset the grayscale value.
310
+ * if (value > 255) {
311
+ * value = 0;
312
+ * }
313
+ * // Uncomment to prevent any default behavior.
314
+ * // return false;
315
+ * }
316
+ * </code>
317
+ * </div>
318
+ *
319
+ * <div>
320
+ * <code>
321
+ * function setup() {
322
+ * createCanvas(100, 100);
323
+ *
324
+ * // Style the circle.
325
+ * fill('orange');
326
+ * stroke('royalblue');
327
+ * strokeWeight(10);
328
+ *
329
+ * describe(
330
+ * 'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.'
331
+ * );
332
+ * }
333
+ *
334
+ * function draw() {
335
+ * background(220);
336
+ *
337
+ * // Draw the circle.
338
+ * circle(50, 50, 20);
339
+ * }
340
+ *
341
+ * // Set the stroke color and weight as soon as the user clicks.
342
+ * function mousePressed() {
343
+ * stroke('deeppink');
344
+ * strokeWeight(3);
345
+ * }
346
+ *
347
+ * // Set the stroke and fill colors as soon as the user releases
348
+ * // the mouse.
349
+ * function mouseReleased() {
350
+ * stroke('royalblue');
351
+ *
352
+ * // This is never visible because fill() is called
353
+ * // in mouseClicked() which runs immediately after
354
+ * // mouseReleased();
355
+ * fill('limegreen');
356
+ * }
357
+ *
358
+ * // Set the fill color and stroke weight after
359
+ * // mousePressed() and mouseReleased() are called.
360
+ * function mouseClicked() {
361
+ * fill('orange');
362
+ * strokeWeight(10);
363
+ * }
364
+ * </code>
365
+ * </div>
366
+ */
367
+ function mouseReleased(event?: MouseEvent): void;
368
+
369
+ /**
370
+ * A function that's called once after a mouse button is pressed and released.Declaring the function `mouseClicked()` sets a code block to run
371
+ * automatically when the user releases a mouse button after having pressed
372
+ * it:`function mouseClicked() {
373
+ * // Code to run.
374
+ * }`The mouse system variables, such as mouseX and
375
+ * mouseY, will be updated with their most recent
376
+ * value when `mouseClicked()` is called by p5.js:`function mouseClicked() {
377
+ * if (mouseX < 50) {
378
+ * // Code to run if the mouse is on the left.
379
+ * }
380
+ *
381
+ * if (mouseY > 50) {
382
+ * // Code to run if the mouse is near the bottom.
383
+ * }
384
+ * }`The parameter, `event`, is optional. `mouseClicked()` is always passed a
385
+ * MouseEvent
386
+ * object with properties that describe the mouse click event:`function mouseClicked(event) {
387
+ * // Code to run that uses the event.
388
+ * console.log(event);
389
+ * }`On touchscreen devices, `mouseClicked()` will run when a user’s touch
390
+ * ends.Browsers may have default behaviors attached to various mouse events. For
391
+ * example, some browsers highlight text when the user moves the mouse while
392
+ * pressing a mouse button. To prevent any default behavior for this event,
393
+ * add `return false;` to the end of the function.Note: mousePressed(),
394
+ * mouseReleased(),
395
+ * and `mouseClicked()` are all related.
396
+ * mousePressed() runs as soon as the user
397
+ * clicks the mouse. mouseReleased() runs as
398
+ * soon as the user releases the mouse click. `mouseClicked()` runs
399
+ * immediately after mouseReleased().
400
+ *
401
+ * @param optional `MouseEvent` argument.
402
+ * @example <div>
403
+ * <code>
404
+ * let value = 0;
405
+ *
406
+ * function setup() {
407
+ * createCanvas(100, 100);
408
+ *
409
+ * describe(
410
+ * 'A gray square with a black square at its center. The inner square changes color when the user presses and releases a mouse button.'
411
+ * );
412
+ * }
413
+ *
414
+ * function draw() {
415
+ * background(200);
416
+ *
417
+ * // Style the square.
418
+ * fill(value);
419
+ *
420
+ * // Draw the square.
421
+ * square(25, 25, 50);
422
+ * }
423
+ *
424
+ * // Toggle the square's color when the user clicks.
425
+ * function mouseClicked() {
426
+ * if (value === 0) {
427
+ * value = 255;
428
+ * } else {
429
+ * value = 0;
430
+ * }
431
+ * // Uncomment to prevent any default behavior.
432
+ * // return false;
433
+ * }
434
+ * </code>
435
+ * </div>
436
+ *
437
+ * <div>
438
+ * <code>
439
+ * function setup() {
440
+ * createCanvas(100, 100);
441
+ *
442
+ * // Style the circle.
443
+ * fill('orange');
444
+ * stroke('royalblue');
445
+ * strokeWeight(10);
446
+ *
447
+ * describe(
448
+ * 'An orange circle with a thick, blue border drawn on a gray background. When the user presses and holds the mouse, the border becomes thin and pink. When the user releases the mouse, the border becomes thicker and changes color to blue.'
449
+ * );
450
+ * }
451
+ *
452
+ * function draw() {
453
+ * background(220);
454
+ *
455
+ * // Draw the circle.
456
+ * circle(50, 50, 20);
457
+ * }
458
+ *
459
+ * // Set the stroke color and weight as soon as the user clicks.
460
+ * function mousePressed() {
461
+ * stroke('deeppink');
462
+ * strokeWeight(3);
463
+ * }
464
+ *
465
+ * // Set the stroke and fill colors as soon as the user releases
466
+ * // the mouse.
467
+ * function mouseReleased() {
468
+ * stroke('royalblue');
469
+ *
470
+ * // This is never visible because fill() is called
471
+ * // in mouseClicked() which runs immediately after
472
+ * // mouseReleased();
473
+ * fill('limegreen');
474
+ * }
475
+ *
476
+ * // Set the fill color and stroke weight after
477
+ * // mousePressed() and mouseReleased() are called.
478
+ * function mouseClicked() {
479
+ * fill('orange');
480
+ * strokeWeight(10);
481
+ * }
482
+ * </code>
483
+ * </div>
484
+ */
485
+ function mouseClicked(event?: MouseEvent): void;
486
+
487
+ /**
488
+ * A function that's called once when a mouse button is clicked twice quickly.Declaring the function `doubleClicked()` sets a code block to run
489
+ * automatically when the user presses and releases the mouse button twice
490
+ * quickly:`function doubleClicked() {
491
+ * // Code to run.
492
+ * }`The mouse system variables, such as mouseX and
493
+ * mouseY, will be updated with their most recent
494
+ * value when `doubleClicked()` is called by p5.js:`function doubleClicked() {
495
+ * if (mouseX < 50) {
496
+ * // Code to run if the mouse is on the left.
497
+ * }
498
+ *
499
+ * if (mouseY > 50) {
500
+ * // Code to run if the mouse is near the bottom.
501
+ * }
502
+ * }`The parameter, `event`, is optional. `doubleClicked()` is always passed a
503
+ * MouseEvent
504
+ * object with properties that describe the double-click event:`function doubleClicked(event) {
505
+ * // Code to run that uses the event.
506
+ * console.log(event);
507
+ * }`On touchscreen devices, code placed in `doubleClicked()` will run after two
508
+ * touches that occur within a short time.Browsers may have default behaviors attached to various mouse events. For
509
+ * example, some browsers highlight text when the user moves the mouse while
510
+ * pressing a mouse button. To prevent any default behavior for this event,
511
+ * add `return false;` to the end of the function.
512
+ *
513
+ * @param optional `MouseEvent` argument.
514
+ * @example <div>
515
+ * <code>
516
+ * let value = 0;
517
+ *
518
+ * function setup() {
519
+ * createCanvas(100, 100);
520
+ *
521
+ * describe(
522
+ * 'A gray square with a black square at its center. The inner square changes color when the user double-clicks.'
523
+ * );
524
+ * }
525
+ *
526
+ * function draw() {
527
+ * background(200);
528
+ *
529
+ * // Style the square.
530
+ * fill(value);
531
+ *
532
+ * // Draw the square.
533
+ * square(25, 25, 50);
534
+ * }
535
+ *
536
+ * // Toggle the square's color when the user double-clicks.
537
+ * function doubleClicked() {
538
+ * if (value === 0) {
539
+ * value = 255;
540
+ * } else {
541
+ * value = 0;
542
+ * }
543
+ * // Uncomment to prevent any default behavior.
544
+ * // return false;
545
+ * }
546
+ * </code>
547
+ * </div>
548
+ *
549
+ * <div>
550
+ * <code>
551
+ * let value = 0;
552
+ *
553
+ * function setup() {
554
+ * createCanvas(100, 100);
555
+ *
556
+ * describe(
557
+ * 'A gray square with a black circle at its center. When the user double-clicks on the circle, it changes color to white.'
558
+ * );
559
+ * }
560
+ *
561
+ * function draw() {
562
+ * background(200);
563
+ *
564
+ * // Style the circle.
565
+ * fill(value);
566
+ *
567
+ * // Draw the circle.
568
+ * circle(50, 50, 80);
569
+ * }
570
+ *
571
+ * // Reassign value to 255 when the user double-clicks on the circle.
572
+ * function doubleClicked() {
573
+ * if (dist(50, 50, mouseX, mouseY) < 40) {
574
+ * value = 255;
575
+ * }
576
+ * // Uncomment to prevent any default behavior.
577
+ * // return false;
578
+ * }
579
+ * </code>
580
+ * </div>
581
+ */
582
+ function doubleClicked(event?: MouseEvent): void;
583
+
584
+ /**
585
+ * A function that's called once when the mouse wheel moves.Declaring the function `mouseWheel()` sets a code block to run
586
+ * automatically when the user scrolls with the mouse wheel:`function mouseWheel() {
587
+ * // Code to run.
588
+ * }`The mouse system variables, such as mouseX and
589
+ * mouseY, will be updated with their most recent
590
+ * value when `mouseWheel()` is called by p5.js:`function mouseWheel() {
591
+ * if (mouseX < 50) {
592
+ * // Code to run if the mouse is on the left.
593
+ * }
594
+ *
595
+ * if (mouseY > 50) {
596
+ * // Code to run if the mouse is near the bottom.
597
+ * }
598
+ * }`The parameter, `event`, is optional. `mouseWheel()` is always passed a
599
+ * MouseEvent
600
+ * object with properties that describe the mouse scroll event:`function mouseWheel(event) {
601
+ * // Code to run that uses the event.
602
+ * console.log(event);
603
+ * }`The `event` object has many properties including `delta`, a `Number`
604
+ * containing the distance that the user scrolled. For example, `event.delta`
605
+ * might have the value 5 when the user scrolls up. `event.delta` is positive
606
+ * if the user scrolls up and negative if they scroll down. The signs are
607
+ * opposite on macOS with "natural" scrolling enabled.Browsers may have default behaviors attached to various mouse events. For
608
+ * example, some browsers highlight text when the user moves the mouse while
609
+ * pressing a mouse button. To prevent any default behavior for this event,
610
+ * add `return false;` to the end of the function.Note: On Safari, `mouseWheel()` may only work as expected if
611
+ * `return false;` is added at the end of the function.
612
+ *
613
+ * @param optional `WheelEvent` argument.
614
+ * @example <div>
615
+ * <code>
616
+ * let circleSize = 0;
617
+ *
618
+ * function setup() {
619
+ * createCanvas(100, 100);
620
+ *
621
+ * describe(
622
+ * 'A gray square. A white circle at its center grows up when the user scrolls the mouse wheel.'
623
+ * );
624
+ * }
625
+ *
626
+ * function draw() {
627
+ * background(200);
628
+ *
629
+ * // Draw the circle
630
+ * circle(circleSize, 50, 50);
631
+ * }
632
+ *
633
+ * // Increment circleSize when the user scrolls the mouse wheel.
634
+ * function mouseWheel() {
635
+ * circleSize += 1;
636
+ * // Uncomment to prevent any default behavior.
637
+ * // return false;
638
+ * }
639
+ * </code>
640
+ * </div>
641
+ *
642
+ * <div>
643
+ * <code>
644
+ * let direction = '';
645
+ *
646
+ * function setup() {
647
+ * createCanvas(100, 100);
648
+ *
649
+ * describe(
650
+ * 'A gray square. An arrow at its center points up when the user scrolls up. The arrow points down when the user scrolls down.'
651
+ * );
652
+ * }
653
+ *
654
+ * function draw() {
655
+ * background(200);
656
+ *
657
+ * // Style the text.
658
+ * textAlign(CENTER);
659
+ * textSize(16);
660
+ *
661
+ * // Draw an arrow that points where
662
+ * // the mouse last scrolled.
663
+ * text(direction, 50, 50);
664
+ * }
665
+ *
666
+ * // Change direction when the user scrolls the mouse wheel.
667
+ * function mouseWheel(event) {
668
+ * if (event.delta > 0) {
669
+ * direction = '▲';
670
+ * } else {
671
+ * direction = '▼';
672
+ * }
673
+ * // Uncomment to prevent any default behavior.
674
+ * // return false;
675
+ * }
676
+ * </code>
677
+ * </div>
678
+ */
679
+ function mouseWheel(event?: WheelEvent): void;
680
+
681
+ /**
682
+ * Locks the mouse pointer to its current position and makes it invisible.`requestPointerLock()` allows the mouse to move forever without leaving the
683
+ * screen. Calling `requestPointerLock()` locks the values of
684
+ * mouseX, mouseY,
685
+ * pmouseX, and pmouseY.
686
+ * movedX and movedY
687
+ * continue updating and can be used to get the distance the mouse moved since
688
+ * the last frame was drawn. Calling
689
+ * exitPointerLock() resumes updating the
690
+ * mouse system variables.Note: Most browsers require an input, such as a click, before calling
691
+ * `requestPointerLock()`. It’s recommended to call `requestPointerLock()` in
692
+ * an event function such as doubleClicked().
693
+ *
694
+ * @example <div>
695
+ * <code>
696
+ * let score = 0;
697
+ *
698
+ * function setup() {
699
+ * createCanvas(100, 100);
700
+ *
701
+ * describe(
702
+ * 'A gray square with the text "Score: X" at its center. The score increases when the user moves the mouse upward. It decreases when the user moves the mouse downward.'
703
+ * );
704
+ * }
705
+ *
706
+ * function draw() {
707
+ * background(200);
708
+ *
709
+ * // Update the score.
710
+ * score -= movedY;
711
+ *
712
+ * // Style the text.
713
+ * textAlign(CENTER);
714
+ * textSize(16);
715
+ *
716
+ * // Display the score.
717
+ * text(`Score: ${score}`, 50, 50);
718
+ * }
719
+ *
720
+ * // Lock the pointer when the user double-clicks.
721
+ * function doubleClicked() {
722
+ * requestPointerLock();
723
+ * }
724
+ * </code>
725
+ * </div>
726
+ */
727
+ function requestPointerLock(): void;
728
+
729
+ /**
730
+ * Exits a pointer lock started with
731
+ * requestPointerLock.Calling `requestPointerLock()` locks the values of
732
+ * mouseX, mouseY,
733
+ * pmouseX, and pmouseY.
734
+ * Calling `exitPointerLock()` resumes updating the mouse system variables.Note: Most browsers require an input, such as a click, before calling
735
+ * `requestPointerLock()`. It’s recommended to call `requestPointerLock()` in
736
+ * an event function such as doubleClicked().
737
+ *
738
+ * @example <div>
739
+ * <code>
740
+ * let isLocked = false;
741
+ *
742
+ * function setup() {
743
+ * createCanvas(100, 100);
744
+ *
745
+ * describe(
746
+ * 'A gray square with a word at its center. The word changes between "Unlocked" and "Locked" when the user double-clicks.'
747
+ * );
748
+ * }
749
+ *
750
+ * function draw() {
751
+ * background(200);
752
+ *
753
+ * // Style the text.
754
+ * textAlign(CENTER);
755
+ * textSize(16);
756
+ *
757
+ * // Tell the user whether the pointer is locked.
758
+ * if (isLocked === true) {
759
+ * text('Locked', 50, 50);
760
+ * } else {
761
+ * text('Unlocked', 50, 50);
762
+ * }
763
+ * }
764
+ *
765
+ * // Toggle the pointer lock when the user double-clicks.
766
+ * function doubleClicked() {
767
+ * if (isLocked === true) {
768
+ * exitPointerLock();
769
+ * isLocked = false;
770
+ * } else {
771
+ * requestPointerLock();
772
+ * isLocked = true;
773
+ * }
774
+ * }
775
+ * </code>
776
+ * </div>
777
+ */
778
+ function exitPointerLock(): void;
779
+
780
+ }
781
+
782
+ export default function pointer(p5: any, fn: any): void;