p5 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/dist/accessibility/color_namer.js +5 -5
  2. package/dist/accessibility/describe.js +10 -0
  3. package/dist/accessibility/index.js +5 -5
  4. package/dist/accessibility/outputs.js +21 -0
  5. package/dist/app.js +5 -5
  6. package/dist/color/color_conversion.js +5 -5
  7. package/dist/color/creating_reading.js +1 -1
  8. package/dist/color/index.js +2 -2
  9. package/dist/color/p5.Color.js +1 -1
  10. package/dist/color/setting.js +2 -2
  11. package/dist/{constants-C-g_eAdC.js → constants-BRcElHU3.js} +19 -3
  12. package/dist/core/constants.js +1 -1
  13. package/dist/core/environment.js +6 -5
  14. package/dist/core/friendly_errors/fes_core.js +1 -1
  15. package/dist/core/friendly_errors/index.js +1 -1
  16. package/dist/core/friendly_errors/param_validator.js +46 -93
  17. package/dist/core/friendly_errors/sketch_reader.js +5 -5
  18. package/dist/core/friendly_errors/sketch_verifier.js +1 -1
  19. package/dist/core/friendly_errors/validate_params.js +5 -5
  20. package/dist/core/helpers.js +1 -1
  21. package/dist/core/init.js +5 -5
  22. package/dist/core/legacy.js +5 -5
  23. package/dist/core/main.js +5 -5
  24. package/dist/core/p5.Graphics.js +4 -4
  25. package/dist/core/p5.Renderer.js +3 -3
  26. package/dist/core/p5.Renderer2D.js +5 -5
  27. package/dist/core/rendering.js +4 -4
  28. package/dist/{creating_reading-D4AAKRbx.js → creating_reading-Cr8L2Jnm.js} +2 -2
  29. package/dist/dom/dom.js +10 -10
  30. package/dist/dom/index.js +2 -2
  31. package/dist/dom/p5.Element.js +2 -2
  32. package/dist/dom/p5.MediaElement.js +2 -2
  33. package/dist/events/acceleration.js +24 -24
  34. package/dist/events/keyboard.js +11 -6
  35. package/dist/image/const.js +1 -1
  36. package/dist/image/filterRenderer2D.js +4 -4
  37. package/dist/image/image.js +4 -4
  38. package/dist/image/index.js +4 -4
  39. package/dist/image/loading_displaying.js +4 -4
  40. package/dist/image/p5.Image.js +3 -3
  41. package/dist/image/pixels.js +1 -0
  42. package/dist/io/files.js +4 -4
  43. package/dist/io/index.js +4 -4
  44. package/dist/io/p5.TableRow.js +2 -2
  45. package/dist/{main-s72KWcUy.js → main-BKN5yFoS.js} +12 -9
  46. package/dist/math/Matrices/Matrix.js +1 -1
  47. package/dist/math/Matrices/MatrixNumjs.js +1 -1
  48. package/dist/math/index.js +1 -1
  49. package/dist/math/math.js +1 -1
  50. package/dist/math/p5.Matrix.js +1 -1
  51. package/dist/math/p5.Vector.js +1 -1
  52. package/dist/math/trigonometry.js +1 -1
  53. package/dist/{p5.Renderer-CwAYZOC2.js → p5.Renderer-R23xoC7s.js} +5 -5
  54. package/dist/{rendering--aAe5aq3.js → rendering-CvUVN-Vb.js} +101 -66
  55. package/dist/shape/2d_primitives.js +1 -1
  56. package/dist/shape/attributes.js +1 -1
  57. package/dist/shape/custom_shapes.js +2 -2
  58. package/dist/shape/index.js +2 -2
  59. package/dist/type/index.js +3 -3
  60. package/dist/type/p5.Font.js +3 -5
  61. package/dist/type/textCore.js +4 -4
  62. package/dist/webgl/3d_primitives.js +4 -4
  63. package/dist/webgl/GeometryBuilder.js +1 -1
  64. package/dist/webgl/ShapeBuilder.js +1 -1
  65. package/dist/webgl/index.js +4 -4
  66. package/dist/webgl/interaction.js +1 -1
  67. package/dist/webgl/light.js +4 -4
  68. package/dist/webgl/loading.js +5 -4
  69. package/dist/webgl/material.js +4 -4
  70. package/dist/webgl/p5.Camera.js +4 -4
  71. package/dist/webgl/p5.Framebuffer.js +4 -4
  72. package/dist/webgl/p5.Geometry.js +1 -1
  73. package/dist/webgl/p5.Quat.js +1 -1
  74. package/dist/webgl/p5.RendererGL.js +4 -4
  75. package/dist/webgl/p5.Shader.js +4 -4
  76. package/dist/webgl/p5.Texture.js +4 -4
  77. package/dist/webgl/text.js +32 -34
  78. package/lib/p5.esm.js +289 -247
  79. package/lib/p5.js +289 -247
  80. package/lib/p5.min.js +1 -1
  81. package/package.json +1 -2
  82. package/types/accessibility/color_namer.d.ts +8 -0
  83. package/types/accessibility/describe.d.ts +184 -0
  84. package/types/accessibility/gridOutput.d.ts +8 -0
  85. package/types/accessibility/outputs.d.ts +235 -0
  86. package/types/accessibility/textOutput.d.ts +8 -0
  87. package/types/color/color_conversion.d.ts +47 -0
  88. package/types/color/creating_reading.d.ts +1348 -0
  89. package/types/color/p5.Color.d.ts +1070 -0
  90. package/types/color/setting.d.ts +2085 -0
  91. package/types/core/constants.d.ts +341 -0
  92. package/types/core/environment.d.ts +668 -0
  93. package/types/core/friendly_errors/fes_core.d.ts +8 -0
  94. package/types/core/friendly_errors/file_errors.d.ts +8 -0
  95. package/types/core/friendly_errors/param_validator.d.ts +30 -0
  96. package/types/core/friendly_errors/sketch_reader.d.ts +8 -0
  97. package/types/core/friendly_errors/stacktrace.d.ts +11 -0
  98. package/types/core/friendly_errors/validate_params.d.ts +8 -0
  99. package/types/core/helpers.d.ts +8 -0
  100. package/types/core/legacy.d.ts +8 -0
  101. package/types/core/main.d.ts +5999 -0
  102. package/types/core/p5.Graphics.d.ts +484 -0
  103. package/types/core/p5.Renderer.d.ts +14 -0
  104. package/types/core/reference.d.ts +8 -0
  105. package/types/core/rendering.d.ts +481 -0
  106. package/types/core/structure.d.ts +492 -0
  107. package/types/core/transform.d.ts +1638 -0
  108. package/types/data/local_storage.d.ts +323 -0
  109. package/types/dom/dom.d.ts +1295 -0
  110. package/types/dom/p5.Element.d.ts +2011 -0
  111. package/types/dom/p5.File.d.ts +13 -0
  112. package/types/dom/p5.MediaElement.d.ts +1249 -0
  113. package/types/events/acceleration.d.ts +193 -0
  114. package/types/events/keyboard.d.ts +501 -0
  115. package/types/events/pointer.d.ts +782 -0
  116. package/types/global.d.ts +5544 -0
  117. package/types/image/filterRenderer2D.d.ts +54 -0
  118. package/types/image/image.d.ts +326 -0
  119. package/types/image/loading_displaying.d.ts +580 -0
  120. package/types/image/p5.Image.d.ts +5882 -0
  121. package/types/image/pixels.d.ts +832 -0
  122. package/types/io/files.d.ts +1447 -0
  123. package/types/io/p5.Table.d.ts +1247 -0
  124. package/types/io/p5.TableRow.d.ts +343 -0
  125. package/types/io/p5.XML.d.ts +1188 -0
  126. package/types/math/Matrices/Matrix.d.ts +1029 -0
  127. package/types/math/Matrices/MatrixNumjs.d.ts +8 -0
  128. package/types/math/calculation.d.ts +923 -0
  129. package/types/math/math.d.ts +90 -0
  130. package/types/math/noise.d.ts +311 -0
  131. package/types/math/p5.Matrix.d.ts +8 -0
  132. package/types/math/p5.Vector.d.ts +3416 -0
  133. package/types/math/random.d.ts +267 -0
  134. package/types/math/trigonometry.d.ts +663 -0
  135. package/types/p5.d.ts +6666 -0
  136. package/types/shape/2d_primitives.d.ts +1033 -0
  137. package/types/shape/attributes.d.ts +466 -0
  138. package/types/shape/curves.d.ts +740 -0
  139. package/types/shape/custom_shapes.d.ts +888 -0
  140. package/types/shape/vertex.d.ts +1141 -0
  141. package/types/type/p5.Font.d.ts +575 -0
  142. package/types/type/textCore.d.ts +1198 -0
  143. package/types/utilities/conversion.d.ts +894 -0
  144. package/types/utilities/time_date.d.ts +295 -0
  145. package/types/utilities/utility_functions.d.ts +587 -0
  146. package/types/webgl/3d_primitives.d.ts +1432 -0
  147. package/types/webgl/ShaderGenerator.d.ts +8 -0
  148. package/types/webgl/interaction.d.ts +371 -0
  149. package/types/webgl/light.d.ts +1184 -0
  150. package/types/webgl/loading.d.ts +482 -0
  151. package/types/webgl/material.d.ts +2656 -0
  152. package/types/webgl/p5.Camera.d.ts +3023 -0
  153. package/types/webgl/p5.DataArray.d.ts +61 -0
  154. package/types/webgl/p5.Framebuffer.d.ts +760 -0
  155. package/types/webgl/p5.Geometry.d.ts +1191 -0
  156. package/types/webgl/p5.Quat.d.ts +45 -0
  157. package/types/webgl/p5.RendererGL.d.ts +234 -0
  158. package/types/webgl/p5.Shader.d.ts +660 -0
  159. package/types/webgl/p5.Texture.d.ts +61 -0
  160. package/types/webgl/text.d.ts +74 -0
@@ -0,0 +1,1184 @@
1
+ // This file is auto-generated from JSDoc documentation
2
+
3
+ import p5 from 'p5';
4
+ import { Color } from '../color/p5.Color';
5
+ import { Vector } from '../math/p5.Vector';
6
+
7
+ declare module 'p5' {
8
+ /**
9
+ * Creates a light that shines from all directions.Ambient light does not come from one direction. Instead, 3D shapes are
10
+ * lit evenly from all sides. Ambient lights are almost always used in
11
+ * combination with other types of lights.There are three ways to call `ambientLight()` with optional parameters to
12
+ * set the light’s color.The first way to call `ambientLight()` has two parameters, `gray` and
13
+ * `alpha`. `alpha` is optional. Grayscale and alpha values between 0 and 255
14
+ * can be passed to set the ambient light’s color, as in `ambientLight(50)` or
15
+ * `ambientLight(50, 30)`.The second way to call `ambientLight()` has one parameter, color. A
16
+ * p5.Color object, an array of color values, or a
17
+ * CSS color string, as in `ambientLight('magenta')`, can be passed to set the
18
+ * ambient light’s color.The third way to call `ambientLight()` has four parameters, `v1`, `v2`,
19
+ * `v3`, and `alpha`. `alpha` is optional. RGBA, HSBA, or HSLA values can be
20
+ * passed to set the ambient light’s colors, as in `ambientLight(255, 0, 0)`
21
+ * or `ambientLight(255, 0, 0, 30)`. Color values will be interpreted using
22
+ * the current colorMode().
23
+ *
24
+ * @param red or hue value in the current
25
+ * <a href="#/p5/colorMode">colorMode()</a>.
26
+ * @param green or saturation value in the current
27
+ * <a href="#/p5/colorMode">colorMode()</a>.
28
+ * @param blue, brightness, or lightness value in the current
29
+ * <a href="#/p5/colorMode">colorMode()</a>.
30
+ * @param alpha (transparency) value in the current
31
+ * <a href="#/p5/colorMode">colorMode()</a>.
32
+ * @example <div>
33
+ * <code>
34
+ * // Click and drag the mouse to view the scene from different angles.
35
+ * // Double-click the canvas to turn on the light.
36
+ *
37
+ * let isLit = false;
38
+ *
39
+ * function setup() {
40
+ * createCanvas(100, 100, WEBGL);
41
+ *
42
+ * describe('A sphere drawn against a gray background. The sphere appears to change color when the user double-clicks.');
43
+ * }
44
+ *
45
+ * function draw() {
46
+ * background(200);
47
+ *
48
+ * // Enable orbiting with the mouse.
49
+ * orbitControl();
50
+ *
51
+ * // Control the light.
52
+ * if (isLit === true) {
53
+ * // Use a grayscale value of 80.
54
+ * ambientLight(80);
55
+ * }
56
+ *
57
+ * // Draw the sphere.
58
+ * sphere(30);
59
+ * }
60
+ *
61
+ * // Turn on the ambient light when the user double-clicks.
62
+ * function doubleClicked() {
63
+ * isLit = true;
64
+ * }
65
+ * </code>
66
+ * </div>
67
+ *
68
+ * <div>
69
+ * <code>
70
+ * // Click and drag the mouse to view the scene from different angles.
71
+ *
72
+ * function setup() {
73
+ * createCanvas(100, 100, WEBGL);
74
+ *
75
+ * describe('A faded magenta sphere drawn against a gray background.');
76
+ * }
77
+ *
78
+ * function draw() {
79
+ * background(200);
80
+ *
81
+ * // Enable orbiting with the mouse.
82
+ * orbitControl();
83
+ *
84
+ * // Turn on the lights.
85
+ * // Use a p5.Color object.
86
+ * let c = color('orchid');
87
+ * ambientLight(c);
88
+ *
89
+ * // Draw the sphere.
90
+ * sphere();
91
+ * }
92
+ * </code>
93
+ * </div>
94
+ *
95
+ * <div>
96
+ * <code>
97
+ * // Click and drag the mouse to view the scene from different angles.
98
+ *
99
+ * function setup() {
100
+ * createCanvas(100, 100, WEBGL);
101
+ *
102
+ * describe('A faded magenta sphere drawn against a gray background.');
103
+ * }
104
+ *
105
+ * function draw() {
106
+ * background(200);
107
+ *
108
+ * // Enable orbiting with the mouse.
109
+ * orbitControl();
110
+ *
111
+ * // Turn on the lights.
112
+ * // Use a CSS color string.
113
+ * ambientLight('#DA70D6');
114
+ *
115
+ * // Draw the sphere.
116
+ * sphere(30);
117
+ * }
118
+ * </code>
119
+ * </div>
120
+ *
121
+ * <div>
122
+ * <code>
123
+ * // Click and drag the mouse to view the scene from different angles.
124
+ *
125
+ * function setup() {
126
+ * createCanvas(100, 100, WEBGL);
127
+ *
128
+ * describe('A faded magenta sphere drawn against a gray background.');
129
+ * }
130
+ *
131
+ * function draw() {
132
+ * background(200);
133
+ *
134
+ * // Enable orbiting with the mouse.
135
+ * orbitControl();
136
+ *
137
+ * // Turn on the lights.
138
+ * // Use RGB values
139
+ * ambientLight(218, 112, 214);
140
+ *
141
+ * // Draw the sphere.
142
+ * sphere(30);
143
+ * }
144
+ * </code>
145
+ * </div>
146
+ */
147
+ function ambientLight(v1: number, v2: number, v3: number, alpha?: number): void;
148
+
149
+ /**
150
+ * @param grayscale value between 0 and 255.
151
+ */
152
+ function ambientLight(gray: number, alpha?: number): void;
153
+
154
+ /**
155
+ * @param color as a CSS string.
156
+ */
157
+ function ambientLight(value: string): void;
158
+
159
+ /**
160
+ * @param color as an array of RGBA, HSBA, or HSLA
161
+ * values.
162
+ */
163
+ function ambientLight(values: number[]): void;
164
+
165
+ /**
166
+ * @param color as a <a href="#/p5.Color">p5.Color</a> object.
167
+ */
168
+ function ambientLight(color: p5.Color): void;
169
+
170
+ /**
171
+ * Sets the specular color for lights.`specularColor()` affects lights that bounce off a surface in a preferred
172
+ * direction. These lights include
173
+ * directionalLight(),
174
+ * pointLight(), and
175
+ * spotLight(). The function helps to create
176
+ * highlights on p5.Geometry objects that are
177
+ * styled with specularMaterial(). If a
178
+ * geometry does not use
179
+ * specularMaterial(), then
180
+ * `specularColor()` will have no effect.Note: `specularColor()` doesn’t affect lights that bounce in all
181
+ * directions, including ambientLight() and
182
+ * imageLight().There are three ways to call `specularColor()` with optional parameters to
183
+ * set the specular highlight color.The first way to call `specularColor()` has two optional parameters, `gray`
184
+ * and `alpha`. Grayscale and alpha values between 0 and 255, as in
185
+ * `specularColor(50)` or `specularColor(50, 80)`, can be passed to set the
186
+ * specular highlight color.The second way to call `specularColor()` has one optional parameter,
187
+ * `color`. A p5.Color object, an array of color
188
+ * values, or a CSS color string can be passed to set the specular highlight
189
+ * color.The third way to call `specularColor()` has four optional parameters, `v1`,
190
+ * `v2`, `v3`, and `alpha`. RGBA, HSBA, or HSLA values, as in
191
+ * `specularColor(255, 0, 0, 80)`, can be passed to set the specular highlight
192
+ * color. Color values will be interpreted using the current
193
+ * colorMode().
194
+ *
195
+ * @param red or hue value in the current
196
+ * <a href="#/p5/colorMode">colorMode()</a>.
197
+ * @param green or saturation value in the current
198
+ * <a href="#/p5/colorMode">colorMode()</a>.
199
+ * @param blue, brightness, or lightness value in the current
200
+ * <a href="#/p5/colorMode">colorMode()</a>.
201
+ * @example <div>
202
+ * <code>
203
+ * // Click and drag the mouse to view the scene from different angles.
204
+ *
205
+ * function setup() {
206
+ * createCanvas(100, 100, WEBGL);
207
+ *
208
+ * describe('A white sphere drawn on a gray background.');
209
+ * }
210
+ *
211
+ * function draw() {
212
+ * background(200);
213
+ *
214
+ * // Enable orbiting with the mouse.
215
+ * orbitControl();
216
+ *
217
+ * // No specular color.
218
+ * // Draw the sphere.
219
+ * sphere(30);
220
+ * }
221
+ * </code>
222
+ * </div>
223
+ *
224
+ * <div>
225
+ * <code>
226
+ * // Click and drag the mouse to view the scene from different angles.
227
+ * // Double-click the canvas to add a point light.
228
+ *
229
+ * let isLit = false;
230
+ *
231
+ * function setup() {
232
+ * createCanvas(100, 100, WEBGL);
233
+ *
234
+ * describe('A sphere drawn on a gray background. A spotlight starts shining when the user double-clicks.');
235
+ * }
236
+ *
237
+ * function draw() {
238
+ * background(200);
239
+ *
240
+ * // Enable orbiting with the mouse.
241
+ * orbitControl();
242
+ *
243
+ * // Style the sphere.
244
+ * noStroke();
245
+ * specularColor(100);
246
+ * specularMaterial(255, 255, 255);
247
+ *
248
+ * // Control the light.
249
+ * if (isLit === true) {
250
+ * // Add a white point light from the top-right.
251
+ * pointLight(255, 255, 255, 30, -20, 40);
252
+ * }
253
+ *
254
+ * // Draw the sphere.
255
+ * sphere(30);
256
+ * }
257
+ *
258
+ * // Turn on the point light when the user double-clicks.
259
+ * function doubleClicked() {
260
+ * isLit = true;
261
+ * }
262
+ * </code>
263
+ * </div>
264
+ *
265
+ * <div>
266
+ * <code>
267
+ * // Click and drag the mouse to view the scene from different angles.
268
+ *
269
+ * function setup() {
270
+ * createCanvas(100, 100, WEBGL);
271
+ *
272
+ * describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.');
273
+ * }
274
+ *
275
+ * function draw() {
276
+ * background(200);
277
+ *
278
+ * // Enable orbiting with the mouse.
279
+ * orbitControl();
280
+ *
281
+ * // Add a specular highlight.
282
+ * // Use a p5.Color object.
283
+ * let c = color('dodgerblue');
284
+ * specularColor(c);
285
+ *
286
+ * // Add a white point light from the top-right.
287
+ * pointLight(255, 255, 255, 30, -20, 40);
288
+ *
289
+ * // Style the sphere.
290
+ * noStroke();
291
+ *
292
+ * // Add a white specular material.
293
+ * specularMaterial(255, 255, 255);
294
+ *
295
+ * // Draw the sphere.
296
+ * sphere(30);
297
+ * }
298
+ * </code>
299
+ * </div>
300
+ *
301
+ * <div>
302
+ * <code>
303
+ * // Click and drag the mouse to view the scene from different angles.
304
+ *
305
+ * function setup() {
306
+ * createCanvas(100, 100, WEBGL);
307
+ *
308
+ * describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.');
309
+ * }
310
+ *
311
+ * function draw() {
312
+ * background(200);
313
+ *
314
+ * // Enable orbiting with the mouse.
315
+ * orbitControl();
316
+ *
317
+ * // Add a specular highlight.
318
+ * // Use a CSS color string.
319
+ * specularColor('#1E90FF');
320
+ *
321
+ * // Add a white point light from the top-right.
322
+ * pointLight(255, 255, 255, 30, -20, 40);
323
+ *
324
+ * // Style the sphere.
325
+ * noStroke();
326
+ *
327
+ * // Add a white specular material.
328
+ * specularMaterial(255, 255, 255);
329
+ *
330
+ * // Draw the sphere.
331
+ * sphere(30);
332
+ * }
333
+ * </code>
334
+ * </div>
335
+ *
336
+ * <div>
337
+ * <code>
338
+ * // Click and drag the mouse to view the scene from different angles.
339
+ *
340
+ * function setup() {
341
+ * createCanvas(100, 100, WEBGL);
342
+ *
343
+ * describe('A black sphere drawn on a gray background. An area on the surface of the sphere is highlighted in blue.');
344
+ * }
345
+ *
346
+ * function draw() {
347
+ * background(200);
348
+ *
349
+ * // Enable orbiting with the mouse.
350
+ * orbitControl();
351
+ *
352
+ * // Add a specular highlight.
353
+ * // Use RGB values.
354
+ * specularColor(30, 144, 255);
355
+ *
356
+ * // Add a white point light from the top-right.
357
+ * pointLight(255, 255, 255, 30, -20, 40);
358
+ *
359
+ * // Style the sphere.
360
+ * noStroke();
361
+ *
362
+ * // Add a white specular material.
363
+ * specularMaterial(255, 255, 255);
364
+ *
365
+ * // Draw the sphere.
366
+ * sphere(30);
367
+ * }
368
+ * </code>
369
+ * </div>
370
+ */
371
+ function specularColor(v1: number, v2: number, v3: number): void;
372
+
373
+ /**
374
+ * @param grayscale value between 0 and 255.
375
+ */
376
+ function specularColor(gray: number): void;
377
+
378
+ /**
379
+ * @param color as a CSS string.
380
+ */
381
+ function specularColor(value: string): void;
382
+
383
+ /**
384
+ * @param color as an array of RGBA, HSBA, or HSLA
385
+ * values.
386
+ */
387
+ function specularColor(values: number[]): void;
388
+
389
+ /**
390
+ * @param color as a <a href="#/p5.Color">p5.Color</a> object.
391
+ */
392
+ function specularColor(color: p5.Color): void;
393
+
394
+ /**
395
+ * Creates a light that shines in one direction.Directional lights don’t shine from a specific point. They’re like a sun
396
+ * that shines from somewhere offscreen. The light’s direction is set using
397
+ * three `(x, y, z)` values between -1 and 1. For example, setting a light’s
398
+ * direction as `(1, 0, 0)` will light p5.Geometry
399
+ * objects from the left since the light faces directly to the right. A
400
+ * maximum of 5 directional lights can be active at once.There are four ways to call `directionalLight()` with parameters to set the
401
+ * light’s color and direction.The first way to call `directionalLight()` has six parameters. The first
402
+ * three parameters, `v1`, `v2`, and `v3`, set the light’s color using the
403
+ * current colorMode(). The last three
404
+ * parameters, `x`, `y`, and `z`, set the light’s direction. For example,
405
+ * `directionalLight(255, 0, 0, 1, 0, 0)` creates a red `(255, 0, 0)` light
406
+ * that shines to the right `(1, 0, 0)`.The second way to call `directionalLight()` has four parameters. The first
407
+ * three parameters, `v1`, `v2`, and `v3`, set the light’s color using the
408
+ * current colorMode(). The last parameter,
409
+ * `direction` sets the light’s direction using a
410
+ * p5.Vector object. For example,
411
+ * `directionalLight(255, 0, 0, lightDir)` creates a red `(255, 0, 0)` light
412
+ * that shines in the direction the `lightDir` vector points.The third way to call `directionalLight()` has four parameters. The first
413
+ * parameter, `color`, sets the light’s color using a
414
+ * p5.Color object or an array of color values. The
415
+ * last three parameters, `x`, `y`, and `z`, set the light’s direction. For
416
+ * example, `directionalLight(myColor, 1, 0, 0)` creates a light that shines
417
+ * to the right `(1, 0, 0)` with the color value of `myColor`.The fourth way to call `directionalLight()` has two parameters. The first
418
+ * parameter, `color`, sets the light’s color using a
419
+ * p5.Color object or an array of color values. The
420
+ * second parameter, `direction`, sets the light’s direction using a
421
+ * p5.Vector object. For example,
422
+ * `directionalLight(myColor, lightDir)` creates a light that shines in the
423
+ * direction the `lightDir` vector points with the color value of `myColor`.
424
+ *
425
+ * @param red or hue value in the current
426
+ * <a href="#/p5/colorMode">colorMode()</a>.
427
+ * @param green or saturation value in the current
428
+ * <a href="#/p5/colorMode">colorMode()</a>.
429
+ * @param blue, brightness, or lightness value in the current
430
+ * <a href="#/p5/colorMode">colorMode()</a>.
431
+ * @param x-component of the light's direction between -1 and 1.
432
+ * @param y-component of the light's direction between -1 and 1.
433
+ * @param z-component of the light's direction between -1 and 1.
434
+ * @example <div>
435
+ * <code>
436
+ * // Click and drag the mouse to view the scene from different angles.
437
+ * // Double-click to turn on the directional light.
438
+ *
439
+ * let isLit = false;
440
+ *
441
+ * function setup() {
442
+ * createCanvas(100, 100, WEBGL);
443
+ *
444
+ * describe('A sphere drawn on a gray background. A red light starts shining from above when the user double-clicks.');
445
+ * }
446
+ *
447
+ * function draw() {
448
+ * background(200);
449
+ *
450
+ * // Enable orbiting with the mouse.
451
+ * orbitControl();
452
+ *
453
+ * // Control the light.
454
+ * if (isLit === true) {
455
+ * // Add a red directional light from above.
456
+ * // Use RGB values and XYZ directions.
457
+ * directionalLight(255, 0, 0, 0, 1, 0);
458
+ * }
459
+ *
460
+ * // Style the sphere.
461
+ * noStroke();
462
+ *
463
+ * // Draw the sphere.
464
+ * sphere(30);
465
+ * }
466
+ * </code>
467
+ * </div>
468
+ *
469
+ * <div>
470
+ * <code>
471
+ * // Click and drag the mouse to view the scene from different angles.
472
+ *
473
+ * function setup() {
474
+ * createCanvas(100, 100, WEBGL);
475
+ *
476
+ * describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.');
477
+ * }
478
+ *
479
+ * function draw() {
480
+ * background(200);
481
+ *
482
+ * // Enable orbiting with the mouse.
483
+ * orbitControl();
484
+ *
485
+ * // Add a red directional light from above.
486
+ * // Use a p5.Color object and XYZ directions.
487
+ * let c = color(255, 0, 0);
488
+ * directionalLight(c, 0, 1, 0);
489
+ *
490
+ * // Style the sphere.
491
+ * noStroke();
492
+ *
493
+ * // Draw the sphere.
494
+ * sphere(30);
495
+ * }
496
+ * </code>
497
+ * </div>
498
+ *
499
+ * <div>
500
+ * <code>
501
+ * // Click and drag the mouse to view the scene from different angles.
502
+ *
503
+ * function setup() {
504
+ * createCanvas(100, 100, WEBGL);
505
+ *
506
+ * describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.');
507
+ * }
508
+ *
509
+ * function draw() {
510
+ * background(200);
511
+ *
512
+ * // Enable orbiting with the mouse.
513
+ * orbitControl();
514
+ *
515
+ * // Add a red directional light from above.
516
+ * // Use a p5.Color object and a p5.Vector object.
517
+ * let c = color(255, 0, 0);
518
+ * let lightDir = createVector(0, 1, 0);
519
+ * directionalLight(c, lightDir);
520
+ *
521
+ * // Style the sphere.
522
+ * noStroke();
523
+ *
524
+ * // Draw the sphere.
525
+ * sphere(30);
526
+ * }
527
+ * </code>
528
+ * </div>
529
+ */
530
+ function directionalLight(v1: number, v2: number, v3: number, x: number, y: number, z: number): void;
531
+
532
+ /**
533
+ * @param direction of the light as a
534
+ * <a href="#/p5.Vector">p5.Vector</a> object.
535
+ */
536
+ function directionalLight(v1: number, v2: number, v3: number, direction: p5.Vector): void;
537
+
538
+ /**
539
+ * @param color as a <a href="#/p5.Color">p5.Color</a> object,
540
+ * an array of color values, or as a CSS string.
541
+ */
542
+ function directionalLight(color: p5.Color | number[] | string, x: number, y: number, z: number): void;
543
+
544
+ /**
545
+ */
546
+ function directionalLight(color: p5.Color | number[] | string, direction: p5.Vector): void;
547
+
548
+ /**
549
+ * Creates a light that shines from a point in all directions.Point lights are like light bulbs that shine in all directions. They can be
550
+ * placed at different positions to achieve different lighting effects. A
551
+ * maximum of 5 point lights can be active at once.There are four ways to call `pointLight()` with parameters to set the
552
+ * light’s color and position.The first way to call `pointLight()` has six parameters. The first three
553
+ * parameters, `v1`, `v2`, and `v3`, set the light’s color using the current
554
+ * colorMode(). The last three parameters, `x`,
555
+ * `y`, and `z`, set the light’s position. For example,
556
+ * `pointLight(255, 0, 0, 50, 0, 0)` creates a red `(255, 0, 0)` light that
557
+ * shines from the coordinates `(50, 0, 0)`.The second way to call `pointLight()` has four parameters. The first three
558
+ * parameters, `v1`, `v2`, and `v3`, set the light’s color using the current
559
+ * colorMode(). The last parameter, position sets
560
+ * the light’s position using a p5.Vector object.
561
+ * For example, `pointLight(255, 0, 0, lightPos)` creates a red `(255, 0, 0)`
562
+ * light that shines from the position set by the `lightPos` vector.The third way to call `pointLight()` has four parameters. The first
563
+ * parameter, `color`, sets the light’s color using a
564
+ * p5.Color object or an array of color values. The
565
+ * last three parameters, `x`, `y`, and `z`, set the light’s position. For
566
+ * example, `directionalLight(myColor, 50, 0, 0)` creates a light that shines
567
+ * from the coordinates `(50, 0, 0)` with the color value of `myColor`.The fourth way to call `pointLight()` has two parameters. The first
568
+ * parameter, `color`, sets the light’s color using a
569
+ * p5.Color object or an array of color values. The
570
+ * second parameter, `position`, sets the light’s position using a
571
+ * p5.Vector object. For example,
572
+ * `directionalLight(myColor, lightPos)` creates a light that shines from the
573
+ * position set by the `lightPos` vector with the color value of `myColor`.
574
+ *
575
+ * @param red or hue value in the current
576
+ * <a href="#/p5/colorMode">colorMode()</a>.
577
+ * @param green or saturation value in the current
578
+ * <a href="#/p5/colorMode">colorMode()</a>.
579
+ * @param blue, brightness, or lightness value in the current
580
+ * <a href="#/p5/colorMode">colorMode()</a>.
581
+ * @param x-coordinate of the light.
582
+ * @param y-coordinate of the light.
583
+ * @param z-coordinate of the light.
584
+ * @example <div>
585
+ * <code>
586
+ * // Click and drag the mouse to view the scene from different angles.
587
+ * // Double-click to turn on the point light.
588
+ *
589
+ * let isLit = false;
590
+ *
591
+ * function setup() {
592
+ * createCanvas(100, 100, WEBGL);
593
+ *
594
+ * describe('A sphere drawn on a gray background. A red light starts shining from above when the user double-clicks.');
595
+ * }
596
+ *
597
+ * function draw() {
598
+ * background(200);
599
+ *
600
+ * // Enable orbiting with the mouse.
601
+ * orbitControl();
602
+ *
603
+ * // Control the light.
604
+ * if (isLit === true) {
605
+ * // Add a red point light from above.
606
+ * // Use RGB values and XYZ coordinates.
607
+ * pointLight(255, 0, 0, 0, -150, 0);
608
+ * }
609
+ *
610
+ * // Style the sphere.
611
+ * noStroke();
612
+ *
613
+ * // Draw the sphere.
614
+ * sphere(30);
615
+ * }
616
+ *
617
+ * // Turn on the point light when the user double-clicks.
618
+ * function doubleClicked() {
619
+ * isLit = true;
620
+ * }
621
+ * </code>
622
+ * </div>
623
+ *
624
+ * <div>
625
+ * <code>
626
+ * // Click and drag the mouse to view the scene from different angles.
627
+ *
628
+ * function setup() {
629
+ * createCanvas(100, 100, WEBGL);
630
+ *
631
+ * describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.');
632
+ * }
633
+ *
634
+ * function draw() {
635
+ * background(200);
636
+ *
637
+ * // Enable orbiting with the mouse.
638
+ * orbitControl();
639
+ *
640
+ * // Add a red point light from above.
641
+ * // Use a p5.Color object and XYZ directions.
642
+ * let c = color(255, 0, 0);
643
+ * pointLight(c, 0, -150, 0);
644
+ *
645
+ * // Style the sphere.
646
+ * noStroke();
647
+ *
648
+ * // Draw the sphere.
649
+ * sphere(30);
650
+ * }
651
+ * </code>
652
+ * </div>
653
+ *
654
+ * <div>
655
+ * <code>
656
+ * // Click and drag the mouse to view the scene from different angles.
657
+ *
658
+ * function setup() {
659
+ * createCanvas(100, 100, WEBGL);
660
+ *
661
+ * describe('A sphere drawn on a gray background. The top of the sphere appears bright red. The color gets darker toward the bottom.');
662
+ * }
663
+ *
664
+ * function draw() {
665
+ * background(200);
666
+ *
667
+ * // Enable orbiting with the mouse.
668
+ * orbitControl();
669
+ *
670
+ * // Add a red point light from above.
671
+ * // Use a p5.Color object and a p5.Vector object.
672
+ * let c = color(255, 0, 0);
673
+ * let lightPos = createVector(0, -150, 0);
674
+ * pointLight(c, lightPos);
675
+ *
676
+ * // Style the sphere.
677
+ * noStroke();
678
+ *
679
+ * // Draw the sphere.
680
+ * sphere(30);
681
+ * }
682
+ * </code>
683
+ * </div>
684
+ *
685
+ * <div>
686
+ * <code>
687
+ * // Click and drag the mouse to view the scene from different angles.
688
+ *
689
+ * function setup() {
690
+ * createCanvas(100, 100, WEBGL);
691
+ *
692
+ * describe('Four spheres arranged in a square and drawn on a gray background. The spheres appear bright red toward the center of the square. The color gets darker toward the corners of the square.');
693
+ * }
694
+ *
695
+ * function draw() {
696
+ * background(200);
697
+ *
698
+ * // Enable orbiting with the mouse.
699
+ * orbitControl();
700
+ *
701
+ * // Add a red point light that points to the center of the scene.
702
+ * // Use a p5.Color object and a p5.Vector object.
703
+ * let c = color(255, 0, 0);
704
+ * let lightPos = createVector(0, 0, 65);
705
+ * pointLight(c, lightPos);
706
+ *
707
+ * // Style the spheres.
708
+ * noStroke();
709
+ *
710
+ * // Draw a sphere up and to the left.
711
+ * push();
712
+ * translate(-25, -25, 25);
713
+ * sphere(10);
714
+ * pop();
715
+ *
716
+ * // Draw a box up and to the right.
717
+ * push();
718
+ * translate(25, -25, 25);
719
+ * sphere(10);
720
+ * pop();
721
+ *
722
+ * // Draw a sphere down and to the left.
723
+ * push();
724
+ * translate(-25, 25, 25);
725
+ * sphere(10);
726
+ * pop();
727
+ *
728
+ * // Draw a box down and to the right.
729
+ * push();
730
+ * translate(25, 25, 25);
731
+ * sphere(10);
732
+ * pop();
733
+ * }
734
+ * </code>
735
+ * </div>
736
+ */
737
+ function pointLight(v1: number, v2: number, v3: number, x: number, y: number, z: number): void;
738
+
739
+ /**
740
+ * @param position of the light as a
741
+ * <a href="#/p5.Vector">p5.Vector</a> object.
742
+ */
743
+ function pointLight(v1: number, v2: number, v3: number, position: p5.Vector): void;
744
+
745
+ /**
746
+ * @param color as a <a href="#/p5.Color">p5.Color</a> object,
747
+ * an array of color values, or a CSS string.
748
+ */
749
+ function pointLight(color: p5.Color | number[] | string, x: number, y: number, z: number): void;
750
+
751
+ /**
752
+ */
753
+ function pointLight(color: p5.Color | number[] | string, position: p5.Vector): void;
754
+
755
+ /**
756
+ * Creates an ambient light from an image.`imageLight()` simulates a light shining from all directions. The effect is
757
+ * like placing the sketch at the center of a giant sphere that uses the image
758
+ * as its texture. The image's diffuse light will be affected by
759
+ * fill() and the specular reflections will be
760
+ * affected by specularMaterial() and
761
+ * shininess().The parameter, `img`, is the p5.Image object to
762
+ * use as the light source.
763
+ *
764
+ * @param image to use as the light source.
765
+ * @example <div class="notest">
766
+ * <code>
767
+ * // Click and drag the mouse to view the scene from different angles.
768
+ *
769
+ * let img;
770
+ *
771
+ * async function setup() {
772
+ * // Load an image and create a p5.Image object.
773
+ * img = await loadImage('assets/outdoor_spheremap.jpg');
774
+ *
775
+ * createCanvas(100, 100, WEBGL);
776
+ *
777
+ * describe('A sphere floating above a landscape. The surface of the sphere reflects the landscape.');
778
+ * }
779
+ *
780
+ * function draw() {
781
+ * // Enable orbiting with the mouse.
782
+ * orbitControl();
783
+ *
784
+ * // Draw the image as a panorama (360˚ background).
785
+ * panorama(img);
786
+ *
787
+ * // Add a soft ambient light.
788
+ * ambientLight(50);
789
+ *
790
+ * // Add light from the image.
791
+ * imageLight(img);
792
+ *
793
+ * // Style the sphere.
794
+ * specularMaterial(20);
795
+ * shininess(100);
796
+ * noStroke();
797
+ *
798
+ * // Draw the sphere.
799
+ * sphere(30);
800
+ * }
801
+ * </code>
802
+ * </div>
803
+ */
804
+ function imageLight(img: p5.image): void;
805
+
806
+ /**
807
+ * Creates an immersive 3D background.`panorama()` transforms images containing 360˚ content, such as maps or
808
+ * HDRIs, into immersive 3D backgrounds that surround a sketch. Exploring the
809
+ * space requires changing the camera's perspective with functions such as
810
+ * orbitControl() or
811
+ * camera().
812
+ *
813
+ * @param 360˚ image to use as the background.
814
+ * @example <div class="notest">
815
+ * <code>
816
+ * // Click and drag the mouse to view the scene from different angles.
817
+ *
818
+ * let img;
819
+ *
820
+ * async function setup() {
821
+ * // Load an image and create a p5.Image object.
822
+ * img = await loadImage('assets/outdoor_spheremap.jpg');
823
+ *
824
+ * createCanvas(100, 100, WEBGL);
825
+ *
826
+ * describe('A sphere floating above a landscape. The surface of the sphere reflects the landscape. The full landscape is viewable in 3D as the user drags the mouse.');
827
+ * }
828
+ *
829
+ * function draw() {
830
+ * // Add the panorama.
831
+ * panorama(img);
832
+ *
833
+ * // Enable orbiting with the mouse.
834
+ * orbitControl();
835
+ *
836
+ * // Use the image as a light source.
837
+ * imageLight(img);
838
+ *
839
+ * // Style the sphere.
840
+ * noStroke();
841
+ * specularMaterial(50);
842
+ * shininess(200);
843
+ * metalness(100);
844
+ *
845
+ * // Draw the sphere.
846
+ * sphere(30);
847
+ * }
848
+ * </code>
849
+ * </div>
850
+ */
851
+ function panorama(img: p5.Image): void;
852
+
853
+ /**
854
+ * Places an ambient and directional light in the scene.
855
+ * The lights are set to ambientLight(128, 128, 128) and
856
+ * directionalLight(128, 128, 128, 0, 0, -1).Note: lights need to be called (whether directly or indirectly)
857
+ * within draw() to remain persistent in a looping program.
858
+ * Placing them in setup() will cause them to only have an effect
859
+ * the first time through the loop.
860
+ *
861
+ * @example <div>
862
+ * <code>
863
+ * // Click and drag the mouse to view the scene from different angles.
864
+ * // Double-click to turn on the lights.
865
+ *
866
+ * let isLit = false;
867
+ *
868
+ * function setup() {
869
+ * createCanvas(100, 100, WEBGL);
870
+ *
871
+ * describe('A white box drawn against a gray background. The quality of the light changes when the user double-clicks.');
872
+ * }
873
+ *
874
+ * function draw() {
875
+ * background(50);
876
+ *
877
+ * // Enable orbiting with the mouse.
878
+ * orbitControl();
879
+ *
880
+ * // Control the lights.
881
+ * if (isLit === true) {
882
+ * lights();
883
+ * }
884
+ *
885
+ * // Draw the box.
886
+ * box();
887
+ * }
888
+ *
889
+ * // Turn on the lights when the user double-clicks.
890
+ * function doubleClicked() {
891
+ * isLit = true;
892
+ * }
893
+ * </code>
894
+ * </div>
895
+ *
896
+ * <div>
897
+ * <code>
898
+ * // Click and drag the mouse to view the scene from different angles.
899
+ *
900
+ * function setup() {
901
+ * createCanvas(100, 100, WEBGL);
902
+ *
903
+ * describe('A white box drawn against a gray background.');
904
+ * }
905
+ *
906
+ * function draw() {
907
+ * background(50);
908
+ *
909
+ * // Enable orbiting with the mouse.
910
+ * orbitControl();
911
+ *
912
+ * // Turn on the lights.
913
+ * ambientLight(128, 128, 128);
914
+ * directionalLight(128, 128, 128, 0, 0, -1);
915
+ *
916
+ * // Draw the box.
917
+ * box();
918
+ * }
919
+ * </code>
920
+ * </div>
921
+ */
922
+ function lights(): void;
923
+
924
+ /**
925
+ * Sets the falloff rate for pointLight()
926
+ * and spotLight().A light’s falloff describes the intensity of its beam at a distance. For
927
+ * example, a lantern has a slow falloff, a flashlight has a medium falloff,
928
+ * and a laser pointer has a sharp falloff.`lightFalloff()` has three parameters, `constant`, `linear`, and
929
+ * `quadratic`. They’re numbers used to calculate falloff at a distance, `d`,
930
+ * as follows:`falloff = 1 / (constant + d * linear + (d * d) * quadratic)`Note: `constant`, `linear`, and `quadratic` should always be set to values
931
+ * greater than 0.
932
+ *
933
+ * @param constant value for calculating falloff.
934
+ * @param linear value for calculating falloff.
935
+ * @param quadratic value for calculating falloff.
936
+ * @example <div>
937
+ * <code>
938
+ * // Click and drag the mouse to view the scene from different angles.
939
+ * // Double-click to change the falloff rate.
940
+ *
941
+ * let useFalloff = false;
942
+ *
943
+ * function setup() {
944
+ * createCanvas(100, 100, WEBGL);
945
+ *
946
+ * describe('A sphere drawn against a gray background. The intensity of the light changes when the user double-clicks.');
947
+ * }
948
+ *
949
+ * function draw() {
950
+ * background(50);
951
+ *
952
+ * // Enable orbiting with the mouse.
953
+ * orbitControl();
954
+ *
955
+ * // Set the light falloff.
956
+ * if (useFalloff === true) {
957
+ * lightFalloff(2, 0, 0);
958
+ * }
959
+ *
960
+ * // Add a white point light from the front.
961
+ * pointLight(255, 255, 255, 0, 0, 100);
962
+ *
963
+ * // Style the sphere.
964
+ * noStroke();
965
+ *
966
+ * // Draw the sphere.
967
+ * sphere(30);
968
+ * }
969
+ *
970
+ * // Change the falloff value when the user double-clicks.
971
+ * function doubleClicked() {
972
+ * useFalloff = true;
973
+ * }
974
+ * </code>
975
+ * </div>
976
+ */
977
+ function lightFalloff(constant: number, linear: number, quadratic: number): void;
978
+
979
+ /**
980
+ * Creates a light that shines from a point in one direction.Spot lights are like flashlights that shine in one direction creating a
981
+ * cone of light. The shape of the cone can be controlled using the angle and
982
+ * concentration parameters. A maximum of 5 spot lights can be active at once.There are eight ways to call `spotLight()` with parameters to set the
983
+ * light’s color, position, direction. For example,
984
+ * `spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0)` creates a red `(255, 0, 0)` light
985
+ * at the origin `(0, 0, 0)` that points to the right `(1, 0, 0)`.The `angle` parameter is optional. It sets the radius of the light cone.
986
+ * For example, `spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0, PI / 16)` creates a
987
+ * red `(255, 0, 0)` light at the origin `(0, 0, 0)` that points to the right
988
+ * `(1, 0, 0)` with an angle of `PI / 16` radians. By default, `angle` is
989
+ * `PI / 3` radians.The `concentration` parameter is also optional. It focuses the light
990
+ * towards the center of the light cone. For example,
991
+ * `spotLight(255, 0, 0, 0, 0, 0, 1, 0, 0, PI / 16, 50)` creates a red
992
+ * `(255, 0, 0)` light at the origin `(0, 0, 0)` that points to the right
993
+ * `(1, 0, 0)` with an angle of `PI / 16` radians at concentration of 50. By
994
+ * default, `concentration` is 100.
995
+ *
996
+ * @param red or hue value in the current
997
+ * <a href="#/p5/colorMode">colorMode()</a>.
998
+ * @param green or saturation value in the current
999
+ * <a href="#/p5/colorMode">colorMode()</a>.
1000
+ * @param blue, brightness, or lightness value in the current
1001
+ * <a href="#/p5/colorMode">colorMode()</a>.
1002
+ * @param x-coordinate of the light.
1003
+ * @param y-coordinate of the light.
1004
+ * @param z-coordinate of the light.
1005
+ * @param x-component of light direction between -1 and 1.
1006
+ * @param y-component of light direction between -1 and 1.
1007
+ * @param z-component of light direction between -1 and 1.
1008
+ * @param angle of the light cone. Defaults to `PI / 3`.
1009
+ * @param concentration of the light. Defaults to 100.
1010
+ * @example <div>
1011
+ * <code>
1012
+ * // Click and drag the mouse to view the scene from different angles.
1013
+ * // Double-click to adjust the spotlight.
1014
+ *
1015
+ * let isLit = false;
1016
+ *
1017
+ * function setup() {
1018
+ * createCanvas(100, 100, WEBGL);
1019
+ *
1020
+ * describe('A white sphere drawn on a gray background. A red spotlight starts shining when the user double-clicks.');
1021
+ * }
1022
+ *
1023
+ * function draw() {
1024
+ * background(50);
1025
+ *
1026
+ * // Enable orbiting with the mouse.
1027
+ * orbitControl();
1028
+ *
1029
+ * // Turn on the lights.
1030
+ * lights();
1031
+ *
1032
+ * // Control the spotlight.
1033
+ * if (isLit === true) {
1034
+ * // Add a red spot light that shines into the screen.
1035
+ * // Set its angle to PI / 32 radians.
1036
+ * spotLight(255, 0, 0, 0, 0, 100, 0, 0, -1, PI / 32);
1037
+ * }
1038
+ *
1039
+ * // Draw the sphere.
1040
+ * sphere(30);
1041
+ * }
1042
+ *
1043
+ * // Turn on the spotlight when the user double-clicks.
1044
+ * function doubleClicked() {
1045
+ * isLit = true;
1046
+ * }
1047
+ * </code>
1048
+ * </div>
1049
+ *
1050
+ * <div>
1051
+ * <code>
1052
+ * // Click and drag the mouse to view the scene from different angles.
1053
+ * // Double-click to adjust the spotlight.
1054
+ *
1055
+ * let isLit = false;
1056
+ *
1057
+ * function setup() {
1058
+ * createCanvas(100, 100, WEBGL);
1059
+ *
1060
+ * describe('A white sphere drawn on a gray background. A red spotlight starts shining when the user double-clicks.');
1061
+ * }
1062
+ *
1063
+ * function draw() {
1064
+ * background(50);
1065
+ *
1066
+ * // Enable orbiting with the mouse.
1067
+ * orbitControl();
1068
+ *
1069
+ * // Turn on the lights.
1070
+ * lights();
1071
+ *
1072
+ * // Control the spotlight.
1073
+ * if (isLit === true) {
1074
+ * // Add a red spot light that shines into the screen.
1075
+ * // Set its angle to PI / 3 radians (default).
1076
+ * // Set its concentration to 1000.
1077
+ * let c = color(255, 0, 0);
1078
+ * let position = createVector(0, 0, 100);
1079
+ * let direction = createVector(0, 0, -1);
1080
+ * spotLight(c, position, direction, PI / 3, 1000);
1081
+ * }
1082
+ *
1083
+ * // Draw the sphere.
1084
+ * sphere(30);
1085
+ * }
1086
+ *
1087
+ * // Turn on the spotlight when the user double-clicks.
1088
+ * function doubleClicked() {
1089
+ * isLit = true;
1090
+ * }
1091
+ * </code>
1092
+ * </div>
1093
+ */
1094
+ function spotLight(v1: number, v2: number, v3: number, x: number, y: number, z: number, rx: number, ry: number, rz: number, angle?: number, concentration?: number): void;
1095
+
1096
+ /**
1097
+ * @param color as a <a href="#/p5.Color">p5.Color</a> object,
1098
+ * an array of color values, or a CSS string.
1099
+ * @param position of the light as a <a href="#/p5.Vector">p5.Vector</a> object.
1100
+ * @param direction of light as a <a href="#/p5.Vector">p5.Vector</a> object.
1101
+ */
1102
+ function spotLight(color: p5.Color | number[] | string, position: p5.Vector, direction: p5.Vector, angle?: number, concentration?: number): void;
1103
+
1104
+ /**
1105
+ */
1106
+ function spotLight(v1: number, v2: number, v3: number, position: p5.Vector, direction: p5.Vector, angle?: number, concentration?: number): void;
1107
+
1108
+ /**
1109
+ */
1110
+ function spotLight(color: p5.Color | number[] | string, x: number, y: number, z: number, direction: p5.Vector, angle?: number, concentration?: number): void;
1111
+
1112
+ /**
1113
+ */
1114
+ function spotLight(color: p5.Color | number[] | string, position: p5.Vector, rx: number, ry: number, rz: number, angle?: number, concentration?: number): void;
1115
+
1116
+ /**
1117
+ */
1118
+ function spotLight(v1: number, v2: number, v3: number, x: number, y: number, z: number, direction: p5.Vector, angle?: number, concentration?: number): void;
1119
+
1120
+ /**
1121
+ */
1122
+ function spotLight(v1: number, v2: number, v3: number, position: p5.Vector, rx: number, ry: number, rz: number, angle?: number, concentration?: number): void;
1123
+
1124
+ /**
1125
+ */
1126
+ function spotLight(color: p5.Color | number[] | string, x: number, y: number, z: number, rx: number, ry: number, rz: number, angle?: number, concentration?: number): void;
1127
+
1128
+ /**
1129
+ * Removes all lights from the sketch.Calling `noLights()` removes any lights created with
1130
+ * lights(),
1131
+ * ambientLight(),
1132
+ * directionalLight(),
1133
+ * pointLight(), or
1134
+ * spotLight(). These functions may be called
1135
+ * after `noLights()` to create a new lighting scheme.
1136
+ *
1137
+ * @example <div>
1138
+ * <code>
1139
+ * // Click and drag the mouse to view the scene from different angles.
1140
+ *
1141
+ * function setup() {
1142
+ * createCanvas(100, 100, WEBGL);
1143
+ *
1144
+ * describe('Two spheres drawn against a gray background. The top sphere is white and the bottom sphere is red.');
1145
+ * }
1146
+ *
1147
+ * function draw() {
1148
+ * background(50);
1149
+ *
1150
+ * // Enable orbiting with the mouse.
1151
+ * orbitControl();
1152
+ *
1153
+ * // Turn on the lights.
1154
+ * lights();
1155
+ *
1156
+ * // Style the spheres.
1157
+ * noStroke();
1158
+ *
1159
+ * // Draw the top sphere.
1160
+ * push();
1161
+ * translate(0, -25, 0);
1162
+ * sphere(20);
1163
+ * pop();
1164
+ *
1165
+ * // Turn off the lights.
1166
+ * noLights();
1167
+ *
1168
+ * // Add a red directional light that points into the screen.
1169
+ * directionalLight(255, 0, 0, 0, 0, -1);
1170
+ *
1171
+ * // Draw the bottom sphere.
1172
+ * push();
1173
+ * translate(0, 25, 0);
1174
+ * sphere(20);
1175
+ * pop();
1176
+ * }
1177
+ * </code>
1178
+ * </div>
1179
+ */
1180
+ function noLights(): void;
1181
+
1182
+ }
1183
+
1184
+ export default function light(p5: any, fn: any): void;