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,2011 @@
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
+ class Element {
8
+ constructor(elt: HTMLElement, pInst?: p5);
9
+
10
+ /**
11
+ * Removes the element, stops all audio/video streams, and removes all
12
+ * callback functions.
13
+ */
14
+ remove(): void;
15
+
16
+ /**
17
+ * Attaches the element to a parent element.For example, a `<div></div>` element may be used as a box to
18
+ * hold two pieces of text, a header and a paragraph. The
19
+ * `<div></div>` is the parent element of both the header and
20
+ * paragraph.The parameter `parent` can have one of three types. `parent` can be a
21
+ * string with the parent element's ID, as in
22
+ * `myElement.parent('container')`. It can also be another
23
+ * p5.Element object, as in
24
+ * `myElement.parent(myDiv)`. Finally, `parent` can be an `HTMLElement`
25
+ * object, as in `myElement.parent(anotherElement)`.Calling `myElement.parent()` without an argument returns the element's
26
+ * parent.
27
+ *
28
+ * @param
29
+ * @param
30
+ */
31
+ parent(p: any, parent: string | p5.Element | object): void;
32
+
33
+ parent(p: any): p5.Element;
34
+
35
+ /**
36
+ * Attaches the element as a child of another element.`myElement.child()` accepts either a string ID, DOM node, or
37
+ * p5.Element. For example,
38
+ * `myElement.child(otherElement)`. If no argument is provided, an array of
39
+ * children DOM nodes is returned.
40
+ *
41
+ * @param
42
+ */
43
+ child(childNode: any): Node[];
44
+
45
+ child(childNode: any, child: string | p5.Element): void;
46
+
47
+ /**
48
+ * Sets the inner HTML of the element, replacing any existing HTML.The second parameter, `append`, is optional. If `true` is passed, as in
49
+ * `myElement.html('hi', true)`, the HTML is appended instead of replacing
50
+ * existing HTML.If no arguments are passed, as in `myElement.html()`, the element's inner
51
+ * HTML is returned.
52
+ *
53
+ * @param
54
+ */
55
+ html(args: any[]): string;
56
+
57
+ html(args: any[], html: string, append: boolean): void;
58
+
59
+ /**
60
+ * Sets the element's ID using a given string.Calling `myElement.id()` without an argument returns its ID as a string.
61
+ *
62
+ * @param
63
+ */
64
+ id(id: string): void;
65
+
66
+ id(id: any): string;
67
+
68
+ /**
69
+ * Adds a
70
+ * class attribute
71
+ * to the element using a given string.Calling `myElement.class()` without an argument returns a string with its current classes.
72
+ *
73
+ * @param
74
+ * @param
75
+ */
76
+ class(c: any, class: string): void;
77
+
78
+ class(c: any): string;
79
+
80
+ /**
81
+ * Adds a class to the element.
82
+ *
83
+ * @param
84
+ * @param
85
+ */
86
+ addClass(c: any, class: string): void;
87
+
88
+ /**
89
+ * Removes a class from the element.
90
+ *
91
+ * @param
92
+ * @param
93
+ */
94
+ removeClass(c: any, class: string): void;
95
+
96
+ /**
97
+ * Checks if a class is already applied to element.
98
+ *
99
+ * @param
100
+ */
101
+ hasClass(c: any): boolean;
102
+
103
+ /**
104
+ * Toggles whether a class is applied to the element.
105
+ *
106
+ * @param
107
+ */
108
+ toggleClass(c: any): void;
109
+
110
+ /**
111
+ * Centers the element either vertically, horizontally, or both.`center()` will center the element relative to its parent or according to
112
+ * the page's body if the element has no parent.If no argument is passed, as in `myElement.center()` the element is aligned
113
+ * both vertically and horizontally.
114
+ *
115
+ * @param
116
+ */
117
+ center(align: string): void;
118
+
119
+ /**
120
+ * Sets the element's position.The first two parameters, `x` and `y`, set the element's position relative
121
+ * to the top-left corner of the web page.The third parameter, `positionType`, is optional. It sets the element's
122
+ * positioning scheme.
123
+ * `positionType` is a string that can be either `'static'`, `'fixed'`,
124
+ * `'relative'`, `'sticky'`, `'initial'`, or `'inherit'`.If no arguments passed, as in `myElement.position()`, the method returns
125
+ * the element's position in an object, as in `{ x: 0, y: 0 }`.
126
+ *
127
+ * @param
128
+ */
129
+ position(args: any[]): object;
130
+
131
+ position(args: any[], x: number, y: number, positionType: string): void;
132
+
133
+ /**
134
+ * Shows the current element.
135
+ */
136
+ show(): void;
137
+
138
+ /**
139
+ * Hides the current element.
140
+ */
141
+ hide(): void;
142
+
143
+ /**
144
+ * Sets the element's width and height.Calling `myElement.size()` without an argument returns the element's size
145
+ * as an object with the properties `width` and `height`. For example,
146
+ * `{ width: 20, height: 10 }`.The first parameter, `width`, is optional. It's a number used to set the
147
+ * element's width. Calling `myElement.size(10)`The second parameter, 'height`, is also optional. It's a
148
+ * number used to set the element's height. For example, calling
149
+ * `myElement.size(20, 10)` sets the element's width to 20 pixels and height
150
+ * to 10 pixels.The constant `AUTO` can be used to adjust one dimension at a time while
151
+ * maintaining the aspect ratio, which is `width / height`. For example,
152
+ * consider an element that's 200 pixels wide and 100 pixels tall. Calling
153
+ * `myElement.size(20, AUTO)` sets the width to 20 pixels and height to 10
154
+ * pixels.Note: In the case of elements that need to load data, such as images, wait
155
+ * to call `myElement.size()` until after the data loads.
156
+ *
157
+ * @param
158
+ * @param
159
+ */
160
+ size(w: any, h: any): object;
161
+
162
+ size(w: number | AUTO, h: number | AUTO): void;
163
+
164
+ /**
165
+ * Applies a style to the element by adding a
166
+ * CSS declaration.The first parameter, `property`, is a string. If the name of a style
167
+ * property is passed, as in `myElement.style('color')`, the method returns
168
+ * the current value as a string or `null` if it hasn't been set. If a
169
+ * `property:style` string is passed, as in
170
+ * `myElement.style('color:deeppink')`, the method sets the style `property`
171
+ * to `value`.The second parameter, `value`, is optional. It sets the property's value.
172
+ * `value` can be a string, as in
173
+ * `myElement.style('color', 'deeppink')`, or a
174
+ * p5.Color object, as in
175
+ * `myElement.style('color', myColor)`.
176
+ *
177
+ * @param
178
+ * @param
179
+ * @param
180
+ */
181
+ style(prop: any, val: any, property: string): string;
182
+
183
+ style(prop: any, val: any, property: string, value: string | p5.Color): string;
184
+
185
+ /**
186
+ * Adds an
187
+ * attribute
188
+ * to the element.This method is useful for advanced tasks. Most commonly-used attributes,
189
+ * such as `id`, can be set with their dedicated methods. For example,
190
+ * `nextButton.id('next')` sets an element's `id` attribute. Calling
191
+ * `nextButton.attribute('id', 'next')` has the same effect.The first parameter, `attr`, is the attribute's name as a string. Calling
192
+ * `myElement.attribute('align')` returns the attribute's current value as a
193
+ * string or `null` if it hasn't been set.The second parameter, `value`, is optional. It's a string used to set the
194
+ * attribute's value. For example, calling
195
+ * `myElement.attribute('align', 'center')` sets the element's horizontal
196
+ * alignment to `center`.
197
+ *
198
+ * @param
199
+ * @param
200
+ */
201
+ attribute(attr: any, value: any): string;
202
+
203
+ attribute(attr: string, value: string): void;
204
+
205
+ /**
206
+ * Removes an attribute from the element.The parameter `attr` is the attribute's name as a string. For example,
207
+ * calling `myElement.removeAttribute('align')` removes its `align`
208
+ * attribute if it's been set.
209
+ *
210
+ * @param
211
+ */
212
+ removeAttribute(attr: string): void;
213
+
214
+ /**
215
+ * Returns or sets the element's value.Calling `myElement.value()` returns the element's current value.The parameter, `value`, is an optional number or string. If provided,
216
+ * as in `myElement.value(123)`, it's used to set the element's value.
217
+ *
218
+ * @param
219
+ */
220
+ value(args: any[]): string | number;
221
+
222
+ value(args: any[], value: string | number): void;
223
+
224
+ /**
225
+ * Calls a function when the mouse is pressed over the element.Calling `myElement.mousePressed(false)` disables the function.Note: Some mobile browsers may also trigger this event when the element
226
+ * receives a quick tap.
227
+ *
228
+ * @param
229
+ */
230
+ mousePressed(fxn: Function | boolean): void;
231
+
232
+ /**
233
+ * Calls a function when the mouse is pressed twice over the element.Calling `myElement.doubleClicked(false)` disables the function.
234
+ *
235
+ * @param
236
+ */
237
+ doubleClicked(fxn: Function | boolean): void;
238
+
239
+ /**
240
+ * Calls a function when the mouse wheel scrolls over the element.The callback function, `fxn`, is passed an `event` object. `event` has
241
+ * two numeric properties, `deltaY` and `deltaX`. `event.deltaY` is
242
+ * negative if the mouse wheel rotates away from the user. It's positive if
243
+ * the mouse wheel rotates toward the user. `event.deltaX` is positive if
244
+ * the mouse wheel moves to the right. It's negative if the mouse wheel moves
245
+ * to the left.Calling `myElement.mouseWheel(false)` disables the function.
246
+ *
247
+ * @param
248
+ */
249
+ mouseWheel(fxn: Function | boolean): void;
250
+
251
+ /**
252
+ * Calls a function when the mouse is released over the element.Calling `myElement.mouseReleased(false)` disables the function.Note: Some mobile browsers may also trigger this event when the element
253
+ * receives a quick tap.
254
+ *
255
+ * @param
256
+ */
257
+ mouseReleased(fxn: Function | boolean): void;
258
+
259
+ /**
260
+ * Calls a function when the mouse is pressed and released over the element.Calling `myElement.mouseReleased(false)` disables the function.Note: Some mobile browsers may also trigger this event when the element
261
+ * receives a quick tap.
262
+ *
263
+ * @param
264
+ */
265
+ mouseClicked(fxn: Function | boolean): void;
266
+
267
+ /**
268
+ * Calls a function when the mouse moves over the element.Calling `myElement.mouseMoved(false)` disables the function.
269
+ *
270
+ * @param
271
+ */
272
+ mouseMoved(fxn: Function | boolean): void;
273
+
274
+ /**
275
+ * Calls a function when the mouse moves onto the element.Calling `myElement.mouseOver(false)` disables the function.
276
+ *
277
+ * @param
278
+ */
279
+ mouseOver(fxn: Function | boolean): void;
280
+
281
+ /**
282
+ * Calls a function when the mouse moves off the element.Calling `myElement.mouseOut(false)` disables the function.
283
+ *
284
+ * @param
285
+ */
286
+ mouseOut(fxn: Function | boolean): void;
287
+
288
+ /**
289
+ * Calls a function when a file is dragged over the element.Calling `myElement.dragOver(false)` disables the function.
290
+ *
291
+ * @param
292
+ */
293
+ dragOver(fxn: Function | boolean): void;
294
+
295
+ /**
296
+ * Calls a function when a file is dragged off the element.Calling `myElement.dragLeave(false)` disables the function.
297
+ *
298
+ * @param
299
+ */
300
+ dragLeave(fxn: Function | boolean): void;
301
+
302
+ /**
303
+ * Calls a function when the element changes.Calling `myElement.changed(false)` disables the function.
304
+ *
305
+ * @param
306
+ */
307
+ changed(fxn: Function | boolean): void;
308
+
309
+ /**
310
+ * Calls a function when the element receives input.`myElement.input()` is often used to with text inputs and sliders. Calling
311
+ * `myElement.input(false)` disables the function.
312
+ *
313
+ * @param
314
+ */
315
+ input(fxn: Function | boolean): void;
316
+
317
+ /**
318
+ * Calls a function when the user drops a file on the element.The first parameter, `callback`, is a function to call once the file loads.
319
+ * The callback function should have one parameter, `file`, that's a
320
+ * p5.File object. If the user drops multiple files on
321
+ * the element, `callback`, is called once for each file.The second parameter, `fxn`, is a function to call when the browser detects
322
+ * one or more dropped files. The callback function should have one
323
+ * parameter, `event`, that's a
324
+ * DragEvent.
325
+ *
326
+ * @param
327
+ * @param
328
+ */
329
+ drop(callback: Function, fxn: Function): void;
330
+
331
+ /**
332
+ * Makes the element draggable.The parameter, `elmnt`, is optional. If another
333
+ * p5.Element object is passed, as in
334
+ * `myElement.draggable(otherElement)`, the other element will become draggable.
335
+ *
336
+ * @param
337
+ * @param
338
+ */
339
+ draggable(elmMove: any, elmnt: p5.Element): void;
340
+
341
+ }
342
+
343
+ /**
344
+ * Removes the element, stops all audio/video streams, and removes all
345
+ * callback functions.
346
+ *
347
+ * @example <div>
348
+ * <code>
349
+ * let p;
350
+ *
351
+ * function setup() {
352
+ * createCanvas(100, 100);
353
+ *
354
+ * background(200);
355
+ *
356
+ * // Create a paragraph element.
357
+ * p = createP('p5*js');
358
+ * p.position(10, 10);
359
+ *
360
+ * describe('The text "p5*js" written at the center of a gray square. ');
361
+ * }
362
+ *
363
+ * // Remove the paragraph when the user double-clicks.
364
+ * function doubleClicked() {
365
+ * p.remove();
366
+ * }
367
+ * </code>
368
+ * </div>
369
+ */
370
+ function remove(): void;
371
+
372
+ /**
373
+ * Attaches the element to a parent element.For example, a `&lt;div&gt;&lt;/div&gt;` element may be used as a box to
374
+ * hold two pieces of text, a header and a paragraph. The
375
+ * `&lt;div&gt;&lt;/div&gt;` is the parent element of both the header and
376
+ * paragraph.The parameter `parent` can have one of three types. `parent` can be a
377
+ * string with the parent element's ID, as in
378
+ * `myElement.parent('container')`. It can also be another
379
+ * p5.Element object, as in
380
+ * `myElement.parent(myDiv)`. Finally, `parent` can be an `HTMLElement`
381
+ * object, as in `myElement.parent(anotherElement)`.Calling `myElement.parent()` without an argument returns the element's
382
+ * parent.
383
+ *
384
+ * @param ID, <a href="#/p5.Element">p5.Element</a>,
385
+ * or HTMLElement of desired parent element.
386
+ * @example <div>
387
+ * <code>
388
+ * function setup() {
389
+ * background(200);
390
+ *
391
+ * // Create a div element.
392
+ * let div = createDiv();
393
+ *
394
+ * // Place the div in the top-left corner.
395
+ * div.position(10, 20);
396
+ *
397
+ * // Set its width and height.
398
+ * div.size(80, 60);
399
+ *
400
+ * // Set its background color to white
401
+ * div.style('background-color', 'white');
402
+ *
403
+ * // Align any text to the center.
404
+ * div.style('text-align', 'center');
405
+ *
406
+ * // Set its ID to "container".
407
+ * div.id('container');
408
+ *
409
+ * // Create a paragraph element.
410
+ * let p = createP('p5*js');
411
+ *
412
+ * // Make the div its parent
413
+ * // using its ID "container".
414
+ * p.parent('container');
415
+ *
416
+ * describe('The text "p5*js" written in black at the center of a white rectangle. The rectangle is inside a gray square.');
417
+ * }
418
+ * </code>
419
+ * </div>
420
+ *
421
+ * <div>
422
+ * <code>
423
+ * function setup() {
424
+ * background(200);
425
+ *
426
+ * // Create rectangular div element.
427
+ * let div = createDiv();
428
+ *
429
+ * // Place the div in the top-left corner.
430
+ * div.position(10, 20);
431
+ *
432
+ * // Set its width and height.
433
+ * div.size(80, 60);
434
+ *
435
+ * // Set its background color and align
436
+ * // any text to the center.
437
+ * div.style('background-color', 'white');
438
+ * div.style('text-align', 'center');
439
+ *
440
+ * // Create a paragraph element.
441
+ * let p = createP('p5*js');
442
+ *
443
+ * // Make the div its parent.
444
+ * p.parent(div);
445
+ *
446
+ * describe('The text "p5*js" written in black at the center of a white rectangle. The rectangle is inside a gray square.');
447
+ * }
448
+ * </code>
449
+ * </div>
450
+ *
451
+ * <div>
452
+ * <code>
453
+ * function setup() {
454
+ * background(200);
455
+ *
456
+ * // Create rectangular div element.
457
+ * let div = createDiv();
458
+ *
459
+ * // Place the div in the top-left corner.
460
+ * div.position(10, 20);
461
+ *
462
+ * // Set its width and height.
463
+ * div.size(80, 60);
464
+ *
465
+ * // Set its background color and align
466
+ * // any text to the center.
467
+ * div.style('background-color', 'white');
468
+ * div.style('text-align', 'center');
469
+ *
470
+ * // Create a paragraph element.
471
+ * let p = createP('p5*js');
472
+ *
473
+ * // Make the div its parent
474
+ * // using the underlying
475
+ * // HTMLElement.
476
+ * p.parent(div.elt);
477
+ *
478
+ * describe('The text "p5*js" written in black at the center of a white rectangle. The rectangle is inside a gray square.');
479
+ * }
480
+ * </code>
481
+ * </div>
482
+ */
483
+ function parent(p: any, parent: string | p5.Element | object): void;
484
+
485
+ /**
486
+ */
487
+ function parent(p: any): p5.Element;
488
+
489
+ /**
490
+ * Attaches the element as a child of another element.`myElement.child()` accepts either a string ID, DOM node, or
491
+ * p5.Element. For example,
492
+ * `myElement.child(otherElement)`. If no argument is provided, an array of
493
+ * children DOM nodes is returned.
494
+ *
495
+ * @returns an array of child nodes.
496
+ * @example <div class='norender'>
497
+ * <code>
498
+ * function setup() {
499
+ * createCanvas(100, 100);
500
+ *
501
+ * background(200);
502
+ *
503
+ * // Create the div elements.
504
+ * let div0 = createDiv('Parent');
505
+ * let div1 = createDiv('Child');
506
+ *
507
+ * // Make div1 the child of div0
508
+ * // using the p5.Element.
509
+ * div0.child(div1);
510
+ *
511
+ * describe('A gray square with the words "Parent" and "Child" written beneath it.');
512
+ * }
513
+ * </code>
514
+ * </div>
515
+ *
516
+ * <div class='norender'>
517
+ * <code>
518
+ * function setup() {
519
+ * createCanvas(100, 100);
520
+ *
521
+ * background(200);
522
+ *
523
+ * // Create the div elements.
524
+ * let div0 = createDiv('Parent');
525
+ * let div1 = createDiv('Child');
526
+ *
527
+ * // Give div1 an ID.
528
+ * div1.id('apples');
529
+ *
530
+ * // Make div1 the child of div0
531
+ * // using its ID.
532
+ * div0.child('apples');
533
+ *
534
+ * describe('A gray square with the words "Parent" and "Child" written beneath it.');
535
+ * }
536
+ * </code>
537
+ * </div>
538
+ *
539
+ * <div class='norender notest'>
540
+ * <code>
541
+ * // This example assumes there is a div already on the page
542
+ * // with id "myChildDiv".
543
+ *
544
+ * function setup() {
545
+ * createCanvas(100, 100);
546
+ *
547
+ * background(200);
548
+ *
549
+ * // Create the div elements.
550
+ * let div0 = createDiv('Parent');
551
+ *
552
+ * // Select the child element by its ID.
553
+ * let elt = document.getElementById('myChildDiv');
554
+ *
555
+ * // Make div1 the child of div0
556
+ * // using its HTMLElement object.
557
+ * div0.child(elt);
558
+ *
559
+ * describe('A gray square with the words "Parent" and "Child" written beneath it.');
560
+ * }
561
+ * </code>
562
+ * </div>
563
+ */
564
+ function child(childNode: any): Node[];
565
+
566
+ /**
567
+ * @param the ID, DOM node, or <a href="#/p5.Element">p5.Element</a>
568
+ * to add to the current element
569
+ */
570
+ function child(childNode: any, child?: string | p5.Element): void;
571
+
572
+ /**
573
+ * Sets the inner HTML of the element, replacing any existing HTML.The second parameter, `append`, is optional. If `true` is passed, as in
574
+ * `myElement.html('hi', true)`, the HTML is appended instead of replacing
575
+ * existing HTML.If no arguments are passed, as in `myElement.html()`, the element's inner
576
+ * HTML is returned.
577
+ *
578
+ * @for p5.Element
579
+ * @returns the inner HTML of the element
580
+ * @example <div class='norender'>
581
+ * <code>
582
+ * function setup() {
583
+ * createCanvas(100, 100);
584
+ *
585
+ * // Create the div element and set its size.
586
+ * let div = createDiv('');
587
+ * div.size(100, 100);
588
+ *
589
+ * // Set the inner HTML to "hi".
590
+ * div.html('hi');
591
+ *
592
+ * describe('A gray square with the word "hi" written beneath it.');
593
+ * }
594
+ * </code>
595
+ * </div>
596
+ *
597
+ * <div class='norender'>
598
+ * <code>
599
+ * function setup() {
600
+ * createCanvas(100, 100);
601
+ *
602
+ * background(200);
603
+ *
604
+ * // Create the div element and set its size.
605
+ * let div = createDiv('Hello ');
606
+ * div.size(100, 100);
607
+ *
608
+ * // Append "World" to the div's HTML.
609
+ * div.html('World', true);
610
+ *
611
+ * describe('A gray square with the text "Hello World" written beneath it.');
612
+ * }
613
+ * </code>
614
+ * </div>
615
+ *
616
+ * <div class='norender'>
617
+ * <code>
618
+ * function setup() {
619
+ * createCanvas(100, 100);
620
+ *
621
+ * background(200);
622
+ *
623
+ * // Create the div element.
624
+ * let div = createDiv('Hello');
625
+ *
626
+ * // Prints "Hello" to the console.
627
+ * print(div.html());
628
+ *
629
+ * describe('A gray square with the word "Hello!" written beneath it.');
630
+ * }
631
+ * </code>
632
+ * </div>
633
+ */
634
+ function html(...args: any[]): string;
635
+
636
+ /**
637
+ * @param the HTML to be placed inside the element
638
+ * @param whether to append HTML to existing
639
+ */
640
+ function html(...args: any[], html?: string, append?: boolean): void;
641
+
642
+ /**
643
+ * Sets the element's ID using a given string.Calling `myElement.id()` without an argument returns its ID as a string.
644
+ *
645
+ * @param ID of the element.
646
+ * @example <div>
647
+ * <code>
648
+ * function setup() {
649
+ * // Create a canvas element and
650
+ * // assign it to cnv.
651
+ * let cnv = createCanvas(100, 100);
652
+ *
653
+ * background(200);
654
+ *
655
+ * // Set the canvas' ID
656
+ * // to "mycanvas".
657
+ * cnv.id('mycanvas');
658
+ *
659
+ * // Get the canvas' ID.
660
+ * let id = cnv.id();
661
+ * text(id, 24, 54);
662
+ *
663
+ * describe('The text "mycanvas" written in black on a gray background.');
664
+ * }
665
+ * </code>
666
+ * </div>
667
+ */
668
+ function id(id: string): void;
669
+
670
+ /**
671
+ * @return ID of the element.
672
+ */
673
+ function id(id: any): string;
674
+
675
+ /**
676
+ * Adds a
677
+ * class attribute
678
+ * to the element using a given string.Calling `myElement.class()` without an argument returns a string with its current classes.
679
+ *
680
+ * @param class to add.
681
+ * @example <div>
682
+ * <code>
683
+ * function setup() {
684
+ * // Create a canvas element and
685
+ * // assign it to cnv.
686
+ * let cnv = createCanvas(100, 100);
687
+ *
688
+ * background(200);
689
+ *
690
+ * // Add the class "small" to the
691
+ * // canvas element.
692
+ * cnv.class('small');
693
+ *
694
+ * // Get the canvas element's class
695
+ * // and display it.
696
+ * let c = cnv.class();
697
+ * text(c, 35, 54);
698
+ *
699
+ * describe('The word "small" written in black on a gray canvas.');
700
+ *
701
+ * }
702
+ * </code>
703
+ * </div>
704
+ */
705
+ function class(c: any, class: string): void;
706
+
707
+ /**
708
+ * @return element's classes, if any.
709
+ */
710
+ function class(c: any): string;
711
+
712
+ /**
713
+ * Adds a class to the element.
714
+ *
715
+ * @for p5.Element
716
+ * @param name of class to add.
717
+ * @example <div class='norender'>
718
+ * <code>
719
+ * function setup() {
720
+ * createCanvas(100, 100);
721
+ *
722
+ * background(200);
723
+ *
724
+ * // Create a div element.
725
+ * let div = createDiv('div');
726
+ *
727
+ * // Add a class to the div.
728
+ * div.addClass('myClass');
729
+ *
730
+ * describe('A gray square.');
731
+ * }
732
+ * </code>
733
+ * </div>
734
+ */
735
+ function addClass(c: any, class: string): void;
736
+
737
+ /**
738
+ * Removes a class from the element.
739
+ *
740
+ * @param name of class to remove.
741
+ * @example <div class='norender'>
742
+ * <code>
743
+ * // In this example, a class is set when the div is created
744
+ * // and removed when mouse is pressed. This could link up
745
+ * // with a CSS style rule to toggle style properties.
746
+ *
747
+ * let div;
748
+ *
749
+ * function setup() {
750
+ * createCanvas(100, 100);
751
+ *
752
+ * background(200);
753
+ *
754
+ * // Create a div element.
755
+ * div = createDiv('div');
756
+ *
757
+ * // Add a class to the div.
758
+ * div.addClass('myClass');
759
+ *
760
+ * describe('A gray square.');
761
+ * }
762
+ *
763
+ * // Remove 'myClass' from the div when the user presses the mouse.
764
+ * function mousePressed() {
765
+ * div.removeClass('myClass');
766
+ * }
767
+ * </code>
768
+ * </div>
769
+ */
770
+ function removeClass(c: any, class: string): void;
771
+
772
+ /**
773
+ * Checks if a class is already applied to element.
774
+ *
775
+ * @returns a boolean value if element has specified class.
776
+ * @param {String} name of class to check.
777
+ * @example <div class='norender'>
778
+ * <code>
779
+ * let div;
780
+ *
781
+ * function setup() {
782
+ * createCanvas(100, 100);
783
+ *
784
+ * background(200);
785
+ *
786
+ * // Create a div element.
787
+ * div = createDiv('div');
788
+ *
789
+ * // Add the class 'show' to the div.
790
+ * div.addClass('show');
791
+ *
792
+ * describe('A gray square.');
793
+ * }
794
+ *
795
+ * // Toggle the class 'show' when the mouse is pressed.
796
+ * function mousePressed() {
797
+ * if (div.hasClass('show')) {
798
+ * div.addClass('show');
799
+ * } else {
800
+ * div.removeClass('show');
801
+ * }
802
+ * }
803
+ * </code>
804
+ * </div>
805
+ */
806
+ function hasClass(c: any): boolean;
807
+
808
+ /**
809
+ * Toggles whether a class is applied to the element.
810
+ *
811
+ * @param {String} class name to toggle.
812
+ * @example <div class='norender'>
813
+ * <code>
814
+ * let div;
815
+ *
816
+ * function setup() {
817
+ * createCanvas(100, 100);
818
+ *
819
+ * background(200);
820
+ *
821
+ * // Create a div element.
822
+ * div = createDiv('div');
823
+ *
824
+ * // Add the 'show' class to the div.
825
+ * div.addClass('show');
826
+ *
827
+ * describe('A gray square.');
828
+ * }
829
+ *
830
+ * // Toggle the 'show' class when the mouse is pressed.
831
+ * function mousePressed() {
832
+ * div.toggleClass('show');
833
+ * }
834
+ * </code>
835
+ * </div>
836
+ */
837
+ function toggleClass(c: any): void;
838
+
839
+ /**
840
+ * Centers the element either vertically, horizontally, or both.`center()` will center the element relative to its parent or according to
841
+ * the page's body if the element has no parent.If no argument is passed, as in `myElement.center()` the element is aligned
842
+ * both vertically and horizontally.
843
+ *
844
+ * @param passing 'vertical', 'horizontal' aligns element accordingly
845
+ * @example <div>
846
+ * <code>
847
+ * function setup() {
848
+ * createCanvas(100, 100);
849
+ *
850
+ * background(200);
851
+ *
852
+ * // Create the div element and style it.
853
+ * let div = createDiv('');
854
+ * div.size(10, 10);
855
+ * div.style('background-color', 'orange');
856
+ *
857
+ * // Center the div relative to the page's body.
858
+ * div.center();
859
+ *
860
+ * describe('A gray square and an orange rectangle. The rectangle is at the center of the page.');
861
+ * }
862
+ * </code>
863
+ * </div>
864
+ */
865
+ function center(align?: string): void;
866
+
867
+ /**
868
+ * Sets the element's position.The first two parameters, `x` and `y`, set the element's position relative
869
+ * to the top-left corner of the web page.The third parameter, `positionType`, is optional. It sets the element's
870
+ * positioning scheme.
871
+ * `positionType` is a string that can be either `'static'`, `'fixed'`,
872
+ * `'relative'`, `'sticky'`, `'initial'`, or `'inherit'`.If no arguments passed, as in `myElement.position()`, the method returns
873
+ * the element's position in an object, as in `{ x: 0, y: 0 }`.
874
+ *
875
+ * @returns object of form `{ x: 0, y: 0 }` containing the element's position.
876
+ * @example <div>
877
+ * <code class='norender'>
878
+ * function setup() {
879
+ * let cnv = createCanvas(100, 100);
880
+ *
881
+ * background(200);
882
+ *
883
+ * // Positions the canvas 50px to the right and 100px
884
+ * // below the top-left corner of the window.
885
+ * cnv.position(50, 100);
886
+ *
887
+ * describe('A gray square that is 50 pixels to the right and 100 pixels down from the top-left corner of the web page.');
888
+ * }
889
+ * </code>
890
+ * </div>
891
+ *
892
+ * <div>
893
+ * <code class='norender'>
894
+ * function setup() {
895
+ * let cnv = createCanvas(100, 100);
896
+ *
897
+ * background(200);
898
+ *
899
+ * // Positions the canvas at the top-left corner
900
+ * // of the window with a 'fixed' position type.
901
+ * cnv.position(0, 0, 'fixed');
902
+ *
903
+ * describe('A gray square in the top-left corner of the web page.');
904
+ * }
905
+ * </code>
906
+ * </div>
907
+ */
908
+ function position(...args: any[]): object;
909
+
910
+ /**
911
+ * @param x-position relative to top-left of window (optional)
912
+ * @param y-position relative to top-left of window (optional)
913
+ * @param it can be static, fixed, relative, sticky, initial or inherit (optional)
914
+ */
915
+ function position(...args: any[], x?: number, y?: number, positionType?: string): void;
916
+
917
+ /**
918
+ * Shows the current element.
919
+ *
920
+ * @example <div>
921
+ * <code>
922
+ * let p;
923
+ *
924
+ * function setup() {
925
+ * createCanvas(100, 100);
926
+ *
927
+ * background(200);
928
+ *
929
+ * // Create a paragraph element and hide it.
930
+ * p = createP('p5*js');
931
+ * p.position(10, 10);
932
+ * p.hide();
933
+ *
934
+ * describe('A gray square. The text "p5*js" appears when the user double-clicks the square.');
935
+ * }
936
+ *
937
+ * // Show the paragraph when the user double-clicks.
938
+ * function doubleClicked() {
939
+ * p.show();
940
+ * }
941
+ * </code>
942
+ * </div>
943
+ */
944
+ function show(): void;
945
+
946
+ /**
947
+ * Hides the current element.
948
+ *
949
+ * @example let p;
950
+ *
951
+ * function setup() {
952
+ * createCanvas(100, 100);
953
+ *
954
+ * background(200);
955
+ *
956
+ * // Create a paragraph element.
957
+ * p = createP('p5*js');
958
+ * p.position(10, 10);
959
+ *
960
+ * describe('The text "p5*js" at the center of a gray square. The text disappears when the user double-clicks the square.');
961
+ * }
962
+ *
963
+ * // Hide the paragraph when the user double-clicks.
964
+ * function doubleClicked() {
965
+ * p.hide();
966
+ * }
967
+ * </code>
968
+ * </div>
969
+ */
970
+ function hide(): void;
971
+
972
+ /**
973
+ * Sets the element's width and height.Calling `myElement.size()` without an argument returns the element's size
974
+ * as an object with the properties `width` and `height`. For example,
975
+ * `{ width: 20, height: 10 }`.The first parameter, `width`, is optional. It's a number used to set the
976
+ * element's width. Calling `myElement.size(10)`The second parameter, 'height`, is also optional. It's a
977
+ * number used to set the element's height. For example, calling
978
+ * `myElement.size(20, 10)` sets the element's width to 20 pixels and height
979
+ * to 10 pixels.The constant `AUTO` can be used to adjust one dimension at a time while
980
+ * maintaining the aspect ratio, which is `width / height`. For example,
981
+ * consider an element that's 200 pixels wide and 100 pixels tall. Calling
982
+ * `myElement.size(20, AUTO)` sets the width to 20 pixels and height to 10
983
+ * pixels.Note: In the case of elements that need to load data, such as images, wait
984
+ * to call `myElement.size()` until after the data loads.
985
+ *
986
+ * @return width and height of the element in an object.
987
+ * @example <div>
988
+ * <code>
989
+ * function setup() {
990
+ * createCanvas(100, 100);
991
+ *
992
+ * background(200);
993
+ *
994
+ * // Create a pink div element and place it at the top-left corner.
995
+ * let div = createDiv();
996
+ * div.position(10, 10);
997
+ * div.style('background-color', 'deeppink');
998
+ *
999
+ * // Set the div's width to 80 pixels and height to 20 pixels.
1000
+ * div.size(80, 20);
1001
+ *
1002
+ * describe('A gray square with a pink rectangle near its top.');
1003
+ * }
1004
+ * </code>
1005
+ * </div>
1006
+ *
1007
+ * <div>
1008
+ * <code>
1009
+ * function setup() {
1010
+ * createCanvas(100, 100);
1011
+ *
1012
+ * background(200);
1013
+ *
1014
+ * // Create a pink div element and place it at the top-left corner.
1015
+ * let div = createDiv();
1016
+ * div.position(10, 10);
1017
+ * div.style('background-color', 'deeppink');
1018
+ *
1019
+ * // Set the div's width to 80 pixels and height to 40 pixels.
1020
+ * div.size(80, 40);
1021
+ *
1022
+ * // Get the div's size as an object.
1023
+ * let s = div.size();
1024
+ *
1025
+ * // Display the div's dimensions.
1026
+ * div.html(`${s.width} x ${s.height}`);
1027
+ *
1028
+ * describe('A gray square with a pink rectangle near its top. The text "80 x 40" is written within the rectangle.');
1029
+ * }
1030
+ * </code>
1031
+ * </div>
1032
+ *
1033
+ * <div>
1034
+ * <code>
1035
+ * let img1;
1036
+ * let img2;
1037
+ *
1038
+ * function setup() {
1039
+ * createCanvas(100, 100);
1040
+ *
1041
+ * background(200);
1042
+ *
1043
+ * // Load an image of an astronaut on the moon
1044
+ * // and place it at the top-left of the canvas.
1045
+ * img1 = createImg(
1046
+ * 'assets/moonwalk.jpg',
1047
+ * 'An astronaut walking on the moon',
1048
+ * ''
1049
+ * );
1050
+ * img1.position(0, 0);
1051
+ *
1052
+ * // Load an image of an astronaut on the moon
1053
+ * // and place it at the top-left of the canvas.
1054
+ * // Resize the image once it's loaded.
1055
+ * img2 = createImg(
1056
+ * 'assets/moonwalk.jpg',
1057
+ * 'An astronaut walking on the moon',
1058
+ * '',
1059
+ * resizeImage
1060
+ * );
1061
+ * img2.position(0, 0);
1062
+ *
1063
+ * describe('A gray square two copies of a space image at the top-left. The copy in front is smaller.');
1064
+ * }
1065
+ *
1066
+ * // Resize img2 and keep its aspect ratio.
1067
+ * function resizeImage() {
1068
+ * img2.size(50, AUTO);
1069
+ * }
1070
+ * </code>
1071
+ * </div>
1072
+ */
1073
+ function size(w: any, h: any): object;
1074
+
1075
+ /**
1076
+ * @param width of the element, either AUTO, or a number.
1077
+ * @param height of the element, either AUTO, or a number.
1078
+ */
1079
+ function size(w?: number | AUTO, h?: number | AUTO): void;
1080
+
1081
+ /**
1082
+ * Applies a style to the element by adding a
1083
+ * CSS declaration.The first parameter, `property`, is a string. If the name of a style
1084
+ * property is passed, as in `myElement.style('color')`, the method returns
1085
+ * the current value as a string or `null` if it hasn't been set. If a
1086
+ * `property:style` string is passed, as in
1087
+ * `myElement.style('color:deeppink')`, the method sets the style `property`
1088
+ * to `value`.The second parameter, `value`, is optional. It sets the property's value.
1089
+ * `value` can be a string, as in
1090
+ * `myElement.style('color', 'deeppink')`, or a
1091
+ * p5.Color object, as in
1092
+ * `myElement.style('color', myColor)`.
1093
+ *
1094
+ * @param style property to set.
1095
+ * @returns value of the property.
1096
+ * @example <div>
1097
+ * <code>
1098
+ * function setup() {
1099
+ * createCanvas(100, 100);
1100
+ *
1101
+ * background(200);
1102
+ *
1103
+ * // Create a paragraph element and set its font color to "deeppink".
1104
+ * let p = createP('p5*js');
1105
+ * p.position(25, 20);
1106
+ * p.style('color', 'deeppink');
1107
+ *
1108
+ * describe('The text p5*js written in pink on a gray background.');
1109
+ * }
1110
+ * </code>
1111
+ * </div>
1112
+ *
1113
+ * <div>
1114
+ * <code>
1115
+ * function setup() {
1116
+ * createCanvas(100, 100);
1117
+ *
1118
+ * background(200);
1119
+ *
1120
+ * // Create a p5.Color object.
1121
+ * let c = color('deeppink');
1122
+ *
1123
+ * // Create a paragraph element and set its font color using a p5.Color object.
1124
+ * let p = createP('p5*js');
1125
+ * p.position(25, 20);
1126
+ * p.style('color', c);
1127
+ *
1128
+ * describe('The text p5*js written in pink on a gray background.');
1129
+ * }
1130
+ * </code>
1131
+ * </div>
1132
+ *
1133
+ * <div>
1134
+ * <code>
1135
+ * function setup() {
1136
+ * createCanvas(100, 100);
1137
+ *
1138
+ * background(200);
1139
+ *
1140
+ * // Create a paragraph element and set its font color to "deeppink"
1141
+ * // using property:value syntax.
1142
+ * let p = createP('p5*js');
1143
+ * p.position(25, 20);
1144
+ * p.style('color:deeppink');
1145
+ *
1146
+ * describe('The text p5*js written in pink on a gray background.');
1147
+ * }
1148
+ * </code>
1149
+ * </div>
1150
+ *
1151
+ * <div>
1152
+ * <code>
1153
+ * function setup() {
1154
+ * createCanvas(100, 100);
1155
+ *
1156
+ * background(200);
1157
+ *
1158
+ * // Create an empty paragraph element and set its font color to "deeppink".
1159
+ * let p = createP();
1160
+ * p.position(5, 5);
1161
+ * p.style('color', 'deeppink');
1162
+ *
1163
+ * // Get the element's color as an RGB color string.
1164
+ * let c = p.style('color');
1165
+ *
1166
+ * // Set the element's inner HTML using the RGB color string.
1167
+ * p.html(c);
1168
+ *
1169
+ * describe('The text "rgb(255, 20, 147)" written in pink on a gray background.');
1170
+ * }
1171
+ * </code>
1172
+ * </div>
1173
+ */
1174
+ function style(prop: any, val: any, property: string): string;
1175
+
1176
+ /**
1177
+ * @param value to assign to the property.
1178
+ * @return value of the property.
1179
+ */
1180
+ function style(prop: any, val: any, property: string, value: string | p5.Color): string;
1181
+
1182
+ /**
1183
+ * Adds an
1184
+ * attribute
1185
+ * to the element.This method is useful for advanced tasks. Most commonly-used attributes,
1186
+ * such as `id`, can be set with their dedicated methods. For example,
1187
+ * `nextButton.id('next')` sets an element's `id` attribute. Calling
1188
+ * `nextButton.attribute('id', 'next')` has the same effect.The first parameter, `attr`, is the attribute's name as a string. Calling
1189
+ * `myElement.attribute('align')` returns the attribute's current value as a
1190
+ * string or `null` if it hasn't been set.The second parameter, `value`, is optional. It's a string used to set the
1191
+ * attribute's value. For example, calling
1192
+ * `myElement.attribute('align', 'center')` sets the element's horizontal
1193
+ * alignment to `center`.
1194
+ *
1195
+ * @return value of the attribute.
1196
+ * @example <div>
1197
+ * <code>
1198
+ * function setup() {
1199
+ * createCanvas(100, 100);
1200
+ *
1201
+ * // Create a container div element and place it at the top-left corner.
1202
+ * let container = createDiv();
1203
+ * container.position(0, 0);
1204
+ *
1205
+ * // Create a paragraph element and place it within the container.
1206
+ * // Set its horizontal alignment to "left".
1207
+ * let p1 = createP('hi');
1208
+ * p1.parent(container);
1209
+ * p1.attribute('align', 'left');
1210
+ *
1211
+ * // Create a paragraph element and place it within the container.
1212
+ * // Set its horizontal alignment to "center".
1213
+ * let p2 = createP('hi');
1214
+ * p2.parent(container);
1215
+ * p2.attribute('align', 'center');
1216
+ *
1217
+ * // Create a paragraph element and place it within the container.
1218
+ * // Set its horizontal alignment to "right".
1219
+ * let p3 = createP('hi');
1220
+ * p3.parent(container);
1221
+ * p3.attribute('align', 'right');
1222
+ *
1223
+ * describe('A gray square with the text "hi" written on three separate lines, each placed further to the right.');
1224
+ * }
1225
+ * </code>
1226
+ * </div>
1227
+ */
1228
+ function attribute(attr: any, value: any): string;
1229
+
1230
+ /**
1231
+ * @param attribute to set.
1232
+ * @param value to assign to the attribute.
1233
+ */
1234
+ function attribute(attr: string, value: string): void;
1235
+
1236
+ /**
1237
+ * Removes an attribute from the element.The parameter `attr` is the attribute's name as a string. For example,
1238
+ * calling `myElement.removeAttribute('align')` removes its `align`
1239
+ * attribute if it's been set.
1240
+ *
1241
+ * @param attribute to remove.
1242
+ * @example <div>
1243
+ * <code>
1244
+ * let p;
1245
+ *
1246
+ * function setup() {
1247
+ * createCanvas(100, 100);
1248
+ *
1249
+ * background(200);
1250
+ *
1251
+ * // Create a paragraph element and place it in the center of the canvas.
1252
+ * // Set its "align" attribute to "center".
1253
+ * p = createP('hi');
1254
+ * p.position(0, 20);
1255
+ * p.attribute('align', 'center');
1256
+ *
1257
+ * describe('The text "hi" written in black at the center of a gray square. The text moves to the left edge when double-clicked.');
1258
+ * }
1259
+ *
1260
+ * // Remove the 'align' attribute when the user double-clicks the paragraph.
1261
+ * function doubleClicked() {
1262
+ * p.removeAttribute('align');
1263
+ * }
1264
+ * </code>
1265
+ * </div>
1266
+ */
1267
+ function removeAttribute(attr: string): void;
1268
+
1269
+ /**
1270
+ * Returns or sets the element's value.Calling `myElement.value()` returns the element's current value.The parameter, `value`, is an optional number or string. If provided,
1271
+ * as in `myElement.value(123)`, it's used to set the element's value.
1272
+ *
1273
+ * @return value of the element.
1274
+ * @example <div>
1275
+ * <code>
1276
+ * let input;
1277
+ *
1278
+ * function setup() {
1279
+ * createCanvas(100, 100);
1280
+ *
1281
+ * // Create a text input and place it beneath the canvas.
1282
+ * // Set its default value to "hello".
1283
+ * input = createInput('hello');
1284
+ * input.position(0, 100);
1285
+ *
1286
+ * describe('The text from an input box is displayed on a gray square.');
1287
+ * }
1288
+ *
1289
+ * function draw() {
1290
+ * background(200);
1291
+ *
1292
+ * // Use the input's value to display a message.
1293
+ * let msg = input.value();
1294
+ * text(msg, 0, 55);
1295
+ * }
1296
+ * </code>
1297
+ * </div>
1298
+ *
1299
+ * <div>
1300
+ * <code>
1301
+ * let input;
1302
+ *
1303
+ * function setup() {
1304
+ * createCanvas(100, 100);
1305
+ *
1306
+ * // Create a text input and place it beneath the canvas.
1307
+ * // Set its default value to "hello".
1308
+ * input = createInput('hello');
1309
+ * input.position(0, 100);
1310
+ *
1311
+ * describe('The text from an input box is displayed on a gray square. The text resets to "hello" when the user double-clicks the square.');
1312
+ * }
1313
+ *
1314
+ * function draw() {
1315
+ * background(200);
1316
+ *
1317
+ * // Use the input's value to display a message.
1318
+ * let msg = input.value();
1319
+ * text(msg, 0, 55);
1320
+ * }
1321
+ *
1322
+ * // Reset the input's value.
1323
+ * function doubleClicked() {
1324
+ * input.value('hello');
1325
+ * }
1326
+ * </code>
1327
+ * </div>
1328
+ */
1329
+ function value(...args: any[]): string | number;
1330
+
1331
+ /**
1332
+ */
1333
+ function value(...args: any[], value: string | number): void;
1334
+
1335
+ /**
1336
+ * Calls a function when the mouse is pressed over the element.Calling `myElement.mousePressed(false)` disables the function.Note: Some mobile browsers may also trigger this event when the element
1337
+ * receives a quick tap.
1338
+ *
1339
+ * @param function to call when the mouse is
1340
+ * pressed over the element.
1341
+ * `false` disables the function.
1342
+ * @example <div>
1343
+ * <code>
1344
+ * function setup() {
1345
+ * // Create a canvas element and
1346
+ * // assign it to cnv.
1347
+ * let cnv = createCanvas(100, 100);
1348
+ *
1349
+ * background(200);
1350
+ *
1351
+ * // Call randomColor() when the canvas
1352
+ * // is pressed.
1353
+ * cnv.mousePressed(randomColor);
1354
+ *
1355
+ * describe('A gray square changes color when the mouse is pressed.');
1356
+ * }
1357
+ *
1358
+ * // Paint the background either
1359
+ * // red, yellow, blue, or green.
1360
+ * function randomColor() {
1361
+ * let c = random(['red', 'yellow', 'blue', 'green']);
1362
+ * background(c);
1363
+ * }
1364
+ * </code>
1365
+ * </div>
1366
+ */
1367
+ function mousePressed(fxn: Function | boolean): void;
1368
+
1369
+ /**
1370
+ * Calls a function when the mouse is pressed twice over the element.Calling `myElement.doubleClicked(false)` disables the function.
1371
+ *
1372
+ * @param function to call when the mouse is
1373
+ * double clicked over the element.
1374
+ * `false` disables the function.
1375
+ * @example <div>
1376
+ * <code>
1377
+ * function setup() {
1378
+ * // Create a canvas element and
1379
+ * // assign it to cnv.
1380
+ * let cnv = createCanvas(100, 100);
1381
+ *
1382
+ * background(200);
1383
+ *
1384
+ * // Call randomColor() when the
1385
+ * // canvas is double-clicked.
1386
+ * cnv.doubleClicked(randomColor);
1387
+ *
1388
+ * describe('A gray square changes color when the user double-clicks the canvas.');
1389
+ * }
1390
+ *
1391
+ * // Paint the background either
1392
+ * // red, yellow, blue, or green.
1393
+ * function randomColor() {
1394
+ * let c = random(['red', 'yellow', 'blue', 'green']);
1395
+ * background(c);
1396
+ * }
1397
+ * </code>
1398
+ * </div>
1399
+ */
1400
+ function doubleClicked(fxn: Function | boolean): void;
1401
+
1402
+ /**
1403
+ * Calls a function when the mouse wheel scrolls over the element.The callback function, `fxn`, is passed an `event` object. `event` has
1404
+ * two numeric properties, `deltaY` and `deltaX`. `event.deltaY` is
1405
+ * negative if the mouse wheel rotates away from the user. It's positive if
1406
+ * the mouse wheel rotates toward the user. `event.deltaX` is positive if
1407
+ * the mouse wheel moves to the right. It's negative if the mouse wheel moves
1408
+ * to the left.Calling `myElement.mouseWheel(false)` disables the function.
1409
+ *
1410
+ * @param function to call when the mouse wheel is
1411
+ * scrolled over the element.
1412
+ * `false` disables the function.
1413
+ * @example <div>
1414
+ * <code>
1415
+ * function setup() {
1416
+ * // Create a canvas element and
1417
+ * // assign it to cnv.
1418
+ * let cnv = createCanvas(100, 100);
1419
+ *
1420
+ * background(200);
1421
+ *
1422
+ * // Call randomColor() when the
1423
+ * // mouse wheel moves.
1424
+ * cnv.mouseWheel(randomColor);
1425
+ *
1426
+ * describe('A gray square changes color when the user scrolls the mouse wheel over the canvas.');
1427
+ * }
1428
+ *
1429
+ * // Paint the background either
1430
+ * // red, yellow, blue, or green.
1431
+ * function randomColor() {
1432
+ * let c = random(['red', 'yellow', 'blue', 'green']);
1433
+ * background(c);
1434
+ * }
1435
+ * </code>
1436
+ * </div>
1437
+ *
1438
+ * <div>
1439
+ * <code>
1440
+ * function setup() {
1441
+ * // Create a canvas element and
1442
+ * // assign it to cnv.
1443
+ * let cnv = createCanvas(100, 100);
1444
+ *
1445
+ * background(200);
1446
+ *
1447
+ * // Call changeBackground() when the
1448
+ * // mouse wheel moves.
1449
+ * cnv.mouseWheel(changeBackground);
1450
+ *
1451
+ * describe('A gray square. When the mouse wheel scrolls over the square, it changes color and displays shapes.');
1452
+ * }
1453
+ *
1454
+ * function changeBackground(event) {
1455
+ * // Change the background color
1456
+ * // based on deltaY.
1457
+ * if (event.deltaY > 0) {
1458
+ * background('deeppink');
1459
+ * } else if (event.deltaY < 0) {
1460
+ * background('cornflowerblue');
1461
+ * } else {
1462
+ * background(200);
1463
+ * }
1464
+ *
1465
+ * // Draw a shape based on deltaX.
1466
+ * if (event.deltaX > 0) {
1467
+ * circle(50, 50, 20);
1468
+ * } else if (event.deltaX < 0) {
1469
+ * square(40, 40, 20);
1470
+ * }
1471
+ * }
1472
+ * </code>
1473
+ * </div>
1474
+ */
1475
+ function mouseWheel(fxn: Function | boolean): void;
1476
+
1477
+ /**
1478
+ * Calls a function when the mouse is released over the element.Calling `myElement.mouseReleased(false)` disables the function.Note: Some mobile browsers may also trigger this event when the element
1479
+ * receives a quick tap.
1480
+ *
1481
+ * @param function to call when the mouse is
1482
+ * pressed over the element.
1483
+ * `false` disables the function.
1484
+ * @example <div>
1485
+ * <code>
1486
+ * function setup() {
1487
+ * // Create a canvas element and
1488
+ * // assign it to cnv.
1489
+ * let cnv = createCanvas(100, 100);
1490
+ *
1491
+ * background(200);
1492
+ *
1493
+ * // Call randomColor() when a
1494
+ * // mouse press ends.
1495
+ * cnv.mouseReleased(randomColor);
1496
+ *
1497
+ * describe('A gray square changes color when the user releases a mouse press.');
1498
+ * }
1499
+ *
1500
+ * // Paint the background either
1501
+ * // red, yellow, blue, or green.
1502
+ * function randomColor() {
1503
+ * let c = random(['red', 'yellow', 'blue', 'green']);
1504
+ * background(c);
1505
+ * }
1506
+ * </code>
1507
+ * </div>
1508
+ */
1509
+ function mouseReleased(fxn: Function | boolean): void;
1510
+
1511
+ /**
1512
+ * Calls a function when the mouse is pressed and released over the element.Calling `myElement.mouseReleased(false)` disables the function.Note: Some mobile browsers may also trigger this event when the element
1513
+ * receives a quick tap.
1514
+ *
1515
+ * @param function to call when the mouse is
1516
+ * pressed and released over the element.
1517
+ * `false` disables the function.
1518
+ * @example <div>
1519
+ * <code>
1520
+ * function setup() {
1521
+ * // Create a canvas element and
1522
+ * // assign it to cnv.
1523
+ * let cnv = createCanvas(100, 100);
1524
+ *
1525
+ * background(200);
1526
+ *
1527
+ * // Call randomColor() when a
1528
+ * // mouse press ends.
1529
+ * cnv.mouseClicked(randomColor);
1530
+ *
1531
+ * describe('A gray square changes color when the user releases a mouse press.');
1532
+ * }
1533
+ *
1534
+ * // Paint the background either
1535
+ * // red, yellow, blue, or green.
1536
+ * function randomColor() {
1537
+ * let c = random(['red', 'yellow', 'blue', 'green']);
1538
+ * background(c);
1539
+ * }
1540
+ * </code>
1541
+ * </div>
1542
+ */
1543
+ function mouseClicked(fxn: Function | boolean): void;
1544
+
1545
+ /**
1546
+ * Calls a function when the mouse moves over the element.Calling `myElement.mouseMoved(false)` disables the function.
1547
+ *
1548
+ * @param function to call when the mouse
1549
+ * moves over the element.
1550
+ * `false` disables the function.
1551
+ * @example <div>
1552
+ * <code>
1553
+ * function setup() {
1554
+ * // Create a canvas element and
1555
+ * // assign it to cnv.
1556
+ * let cnv = createCanvas(100, 100);
1557
+ *
1558
+ * background(200);
1559
+ *
1560
+ * // Call randomColor() when the
1561
+ * // mouse moves.
1562
+ * cnv.mouseMoved(randomColor);
1563
+ *
1564
+ * describe('A gray square changes color when the mouse moves over the canvas.');
1565
+ * }
1566
+ *
1567
+ * // Paint the background either
1568
+ * // red, yellow, blue, or green.
1569
+ * function randomColor() {
1570
+ * let c = random(['red', 'yellow', 'blue', 'green']);
1571
+ * background(c);
1572
+ * }
1573
+ * </code>
1574
+ * </div>
1575
+ */
1576
+ function mouseMoved(fxn: Function | boolean): void;
1577
+
1578
+ /**
1579
+ * Calls a function when the mouse moves onto the element.Calling `myElement.mouseOver(false)` disables the function.
1580
+ *
1581
+ * @param function to call when the mouse
1582
+ * moves onto the element.
1583
+ * `false` disables the function.
1584
+ * @example <div>
1585
+ * <code>
1586
+ * function setup() {
1587
+ * // Create a canvas element and
1588
+ * // assign it to cnv.
1589
+ * let cnv = createCanvas(100, 100);
1590
+ *
1591
+ * background(200);
1592
+ *
1593
+ * // Call randomColor() when the
1594
+ * // mouse moves onto the canvas.
1595
+ * cnv.mouseOver(randomColor);
1596
+ *
1597
+ * describe('A gray square changes color when the mouse moves onto the canvas.');
1598
+ * }
1599
+ *
1600
+ * // Paint the background either
1601
+ * // red, yellow, blue, or green.
1602
+ * function randomColor() {
1603
+ * let c = random(['red', 'yellow', 'blue', 'green']);
1604
+ * background(c);
1605
+ * }
1606
+ * </code>
1607
+ * </div>
1608
+ */
1609
+ function mouseOver(fxn: Function | boolean): void;
1610
+
1611
+ /**
1612
+ * Calls a function when the mouse moves off the element.Calling `myElement.mouseOut(false)` disables the function.
1613
+ *
1614
+ * @param function to call when the mouse
1615
+ * moves off the element.
1616
+ * `false` disables the function.
1617
+ * @example <div>
1618
+ * <code>
1619
+ * function setup() {
1620
+ * // Create a canvas element and
1621
+ * // assign it to cnv.
1622
+ * let cnv = createCanvas(100, 100);
1623
+ *
1624
+ * background(200);
1625
+ *
1626
+ * // Call randomColor() when the
1627
+ * // mouse moves off the canvas.
1628
+ * cnv.mouseOut(randomColor);
1629
+ *
1630
+ * describe('A gray square changes color when the mouse moves off the canvas.');
1631
+ * }
1632
+ *
1633
+ * // Paint the background either
1634
+ * // red, yellow, blue, or green.
1635
+ * function randomColor() {
1636
+ * let c = random(['red', 'yellow', 'blue', 'green']);
1637
+ * background(c);
1638
+ * }
1639
+ * </code>
1640
+ * </div>
1641
+ */
1642
+ function mouseOut(fxn: Function | boolean): void;
1643
+
1644
+ /**
1645
+ * Calls a function when a file is dragged over the element.Calling `myElement.dragOver(false)` disables the function.
1646
+ *
1647
+ * @param function to call when the file is
1648
+ * dragged over the element.
1649
+ * `false` disables the function.
1650
+ * @example <div>
1651
+ * <code>
1652
+ * // Drag a file over the canvas to test.
1653
+ *
1654
+ * function setup() {
1655
+ * // Create a canvas element and
1656
+ * // assign it to cnv.
1657
+ * let cnv = createCanvas(100, 100);
1658
+ *
1659
+ * background(200);
1660
+ *
1661
+ * // Call helloFile() when a
1662
+ * // file is dragged over
1663
+ * // the canvas.
1664
+ * cnv.dragOver(helloFile);
1665
+ *
1666
+ * describe('A gray square. The text "hello, file" appears when a file is dragged over the square.');
1667
+ * }
1668
+ *
1669
+ * function helloFile() {
1670
+ * text('hello, file', 50, 50);
1671
+ * }
1672
+ * </code>
1673
+ * </div>
1674
+ */
1675
+ function dragOver(fxn: Function | boolean): void;
1676
+
1677
+ /**
1678
+ * Calls a function when a file is dragged off the element.Calling `myElement.dragLeave(false)` disables the function.
1679
+ *
1680
+ * @param function to call when the file is
1681
+ * dragged off the element.
1682
+ * `false` disables the function.
1683
+ * @example <div>
1684
+ * <code>
1685
+ * // Drag a file over, then off
1686
+ * // the canvas to test.
1687
+ *
1688
+ * function setup() {
1689
+ * // Create a canvas element and
1690
+ * // assign it to cnv.
1691
+ * let cnv = createCanvas(100, 100);
1692
+ *
1693
+ * background(200);
1694
+ *
1695
+ * // Call byeFile() when a
1696
+ * // file is dragged over,
1697
+ * // then off the canvas.
1698
+ * cnv.dragLeave(byeFile);
1699
+ *
1700
+ * describe('A gray square. The text "bye, file" appears when a file is dragged over, then off the square.');
1701
+ * }
1702
+ *
1703
+ * function byeFile() {
1704
+ * text('bye, file', 50, 50);
1705
+ * }
1706
+ * </code>
1707
+ * </div>
1708
+ */
1709
+ function dragLeave(fxn: Function | boolean): void;
1710
+
1711
+ /**
1712
+ * Calls a function when the element changes.Calling `myElement.changed(false)` disables the function.
1713
+ *
1714
+ * @param function to call when the element changes.
1715
+ * `false` disables the function.
1716
+ * @example <div>
1717
+ * <code>
1718
+ * let dropdown;
1719
+ *
1720
+ * function setup() {
1721
+ * createCanvas(100, 100);
1722
+ *
1723
+ * background(200);
1724
+ *
1725
+ * // Create a dropdown menu and add a few color options.
1726
+ * dropdown = createSelect();
1727
+ * dropdown.position(0, 0);
1728
+ * dropdown.option('red');
1729
+ * dropdown.option('green');
1730
+ * dropdown.option('blue');
1731
+ *
1732
+ * // Call paintBackground() when the color option changes.
1733
+ * dropdown.changed(paintBackground);
1734
+ *
1735
+ * describe('A gray square with a dropdown menu at the top. The square changes color when an option is selected.');
1736
+ * }
1737
+ *
1738
+ * // Paint the background with the selected color.
1739
+ * function paintBackground() {
1740
+ * let c = dropdown.value();
1741
+ * background(c);
1742
+ * }
1743
+ * </code>
1744
+ * </div>
1745
+ *
1746
+ * <div>
1747
+ * <code>
1748
+ * let checkbox;
1749
+ *
1750
+ * function setup() {
1751
+ * createCanvas(100, 100);
1752
+ *
1753
+ * background(200);
1754
+ *
1755
+ * // Create a checkbox and place it beneath the canvas.
1756
+ * checkbox = createCheckbox(' circle');
1757
+ * checkbox.position(0, 100);
1758
+ *
1759
+ * // Call repaint() when the checkbox changes.
1760
+ * checkbox.changed(repaint);
1761
+ *
1762
+ * describe('A gray square with a checkbox underneath it that says "circle". A white circle appears when the box is checked and disappears otherwise.');
1763
+ * }
1764
+ *
1765
+ * // Paint the background gray and determine whether to draw a circle.
1766
+ * function repaint() {
1767
+ * background(200);
1768
+ * if (checkbox.checked() === true) {
1769
+ * circle(50, 50, 30);
1770
+ * }
1771
+ * }
1772
+ * </code>
1773
+ * </div>
1774
+ */
1775
+ function changed(fxn: Function | boolean): void;
1776
+
1777
+ /**
1778
+ * Calls a function when the element receives input.`myElement.input()` is often used to with text inputs and sliders. Calling
1779
+ * `myElement.input(false)` disables the function.
1780
+ *
1781
+ * @param function to call when input is detected within
1782
+ * the element.
1783
+ * `false` disables the function.
1784
+ * @example <div>
1785
+ * <code>
1786
+ * let slider;
1787
+ *
1788
+ * function setup() {
1789
+ * createCanvas(100, 100);
1790
+ *
1791
+ * background(200);
1792
+ *
1793
+ * // Create a slider and place it beneath the canvas.
1794
+ * slider = createSlider(0, 255, 200);
1795
+ * slider.position(0, 100);
1796
+ *
1797
+ * // Call repaint() when the slider changes.
1798
+ * slider.input(repaint);
1799
+ *
1800
+ * describe('A gray square with a range slider underneath it. The background changes shades of gray when the slider is moved.');
1801
+ * }
1802
+ *
1803
+ * // Paint the background using slider's value.
1804
+ * function repaint() {
1805
+ * let g = slider.value();
1806
+ * background(g);
1807
+ * }
1808
+ * </code>
1809
+ * </div>
1810
+ *
1811
+ * <div>
1812
+ * <code>
1813
+ * let input;
1814
+ *
1815
+ * function setup() {
1816
+ * createCanvas(100, 100);
1817
+ *
1818
+ * background(200);
1819
+ *
1820
+ * // Create an input and place it beneath the canvas.
1821
+ * input = createInput('');
1822
+ * input.position(0, 100);
1823
+ *
1824
+ * // Call repaint() when input is detected.
1825
+ * input.input(repaint);
1826
+ *
1827
+ * describe('A gray square with a text input bar beneath it. Any text written in the input appears in the middle of the square.');
1828
+ * }
1829
+ *
1830
+ * // Paint the background gray and display the input's value.
1831
+ * function repaint() {
1832
+ * background(200);
1833
+ * let msg = input.value();
1834
+ * text(msg, 5, 50);
1835
+ * }
1836
+ * </code>
1837
+ * </div>
1838
+ */
1839
+ function input(fxn: Function | boolean): void;
1840
+
1841
+ /**
1842
+ * Calls a function when the user drops a file on the element.The first parameter, `callback`, is a function to call once the file loads.
1843
+ * The callback function should have one parameter, `file`, that's a
1844
+ * p5.File object. If the user drops multiple files on
1845
+ * the element, `callback`, is called once for each file.The second parameter, `fxn`, is a function to call when the browser detects
1846
+ * one or more dropped files. The callback function should have one
1847
+ * parameter, `event`, that's a
1848
+ * DragEvent.
1849
+ *
1850
+ * @param called when a file loads. Called once for each file dropped.
1851
+ * @param called once when any files are dropped.
1852
+ * @example <div>
1853
+ * <code>
1854
+ * // Drop an image on the canvas to view
1855
+ * // this example.
1856
+ * let img;
1857
+ *
1858
+ * function setup() {
1859
+ * let c = createCanvas(100, 100);
1860
+ *
1861
+ * background(200);
1862
+ *
1863
+ * // Call handleFile() when a file that's dropped on the canvas has loaded.
1864
+ * c.drop(handleFile);
1865
+ *
1866
+ * describe('A gray square. When the user drops an image on the square, it is displayed.');
1867
+ * }
1868
+ *
1869
+ * // Remove the existing image and display the new one.
1870
+ * function handleFile(file) {
1871
+ * // Remove the current image, if any.
1872
+ * if (img) {
1873
+ * img.remove();
1874
+ * }
1875
+ *
1876
+ * // Create an <img> element with the
1877
+ * // dropped file.
1878
+ * img = createImg(file.data, '');
1879
+ * img.hide();
1880
+ *
1881
+ * // Draw the image.
1882
+ * image(img, 0, 0, width, height);
1883
+ * }
1884
+ * </code>
1885
+ * </div>
1886
+ *
1887
+ * <div>
1888
+ * <code>
1889
+ * // Drop an image on the canvas to view
1890
+ * // this example.
1891
+ * let img;
1892
+ * let msg;
1893
+ *
1894
+ * function setup() {
1895
+ * let c = createCanvas(100, 100);
1896
+ *
1897
+ * background(200);
1898
+ *
1899
+ * // Call functions when the user drops a file on the canvas
1900
+ * // and when the file loads.
1901
+ * c.drop(handleFile, handleDrop);
1902
+ *
1903
+ * describe('A gray square. When the user drops an image on the square, it is displayed. The id attribute of canvas element is also displayed.');
1904
+ * }
1905
+ *
1906
+ * // Display the image when it loads.
1907
+ * function handleFile(file) {
1908
+ * // Remove the current image, if any.
1909
+ * if (img) {
1910
+ * img.remove();
1911
+ * }
1912
+ *
1913
+ * // Create an img element with the dropped file.
1914
+ * img = createImg(file.data, '');
1915
+ * img.hide();
1916
+ *
1917
+ * // Draw the image.
1918
+ * image(img, 0, 0, width, height);
1919
+ * }
1920
+ *
1921
+ * // Display the file's name when it loads.
1922
+ * function handleDrop(event) {
1923
+ * // Remove current paragraph, if any.
1924
+ * if (msg) {
1925
+ * msg.remove();
1926
+ * }
1927
+ *
1928
+ * // Use event to get the drop target's id.
1929
+ * let id = event.target.id;
1930
+ *
1931
+ * // Write the canvas' id beneath it.
1932
+ * msg = createP(id);
1933
+ * msg.position(0, 100);
1934
+ *
1935
+ * // Set the font color randomly for each drop.
1936
+ * let c = random(['red', 'green', 'blue']);
1937
+ * msg.style('color', c);
1938
+ * msg.style('font-size', '12px');
1939
+ * }
1940
+ * </code>
1941
+ * </div>
1942
+ */
1943
+ function drop(callback: Function, fxn?: Function): void;
1944
+
1945
+ /**
1946
+ * Makes the element draggable.The parameter, `elmnt`, is optional. If another
1947
+ * p5.Element object is passed, as in
1948
+ * `myElement.draggable(otherElement)`, the other element will become draggable.
1949
+ *
1950
+ * @param another <a href="#/p5.Element">p5.Element</a>.
1951
+ * @example <div>
1952
+ * <code>
1953
+ * let stickyNote;
1954
+ * let textInput;
1955
+ *
1956
+ * function setup() {
1957
+ * createCanvas(100, 100);
1958
+ *
1959
+ * background(200);
1960
+ *
1961
+ * // Create a div element and style it.
1962
+ * stickyNote = createDiv('Note');
1963
+ * stickyNote.position(5, 5);
1964
+ * stickyNote.size(80, 20);
1965
+ * stickyNote.style('font-size', '16px');
1966
+ * stickyNote.style('font-family', 'Comic Sans MS');
1967
+ * stickyNote.style('background', 'orchid');
1968
+ * stickyNote.style('padding', '5px');
1969
+ *
1970
+ * // Make the note draggable.
1971
+ * stickyNote.draggable();
1972
+ *
1973
+ * // Create a panel div and style it.
1974
+ * let panel = createDiv('');
1975
+ * panel.position(5, 40);
1976
+ * panel.size(80, 50);
1977
+ * panel.style('background', 'orchid');
1978
+ * panel.style('font-size', '16px');
1979
+ * panel.style('padding', '5px');
1980
+ * panel.style('text-align', 'center');
1981
+ *
1982
+ * // Make the panel draggable.
1983
+ * panel.draggable();
1984
+ *
1985
+ * // Create a text input and style it.
1986
+ * textInput = createInput('Note');
1987
+ * textInput.size(70);
1988
+ *
1989
+ * // Add the input to the panel.
1990
+ * textInput.parent(panel);
1991
+ *
1992
+ * // Call handleInput() when text is input.
1993
+ * textInput.input(handleInput);
1994
+ *
1995
+ * describe(
1996
+ * 'A gray square with two purple rectangles that move when dragged. The top rectangle displays the text that is typed into the bottom rectangle.'
1997
+ * );
1998
+ * }
1999
+ *
2000
+ * // Update stickyNote's HTML when text is input.
2001
+ * function handleInput() {
2002
+ * stickyNote.html(textInput.value());
2003
+ * }
2004
+ * </code>
2005
+ * </div>
2006
+ */
2007
+ function draggable(elmMove: any, elmnt?: p5.Element): void;
2008
+
2009
+ }
2010
+
2011
+ export default function p5_Element(p5: any, fn: any): void;