p5 2.0.0 → 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 (267) hide show
  1. package/{src → dist}/accessibility/color_namer.js +48 -3
  2. package/{src → dist}/accessibility/describe.js +12 -2
  3. package/{src → dist}/accessibility/gridOutput.js +2 -2
  4. package/dist/accessibility/index.js +60 -0
  5. package/{src → dist}/accessibility/outputs.js +23 -2
  6. package/{src → dist}/accessibility/textOutput.js +2 -2
  7. package/dist/app.js +120 -0
  8. package/{src → dist}/color/color_conversion.js +48 -10
  9. package/{src → dist}/color/color_spaces/hsb.js +3 -1
  10. package/dist/color/creating_reading.js +3 -0
  11. package/dist/color/index.js +13 -0
  12. package/dist/color/p5.Color.culori.js +1 -0
  13. package/dist/color/p5.Color.js +3 -0
  14. package/{src → dist}/color/setting.js +9 -6
  15. package/{src/core/constants.js → dist/constants-tYr0tCl8.js} +284 -132
  16. package/{src → dist}/core/States.js +3 -1
  17. package/dist/core/constants.js +1 -0
  18. package/{src → dist}/core/environment.js +12 -10
  19. package/{src → dist}/core/friendly_errors/browser_errors.js +1 -1
  20. package/{src → dist}/core/friendly_errors/fes_core.js +14 -44
  21. package/{src → dist}/core/friendly_errors/file_errors.js +6 -3
  22. package/dist/core/friendly_errors/index.js +23 -0
  23. package/dist/core/friendly_errors/param_validator.js +5421 -0
  24. package/{src → dist}/core/friendly_errors/sketch_reader.js +50 -4
  25. package/{src → dist}/core/friendly_errors/sketch_verifier.js +6 -6
  26. package/{src → dist}/core/friendly_errors/stacktrace.js +3 -5
  27. package/{src → dist}/core/friendly_errors/validate_params.js +50 -41
  28. package/{src → dist}/core/helpers.js +9 -6
  29. package/dist/core/init.js +105 -0
  30. package/dist/core/internationalization.js +302 -0
  31. package/dist/core/legacy.js +73 -0
  32. package/dist/core/main.js +44 -0
  33. package/dist/core/noop.js +3 -0
  34. package/dist/core/p5.Graphics.js +40 -0
  35. package/dist/core/p5.Renderer.js +11 -0
  36. package/dist/core/p5.Renderer2D.js +44 -0
  37. package/dist/core/reference.js +1 -0
  38. package/dist/core/rendering.js +40 -0
  39. package/{src → dist}/core/structure.js +3 -3
  40. package/{src → dist}/core/transform.js +2 -2
  41. package/{src/color/creating_reading.js → dist/creating_reading-Cr8L2Jnm.js} +841 -13
  42. package/{src → dist}/data/index.js +3 -1
  43. package/{src → dist}/data/local_storage.js +2 -8
  44. package/{src → dist}/dom/dom.js +19 -13
  45. package/dist/dom/index.js +18 -0
  46. package/{src → dist}/dom/p5.Element.js +14 -12
  47. package/{src → dist}/dom/p5.File.js +4 -4
  48. package/{src → dist}/dom/p5.MediaElement.js +10 -4
  49. package/{src → dist}/events/acceleration.js +26 -26
  50. package/{src → dist}/events/index.js +3 -1
  51. package/{src → dist}/events/keyboard.js +14 -12
  52. package/{src → dist}/events/pointer.js +16 -17
  53. package/dist/image/const.js +9 -0
  54. package/{src → dist}/image/filterRenderer2D.js +57 -37
  55. package/{src → dist}/image/filters.js +1 -3
  56. package/dist/image/image.js +40 -0
  57. package/dist/image/index.js +51 -0
  58. package/dist/image/loading_displaying.js +40 -0
  59. package/dist/image/p5.Image.js +11 -0
  60. package/{src → dist}/image/pixels.js +5 -3
  61. package/{src → dist}/io/csv.js +72 -70
  62. package/dist/io/files.js +40 -0
  63. package/dist/io/index.js +51 -0
  64. package/{src → dist}/io/p5.Table.js +6 -6
  65. package/{src → dist}/io/p5.TableRow.js +5 -6
  66. package/{src → dist}/io/p5.XML.js +2 -5
  67. package/{src → dist}/io/utilities.js +1 -1
  68. package/{src/core/p5.Renderer2D.js → dist/main-CAxvgiOV.js} +738 -57
  69. package/{src → dist}/math/Matrices/Matrix.js +10 -8
  70. package/{src → dist}/math/Matrices/MatrixInterface.js +5 -3
  71. package/{src → dist}/math/Matrices/MatrixNumjs.js +12 -26
  72. package/{src → dist}/math/calculation.js +2 -2
  73. package/{src → dist}/math/index.js +6 -3
  74. package/{src → dist}/math/math.js +3 -3
  75. package/{src → dist}/math/noise.js +2 -2
  76. package/{src → dist}/math/p5.Matrix.js +7 -4
  77. package/{src → dist}/math/p5.Vector.js +6 -6
  78. package/{src → dist}/math/random.js +2 -2
  79. package/{src → dist}/math/trigonometry.js +16 -15
  80. package/{src/image/p5.Image.js → dist/p5.Renderer-Swjl9HQO.js} +393 -22
  81. package/dist/rendering-B5TRR7aY.js +24960 -0
  82. package/{src → dist}/shape/2d_primitives.js +18 -17
  83. package/{src → dist}/shape/attributes.js +18 -17
  84. package/{src → dist}/shape/curves.js +2 -2
  85. package/{src → dist}/shape/custom_shapes.js +44 -64
  86. package/{src → dist}/shape/index.js +10 -2
  87. package/{src → dist}/shape/vertex.js +2 -3
  88. package/dist/type/index.js +25 -0
  89. package/{src → dist}/type/lib/Typr.js +76 -94
  90. package/{src → dist}/type/p5.Font.js +37 -63
  91. package/{src → dist}/type/textCore.js +35 -58
  92. package/{src → dist}/type/unicodeRanges.js +3 -1
  93. package/{src → dist}/utilities/conversion.js +2 -2
  94. package/{src → dist}/utilities/index.js +3 -1
  95. package/{src → dist}/utilities/time_date.js +6 -7
  96. package/{src → dist}/utilities/utility_functions.js +2 -2
  97. package/dist/webgl/3d_primitives.js +40 -0
  98. package/{src → dist}/webgl/GeometryBufferCache.js +3 -1
  99. package/{src → dist}/webgl/GeometryBuilder.js +12 -8
  100. package/{src → dist}/webgl/ShaderGenerator.js +79 -82
  101. package/{src → dist}/webgl/ShapeBuilder.js +26 -23
  102. package/dist/webgl/index.js +76 -0
  103. package/{src → dist}/webgl/interaction.js +7 -6
  104. package/dist/webgl/light.js +40 -0
  105. package/{src → dist}/webgl/loading.js +45 -12
  106. package/dist/webgl/material.js +40 -0
  107. package/dist/webgl/p5.Camera.js +40 -0
  108. package/{src → dist}/webgl/p5.DataArray.js +3 -5
  109. package/dist/webgl/p5.Framebuffer.js +40 -0
  110. package/{src → dist}/webgl/p5.Geometry.js +12 -15
  111. package/{src → dist}/webgl/p5.Quat.js +5 -4
  112. package/{src → dist}/webgl/p5.RenderBuffer.js +2 -3
  113. package/dist/webgl/p5.RendererGL.js +40 -0
  114. package/dist/webgl/p5.Shader.js +40 -0
  115. package/dist/webgl/p5.Texture.js +40 -0
  116. package/{src → dist}/webgl/text.js +78 -38
  117. package/lib/p5.esm.js +296 -194
  118. package/lib/p5.js +296 -194
  119. package/lib/p5.min.js +1 -1
  120. package/package.json +17 -17
  121. package/translations/dev.js +6 -6
  122. package/translations/index.js +1 -1
  123. package/types/accessibility/color_namer.d.ts +8 -0
  124. package/types/accessibility/describe.d.ts +184 -0
  125. package/types/accessibility/gridOutput.d.ts +8 -0
  126. package/types/accessibility/outputs.d.ts +235 -0
  127. package/types/accessibility/textOutput.d.ts +8 -0
  128. package/types/color/color_conversion.d.ts +47 -0
  129. package/types/color/creating_reading.d.ts +1348 -0
  130. package/types/color/p5.Color.d.ts +1070 -0
  131. package/types/color/setting.d.ts +2085 -0
  132. package/types/core/constants.d.ts +341 -0
  133. package/types/core/environment.d.ts +668 -0
  134. package/types/core/friendly_errors/fes_core.d.ts +8 -0
  135. package/types/core/friendly_errors/file_errors.d.ts +8 -0
  136. package/types/core/friendly_errors/param_validator.d.ts +30 -0
  137. package/types/core/friendly_errors/sketch_reader.d.ts +8 -0
  138. package/types/core/friendly_errors/stacktrace.d.ts +11 -0
  139. package/types/core/friendly_errors/validate_params.d.ts +8 -0
  140. package/types/core/helpers.d.ts +8 -0
  141. package/types/core/legacy.d.ts +8 -0
  142. package/types/core/main.d.ts +5996 -0
  143. package/types/core/p5.Graphics.d.ts +484 -0
  144. package/types/core/p5.Renderer.d.ts +14 -0
  145. package/types/core/reference.d.ts +8 -0
  146. package/types/core/rendering.d.ts +481 -0
  147. package/types/core/structure.d.ts +492 -0
  148. package/types/core/transform.d.ts +1638 -0
  149. package/types/data/local_storage.d.ts +323 -0
  150. package/types/dom/dom.d.ts +1295 -0
  151. package/types/dom/p5.Element.d.ts +2011 -0
  152. package/types/dom/p5.File.d.ts +13 -0
  153. package/types/dom/p5.MediaElement.d.ts +1249 -0
  154. package/types/events/acceleration.d.ts +193 -0
  155. package/types/events/keyboard.d.ts +499 -0
  156. package/types/events/pointer.d.ts +782 -0
  157. package/types/global.d.ts +5542 -0
  158. package/types/image/filterRenderer2D.d.ts +54 -0
  159. package/types/image/image.d.ts +326 -0
  160. package/types/image/loading_displaying.d.ts +580 -0
  161. package/types/image/p5.Image.d.ts +5882 -0
  162. package/types/image/pixels.d.ts +832 -0
  163. package/types/io/files.d.ts +1447 -0
  164. package/types/io/p5.Table.d.ts +1247 -0
  165. package/types/io/p5.TableRow.d.ts +343 -0
  166. package/types/io/p5.XML.d.ts +1188 -0
  167. package/types/math/Matrices/Matrix.d.ts +1029 -0
  168. package/types/math/Matrices/MatrixNumjs.d.ts +8 -0
  169. package/types/math/calculation.d.ts +923 -0
  170. package/types/math/math.d.ts +90 -0
  171. package/types/math/noise.d.ts +311 -0
  172. package/types/math/p5.Matrix.d.ts +8 -0
  173. package/types/math/p5.Vector.d.ts +3416 -0
  174. package/types/math/random.d.ts +267 -0
  175. package/types/math/trigonometry.d.ts +663 -0
  176. package/types/p5.d.ts +6663 -0
  177. package/types/shape/2d_primitives.d.ts +1033 -0
  178. package/types/shape/attributes.d.ts +466 -0
  179. package/types/shape/curves.d.ts +740 -0
  180. package/types/shape/custom_shapes.d.ts +888 -0
  181. package/types/shape/vertex.d.ts +1141 -0
  182. package/types/type/p5.Font.d.ts +575 -0
  183. package/types/type/textCore.d.ts +1198 -0
  184. package/types/utilities/conversion.d.ts +894 -0
  185. package/types/utilities/time_date.d.ts +295 -0
  186. package/types/utilities/utility_functions.d.ts +587 -0
  187. package/types/webgl/3d_primitives.d.ts +1432 -0
  188. package/types/webgl/ShaderGenerator.d.ts +8 -0
  189. package/types/webgl/interaction.d.ts +371 -0
  190. package/types/webgl/light.d.ts +1184 -0
  191. package/types/webgl/loading.d.ts +481 -0
  192. package/types/webgl/material.d.ts +2656 -0
  193. package/types/webgl/p5.Camera.d.ts +3023 -0
  194. package/types/webgl/p5.DataArray.d.ts +61 -0
  195. package/types/webgl/p5.Framebuffer.d.ts +760 -0
  196. package/types/webgl/p5.Geometry.d.ts +1191 -0
  197. package/types/webgl/p5.Quat.d.ts +45 -0
  198. package/types/webgl/p5.RendererGL.d.ts +234 -0
  199. package/types/webgl/p5.Shader.d.ts +660 -0
  200. package/types/webgl/p5.Texture.d.ts +61 -0
  201. package/types/webgl/text.d.ts +74 -0
  202. package/src/README.md +0 -27
  203. package/src/accessibility/index.js +0 -13
  204. package/src/app.js +0 -61
  205. package/src/color/index.js +0 -9
  206. package/src/color/p5.Color.culori.js +0 -66
  207. package/src/color/p5.Color.js +0 -851
  208. package/src/core/README.md +0 -91
  209. package/src/core/friendly_errors/index.js +0 -13
  210. package/src/core/friendly_errors/param_validator.js +0 -561
  211. package/src/core/init.js +0 -58
  212. package/src/core/internationalization.js +0 -195
  213. package/src/core/legacy.js +0 -29
  214. package/src/core/main.js +0 -689
  215. package/src/core/noop.js +0 -1
  216. package/src/core/p5.Graphics.js +0 -696
  217. package/src/core/p5.Renderer.js +0 -408
  218. package/src/core/reference.js +0 -2060
  219. package/src/core/rendering.js +0 -697
  220. package/src/dom/index.js +0 -11
  221. package/src/image/const.js +0 -6
  222. package/src/image/image.js +0 -731
  223. package/src/image/index.js +0 -15
  224. package/src/image/loading_displaying.js +0 -1431
  225. package/src/io/files.js +0 -2210
  226. package/src/io/index.js +0 -11
  227. package/src/math/README.md +0 -40
  228. package/src/type/index.js +0 -9
  229. package/src/webgl/3d_primitives.js +0 -2741
  230. package/src/webgl/index.js +0 -37
  231. package/src/webgl/light.js +0 -1851
  232. package/src/webgl/material.js +0 -3854
  233. package/src/webgl/p5.Camera.js +0 -4010
  234. package/src/webgl/p5.Framebuffer.js +0 -1865
  235. package/src/webgl/p5.RendererGL.js +0 -2867
  236. package/src/webgl/p5.Shader.js +0 -1505
  237. package/src/webgl/p5.Texture.js +0 -541
  238. package/src/webgl/shaders/basic.frag +0 -6
  239. package/src/webgl/shaders/filters/base.frag +0 -22
  240. package/src/webgl/shaders/filters/base.vert +0 -19
  241. package/src/webgl/shaders/filters/blur.frag +0 -60
  242. package/src/webgl/shaders/filters/default.vert +0 -18
  243. package/src/webgl/shaders/filters/dilate.frag +0 -39
  244. package/src/webgl/shaders/filters/erode.frag +0 -39
  245. package/src/webgl/shaders/filters/gray.frag +0 -16
  246. package/src/webgl/shaders/filters/invert.frag +0 -15
  247. package/src/webgl/shaders/filters/opaque.frag +0 -12
  248. package/src/webgl/shaders/filters/posterize.frag +0 -29
  249. package/src/webgl/shaders/filters/threshold.frag +0 -23
  250. package/src/webgl/shaders/font.frag +0 -216
  251. package/src/webgl/shaders/font.vert +0 -44
  252. package/src/webgl/shaders/imageLight.vert +0 -33
  253. package/src/webgl/shaders/imageLightDiffused.frag +0 -82
  254. package/src/webgl/shaders/imageLightSpecular.frag +0 -134
  255. package/src/webgl/shaders/light.vert +0 -37
  256. package/src/webgl/shaders/light_texture.frag +0 -26
  257. package/src/webgl/shaders/lighting.glsl +0 -227
  258. package/src/webgl/shaders/line.frag +0 -74
  259. package/src/webgl/shaders/line.vert +0 -294
  260. package/src/webgl/shaders/normal.frag +0 -6
  261. package/src/webgl/shaders/normal.vert +0 -72
  262. package/src/webgl/shaders/phong.frag +0 -84
  263. package/src/webgl/shaders/phong.vert +0 -87
  264. package/src/webgl/shaders/point.frag +0 -29
  265. package/src/webgl/shaders/point.vert +0 -19
  266. package/src/webgl/shaders/sphereMapping.frag +0 -26
  267. package/src/webgl/shaders/webgl2Compatibility.glsl +0 -34
@@ -0,0 +1,1295 @@
1
+ // This file is auto-generated from JSDoc documentation
2
+
3
+ import p5 from 'p5';
4
+ import { Color } from '../color/p5.Color';
5
+
6
+ declare module 'p5' {
7
+ /**
8
+ * Helper function for select and selectAll
9
+ *
10
+ */
11
+ function _getContainer(p: any): void;
12
+
13
+ /**
14
+ * Helper function for getElement and getElements.
15
+ *
16
+ */
17
+ function _wrapElement(elt: any): void;
18
+
19
+ /**
20
+ * Searches the page for the first element that matches the given
21
+ * CSS selector string.The selector string can be an ID, class, tag name, or a combination.
22
+ * `select()` returns a p5.Element object if it
23
+ * finds a match and `null` if not.The second parameter, `container`, is optional. It specifies a container to
24
+ * search within. `container` can be CSS selector string, a
25
+ * p5.Element object, or an
26
+ * HTMLElement object.
27
+ *
28
+ * @param CSS selector string of element to search for.
29
+ * @param CSS selector string, <a href="#/p5.Element">p5.Element</a>, or
30
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement" target="_blank">HTMLElement</a> to search within.
31
+ * @return <a href="#/p5.Element">p5.Element</a> containing the element.
32
+ * @example <div>
33
+ * <code>
34
+ * function setup() {
35
+ * createCanvas(100, 100);
36
+ * background(200);
37
+ *
38
+ * // Select the canvas by its tag.
39
+ * let cnv = select('canvas');
40
+ * cnv.style('border', '5px deeppink dashed');
41
+ *
42
+ * describe('A gray square with a dashed pink border.');
43
+ * }
44
+ * </code>
45
+ * </div>
46
+ *
47
+ * <div>
48
+ * <code>
49
+ * function setup() {
50
+ * let cnv = createCanvas(100, 100);
51
+ *
52
+ * // Add a class attribute to the canvas.
53
+ * cnv.class('pinkborder');
54
+ *
55
+ * background(200);
56
+ *
57
+ * // Select the canvas by its class.
58
+ * cnv = select('.pinkborder');
59
+ *
60
+ * // Style its border.
61
+ * cnv.style('border', '5px deeppink dashed');
62
+ *
63
+ * describe('A gray square with a dashed pink border.');
64
+ * }
65
+ * </code>
66
+ * </div>
67
+ *
68
+ * <div>
69
+ * <code>
70
+ * function setup() {
71
+ * let cnv = createCanvas(100, 100);
72
+ *
73
+ * // Set the canvas' ID.
74
+ * cnv.id('mycanvas');
75
+ *
76
+ * background(200);
77
+ *
78
+ * // Select the canvas by its ID.
79
+ * cnv = select('#mycanvas');
80
+ *
81
+ * // Style its border.
82
+ * cnv.style('border', '5px deeppink dashed');
83
+ *
84
+ * describe('A gray square with a dashed pink border.');
85
+ * }
86
+ * </code>
87
+ * </div>
88
+ */
89
+ function select(selectors: string, container?: string | p5.Element | HTMLElement): p5.Element | any;
90
+
91
+ /**
92
+ * Searches the page for all elements that matches the given
93
+ * CSS selector string.The selector string can be an ID, class, tag name, or a combination.
94
+ * `selectAll()` returns an array of p5.Element
95
+ * objects if it finds any matches and an empty array if none are found.The second parameter, `container`, is optional. It specifies a container to
96
+ * search within. `container` can be CSS selector string, a
97
+ * p5.Element object, or an
98
+ * HTMLElement object.
99
+ *
100
+ * @param CSS selector string of element to search for.
101
+ * @param CSS selector string, <a href="#/p5.Element">p5.Element</a>, or
102
+ * <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement" target="_blank">HTMLElement</a> to search within.
103
+ * @return array of <a href="#/p5.Element">p5.Element</a>s containing any elements found.
104
+ * @example <div>
105
+ * <code>
106
+ * function setup() {
107
+ * createCanvas(100, 100);
108
+ *
109
+ * // Create three buttons.
110
+ * createButton('1');
111
+ * createButton('2');
112
+ * createButton('3');
113
+ *
114
+ * // Select the buttons by their tag.
115
+ * let buttons = selectAll('button');
116
+ *
117
+ * // Position the buttons.
118
+ * for (let i = 0; i < 3; i += 1) {
119
+ * buttons[i].position(0, i * 30);
120
+ * }
121
+ *
122
+ * describe('Three buttons stacked vertically. The buttons are labeled, "1", "2", and "3".');
123
+ * }
124
+ * </code>
125
+ * </div>
126
+ *
127
+ * <div>
128
+ * <code>
129
+ * function setup() {
130
+ * // Create three buttons and position them.
131
+ * let b1 = createButton('1');
132
+ * b1.position(0, 0);
133
+ * let b2 = createButton('2');
134
+ * b2.position(0, 30);
135
+ * let b3 = createButton('3');
136
+ * b3.position(0, 60);
137
+ *
138
+ * // Add a class attribute to each button.
139
+ * b1.class('btn');
140
+ * b2.class('btn btn-pink');
141
+ * b3.class('btn');
142
+ *
143
+ * // Select the buttons by their class.
144
+ * let buttons = selectAll('.btn');
145
+ * let pinkButtons = selectAll('.btn-pink');
146
+ *
147
+ * // Style the selected buttons.
148
+ * buttons.forEach(setFont);
149
+ * pinkButtons.forEach(setColor);
150
+ *
151
+ * describe('Three buttons stacked vertically. The buttons are labeled, "1", "2", and "3". Buttons "1" and "3" are gray. Button "2" is pink.');
152
+ * }
153
+ *
154
+ * // Set a button's font to Comic Sans MS.
155
+ * function setFont(btn) {
156
+ * btn.style('font-family', 'Comic Sans MS');
157
+ * }
158
+ *
159
+ * // Set a button's background and font color.
160
+ * function setColor(btn) {
161
+ * btn.style('background', 'deeppink');
162
+ * btn.style('color', 'white');
163
+ * }
164
+ * </code>
165
+ * </div>
166
+ */
167
+ function selectAll(selectors: string, container?: string | p5.Element | HTMLElement): p5.Element[];
168
+
169
+ /**
170
+ * Creates a new p5.Element object.The first parameter, `tag`, is a string an HTML tag such as `'h5'`.The second parameter, `content`, is optional. It's a string that sets the
171
+ * HTML content to insert into the new element. New elements have no content
172
+ * by default.
173
+ *
174
+ * @param tag for the new element.
175
+ * @param HTML content to insert into the element.
176
+ * @return new <a href="#/p5.Element">p5.Element</a> object.
177
+ * @example <div>
178
+ * <code>
179
+ * function setup() {
180
+ * createCanvas(100, 100);
181
+ *
182
+ * background(200);
183
+ *
184
+ * // Create an h5 element with nothing in it.
185
+ * createElement('h5');
186
+ *
187
+ * describe('A gray square.');
188
+ * }
189
+ * </code>
190
+ * </div>
191
+ *
192
+ * <div>
193
+ * <code>
194
+ * function setup() {
195
+ * createCanvas(100, 100);
196
+ *
197
+ * background(200);
198
+ *
199
+ * // Create an h5 element with the content "p5*js".
200
+ * let h5 = createElement('h5', 'p5*js');
201
+ *
202
+ * // Set the element's style and position.
203
+ * h5.style('color', 'deeppink');
204
+ * h5.position(30, 15);
205
+ *
206
+ * describe('The text "p5*js" written in pink in the middle of a gray square.');
207
+ * }
208
+ * </code>
209
+ * </div>
210
+ */
211
+ function createElement(tag: string, content?: string): p5.Element;
212
+
213
+ /**
214
+ * Removes all elements created by p5.js, including any event handlers.There are two exceptions:
215
+ * canvas elements created by createCanvas()
216
+ * and p5.Render objects created by
217
+ * createGraphics().
218
+ *
219
+ * @example <div>
220
+ * <code>
221
+ * function setup() {
222
+ * createCanvas(100, 100);
223
+ *
224
+ * background(200);
225
+ *
226
+ * // Create a paragraph element and place
227
+ * // it in the middle of the canvas.
228
+ * let p = createP('p5*js');
229
+ * p.position(25, 25);
230
+ *
231
+ * describe('A gray square with the text "p5*js" written in its center. The text disappears when the mouse is pressed.');
232
+ * }
233
+ *
234
+ * // Remove all elements when the mouse is pressed.
235
+ * function mousePressed() {
236
+ * removeElements();
237
+ * }
238
+ * </code>
239
+ * </div>
240
+ *
241
+ * <div>
242
+ * <code>
243
+ * let slider;
244
+ *
245
+ * function setup() {
246
+ * createCanvas(200, 200);
247
+ *
248
+ * // Create a paragraph element and place
249
+ * // it at the top of the canvas.
250
+ * let p = createP('p5*js');
251
+ * p.position(25, 25);
252
+ *
253
+ * // Create a slider element and place it
254
+ * // beneath the canvas.
255
+ * slider = createSlider(0, 255, 200);
256
+ * slider.position(0, 100);
257
+ *
258
+ * describe('A gray square with the text "p5*js" written in its center and a range slider beneath it. The square changes color when the slider is moved. The text and slider disappear when the square is double-clicked.');
259
+ * }
260
+ *
261
+ * function draw() {
262
+ * // Use the slider value to change the background color.
263
+ * let g = slider.value();
264
+ * background(g);
265
+ * }
266
+ *
267
+ * // Remove all elements when the mouse is double-clicked.
268
+ * function doubleClicked() {
269
+ * removeElements();
270
+ * }
271
+ * </code>
272
+ * </div>
273
+ */
274
+ function removeElements(): void;
275
+
276
+ /**
277
+ * Helpers for create methods.
278
+ *
279
+ */
280
+ function addElement(elt: any, pInst: any, media: any): void;
281
+
282
+ /**
283
+ * Creates a `&lt;div&gt;&lt;/div&gt;` element.`&lt;div&gt;&lt;/div&gt;` elements are commonly used as containers for
284
+ * other elements.The parameter `html` is optional. It accepts a string that sets the
285
+ * inner HTML of the new `&lt;div&gt;&lt;/div&gt;`.
286
+ *
287
+ * @param inner HTML for the new `&lt;div&gt;&lt;/div&gt;` element.
288
+ * @return new <a href="#/p5.Element">p5.Element</a> object.
289
+ * @example <div>
290
+ * <code>
291
+ * function setup() {
292
+ * createCanvas(100, 100);
293
+ *
294
+ * background(200);
295
+ *
296
+ * // Create a div element and set its position.
297
+ * let div = createDiv('p5*js');
298
+ * div.position(25, 35);
299
+ *
300
+ * describe('A gray square with the text "p5*js" written in its center.');
301
+ * }
302
+ * </code>
303
+ * </div>
304
+ *
305
+ * <div>
306
+ * <code>
307
+ * function setup() {
308
+ * createCanvas(100, 100);
309
+ *
310
+ * background(200);
311
+ *
312
+ * // Create an h3 element within the div.
313
+ * let div = createDiv('<h3>p5*js</h3>');
314
+ * div.position(20, 5);
315
+ *
316
+ * describe('A gray square with the text "p5*js" written in its center.');
317
+ * }
318
+ * </code>
319
+ * </div>
320
+ */
321
+ function createDiv(html?: string): p5.Element;
322
+
323
+ /**
324
+ * Creates a paragraph element.`&lt;p&gt;&lt;/p&gt;` elements are commonly used for paragraph-length text.The parameter `html` is optional. It accepts a string that sets the
325
+ * inner HTML of the new `&lt;p&gt;&lt;/p&gt;`.
326
+ *
327
+ * @param inner HTML for the new `&lt;p&gt;&lt;/p&gt;` element.
328
+ * @return new <a href="#/p5.Element">p5.Element</a> object.
329
+ * @example <div>
330
+ * <code>
331
+ * function setup() {
332
+ * createCanvas(100, 100);
333
+ *
334
+ * background(200);
335
+ *
336
+ * // Create a paragraph element and set its position.
337
+ * let p = createP('Tell me a story.');
338
+ * p.position(5, 0);
339
+ *
340
+ * describe('A gray square displaying the text "Tell me a story." written in black.');
341
+ * }
342
+ * </code>
343
+ * </div>
344
+ */
345
+ function createP(html?: string): p5.Element;
346
+
347
+ /**
348
+ * Creates a `&lt;span&gt;&lt;/span&gt;` element.`&lt;span&gt;&lt;/span&gt;` elements are commonly used as containers
349
+ * for inline elements. For example, a `&lt;span&gt;&lt;/span&gt;`
350
+ * can hold part of a sentence that's a
351
+ * different style.The parameter `html` is optional. It accepts a string that sets the
352
+ * inner HTML of the new `&lt;span&gt;&lt;/span&gt;`.
353
+ *
354
+ * @param inner HTML for the new `&lt;span&gt;&lt;/span&gt;` element.
355
+ * @return new <a href="#/p5.Element">p5.Element</a> object.
356
+ * @example <div>
357
+ * <code>
358
+ * function setup() {
359
+ * createCanvas(100, 100);
360
+ *
361
+ * background(200);
362
+ *
363
+ * // Create a span element and set its position.
364
+ * let span = createSpan('p5*js');
365
+ * span.position(25, 35);
366
+ *
367
+ * describe('A gray square with the text "p5*js" written in its center.');
368
+ * }
369
+ * </code>
370
+ * </div>
371
+ *
372
+ * <div>
373
+ * <code>
374
+ * function setup() {
375
+ * background(200);
376
+ *
377
+ * // Create a div element as a container.
378
+ * let div = createDiv();
379
+ *
380
+ * // Place the div at the center.
381
+ * div.position(25, 35);
382
+ *
383
+ * // Create a span element.
384
+ * let s1 = createSpan('p5');
385
+ *
386
+ * // Create a second span element.
387
+ * let s2 = createSpan('*');
388
+ *
389
+ * // Set the second span's font color.
390
+ * s2.style('color', 'deeppink');
391
+ *
392
+ * // Create a third span element.
393
+ * let s3 = createSpan('js');
394
+ *
395
+ * // Add all the spans to the container div.
396
+ * s1.parent(div);
397
+ * s2.parent(div);
398
+ * s3.parent(div);
399
+ *
400
+ * describe('A gray square with the text "p5*js" written in black at its center. The asterisk is pink.');
401
+ * }
402
+ * </code>
403
+ * </div>
404
+ */
405
+ function createSpan(html?: string): p5.Element;
406
+
407
+ /**
408
+ * Creates an `&lt;img&gt;` element that can appear outside of the canvas.The first parameter, `src`, is a string with the path to the image file.
409
+ * `src` should be a relative path, as in `'assets/image.png'`, or a URL, as
410
+ * in `'https://example.com/image.png'`.The second parameter, `alt`, is a string with the
411
+ * alternate text
412
+ * for the image. An empty string `''` can be used for images that aren't displayed.The third parameter, `crossOrigin`, is optional. It's a string that sets the
413
+ * crossOrigin property
414
+ * of the image. Use `'anonymous'` or `'use-credentials'` to fetch the image
415
+ * with cross-origin access.The fourth parameter, `callback`, is also optional. It sets a function to
416
+ * call after the image loads. The new image is passed to the callback
417
+ * function as a p5.Element object.
418
+ *
419
+ * @param relative path or URL for the image.
420
+ * @param alternate text for the image.
421
+ * @return new <a href="#/p5.Element">p5.Element</a> object.
422
+ * @example <div>
423
+ * <code>
424
+ * function setup() {
425
+ * createCanvas(100, 100);
426
+ *
427
+ * background(200);
428
+ *
429
+ * let img = createImg(
430
+ * '/assets/cat.jpg',
431
+ * 'image of a cat'
432
+ * );
433
+ * img.position(0, 10);
434
+ *
435
+ * describe('A gray square with a magenta asterisk in its center.');
436
+ * }
437
+ * </code>
438
+ * </div>
439
+ */
440
+ function createImg(src: string, alt: string): p5.Element;
441
+
442
+ /**
443
+ * @param crossOrigin property to use when fetching the image.
444
+ * @param function to call once the image loads. The new image will be passed
445
+ * to the function as a <a href="#/p5.Element">p5.Element</a> object.
446
+ * @return new <a href="#/p5.Element">p5.Element</a> object.
447
+ */
448
+ function createImg(src: string, alt: string, crossOrigin?: string, successCallback?: Function): p5.Element;
449
+
450
+ /**
451
+ * Creates an `&lt;a&gt;&lt;/a&gt;` element that links to another web page.The first parmeter, `href`, is a string that sets the URL of the linked
452
+ * page.The second parameter, `html`, is a string that sets the inner HTML of the
453
+ * link. It's common to use text, images, or buttons as links.The third parameter, `target`, is optional. It's a string that tells the
454
+ * web browser where to open the link. By default, links open in the current
455
+ * browser tab. Passing `'_blank'` will cause the link to open in a new
456
+ * browser tab. MDN describes a few
457
+ * other options.
458
+ *
459
+ * @param URL of linked page.
460
+ * @param inner HTML of link element to display.
461
+ * @param target where the new link should open,
462
+ * either `'_blank'`, `'_self'`, `'_parent'`, or `'_top'`.
463
+ * @return new <a href="#/p5.Element">p5.Element</a> object.
464
+ * @example <div>
465
+ * <code>
466
+ * function setup() {
467
+ * createCanvas(100, 100);
468
+ *
469
+ * background(200);
470
+ *
471
+ * // Create an anchor element that links to p5js.org.
472
+ * let a = createA('https://p5js.org/', 'p5*js');
473
+ * a.position(25, 35);
474
+ *
475
+ * describe('The text "p5*js" written at the center of a gray square.');
476
+ * }
477
+ * </code>
478
+ * </div>
479
+ *
480
+ * <div>
481
+ * <code>
482
+ * function setup() {
483
+ * background(200);
484
+ *
485
+ * // Create an anchor tag that links to p5js.org.
486
+ * // Open the link in a new tab.
487
+ * let a = createA('https://p5js.org/', 'p5*js', '_blank');
488
+ * a.position(25, 35);
489
+ *
490
+ * describe('The text "p5*js" written at the center of a gray square.');
491
+ * }
492
+ * </code>
493
+ * </div>
494
+ */
495
+ function createA(href: string, html: string, target?: string): p5.Element;
496
+
497
+ /**
498
+ * Creates a slider `&lt;input&gt;&lt;/input&gt;` element.Range sliders are useful for quickly selecting numbers from a given range.The first two parameters, `min` and `max`, are numbers that set the
499
+ * slider's minimum and maximum.The third parameter, `value`, is optional. It's a number that sets the
500
+ * slider's default value.The fourth parameter, `step`, is also optional. It's a number that sets the
501
+ * spacing between each value in the slider's range. Setting `step` to 0
502
+ * allows the slider to move smoothly from `min` to `max`.
503
+ *
504
+ * @param minimum value of the slider.
505
+ * @param maximum value of the slider.
506
+ * @param default value of the slider.
507
+ * @param size for each step in the slider's range.
508
+ * @return new <a href="#/p5.Element">p5.Element</a> object.
509
+ * @example <div>
510
+ * <code>
511
+ * let slider;
512
+ *
513
+ * function setup() {
514
+ * createCanvas(100, 100);
515
+ *
516
+ * // Create a slider and place it at the top of the canvas.
517
+ * slider = createSlider(0, 255);
518
+ * slider.position(10, 10);
519
+ * slider.size(80);
520
+ *
521
+ * describe('A dark gray square with a range slider at the top. The square changes color when the slider is moved.');
522
+ * }
523
+ *
524
+ * function draw() {
525
+ * // Use the slider as a grayscale value.
526
+ * let g = slider.value();
527
+ * background(g);
528
+ * }
529
+ * </code>
530
+ * </div>
531
+ *
532
+ * <div>
533
+ * <code>
534
+ * let slider;
535
+ *
536
+ * function setup() {
537
+ * createCanvas(100, 100);
538
+ *
539
+ * // Create a slider and place it at the top of the canvas.
540
+ * // Set its default value to 0.
541
+ * slider = createSlider(0, 255, 0);
542
+ * slider.position(10, 10);
543
+ * slider.size(80);
544
+ *
545
+ * describe('A black square with a range slider at the top. The square changes color when the slider is moved.');
546
+ * }
547
+ *
548
+ * function draw() {
549
+ * // Use the slider as a grayscale value.
550
+ * let g = slider.value();
551
+ * background(g);
552
+ * }
553
+ * </code>
554
+ * </div>
555
+ *
556
+ * <div>
557
+ * <code>
558
+ * let slider;
559
+ *
560
+ * function setup() {
561
+ * createCanvas(100, 100);
562
+ *
563
+ * // Create a slider and place it at the top of the canvas.
564
+ * // Set its default value to 0.
565
+ * // Set its step size to 50.
566
+ * slider = createSlider(0, 255, 0, 50);
567
+ * slider.position(10, 10);
568
+ * slider.size(80);
569
+ *
570
+ * describe('A black square with a range slider at the top. The square changes color when the slider is moved.');
571
+ * }
572
+ *
573
+ * function draw() {
574
+ * // Use the slider as a grayscale value.
575
+ * let g = slider.value();
576
+ * background(g);
577
+ * }
578
+ * </code>
579
+ * </div>
580
+ *
581
+ * <div>
582
+ * <code>
583
+ * let slider;
584
+ *
585
+ * function setup() {
586
+ * createCanvas(100, 100);
587
+ *
588
+ * // Create a slider and place it at the top of the canvas.
589
+ * // Set its default value to 0.
590
+ * // Set its step size to 0 so that it moves smoothly.
591
+ * slider = createSlider(0, 255, 0, 0);
592
+ * slider.position(10, 10);
593
+ * slider.size(80);
594
+ *
595
+ * describe('A black square with a range slider at the top. The square changes color when the slider is moved.');
596
+ * }
597
+ *
598
+ * function draw() {
599
+ * // Use the slider as a grayscale value.
600
+ * let g = slider.value();
601
+ * background(g);
602
+ * }
603
+ * </code>
604
+ * </div>
605
+ */
606
+ function createSlider(min: number, max: number, value?: number, step?: number): p5.Element;
607
+
608
+ /**
609
+ * Creates a `&lt;button&gt;&lt;/button&gt;` element.The first parameter, `label`, is a string that sets the label displayed on
610
+ * the button.The second parameter, `value`, is optional. It's a string that sets the
611
+ * button's value. See
612
+ * MDN
613
+ * for more details.
614
+ *
615
+ * @param label displayed on the button.
616
+ * @param value of the button.
617
+ * @return new <a href="#/p5.Element">p5.Element</a> object.
618
+ * @example <div>
619
+ * <code>
620
+ * function setup() {
621
+ * createCanvas(100, 100);
622
+ *
623
+ * background(200);
624
+ *
625
+ * // Create a button and place it beneath the canvas.
626
+ * let button = createButton('click me');
627
+ * button.position(0, 100);
628
+ *
629
+ * // Call repaint() when the button is pressed.
630
+ * button.mousePressed(repaint);
631
+ *
632
+ * describe('A gray square with a button that says "click me" beneath it. The square changes color when the button is clicked.');
633
+ * }
634
+ *
635
+ * // Change the background color.
636
+ * function repaint() {
637
+ * let g = random(255);
638
+ * background(g);
639
+ * }
640
+ * </code>
641
+ * </div>
642
+ *
643
+ * <div>
644
+ * <code>
645
+ * let button;
646
+ *
647
+ * function setup() {
648
+ * createCanvas(100, 100);
649
+ *
650
+ * background(200);
651
+ *
652
+ * // Create a button and set its value to 0.
653
+ * // Place the button beneath the canvas.
654
+ * button = createButton('click me', 'red');
655
+ * button.position(0, 100);
656
+ *
657
+ * // Call randomColor() when the button is pressed.
658
+ * button.mousePressed(randomColor);
659
+ *
660
+ * describe('A red square with a button that says "click me" beneath it. The square changes color when the button is clicked.');
661
+ * }
662
+ *
663
+ * function draw() {
664
+ * // Use the button's value to set the background color.
665
+ * let c = button.value();
666
+ * background(c);
667
+ * }
668
+ *
669
+ * // Set the button's value to a random color.
670
+ * function randomColor() {
671
+ * let c = random(['red', 'green', 'blue', 'yellow']);
672
+ * button.value(c);
673
+ * }
674
+ * </code>
675
+ * </div>
676
+ */
677
+ function createButton(label: string, value?: string): p5.Element;
678
+
679
+ /**
680
+ * Creates a checkbox `&lt;input&gt;&lt;/input&gt;` element.Checkboxes extend the p5.Element class with a
681
+ * `checked()` method. Calling `myBox.checked()` returns `true` if it the box
682
+ * is checked and `false` if not.The first parameter, `label`, is optional. It's a string that sets the label
683
+ * to display next to the checkbox.The second parameter, `value`, is also optional. It's a boolean that sets the
684
+ * checkbox's value.
685
+ *
686
+ * @param label displayed after the checkbox.
687
+ * @param value of the checkbox. Checked is `true` and unchecked is `false`.
688
+ * @return new <a href="#/p5.Element">p5.Element</a> object.
689
+ * @example <div>
690
+ * <code>
691
+ * let checkbox;
692
+ *
693
+ * function setup() {
694
+ * createCanvas(100, 100);
695
+ *
696
+ * // Create a checkbox and place it beneath the canvas.
697
+ * checkbox = createCheckbox();
698
+ * checkbox.position(0, 70);
699
+ *
700
+ * describe('A black square with a checkbox beneath it. The square turns white when the box is checked.');
701
+ * }
702
+ *
703
+ * function draw() {
704
+ * // Use the checkbox to set the background color.
705
+ * if (checkbox.checked()) {
706
+ * background(255);
707
+ * } else {
708
+ * background(0);
709
+ * }
710
+ * }
711
+ * </code>
712
+ * </div>
713
+ *
714
+ * <div>
715
+ * <code>
716
+ * let checkbox;
717
+ *
718
+ * function setup() {
719
+ * createCanvas(100, 100);
720
+ *
721
+ * // Create a checkbox and place it beneath the canvas.
722
+ * // Label the checkbox "white".
723
+ * checkbox = createCheckbox(' white');
724
+ * checkbox.position(0, 70);
725
+ *
726
+ * describe('A black square with a checkbox labeled "white" beneath it. The square turns white when the box is checked.');
727
+ * }
728
+ *
729
+ * function draw() {
730
+ * // Use the checkbox to set the background color.
731
+ * if (checkbox.checked()) {
732
+ * background(255);
733
+ * } else {
734
+ * background(0);
735
+ * }
736
+ * }
737
+ * </code>
738
+ * </div>
739
+ *
740
+ * <div>
741
+ * <code>
742
+ * let checkbox;
743
+ *
744
+ * function setup() {
745
+ * createCanvas(100, 100);
746
+ *
747
+ * // Create a checkbox and place it beneath the canvas.
748
+ * // Label the checkbox "white" and set its value to true.
749
+ * checkbox = createCheckbox(' white', true);
750
+ * checkbox.position(0, 70);
751
+ *
752
+ * describe('A white square with a checkbox labeled "white" beneath it. The square turns black when the box is unchecked.');
753
+ * }
754
+ *
755
+ * function draw() {
756
+ * // Use the checkbox to set the background color.
757
+ * if (checkbox.checked()) {
758
+ * background(255);
759
+ * } else {
760
+ * background(0);
761
+ * }
762
+ * }
763
+ * </code>
764
+ * </div>
765
+ */
766
+ function createCheckbox(label?: string, value?: boolean): p5.Element;
767
+
768
+ /**
769
+ * Creates a dropdown menu `&lt;select&gt;&lt;/select&gt;` element.The parameter is optional. If `true` is passed, as in
770
+ * `let mySelect = createSelect(true)`, then the dropdown will support
771
+ * multiple selections. If an existing `&lt;select&gt;&lt;/select&gt;` element
772
+ * is passed, as in `let mySelect = createSelect(otherSelect)`, the existing
773
+ * element will be wrapped in a new p5.Element
774
+ * object.Dropdowns extend the p5.Element class with a few
775
+ * helpful methods for managing options:
776
+ *
777
+ * @param support multiple selections.
778
+ * @return new <a href="#/p5.Element">p5.Element</a> object.
779
+ * @example <div>
780
+ * <code>
781
+ * let mySelect;
782
+ *
783
+ * function setup() {
784
+ * createCanvas(100, 100);
785
+ *
786
+ * // Create a dropdown and place it beneath the canvas.
787
+ * mySelect = createSelect();
788
+ * mySelect.position(0, 100);
789
+ *
790
+ * // Add color options.
791
+ * mySelect.option('red');
792
+ * mySelect.option('green');
793
+ * mySelect.option('blue');
794
+ * mySelect.option('yellow');
795
+ *
796
+ * // Set the selected option to "red".
797
+ * mySelect.selected('red');
798
+ *
799
+ * describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.');
800
+ * }
801
+ *
802
+ * function draw() {
803
+ * // Use the selected value to paint the background.
804
+ * let c = mySelect.selected();
805
+ * background(c);
806
+ * }
807
+ * </code>
808
+ * </div>
809
+ *
810
+ * <div>
811
+ * <code>
812
+ * let mySelect;
813
+ *
814
+ * function setup() {
815
+ * createCanvas(100, 100);
816
+ *
817
+ * // Create a dropdown and place it beneath the canvas.
818
+ * mySelect = createSelect();
819
+ * mySelect.position(0, 100);
820
+ *
821
+ * // Add color options.
822
+ * mySelect.option('red');
823
+ * mySelect.option('green');
824
+ * mySelect.option('blue');
825
+ * mySelect.option('yellow');
826
+ *
827
+ * // Set the selected option to "red".
828
+ * mySelect.selected('red');
829
+ *
830
+ * // Disable the "yellow" option.
831
+ * mySelect.disable('yellow');
832
+ *
833
+ * describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.');
834
+ * }
835
+ *
836
+ * function draw() {
837
+ * // Use the selected value to paint the background.
838
+ * let c = mySelect.selected();
839
+ * background(c);
840
+ * }
841
+ * </code>
842
+ * </div>
843
+ *
844
+ * <div>
845
+ * <code>
846
+ * let mySelect;
847
+ *
848
+ * function setup() {
849
+ * createCanvas(100, 100);
850
+ *
851
+ * // Create a dropdown and place it beneath the canvas.
852
+ * mySelect = createSelect();
853
+ * mySelect.position(0, 100);
854
+ *
855
+ * // Add color options with names and values.
856
+ * mySelect.option('one', 'red');
857
+ * mySelect.option('two', 'green');
858
+ * mySelect.option('three', 'blue');
859
+ * mySelect.option('four', 'yellow');
860
+ *
861
+ * // Set the selected option to "one".
862
+ * mySelect.selected('one');
863
+ *
864
+ * describe('A red square with a dropdown menu beneath it. The square changes color when a new color is selected.');
865
+ * }
866
+ *
867
+ * function draw() {
868
+ * // Use the selected value to paint the background.
869
+ * let c = mySelect.selected();
870
+ * background(c);
871
+ * }
872
+ * </code>
873
+ * </div>
874
+ *
875
+ * <div>
876
+ * <code>
877
+ * // Hold CTRL to select multiple options on Windows and Linux.
878
+ * // Hold CMD to select multiple options on macOS.
879
+ * let mySelect;
880
+ *
881
+ * function setup() {
882
+ * createCanvas(100, 100);
883
+ *
884
+ * // Create a dropdown and allow multiple selections.
885
+ * // Place it beneath the canvas.
886
+ * mySelect = createSelect(true);
887
+ * mySelect.position(0, 100);
888
+ *
889
+ * // Add color options.
890
+ * mySelect.option('red');
891
+ * mySelect.option('green');
892
+ * mySelect.option('blue');
893
+ * mySelect.option('yellow');
894
+ *
895
+ * describe('A gray square with a dropdown menu beneath it. Colorful circles appear when their color is selected.');
896
+ * }
897
+ *
898
+ * function draw() {
899
+ * background(200);
900
+ *
901
+ * // Use the selected value(s) to draw circles.
902
+ * let colors = mySelect.selected();
903
+ * for (let i = 0; i < colors.length; i += 1) {
904
+ * // Calculate the x-coordinate.
905
+ * let x = 10 + i * 20;
906
+ *
907
+ * // Access the color.
908
+ * let c = colors[i];
909
+ *
910
+ * // Draw the circle.
911
+ * fill(c);
912
+ * circle(x, 50, 20);
913
+ * }
914
+ * }
915
+ * </code>
916
+ * </div>
917
+ */
918
+ function createSelect(multiple?: boolean): p5.Element;
919
+
920
+ /**
921
+ * @param select element to wrap, either as a <a href="#/p5.Element">p5.Element</a> or
922
+ * a <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement" target="_blank">HTMLSelectElement</a>.
923
+ */
924
+ function createSelect(existing: object): p5.Element;
925
+
926
+ /**
927
+ * Creates a radio button element.The parameter is optional. If a string is passed, as in
928
+ * `let myRadio = createSelect('food')`, then each radio option will
929
+ * have `"food"` as its `name` parameter: `&lt;input name="food"&gt;&lt;/input&gt;`.
930
+ * If an existing `&lt;div&gt;&lt;/div&gt;` or `&lt;span&gt;&lt;/span&gt;`
931
+ * element is passed, as in `let myRadio = createSelect(container)`, it will
932
+ * become the radio button's parent element.Radio buttons extend the p5.Element class with a few
933
+ * helpful methods for managing options:
934
+ *
935
+ * @param container HTML Element, either a `&lt;div&gt;&lt;/div&gt;`
936
+ * or `&lt;span&gt;&lt;/span&gt;`.
937
+ * @return new <a href="#/p5.Element">p5.Element</a> object.
938
+ * @example <div>
939
+ * <code>
940
+ * let style = document.createElement('style');
941
+ * style.innerHTML = `
942
+ * .p5-radio label {
943
+ * display: flex;
944
+ * align-items: center;
945
+ * }
946
+ * .p5-radio input {
947
+ * margin-right: 5px;
948
+ * }
949
+ * `;
950
+ * document.head.appendChild(style);
951
+ *
952
+ * let myRadio;
953
+ *
954
+ * function setup() {
955
+ * createCanvas(100, 100);
956
+ *
957
+ * // Create a radio button element and place it
958
+ * // in the top-left corner.
959
+ * myRadio = createRadio();
960
+ * myRadio.position(0, 0);
961
+ * myRadio.class('p5-radio');
962
+ * myRadio.size(60);
963
+ *
964
+ * // Add a few color options.
965
+ * myRadio.option('red');
966
+ * myRadio.option('yellow');
967
+ * myRadio.option('blue');
968
+ *
969
+ * // Choose a default option.
970
+ * myRadio.selected('yellow');
971
+ *
972
+ * describe('A yellow square with three color options listed, "red", "yellow", and "blue". The square changes color when the user selects a new option.');
973
+ * }
974
+ *
975
+ * function draw() {
976
+ * // Set the background color using the radio button.
977
+ * let g = myRadio.value();
978
+ * background(g);
979
+ * }
980
+ * </code>
981
+ * </div>
982
+ *
983
+ * <div>
984
+ * <code>
985
+ * let myRadio;
986
+ *
987
+ * function setup() {
988
+ * createCanvas(100, 100);
989
+ *
990
+ * // Create a radio button element and place it
991
+ * // in the top-left corner.
992
+ * myRadio = createRadio();
993
+ * myRadio.position(0, 0);
994
+ * myRadio.size(50);
995
+ *
996
+ * // Add a few color options.
997
+ * // Color values are labeled with
998
+ * // emotions they evoke.
999
+ * myRadio.option('red', 'love');
1000
+ * myRadio.option('yellow', 'joy');
1001
+ * myRadio.option('blue', 'trust');
1002
+ *
1003
+ * // Choose a default option.
1004
+ * myRadio.selected('yellow');
1005
+ *
1006
+ * describe('A yellow square with three options listed, "love", "joy", and "trust". The square changes color when the user selects a new option.');
1007
+ * }
1008
+ *
1009
+ * function draw() {
1010
+ * // Set the background color using the radio button.
1011
+ * let c = myRadio.value();
1012
+ * background(c);
1013
+ * }
1014
+ * </code>
1015
+ * </div>
1016
+ *
1017
+ * <div>
1018
+ * <code>
1019
+ * let myRadio;
1020
+ *
1021
+ * function setup() {
1022
+ * createCanvas(100, 100);
1023
+ *
1024
+ * // Create a radio button element and place it
1025
+ * // in the top-left corner.
1026
+ * myRadio = createRadio();
1027
+ * myRadio.position(0, 0);
1028
+ * myRadio.size(50);
1029
+ *
1030
+ * // Add a few color options.
1031
+ * myRadio.option('red');
1032
+ * myRadio.option('yellow');
1033
+ * myRadio.option('blue');
1034
+ *
1035
+ * // Choose a default option.
1036
+ * myRadio.selected('yellow');
1037
+ *
1038
+ * // Create a button and place it beneath the canvas.
1039
+ * let btn = createButton('disable');
1040
+ * btn.position(0, 100);
1041
+ *
1042
+ * // Call disableRadio() when btn is pressed.
1043
+ * btn.mousePressed(disableRadio);
1044
+ *
1045
+ * describe('A yellow square with three options listed, "red", "yellow", and "blue". The square changes color when the user selects a new option. A "disable" button beneath the canvas disables the color options when pressed.');
1046
+ * }
1047
+ *
1048
+ * function draw() {
1049
+ * // Set the background color using the radio button.
1050
+ * let c = myRadio.value();
1051
+ * background(c);
1052
+ * }
1053
+ *
1054
+ * // Disable myRadio.
1055
+ * function disableRadio() {
1056
+ * myRadio.disable(true);
1057
+ * }
1058
+ * </code>
1059
+ * </div>
1060
+ */
1061
+ function createRadio(containerElement?: object): p5.Element;
1062
+
1063
+ /**
1064
+ * @param name parameter assigned to each option's `&lt;input&gt;&lt;/input&gt;` element.
1065
+ * @return new <a href="#/p5.Element">p5.Element</a> object.
1066
+ */
1067
+ function createRadio(name?: string): p5.Element;
1068
+
1069
+ /**
1070
+ * @return new <a href="#/p5.Element">p5.Element</a> object.
1071
+ */
1072
+ function createRadio(): p5.Element;
1073
+
1074
+ /**
1075
+ * Creates a color picker element.The parameter, `value`, is optional. If a color string or
1076
+ * p5.Color object is passed, it will set the default
1077
+ * color.Color pickers extend the p5.Element class with a
1078
+ * couple of helpful methods for managing colors:
1079
+ *
1080
+ * @param default color as a <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/color" target="_blank">CSS color string</a>.
1081
+ * @return new <a href="#/p5.Element">p5.Element</a> object.
1082
+ * @example <div>
1083
+ * <code>
1084
+ * let myPicker;
1085
+ *
1086
+ * function setup() {
1087
+ * createCanvas(100, 100);
1088
+ *
1089
+ * // Create a color picker and set its position.
1090
+ * myPicker = createColorPicker('deeppink');
1091
+ * myPicker.position(0, 100);
1092
+ *
1093
+ * describe('A pink square with a color picker beneath it. The square changes color when the user picks a new color.');
1094
+ * }
1095
+ *
1096
+ * function draw() {
1097
+ * // Use the color picker to paint the background.
1098
+ * let c = myPicker.color();
1099
+ * background(c);
1100
+ * }
1101
+ * </code>
1102
+ * </div>
1103
+ *
1104
+ * <div>
1105
+ * <code>
1106
+ * let myPicker;
1107
+ *
1108
+ * function setup() {
1109
+ * createCanvas(100, 100);
1110
+ *
1111
+ * // Create a color picker and set its position.
1112
+ * myPicker = createColorPicker('deeppink');
1113
+ * myPicker.position(0, 100);
1114
+ *
1115
+ * describe('A number with the format "#rrggbb" is displayed on a pink canvas. The background color and number change when the user picks a new color.');
1116
+ * }
1117
+ *
1118
+ * function draw() {
1119
+ * // Use the color picker to paint the background.
1120
+ * let c = myPicker.value();
1121
+ * background(c);
1122
+ *
1123
+ * // Display the current color as a hex string.
1124
+ * text(c, 25, 55);
1125
+ * }
1126
+ * </code>
1127
+ * </div>
1128
+ */
1129
+ function createColorPicker(value?: string | p5.Color): p5.Element;
1130
+
1131
+ /**
1132
+ * Creates a text `&lt;input&gt;&lt;/input&gt;` element.Call `myInput.size()` to set the length of the text box.The first parameter, `value`, is optional. It's a string that sets the
1133
+ * input's default value. The input is blank by default.The second parameter, `type`, is also optional. It's a string that
1134
+ * specifies the type of text being input. See MDN for a full
1135
+ * list of options.
1136
+ * The default is `'text'`.
1137
+ *
1138
+ * @param default value of the input box. Defaults to an empty string `''`.
1139
+ * @param type of input. Defaults to `'text'`.
1140
+ * @return new <a href="#/p5.Element">p5.Element</a> object.
1141
+ * @example <div>
1142
+ * <code>
1143
+ * let myInput;
1144
+ *
1145
+ * function setup() {
1146
+ * createCanvas(100, 100);
1147
+ *
1148
+ * // Create an input element and place it
1149
+ * // beneath the canvas.
1150
+ * myInput = createInput();
1151
+ * myInput.position(0, 100);
1152
+ *
1153
+ * describe('A gray square with a text box beneath it. The text in the square changes when the user types something new in the input bar.');
1154
+ * }
1155
+ *
1156
+ * function draw() {
1157
+ * background(200);
1158
+ *
1159
+ * // Use the input to display a message.
1160
+ * let msg = myInput.value();
1161
+ * text(msg, 25, 55);
1162
+ * }
1163
+ * </code>
1164
+ * </div>
1165
+ *
1166
+ * <div>
1167
+ * <code>
1168
+ * let myInput;
1169
+ *
1170
+ * function setup() {
1171
+ * createCanvas(100, 100);
1172
+ *
1173
+ * // Create an input element and place it
1174
+ * // beneath the canvas. Set its default
1175
+ * // text to "hello!".
1176
+ * myInput = createInput('hello!');
1177
+ * myInput.position(0, 100);
1178
+ *
1179
+ * describe('The text "hello!" written at the center of a gray square. A text box beneath the square also says "hello!". The text in the square changes when the user types something new in the input bar.');
1180
+ * }
1181
+ *
1182
+ * function draw() {
1183
+ * background(200);
1184
+ *
1185
+ * // Use the input to display a message.
1186
+ * let msg = myInput.value();
1187
+ * text(msg, 25, 55);
1188
+ * }
1189
+ * </code>
1190
+ * </div>
1191
+ */
1192
+ function createInput(value?: string, type?: string): p5.Element;
1193
+
1194
+ /**
1195
+ */
1196
+ function createInput(value?: string): p5.Element;
1197
+
1198
+ /**
1199
+ * Creates an `&lt;input&gt;&lt;/input&gt;` element of type `'file'`.`createFileInput()` allows users to select local files for use in a sketch.
1200
+ * It returns a p5.File object.The first parameter, `callback`, is a function that's called when the file
1201
+ * loads. The callback function should have one parameter, `file`, that's a
1202
+ * p5.File object.The second parameter, `multiple`, is optional. It's a boolean value that
1203
+ * allows loading multiple files if set to `true`. If `true`, `callback`
1204
+ * will be called once per file.
1205
+ *
1206
+ * @param function to call once the file loads.
1207
+ * @param allow multiple files to be selected.
1208
+ * @return new <a href="#/p5.File">p5.File</a> object.
1209
+ * @example <div>
1210
+ * <code>
1211
+ * // Use the file input to select an image to
1212
+ * // load and display.
1213
+ * let input;
1214
+ * let img;
1215
+ *
1216
+ * function setup() {
1217
+ * createCanvas(200, 200);
1218
+ *
1219
+ * // Create a file input and place it beneath
1220
+ * // the canvas.
1221
+ * input = createFileInput(handleImage);
1222
+ * input.position(0, 100);
1223
+ *
1224
+ * describe('A gray square with a file input beneath it. If the user selects an image file to load, it is displayed on the square.');
1225
+ * }
1226
+ *
1227
+ * function draw() {
1228
+ * background(200);
1229
+ *
1230
+ * // Draw the image if loaded.
1231
+ * if (img) {
1232
+ * image(img, 0, 0, width, height);
1233
+ * }
1234
+ * }
1235
+ *
1236
+ * // Create an image if the file is an image.
1237
+ * function handleImage(file) {
1238
+ * if (file.type === 'image') {
1239
+ * img = createImg(file.data, '');
1240
+ * img.hide();
1241
+ * } else {
1242
+ * img = null;
1243
+ * }
1244
+ * }
1245
+ * </code>
1246
+ * </div>
1247
+ *
1248
+ * <div>
1249
+ * <code>
1250
+ * // Use the file input to select multiple images
1251
+ * // to load and display.
1252
+ * let input;
1253
+ * let images = [];
1254
+ *
1255
+ * function setup() {
1256
+ * // Create a file input and place it beneath
1257
+ * // the canvas. Allow it to load multiple files.
1258
+ * input = createFileInput(handleImage, true);
1259
+ * input.position(0, 100);
1260
+ * }
1261
+ *
1262
+ * function draw() {
1263
+ * background(200);
1264
+ *
1265
+ * // Draw the images if loaded. Each image
1266
+ * // is drawn 20 pixels lower than the
1267
+ * // previous image.
1268
+ * for (let i = 0; i < images.length; i += 1) {
1269
+ * // Calculate the y-coordinate.
1270
+ * let y = i * 20;
1271
+ *
1272
+ * // Draw the image.
1273
+ * image(img, 0, y, 100, 100);
1274
+ * }
1275
+ *
1276
+ * describe('A gray square with a file input beneath it. If the user selects multiple image files to load, they are displayed on the square.');
1277
+ * }
1278
+ *
1279
+ * // Create an image if the file is an image,
1280
+ * // then add it to the images array.
1281
+ * function handleImage(file) {
1282
+ * if (file.type === 'image') {
1283
+ * let img = createImg(file.data, '');
1284
+ * img.hide();
1285
+ * images.push(img);
1286
+ * }
1287
+ * }
1288
+ * </code>
1289
+ * </div>
1290
+ */
1291
+ function createFileInput(callback: Function, multiple?: boolean): p5.File;
1292
+
1293
+ }
1294
+
1295
+ export default function dom(p5: any, fn: any): void;