p5 2.0.1 → 2.0.2

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-tYr0tCl8.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 +41 -75
  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 +1 -2
  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-CAxvgiOV.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-Swjl9HQO.js} +5 -5
  54. package/dist/{rendering--aAe5aq3.js → rendering-B5TRR7aY.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 +4 -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 +273 -225
  79. package/lib/p5.js +273 -225
  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 +5996 -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 +499 -0
  115. package/types/events/pointer.d.ts +782 -0
  116. package/types/global.d.ts +5542 -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 +6663 -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 +481 -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,54 @@
1
+ // This file is auto-generated from JSDoc documentation
2
+
3
+ import p5 from 'p5';
4
+
5
+ declare module 'p5' {
6
+ /**
7
+ * Creates a new FilterRenderer2D instance.
8
+ *
9
+ * @param The p5.js instance.
10
+ */
11
+ function constructor(pInst: p5): void;
12
+
13
+ /**
14
+ * Set the current filter operation and parameter. If a customShader is provided,
15
+ * that overrides the operation-based shader.
16
+ *
17
+ * @param The filter operation type (e.g., constants.BLUR).
18
+ * @param The strength of the filter.
19
+ * @param Optional custom shader.
20
+ */
21
+ function setOperation(operation: string, filterParameter: number, customShader: p5.Shader): void;
22
+
23
+ /**
24
+ * Initializes or retrieves the shader program for the current operation.
25
+ * If a customShader is provided, that is used.
26
+ * Otherwise, returns a cached shader if available, or creates a new one, caches it, and sets it as current.
27
+ *
28
+ */
29
+ function _initializeShader(): void;
30
+
31
+ /**
32
+ * Binds a buffer to the drawing context
33
+ * when passed more than two arguments it also updates or initializes
34
+ * the data associated with the buffer
35
+ *
36
+ */
37
+ function _bindBufferData(buffer: any, target: any, values: any): void;
38
+
39
+ /**
40
+ * Prepares and runs the full-screen quad draw call.
41
+ *
42
+ */
43
+ function _renderPass(): void;
44
+
45
+ /**
46
+ * Applies the current filter operation. If the filter requires multiple passes (e.g. blur),
47
+ * it handles those internally. Make sure setOperation() has been called before applyFilter().
48
+ *
49
+ */
50
+ function applyFilter(): void;
51
+
52
+ }
53
+
54
+ export default function filterRenderer2D(p5: any, fn: any): void;
@@ -0,0 +1,326 @@
1
+ // This file is auto-generated from JSDoc documentation
2
+
3
+ import p5 from 'p5';
4
+
5
+ declare module 'p5' {
6
+ /**
7
+ * Creates a new p5.Image object.`createImage()` uses the `width` and `height` parameters to set the new
8
+ * p5.Image object's dimensions in pixels. The new
9
+ * p5.Image can be modified by updating its
10
+ * pixels array or by calling its
11
+ * get() and
12
+ * set() methods. The
13
+ * loadPixels() method must be called
14
+ * before reading or modifying pixel values. The
15
+ * updatePixels() method must be called
16
+ * for updates to take effect.Note: The new p5.Image object is transparent by
17
+ * default.
18
+ *
19
+ * @param width in pixels.
20
+ * @param height in pixels.
21
+ * @return new <a href="#/p5.Image">p5.Image</a> object.
22
+ * @example <div>
23
+ * <code>
24
+ * function setup() {
25
+ * createCanvas(100, 100);
26
+ *
27
+ * background(200);
28
+ *
29
+ * // Create a p5.Image object.
30
+ * let img = createImage(66, 66);
31
+ *
32
+ * // Load the image's pixels into memory.
33
+ * img.loadPixels();
34
+ *
35
+ * // Set all the image's pixels to black.
36
+ * for (let x = 0; x < img.width; x += 1) {
37
+ * for (let y = 0; y < img.height; y += 1) {
38
+ * img.set(x, y, 0);
39
+ * }
40
+ * }
41
+ *
42
+ * // Update the image's pixel values.
43
+ * img.updatePixels();
44
+ *
45
+ * // Draw the image.
46
+ * image(img, 17, 17);
47
+ *
48
+ * describe('A black square drawn in the middle of a gray square.');
49
+ * }
50
+ * </code>
51
+ * </div>
52
+ *
53
+ * <div>
54
+ * <code>
55
+ * function setup() {
56
+ * createCanvas(100, 100);
57
+ *
58
+ * background(200);
59
+ *
60
+ * // Create a p5.Image object.
61
+ * let img = createImage(66, 66);
62
+ *
63
+ * // Load the image's pixels into memory.
64
+ * img.loadPixels();
65
+ *
66
+ * // Create a color gradient.
67
+ * for (let x = 0; x < img.width; x += 1) {
68
+ * for (let y = 0; y < img.height; y += 1) {
69
+ * // Calculate the transparency.
70
+ * let a = map(x, 0, img.width, 0, 255);
71
+ *
72
+ * // Create a p5.Color object.
73
+ * let c = color(0, a);
74
+ *
75
+ * // Set the pixel's color.
76
+ * img.set(x, y, c);
77
+ * }
78
+ * }
79
+ *
80
+ * // Update the image's pixels.
81
+ * img.updatePixels();
82
+ *
83
+ * // Display the image.
84
+ * image(img, 17, 17);
85
+ *
86
+ * describe('A square with a horizontal color gradient that transitions from gray to black.');
87
+ * }
88
+ * </code>
89
+ * </div>
90
+ *
91
+ * <div>
92
+ * <code>
93
+ * function setup() {
94
+ * createCanvas(100, 100);
95
+ *
96
+ * background(200);
97
+ *
98
+ * // Create a p5.Image object.
99
+ * let img = createImage(66, 66);
100
+ *
101
+ * // Load the pixels into memory.
102
+ * img.loadPixels();
103
+ * // Get the current pixel density.
104
+ * let d = pixelDensity();
105
+ *
106
+ * // Calculate the pixel that is halfway through the image's pixel array.
107
+ * let halfImage = 4 * (d * img.width) * (d * img.height / 2);
108
+ *
109
+ * // Set half of the image's pixels to black.
110
+ * for (let i = 0; i < halfImage; i += 4) {
111
+ * // Red.
112
+ * img.pixels[i] = 0;
113
+ * // Green.
114
+ * img.pixels[i + 1] = 0;
115
+ * // Blue.
116
+ * img.pixels[i + 2] = 0;
117
+ * // Alpha.
118
+ * img.pixels[i + 3] = 255;
119
+ * }
120
+ *
121
+ * // Update the image's pixels.
122
+ * img.updatePixels();
123
+ *
124
+ * // Display the image.
125
+ * image(img, 17, 17);
126
+ *
127
+ * describe('A black square drawn in the middle of a gray square.');
128
+ * }
129
+ * </code>
130
+ * </div>
131
+ */
132
+ function createImage(width: number, height: number): p5.Image;
133
+
134
+ /**
135
+ * Saves the current canvas as an image.By default, `saveCanvas()` saves the canvas as a PNG image called
136
+ * `untitled.png`.The first parameter, `filename`, is optional. It's a string that sets the
137
+ * file's name. If a file extension is included, as in
138
+ * `saveCanvas('drawing.png')`, then the image will be saved using that
139
+ * format.The second parameter, `extension`, is also optional. It sets the files format.
140
+ * Either `'png'`, `'webp'`, or `'jpg'` can be used. For example, `saveCanvas('drawing', 'jpg')`
141
+ * saves the canvas to a file called `drawing.jpg`.Note: The browser will either save the file immediately or prompt the user
142
+ * with a dialogue window.
143
+ *
144
+ * @param reference to a
145
+ * specific HTML5 canvas element.
146
+ * @param file name. Defaults to 'untitled'.
147
+ * @param file extension, either 'png', 'webp', or 'jpg'. Defaults to 'png'.
148
+ * @example <div class='norender'>
149
+ * <code>
150
+ * function setup() {
151
+ * createCanvas(100, 100);
152
+ * background(255);
153
+ *
154
+ * // Save the canvas to 'untitled.png'.
155
+ * saveCanvas();
156
+ *
157
+ * describe('A white square.');
158
+ * }
159
+ * </code>
160
+ * </div>
161
+ *
162
+ * <div class='norender'>
163
+ * <code>
164
+ * function setup() {
165
+ * createCanvas(100, 100);
166
+ *
167
+ * background(255);
168
+ *
169
+ * // Save the canvas to 'myCanvas.jpg'.
170
+ * saveCanvas('myCanvas.jpg');
171
+ *
172
+ * describe('A white square.');
173
+ * }
174
+ * </code>
175
+ * </div>
176
+ *
177
+ * <div class='norender'>
178
+ * <code>
179
+ * function setup() {
180
+ * createCanvas(100, 100);
181
+ *
182
+ * background(255);
183
+ *
184
+ * // Save the canvas to 'myCanvas.jpg'.
185
+ * saveCanvas('myCanvas', 'jpg');
186
+ *
187
+ * describe('A white square.');
188
+ * }
189
+ * </code>
190
+ * </div>
191
+ *
192
+ * <div class='norender'>
193
+ * <code>
194
+ * function setup() {
195
+ * let cnv = createCanvas(100, 100);
196
+ *
197
+ * background(255);
198
+ *
199
+ * // Save the canvas to 'untitled.png'.
200
+ * saveCanvas(cnv);
201
+ *
202
+ * describe('A white square.');
203
+ * }
204
+ * </code>
205
+ * </div>
206
+ *
207
+ * <div class='norender'>
208
+ * <code>
209
+ * function setup() {
210
+ * let cnv = createCanvas(100, 100);
211
+ *
212
+ * background(255);
213
+ *
214
+ * // Save the canvas to 'myCanvas.jpg'.
215
+ * saveCanvas(cnv, 'myCanvas.jpg');
216
+ *
217
+ * describe('A white square.');
218
+ * }
219
+ * </code>
220
+ * </div>
221
+ *
222
+ * <div class='norender'>
223
+ * <code>
224
+ * function setup() {
225
+ * let cnv = createCanvas(100, 100);
226
+ *
227
+ * background(255);
228
+ *
229
+ * // Save the canvas to 'myCanvas.jpg'.
230
+ * saveCanvas(cnv, 'myCanvas', 'jpg');
231
+ *
232
+ * describe('A white square.');
233
+ * }
234
+ * </code>
235
+ * </div>
236
+ */
237
+ function saveCanvas(selectedCanvas: p5.Framebuffer | p5.Element | HTMLCanvasElement, filename?: string, extension?: string): void;
238
+
239
+ /**
240
+ */
241
+ function saveCanvas(filename?: string, extension?: string): void;
242
+
243
+ /**
244
+ * Captures a sequence of frames from the canvas that can be saved as images.`saveFrames()` creates an array of frame objects. Each frame is stored as
245
+ * an object with its file type, file name, and image data as a string. For
246
+ * example, the first saved frame might have the following properties:`{ ext: 'png', filenmame: 'frame0', imageData: 'data:image/octet-stream;base64, abc123' }`.The first parameter, `filename`, sets the prefix for the file names. For
247
+ * example, setting the prefix to `'frame'` would generate the image files
248
+ * `frame0.png`, `frame1.png`, and so on.The second parameter, `extension`, sets the file type to either `'png'` or
249
+ * `'jpg'`.The third parameter, `duration`, sets the duration to record in seconds.
250
+ * The maximum duration is 15 seconds.The fourth parameter, `framerate`, sets the number of frames to record per
251
+ * second. The maximum frame rate value is 22. Limits are placed on `duration`
252
+ * and `framerate` to avoid using too much memory. Recording large canvases
253
+ * can easily crash sketches or even web browsers.The fifth parameter, `callback`, is optional. If a function is passed,
254
+ * image files won't be saved by default. The callback function can be used
255
+ * to process an array containing the data for each captured frame. The array
256
+ * of image data contains a sequence of objects with three properties for each
257
+ * frame: `imageData`, `filename`, and `extension`.Note: Frames are downloaded as individual image files by default.
258
+ *
259
+ * @param prefix of file name.
260
+ * @param file extension, either 'jpg' or 'png'.
261
+ * @param duration in seconds to record. This parameter will be constrained to be less or equal to 15.
262
+ * @param number of frames to save per second. This parameter will be constrained to be less or equal to 22.
263
+ * @param callback function that will be executed
264
+ * to handle the image data. This function
265
+ * should accept an array as argument. The
266
+ * array will contain the specified number of
267
+ * frames of objects. Each object has three
268
+ * properties: `imageData`, `filename`, and `extension`.
269
+ * @example <div>
270
+ * <code>
271
+ * function setup() {
272
+ * createCanvas(100, 100);
273
+ *
274
+ * describe('A square repeatedly changes color from blue to pink.');
275
+ * }
276
+ *
277
+ * function draw() {
278
+ * let r = frameCount % 255;
279
+ * let g = 50;
280
+ * let b = 100;
281
+ * background(r, g, b);
282
+ * }
283
+ *
284
+ * // Save the frames when the user presses the 's' key.
285
+ * function keyPressed() {
286
+ * if (key === 's') {
287
+ * saveFrames('frame', 'png', 1, 5);
288
+ * }
289
+ * }
290
+ * </code>
291
+ * </div>
292
+ *
293
+ * <div>
294
+ * <code>
295
+ * function setup() {
296
+ * createCanvas(100, 100);
297
+ *
298
+ * describe('A square repeatedly changes color from blue to pink.');
299
+ * }
300
+ *
301
+ * function draw() {
302
+ * let r = frameCount % 255;
303
+ * let g = 50;
304
+ * let b = 100;
305
+ * background(r, g, b);
306
+ * }
307
+ *
308
+ * // Print 5 frames when the user presses the mouse.
309
+ * function mousePressed() {
310
+ * saveFrames('frame', 'png', 1, 5, printFrames);
311
+ * }
312
+ *
313
+ * // Prints an array of objects containing raw image data, filenames, and extensions.
314
+ * function printFrames(frames) {
315
+ * for (let frame of frames) {
316
+ * print(frame);
317
+ * }
318
+ * }
319
+ * </code>
320
+ * </div>
321
+ */
322
+ function saveFrames(filename: string, extension: string, duration: number, framerate: number, callback?: any): void;
323
+
324
+ }
325
+
326
+ export default function image(p5: any, fn: any): void;