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,575 @@
1
+ // This file is auto-generated from JSDoc documentation
2
+
3
+ import p5 from 'p5';
4
+
5
+ declare module 'p5' {
6
+ class Font {
7
+ /**
8
+ * Returns a flat array of path commands that describe the outlines of a string of text.Each command is represented as an array of the form `[type, ...coords]`, where:`'M'` indicates a "move to" (starting a new contour),
9
+ * `'L'` a line segment,
10
+ * `'Q'` a quadratic bezier,
11
+ * `'C'` a cubic bezier, and
12
+ * `'Z'` closes the current path.The first two parameters, `x` and `y`, specify the baseline origin for the text.
13
+ * Optionally, you can provide a `width` and `height` for text wrapping; if you don't need
14
+ * wrapping, you can omit them and directly pass `options` as the fourth parameter.
15
+ *
16
+ * @param
17
+ * @param
18
+ * @param
19
+ * @param
20
+ * @param
21
+ * @param
22
+ */
23
+ textToPaths(str: string, x: number, y: number, width: number, height: number, options: object): Array[];
24
+
25
+ /**
26
+ * Returns an array of points outlining a string of text written using the
27
+ * font.Each point object in the array has three properties that describe the
28
+ * point's location and orientation, called its path angle. For example,
29
+ * `{ x: 10, y: 20, alpha: 450 }`.The first parameter, `str`, is a string of text. The second and third
30
+ * parameters, `x` and `y`, are the text's position. By default, they set the
31
+ * coordinates of the bounding box's bottom-left corner. See
32
+ * textAlign() for more ways to align text.The fourth parameter, `options`, is also optional. `font.textToPoints()`
33
+ * expects an object with the following properties:`sampleFactor` is the ratio of the text's path length to the number of
34
+ * samples. It defaults to 0.1. Higher values produce more points along the
35
+ * path and are more precise.`simplifyThreshold` removes collinear points if it's set to a number other
36
+ * than 0. The value represents the threshold angle to use when determining
37
+ * whether two edges are collinear.
38
+ *
39
+ * @param
40
+ * @param
41
+ * @param
42
+ * @param
43
+ * @param
44
+ * @param
45
+ */
46
+ textToPoints(str: string, x: number, y: number, width: any, height: any, options: object): object[];
47
+
48
+ /**
49
+ * Returns an array of arrays of points outlining a string of text written using the
50
+ * font. Each array represents a contour, so the letter O will have two outer arrays:
51
+ * one for the outer edge of the shape, and one for the inner edge of the hole.Each point object in a contour array has three properties that describe the
52
+ * point's location and orientation, called its path angle. For example,
53
+ * `{ x: 10, y: 20, alpha: 450 }`.The first parameter, `str`, is a string of text. The second and third
54
+ * parameters, `x` and `y`, are the text's position. By default, they set the
55
+ * coordinates of the bounding box's bottom-left corner. See
56
+ * textAlign() for more ways to align text.The fourth parameter, `options`, is also optional. `font.textToPoints()`
57
+ * expects an object with the following properties:`sampleFactor` is the ratio of the text's path length to the number of
58
+ * samples. It defaults to 0.1. Higher values produce more points along the
59
+ * path and are more precise.`simplifyThreshold` removes collinear points if it's set to a number other
60
+ * than 0. The value represents the threshold angle to use when determining
61
+ * whether two edges are collinear.
62
+ *
63
+ * @param
64
+ * @param
65
+ * @param
66
+ * @param
67
+ * @param
68
+ * @param
69
+ */
70
+ textToContours(str: string, x: number, y: number, width: any, height: any, options: object): object[][];
71
+
72
+ /**
73
+ * Converts text into a 3D model that can be rendered in WebGL mode.This method transforms flat text into extruded 3D geometry, allowing
74
+ * for dynamic effects like depth, warping, and custom shading.It works by taking the outlines (contours) of each character in the
75
+ * provided text string and constructing a 3D shape from them.Once your 3D text is ready, you can rotate it in 3D space using orbitControl()
76
+ * — just click and drag with your mouse to see it from all angles!Use the extrude slider to give your letters depth: slide it up, and your
77
+ * flat text turns into a solid, multi-dimensional object.You can also choose from various fonts such as "Anton", "Montserrat", or "Source Serif",
78
+ * much like selecting fancy fonts in a word processor,The generated model (a Geometry object) can be manipulated further—rotated, scaled,
79
+ * or styled with shaders—to create engaging, interactive visual art.
80
+ *
81
+ * @param
82
+ * @param
83
+ * @param
84
+ * @param
85
+ * @param
86
+ * @param
87
+ */
88
+ textToModel(str: string, x: number, y: number, width: number, height: number, options: object): p5.Geometry;
89
+
90
+ }
91
+
92
+ /**
93
+ * Returns a flat array of path commands that describe the outlines of a string of text.Each command is represented as an array of the form `[type, ...coords]`, where:`'M'` indicates a "move to" (starting a new contour),
94
+ * `'L'` a line segment,
95
+ * `'Q'` a quadratic bezier,
96
+ * `'C'` a cubic bezier, and
97
+ * `'Z'` closes the current path.The first two parameters, `x` and `y`, specify the baseline origin for the text.
98
+ * Optionally, you can provide a `width` and `height` for text wrapping; if you don't need
99
+ * wrapping, you can omit them and directly pass `options` as the fourth parameter.
100
+ *
101
+ * @param The text to convert into path commands.
102
+ * @param x‐coordinate of the text baseline.
103
+ * @param y‐coordinate of the text baseline.
104
+ * @param Optional width for text wrapping.
105
+ * @param Optional height for text wrapping.
106
+ * @param Configuration object for rendering text.
107
+ * @return A flat array of path commands.
108
+ * @example <div>
109
+ * <code>
110
+ * let font;
111
+ *
112
+ * async function setup() {
113
+ * font = await loadFont('assets/inconsolata.otf');
114
+ * createCanvas(200, 200);
115
+ * background(220);
116
+ * noLoop();
117
+ * }
118
+ *
119
+ * function draw() {
120
+ * background(220);
121
+ * stroke(0);
122
+ * noFill();
123
+ * textSize(60);
124
+ *
125
+ * // Get path commands for "Hello" (drawn at baseline x=50, y=100):
126
+ * const pathCommands = font.textToPaths('Hello', 30, 110);
127
+ *
128
+ * beginShape();
129
+ * for (let i = 0; i < pathCommands.length; i++) {
130
+ * const cmd = pathCommands[i];
131
+ * const type = cmd[0];
132
+ *
133
+ * switch (type) {
134
+ * case 'M': {
135
+ * // Move to (start a new contour)
136
+ * const x = cmd[1];
137
+ * const y = cmd[2];
138
+ * endContour(); // In case we were already drawing
139
+ * beginContour();
140
+ * vertex(x, y);
141
+ * break;
142
+ * }
143
+ * case 'L': {
144
+ * // Line to
145
+ * const x = cmd[1];
146
+ * const y = cmd[2];
147
+ * vertex(x, y);
148
+ * break;
149
+ * }
150
+ * case 'Q': {
151
+ * // Quadratic bezier
152
+ * const cx = cmd[1];
153
+ * const cy = cmd[2];
154
+ * const x = cmd[3];
155
+ * const y = cmd[4];
156
+ * bezierOrder(2);
157
+ * bezierVertex(cx, cy);
158
+ * bezierVertex(x, y);
159
+ * break;
160
+ * }
161
+ * case 'C': {
162
+ * // Cubic bezier
163
+ * const cx1 = cmd[1];
164
+ * const cy1 = cmd[2];
165
+ * const cx2 = cmd[3];
166
+ * const cy2 = cmd[4];
167
+ * const x = cmd[5];
168
+ * const y = cmd[6];
169
+ * bezierOrder(3);
170
+ * bezierVertex(cx1, cy1);
171
+ * bezierVertex(cx2, cy2);
172
+ * bezierVertex(x, y);
173
+ * break;
174
+ * }
175
+ * case 'Z': {
176
+ * // Close path
177
+ * endContour(CLOSE);
178
+ * beginContour();
179
+ * break;
180
+ * }
181
+ * }
182
+ * }
183
+ * endContour();
184
+ * endShape();
185
+ * }
186
+ * </code>
187
+ * </div>
188
+ */
189
+ function textToPaths(str: string, x: number, y: number, width?: number, height?: number, options?: object): Array[];
190
+
191
+ /**
192
+ * Returns an array of points outlining a string of text written using the
193
+ * font.Each point object in the array has three properties that describe the
194
+ * point's location and orientation, called its path angle. For example,
195
+ * `{ x: 10, y: 20, alpha: 450 }`.The first parameter, `str`, is a string of text. The second and third
196
+ * parameters, `x` and `y`, are the text's position. By default, they set the
197
+ * coordinates of the bounding box's bottom-left corner. See
198
+ * textAlign() for more ways to align text.The fourth parameter, `options`, is also optional. `font.textToPoints()`
199
+ * expects an object with the following properties:`sampleFactor` is the ratio of the text's path length to the number of
200
+ * samples. It defaults to 0.1. Higher values produce more points along the
201
+ * path and are more precise.`simplifyThreshold` removes collinear points if it's set to a number other
202
+ * than 0. The value represents the threshold angle to use when determining
203
+ * whether two edges are collinear.
204
+ *
205
+ * @param string of text.
206
+ * @param x-coordinate of the text.
207
+ * @param y-coordinate of the text.
208
+ * @param object with sampleFactor and simplifyThreshold
209
+ * properties.
210
+ * @return array of point objects, each with `x`, `y`, and `alpha` (path angle) properties.
211
+ * @example <div>
212
+ * <code>
213
+ * let font;
214
+ *
215
+ * async function setup() {
216
+ * createCanvas(100, 100);
217
+ * font = await loadFont('assets/inconsolata.otf');
218
+ *
219
+ * background(200);
220
+ * textSize(35);
221
+ *
222
+ * // Get the point array.
223
+ * let points = font.textToPoints('p5*js', 6, 60, { sampleFactor: 0.5 });
224
+ *
225
+ * // Draw a dot at each point.
226
+ * for (let p of points) {
227
+ * point(p.x, p.y);
228
+ * }
229
+ *
230
+ * describe('A set of black dots outlining the text "p5*js" on a gray background.');
231
+ * }
232
+ * </code>
233
+ * </div>
234
+ */
235
+ function textToPoints(str: string, x: number, y: number, width: any, height: any, options?: object): object[];
236
+
237
+ /**
238
+ * Returns an array of arrays of points outlining a string of text written using the
239
+ * font. Each array represents a contour, so the letter O will have two outer arrays:
240
+ * one for the outer edge of the shape, and one for the inner edge of the hole.Each point object in a contour array has three properties that describe the
241
+ * point's location and orientation, called its path angle. For example,
242
+ * `{ x: 10, y: 20, alpha: 450 }`.The first parameter, `str`, is a string of text. The second and third
243
+ * parameters, `x` and `y`, are the text's position. By default, they set the
244
+ * coordinates of the bounding box's bottom-left corner. See
245
+ * textAlign() for more ways to align text.The fourth parameter, `options`, is also optional. `font.textToPoints()`
246
+ * expects an object with the following properties:`sampleFactor` is the ratio of the text's path length to the number of
247
+ * samples. It defaults to 0.1. Higher values produce more points along the
248
+ * path and are more precise.`simplifyThreshold` removes collinear points if it's set to a number other
249
+ * than 0. The value represents the threshold angle to use when determining
250
+ * whether two edges are collinear.
251
+ *
252
+ * @param string of text.
253
+ * @param x-coordinate of the text.
254
+ * @param y-coordinate of the text.
255
+ * @param object with sampleFactor and simplifyThreshold
256
+ * properties.
257
+ * @return array of point objects, each with `x`, `y`, and `alpha` (path angle) properties.
258
+ * @example <div>
259
+ * <code>
260
+ * let font;
261
+ *
262
+ * async function setup() {
263
+ * createCanvas(100, 100);
264
+ * font = await loadFont('/assets/inconsolata.otf');
265
+ * }
266
+ *
267
+ * function draw() {
268
+ * background(200);
269
+ * textAlign(CENTER, CENTER);
270
+ * textSize(30);
271
+ *
272
+ * // Get the point array.
273
+ * let contours = font.textToContours('p5*js', width/2, height/2, { sampleFactor: 0.5 });
274
+ *
275
+ * beginShape();
276
+ * for (const pts of contours) {
277
+ * beginContour();
278
+ * for (const pt of pts) {
279
+ * vertex(pt.x + 5*sin(pt.y*0.1 + millis()*0.01), pt.y);
280
+ * }
281
+ * endContour(CLOSE);
282
+ * }
283
+ * endShape();
284
+ *
285
+ * describe('The text p5*js wobbling over time');
286
+ * }
287
+ * </code>
288
+ * </div>
289
+ */
290
+ function textToContours(str: string, x: number, y: number, width: any, height: any, options?: object): object[][];
291
+
292
+ /**
293
+ * Converts text into a 3D model that can be rendered in WebGL mode.This method transforms flat text into extruded 3D geometry, allowing
294
+ * for dynamic effects like depth, warping, and custom shading.It works by taking the outlines (contours) of each character in the
295
+ * provided text string and constructing a 3D shape from them.Once your 3D text is ready, you can rotate it in 3D space using orbitControl()
296
+ * — just click and drag with your mouse to see it from all angles!Use the extrude slider to give your letters depth: slide it up, and your
297
+ * flat text turns into a solid, multi-dimensional object.You can also choose from various fonts such as "Anton", "Montserrat", or "Source Serif",
298
+ * much like selecting fancy fonts in a word processor,The generated model (a Geometry object) can be manipulated further—rotated, scaled,
299
+ * or styled with shaders—to create engaging, interactive visual art.
300
+ *
301
+ * @param The text string to convert into a 3D model.
302
+ * @param The x-coordinate for the starting position of the text.
303
+ * @param The y-coordinate for the starting position of the text.
304
+ * @param Maximum width of the text block (wraps text if exceeded).
305
+ * @param Maximum height of the text block.
306
+ * @param Configuration options for the 3D text:
307
+ * @param The depth to extrude the text. A value of 0 produces
308
+ * flat text; higher values create thicker, 3D models.
309
+ * @param A factor controlling the level of detail for the text contours.
310
+ * Higher values result in smoother curves.
311
+ * @return A geometry object representing the 3D model of the text.
312
+ * @example <div modernizr='webgl'>
313
+ * <code>
314
+ * let font;
315
+ * let geom;
316
+ *
317
+ * async function setup() {
318
+ * createCanvas(200, 200, WEBGL);
319
+ * font = await loadFont('https://fonts.gstatic.com/s/anton/v25/1Ptgg87LROyAm0K08i4gS7lu.ttf');
320
+ *
321
+ * geom = font.textToModel("Hello", 50, 0, { sampleFactor: 2 });
322
+ * geom.clearColors();
323
+ * geom.normalize();
324
+ * }
325
+ *
326
+ * function draw() {
327
+ * background(255);
328
+ * orbitControl();
329
+ * fill("red");
330
+ * strokeWeight(4);
331
+ * scale(min(width, height) / 300);
332
+ * model(geom);
333
+ * describe('A red non-extruded "Hello" in Anton on white canvas, rotatable via mouse.');
334
+ * }
335
+ * </code>
336
+ * </div>
337
+ * @example <div modernizr='webgl'>
338
+ * <code>
339
+ * let font;
340
+ * let geom;
341
+ *
342
+ * async function setup() {
343
+ * createCanvas(200, 200, WEBGL);
344
+ *
345
+ * // Alternative fonts:
346
+ * // Anton: 'https://fonts.gstatic.com/s/anton/v25/1Ptgg87LROyAm0K08i4gS7lu.ttf'
347
+ * // Montserrat: 'https://fonts.gstatic.com/s/montserrat/v29/JTUHjIg1_i6t8kCHKm4532VJOt5-QNFgpCtr6Ew-Y3tcoqK5.ttf'
348
+ * // Source Serif: 'https://fonts.gstatic.com/s/sourceserif4/v8/vEFy2_tTDB4M7-auWDN0ahZJW3IX2ih5nk3AucvUHf6OAVIJmeUDygwjihdqrhxXD-wGvjU.ttf'
349
+ *
350
+ * // Using Source Serif for this example:
351
+ * font = await loadFont('https://fonts.gstatic.com/s/sourceserif4/v8/vEFy2_tTDB4M7-auWDN0ahZJW3IX2ih5nk3AucvUHf6OAVIJmeUDygwjihdqrhxXD-wGvjU.ttf');
352
+ *
353
+ * geom = font.textToModel("Hello", 50, 0, { sampleFactor: 2, extrude: 5 });
354
+ * geom.clearColors();
355
+ * geom.normalize();
356
+ * }
357
+ *
358
+ * function draw() {
359
+ * background(255);
360
+ * orbitControl();
361
+ * fill("red");
362
+ * strokeWeight(4);
363
+ * scale(min(width, height) / 300);
364
+ * model(geom);
365
+ * describe('3D red extruded "Hello" in Source Serif on white, rotatable via mouse.');
366
+ * }
367
+ * </code>
368
+ * </div>
369
+ * @example <div modernizr='webgl'>
370
+ * <code>
371
+ * let geom;
372
+ * let activeFont;
373
+ * let artShader;
374
+ * let lineShader;
375
+ *
376
+ * // Define parameters as simple variables
377
+ * let words = 'HELLO';
378
+ * let warp = 1;
379
+ * let extrude = 5;
380
+ * let palette = ["#ffe03d", "#fe4830", "#d33033", "#6d358a", "#1c509e", "#00953c"];
381
+ *
382
+ * async function setup() {
383
+ * createCanvas(200, 200, WEBGL);
384
+ *
385
+ * // Using Anton as the default font for this example:
386
+ *
387
+ * // Alternative fonts:
388
+ * // Anton: 'https://fonts.gstatic.com/s/anton/v25/1Ptgg87LROyAm0K08i4gS7lu.ttf'
389
+ * // Montserrat: 'https://fonts.gstatic.com/s/montserrat/v29/JTUHjIg1_i6t8kCHKm4532VJOt5-QNFgpCtr6Ew-Y3tcoqK5.ttf'
390
+ * // Source Serif: 'https://fonts.gstatic.com/s/sourceserif4/v8/vEFy2_tTDB4M7-auWDN0ahZJW3IX2ih5nk3AucvUHf6OAVIJmeUDygwjihdqrhxXD-wGvjU.ttf'
391
+ * activeFont = await loadFont('https://fonts.gstatic.com/s/anton/v25/1Ptgg87LROyAm0K08i4gS7lu.ttf');
392
+ *
393
+ * geom = activeFont.textToModel(words, 0, 50, { sampleFactor: 2, extrude });
394
+ * geom.clearColors();
395
+ * geom.normalize();
396
+ *
397
+ * artShader = baseMaterialShader().modify({
398
+ * uniforms: {
399
+ * 'float time': () => millis(),
400
+ * 'float warp': () => warp,
401
+ * 'float numColors': () => palette.length,
402
+ * 'vec3[6] colors': () => palette.flatMap((c) => [red(c)/255, green(c)/255, blue(c)/255]),
403
+ * },
404
+ * vertexDeclarations: 'out vec3 vPos;',
405
+ * fragmentDeclarations: 'in vec3 vPos;',
406
+ * 'Vertex getObjectInputs': `(Vertex inputs) {
407
+ * vPos = inputs.position;
408
+ * inputs.position.x += 5. * warp * sin(inputs.position.y * 0.1 + time * 0.001) / (1. + warp);
409
+ * inputs.position.y += 5. * warp * sin(inputs.position.x * 0.1 + time * 0.0009) / (1. + warp);
410
+ * return inputs;
411
+ * }`,
412
+ * 'vec4 getFinalColor': `(vec4 _c) {
413
+ * float x = vPos.x * 0.005;
414
+ * float a = floor(fract(x) * numColors);
415
+ * float b = a == numColors - 1. ? 0. : a + 1.;
416
+ * float t = fract(x * numColors);
417
+ * vec3 c = mix(colors[int(a)], colors[int(b)], t);
418
+ * return vec4(c, 1.);
419
+ * }`
420
+ * });
421
+ *
422
+ * lineShader = baseStrokeShader().modify({
423
+ * uniforms: {
424
+ * 'float time': () => millis(),
425
+ * 'float warp': () => warp,
426
+ * },
427
+ * 'StrokeVertex getObjectInputs': `(StrokeVertex inputs) {
428
+ * inputs.position.x += 5. * warp * sin(inputs.position.y * 0.1 + time * 0.001) / (1. + warp);
429
+ * inputs.position.y += 5. * warp * sin(inputs.position.x * 0.1 + time * 0.0009) / (1. + warp);
430
+ * return inputs;
431
+ * }`,
432
+ * });
433
+ * }
434
+ *
435
+ * function draw() {
436
+ * background(255);
437
+ * orbitControl();
438
+ * shader(artShader);
439
+ * strokeShader(lineShader);
440
+ * strokeWeight(4);
441
+ * scale(min(width, height) / 210);
442
+ * model(geom);
443
+ * describe('3D wavy with different color sets "Hello" in Anton on white canvas, rotatable via mouse.');
444
+ * }
445
+ * </code>
446
+ * </div>
447
+ */
448
+ function textToModel(str: string, x: number, y: number, width: number, height: number, options?: object): p5.Geometry;
449
+
450
+ /**
451
+ * Loads a font and creates a p5.Font object.
452
+ * `loadFont()` can load fonts in either .otf or .ttf format. Loaded fonts can
453
+ * be used to style text on the canvas and in HTML elements.The first parameter, `path`, is the path to a font file.
454
+ * Paths to local files should be relative. For example,
455
+ * `'assets/inconsolata.otf'`. The Inconsolata font used in the following
456
+ * examples can be downloaded for free
457
+ * here.
458
+ * Paths to remote files should be URLs. For example,
459
+ * `'https://example.com/inconsolata.otf'`. URLs may be blocked due to browser
460
+ * security.In 2D mode, `path` can take on a few other forms. It could be a path to a CSS file,
461
+ * such as one from Google Fonts. It could also
462
+ * be a string with a CSS `@font-face` declaration.The second parameter, `successCallback`, is optional. If a function is
463
+ * passed, it will be called once the font has loaded. The callback function
464
+ * may use the new p5.Font object if needed.The third parameter, `failureCallback`, is also optional. If a function is
465
+ * passed, it will be called if the font fails to load. The callback function
466
+ * may use the error
467
+ * Event
468
+ * object if needed.Fonts can take time to load. `await` the result of `loadFont()` in
469
+ * setup() before using the result.
470
+ *
471
+ * @for p5
472
+ * @param path of the font or CSS file to be loaded, or a CSS `@font-face` string.
473
+ * @param An alias that can be used for this font in `textFont()`. Defaults to the name in the font's metadata.
474
+ * @param An optional object with extra CSS font face descriptors, or p5.js font settings.
475
+ * @param (Experimental) An optional string of list of strings with Unicode character set names that should be included. When a CSS file is used as the font, it may contain multiple font files. The font best matching the requested character sets will be picked.
476
+ * @param function called with the
477
+ * <a href="#/p5.Font">p5.Font</a> object after it
478
+ * loads.
479
+ * @param function called with the error
480
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/Event" target="_blank">Event</a>
481
+ * object if the font fails to load.
482
+ * @return <a href="#/p5.Font">p5.Font</a> object.
483
+ * @example <div>
484
+ * <code>
485
+ * let font;
486
+ *
487
+ * async function setup() {
488
+ * createCanvas(100, 100);
489
+ * font = await loadFont('assets/inconsolata.otf');
490
+ * fill('deeppink');
491
+ * textFont(font);
492
+ * textSize(36);
493
+ * text('p5*js', 10, 50);
494
+ *
495
+ * describe('The text "p5*js" written in pink on a white background.');
496
+ * }
497
+ * </code>
498
+ * </div>
499
+ * @example <div>
500
+ * <code>
501
+ * function setup() {
502
+ * createCanvas(100, 100);
503
+ * loadFont('assets/inconsolata.otf', font => {
504
+ * fill('deeppink');
505
+ * textFont(font);
506
+ * textSize(36);
507
+ * text('p5*js', 10, 50);
508
+ *
509
+ * describe('The text "p5*js" written in pink on a white background.');
510
+ * });
511
+ * }
512
+ * </code>
513
+ * </div>
514
+ * @example <div>
515
+ * <code>
516
+ * function setup() {
517
+ * createCanvas(100, 100);
518
+ * loadFont('assets/inconsolata.otf', success, failure);
519
+ * }
520
+ *
521
+ * function success(font) {
522
+ * fill('deeppink');
523
+ * textFont(font);
524
+ * textSize(36);
525
+ * text('p5*js', 10, 50);
526
+ *
527
+ * describe('The text "p5*js" written in pink on a white background.');
528
+ * }
529
+ *
530
+ * function failure(event) {
531
+ * console.error('Oops!', event);
532
+ * }
533
+ * </code>
534
+ * </div>
535
+ * @example <div>
536
+ * <code>
537
+ * async function setup() {
538
+ * createCanvas(100, 100);
539
+ * await loadFont('assets/inconsolata.otf');
540
+ * let p = createP('p5*js');
541
+ * p.style('color', 'deeppink');
542
+ * p.style('font-family', 'Inconsolata');
543
+ * p.style('font-size', '36px');
544
+ * p.position(10, 50);
545
+ *
546
+ * describe('The text "p5*js" written in pink on a white background.');
547
+ * }
548
+ * </code>
549
+ * </div>
550
+ * @example <div class="norender">
551
+ * <code>
552
+ * // Some other forms of loading fonts:
553
+ * loadFont("https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,200..800&display=swap");
554
+ * loadFont(`@font-face { font-family: "Bricolage Grotesque", serif; font-optical-sizing: auto; font-weight: 400; font-style: normal; font-variation-settings: "wdth" 100; }`);
555
+ * </code>
556
+ * </div>
557
+ */
558
+ function loadFont(path: string, name?: string, options?: object, successCallback?: Function, failureCallback?: Function): Promise<p5.Font>;
559
+
560
+ /**
561
+ * @for p5
562
+ * @param path of the font to be loaded.
563
+ * @param function called with the
564
+ * <a href="#/p5.Font">p5.Font</a> object after it
565
+ * loads.
566
+ * @param function called with the error
567
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/Event" target="_blank">Event</a>
568
+ * object if the font fails to load.
569
+ * @returns The font.
570
+ */
571
+ function loadFont(path: string, successCallback?: Function, failureCallback?: Function): Promise<p5.Font>;
572
+
573
+ }
574
+
575
+ export default function p5_Font(p5: any, fn: any): void;