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.
- package/dist/accessibility/color_namer.js +5 -5
- package/dist/accessibility/describe.js +10 -0
- package/dist/accessibility/index.js +5 -5
- package/dist/accessibility/outputs.js +21 -0
- package/dist/app.js +5 -5
- package/dist/color/color_conversion.js +5 -5
- package/dist/color/creating_reading.js +1 -1
- package/dist/color/index.js +2 -2
- package/dist/color/p5.Color.js +1 -1
- package/dist/color/setting.js +2 -2
- package/dist/{constants-C-g_eAdC.js → constants-BRcElHU3.js} +19 -3
- package/dist/core/constants.js +1 -1
- package/dist/core/environment.js +6 -5
- package/dist/core/friendly_errors/fes_core.js +1 -1
- package/dist/core/friendly_errors/index.js +1 -1
- package/dist/core/friendly_errors/param_validator.js +46 -93
- package/dist/core/friendly_errors/sketch_reader.js +5 -5
- package/dist/core/friendly_errors/sketch_verifier.js +1 -1
- package/dist/core/friendly_errors/validate_params.js +5 -5
- package/dist/core/helpers.js +1 -1
- package/dist/core/init.js +5 -5
- package/dist/core/legacy.js +5 -5
- package/dist/core/main.js +5 -5
- package/dist/core/p5.Graphics.js +4 -4
- package/dist/core/p5.Renderer.js +3 -3
- package/dist/core/p5.Renderer2D.js +5 -5
- package/dist/core/rendering.js +4 -4
- package/dist/{creating_reading-D4AAKRbx.js → creating_reading-Cr8L2Jnm.js} +2 -2
- package/dist/dom/dom.js +10 -10
- package/dist/dom/index.js +2 -2
- package/dist/dom/p5.Element.js +2 -2
- package/dist/dom/p5.MediaElement.js +2 -2
- package/dist/events/acceleration.js +24 -24
- package/dist/events/keyboard.js +11 -6
- package/dist/image/const.js +1 -1
- package/dist/image/filterRenderer2D.js +4 -4
- package/dist/image/image.js +4 -4
- package/dist/image/index.js +4 -4
- package/dist/image/loading_displaying.js +4 -4
- package/dist/image/p5.Image.js +3 -3
- package/dist/image/pixels.js +1 -0
- package/dist/io/files.js +4 -4
- package/dist/io/index.js +4 -4
- package/dist/io/p5.TableRow.js +2 -2
- package/dist/{main-s72KWcUy.js → main-BKN5yFoS.js} +12 -9
- package/dist/math/Matrices/Matrix.js +1 -1
- package/dist/math/Matrices/MatrixNumjs.js +1 -1
- package/dist/math/index.js +1 -1
- package/dist/math/math.js +1 -1
- package/dist/math/p5.Matrix.js +1 -1
- package/dist/math/p5.Vector.js +1 -1
- package/dist/math/trigonometry.js +1 -1
- package/dist/{p5.Renderer-CwAYZOC2.js → p5.Renderer-R23xoC7s.js} +5 -5
- package/dist/{rendering--aAe5aq3.js → rendering-CvUVN-Vb.js} +101 -66
- package/dist/shape/2d_primitives.js +1 -1
- package/dist/shape/attributes.js +1 -1
- package/dist/shape/custom_shapes.js +2 -2
- package/dist/shape/index.js +2 -2
- package/dist/type/index.js +3 -3
- package/dist/type/p5.Font.js +3 -5
- package/dist/type/textCore.js +4 -4
- package/dist/webgl/3d_primitives.js +4 -4
- package/dist/webgl/GeometryBuilder.js +1 -1
- package/dist/webgl/ShapeBuilder.js +1 -1
- package/dist/webgl/index.js +4 -4
- package/dist/webgl/interaction.js +1 -1
- package/dist/webgl/light.js +4 -4
- package/dist/webgl/loading.js +5 -4
- package/dist/webgl/material.js +4 -4
- package/dist/webgl/p5.Camera.js +4 -4
- package/dist/webgl/p5.Framebuffer.js +4 -4
- package/dist/webgl/p5.Geometry.js +1 -1
- package/dist/webgl/p5.Quat.js +1 -1
- package/dist/webgl/p5.RendererGL.js +4 -4
- package/dist/webgl/p5.Shader.js +4 -4
- package/dist/webgl/p5.Texture.js +4 -4
- package/dist/webgl/text.js +32 -34
- package/lib/p5.esm.js +289 -247
- package/lib/p5.js +289 -247
- package/lib/p5.min.js +1 -1
- package/package.json +1 -2
- package/types/accessibility/color_namer.d.ts +8 -0
- package/types/accessibility/describe.d.ts +184 -0
- package/types/accessibility/gridOutput.d.ts +8 -0
- package/types/accessibility/outputs.d.ts +235 -0
- package/types/accessibility/textOutput.d.ts +8 -0
- package/types/color/color_conversion.d.ts +47 -0
- package/types/color/creating_reading.d.ts +1348 -0
- package/types/color/p5.Color.d.ts +1070 -0
- package/types/color/setting.d.ts +2085 -0
- package/types/core/constants.d.ts +341 -0
- package/types/core/environment.d.ts +668 -0
- package/types/core/friendly_errors/fes_core.d.ts +8 -0
- package/types/core/friendly_errors/file_errors.d.ts +8 -0
- package/types/core/friendly_errors/param_validator.d.ts +30 -0
- package/types/core/friendly_errors/sketch_reader.d.ts +8 -0
- package/types/core/friendly_errors/stacktrace.d.ts +11 -0
- package/types/core/friendly_errors/validate_params.d.ts +8 -0
- package/types/core/helpers.d.ts +8 -0
- package/types/core/legacy.d.ts +8 -0
- package/types/core/main.d.ts +5999 -0
- package/types/core/p5.Graphics.d.ts +484 -0
- package/types/core/p5.Renderer.d.ts +14 -0
- package/types/core/reference.d.ts +8 -0
- package/types/core/rendering.d.ts +481 -0
- package/types/core/structure.d.ts +492 -0
- package/types/core/transform.d.ts +1638 -0
- package/types/data/local_storage.d.ts +323 -0
- package/types/dom/dom.d.ts +1295 -0
- package/types/dom/p5.Element.d.ts +2011 -0
- package/types/dom/p5.File.d.ts +13 -0
- package/types/dom/p5.MediaElement.d.ts +1249 -0
- package/types/events/acceleration.d.ts +193 -0
- package/types/events/keyboard.d.ts +501 -0
- package/types/events/pointer.d.ts +782 -0
- package/types/global.d.ts +5544 -0
- package/types/image/filterRenderer2D.d.ts +54 -0
- package/types/image/image.d.ts +326 -0
- package/types/image/loading_displaying.d.ts +580 -0
- package/types/image/p5.Image.d.ts +5882 -0
- package/types/image/pixels.d.ts +832 -0
- package/types/io/files.d.ts +1447 -0
- package/types/io/p5.Table.d.ts +1247 -0
- package/types/io/p5.TableRow.d.ts +343 -0
- package/types/io/p5.XML.d.ts +1188 -0
- package/types/math/Matrices/Matrix.d.ts +1029 -0
- package/types/math/Matrices/MatrixNumjs.d.ts +8 -0
- package/types/math/calculation.d.ts +923 -0
- package/types/math/math.d.ts +90 -0
- package/types/math/noise.d.ts +311 -0
- package/types/math/p5.Matrix.d.ts +8 -0
- package/types/math/p5.Vector.d.ts +3416 -0
- package/types/math/random.d.ts +267 -0
- package/types/math/trigonometry.d.ts +663 -0
- package/types/p5.d.ts +6666 -0
- package/types/shape/2d_primitives.d.ts +1033 -0
- package/types/shape/attributes.d.ts +466 -0
- package/types/shape/curves.d.ts +740 -0
- package/types/shape/custom_shapes.d.ts +888 -0
- package/types/shape/vertex.d.ts +1141 -0
- package/types/type/p5.Font.d.ts +575 -0
- package/types/type/textCore.d.ts +1198 -0
- package/types/utilities/conversion.d.ts +894 -0
- package/types/utilities/time_date.d.ts +295 -0
- package/types/utilities/utility_functions.d.ts +587 -0
- package/types/webgl/3d_primitives.d.ts +1432 -0
- package/types/webgl/ShaderGenerator.d.ts +8 -0
- package/types/webgl/interaction.d.ts +371 -0
- package/types/webgl/light.d.ts +1184 -0
- package/types/webgl/loading.d.ts +482 -0
- package/types/webgl/material.d.ts +2656 -0
- package/types/webgl/p5.Camera.d.ts +3023 -0
- package/types/webgl/p5.DataArray.d.ts +61 -0
- package/types/webgl/p5.Framebuffer.d.ts +760 -0
- package/types/webgl/p5.Geometry.d.ts +1191 -0
- package/types/webgl/p5.Quat.d.ts +45 -0
- package/types/webgl/p5.RendererGL.d.ts +234 -0
- package/types/webgl/p5.Shader.d.ts +660 -0
- package/types/webgl/p5.Texture.d.ts +61 -0
- package/types/webgl/text.d.ts +74 -0
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
// This file is auto-generated from JSDoc documentation
|
|
2
|
+
|
|
3
|
+
import p5 from 'p5';
|
|
4
|
+
import { Color } from '../color/p5.Color';
|
|
5
|
+
|
|
6
|
+
declare module 'p5' {
|
|
7
|
+
/**
|
|
8
|
+
* Loads an image to create a p5.Image object.`loadImage()` interprets the first parameter one of three ways. If the path
|
|
9
|
+
* to an image file is provided, `loadImage()` will load it. Paths to local
|
|
10
|
+
* files should be relative, such as `'assets/thundercat.jpg'`. URLs such as
|
|
11
|
+
* `'https://example.com/thundercat.jpg'` may be blocked due to browser
|
|
12
|
+
* security. Raw image data can also be passed as a base64 encoded image in
|
|
13
|
+
* the form `'data:image/png;base64,arandomsequenceofcharacters'`. The `path`
|
|
14
|
+
* parameter can also be defined as a
|
|
15
|
+
* object for more advanced usage.The second parameter is optional. If a function is passed, it will be
|
|
16
|
+
* called once the image has loaded. The callback function can optionally use
|
|
17
|
+
* the new p5.Image object. The return value of the
|
|
18
|
+
* function will be used as the final return value of `loadImage()`.The third parameter is also optional. If a function is passed, it will be
|
|
19
|
+
* called if the image fails to load. The callback function can optionally use
|
|
20
|
+
* the event error. The return value of the function will be used as the final
|
|
21
|
+
* return value of `loadImage()`.This function returns a `Promise` and should be used in an `async` setup with
|
|
22
|
+
* `await`. See the examples for the usage syntax.
|
|
23
|
+
*
|
|
24
|
+
* @param path of the image to be loaded or base64 encoded image.
|
|
25
|
+
* @param function called with
|
|
26
|
+
* <a href="#/p5.Image">p5.Image</a> once it
|
|
27
|
+
* loads.
|
|
28
|
+
* @param function called with event
|
|
29
|
+
* error if the image fails to load.
|
|
30
|
+
* @return the <a href="#/p5.Image">p5.Image</a> object.
|
|
31
|
+
* @example <div>
|
|
32
|
+
* <code>
|
|
33
|
+
* let img;
|
|
34
|
+
*
|
|
35
|
+
* // Load the image and create a p5.Image object.
|
|
36
|
+
* async function setup() {
|
|
37
|
+
* img = await loadImage('assets/laDefense.jpg');
|
|
38
|
+
* createCanvas(100, 100);
|
|
39
|
+
*
|
|
40
|
+
* // Draw the image.
|
|
41
|
+
* image(img, 0, 0);
|
|
42
|
+
*
|
|
43
|
+
* describe('Image of the underside of a white umbrella and a gridded ceiling.');
|
|
44
|
+
* }
|
|
45
|
+
* </code>
|
|
46
|
+
* </div>
|
|
47
|
+
*
|
|
48
|
+
* <div>
|
|
49
|
+
* <code>
|
|
50
|
+
* async function setup() {
|
|
51
|
+
* // Call handleImage() once the image loads.
|
|
52
|
+
* await loadImage('assets/laDefense.jpg', handleImage);
|
|
53
|
+
*
|
|
54
|
+
* describe('Image of the underside of a white umbrella and a gridded ceiling.');
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* // Display the image.
|
|
58
|
+
* function handleImage(img) {
|
|
59
|
+
* image(img, 0, 0);
|
|
60
|
+
* }
|
|
61
|
+
* </code>
|
|
62
|
+
* </div>
|
|
63
|
+
*
|
|
64
|
+
* <div>
|
|
65
|
+
* <code>
|
|
66
|
+
* async function setup() {
|
|
67
|
+
* // Call handleImage() once the image loads or
|
|
68
|
+
* // call handleError() if an error occurs.
|
|
69
|
+
* await loadImage('assets/laDefense.jpg', handleImage, handleError);
|
|
70
|
+
* }
|
|
71
|
+
*
|
|
72
|
+
* // Display the image.
|
|
73
|
+
* function handleImage(img) {
|
|
74
|
+
* image(img, 0, 0);
|
|
75
|
+
*
|
|
76
|
+
* describe('Image of the underside of a white umbrella and a gridded ceiling.');
|
|
77
|
+
* }
|
|
78
|
+
*
|
|
79
|
+
* // Log the error.
|
|
80
|
+
* function handleError(event) {
|
|
81
|
+
* console.error('Oops!', event);
|
|
82
|
+
* }
|
|
83
|
+
* </code>
|
|
84
|
+
* </div>
|
|
85
|
+
*/
|
|
86
|
+
function loadImage(path: string | Request, successCallback?: any, failureCallback?: any): Promise<p5.Image>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Generates a gif from a sketch and saves it to a file.`saveGif()` may be called in setup() or at any
|
|
90
|
+
* point while a sketch is running.The first parameter, `fileName`, sets the gif's file name.The second parameter, `duration`, sets the gif's duration in seconds.The third parameter, `options`, is optional. If an object is passed,
|
|
91
|
+
* `saveGif()` will use its properties to customize the gif. `saveGif()`
|
|
92
|
+
* recognizes the properties `delay`, `units`, `silent`,
|
|
93
|
+
* `notificationDuration`, and `notificationID`.
|
|
94
|
+
*
|
|
95
|
+
* @param file name of gif.
|
|
96
|
+
* @param duration in seconds to capture from the sketch.
|
|
97
|
+
* @param an object that can contain five more properties:
|
|
98
|
+
* `delay`, a Number specifying how much time to wait before recording;
|
|
99
|
+
* `units`, a String that can be either 'seconds' or 'frames'. By default it's 'seconds’;
|
|
100
|
+
* `silent`, a Boolean that defines presence of progress notifications. By default it’s `false`;
|
|
101
|
+
* `notificationDuration`, a Number that defines how long in seconds the final notification
|
|
102
|
+
* will live. By default it's `0`, meaning the notification will never be removed;
|
|
103
|
+
* `notificationID`, a String that specifies the id of the notification's DOM element. By default it’s `'progressBar’`.
|
|
104
|
+
* @example <div>
|
|
105
|
+
* <code>
|
|
106
|
+
* function setup() {
|
|
107
|
+
* createCanvas(100, 100);
|
|
108
|
+
*
|
|
109
|
+
* describe('A circle drawn in the middle of a gray square. The circle changes color from black to white, then repeats.');
|
|
110
|
+
* }
|
|
111
|
+
*
|
|
112
|
+
* function draw() {
|
|
113
|
+
* background(200);
|
|
114
|
+
*
|
|
115
|
+
* // Style the circle.
|
|
116
|
+
* let c = frameCount % 255;
|
|
117
|
+
* fill(c);
|
|
118
|
+
*
|
|
119
|
+
* // Display the circle.
|
|
120
|
+
* circle(50, 50, 25);
|
|
121
|
+
* }
|
|
122
|
+
*
|
|
123
|
+
* // Save a 5-second gif when the user presses the 's' key.
|
|
124
|
+
* function keyPressed() {
|
|
125
|
+
* if (key === 's') {
|
|
126
|
+
* saveGif('mySketch', 5);
|
|
127
|
+
* }
|
|
128
|
+
* }
|
|
129
|
+
* </code>
|
|
130
|
+
* </div>
|
|
131
|
+
*
|
|
132
|
+
* <div>
|
|
133
|
+
* <code>
|
|
134
|
+
* function setup() {
|
|
135
|
+
* createCanvas(100, 100);
|
|
136
|
+
*
|
|
137
|
+
* describe('A circle drawn in the middle of a gray square. The circle changes color from black to white, then repeats.');
|
|
138
|
+
* }
|
|
139
|
+
*
|
|
140
|
+
* function draw() {
|
|
141
|
+
* background(200);
|
|
142
|
+
*
|
|
143
|
+
* // Style the circle.
|
|
144
|
+
* let c = frameCount % 255;
|
|
145
|
+
* fill(c);
|
|
146
|
+
*
|
|
147
|
+
* // Display the circle.
|
|
148
|
+
* circle(50, 50, 25);
|
|
149
|
+
* }
|
|
150
|
+
*
|
|
151
|
+
* // Save a 5-second gif when the user presses the 's' key.
|
|
152
|
+
* // Wait 1 second after the key press before recording.
|
|
153
|
+
* function keyPressed() {
|
|
154
|
+
* if (key === 's') {
|
|
155
|
+
* saveGif('mySketch', 5, { delay: 1 });
|
|
156
|
+
* }
|
|
157
|
+
* }
|
|
158
|
+
* </code>
|
|
159
|
+
* </div>
|
|
160
|
+
*/
|
|
161
|
+
function saveGif(filename: string, duration: number, options?: object): void;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Helper function for loading GIF-based images
|
|
165
|
+
*
|
|
166
|
+
*/
|
|
167
|
+
function _createGif(arrayBuffer: any, pImg: any): void;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Draws an image to the canvas.The first parameter, `img`, is the source image to be drawn. `img` can be
|
|
171
|
+
* any of the following objects:The second and third parameters, `dx` and `dy`, set the coordinates of the
|
|
172
|
+
* destination image's top left corner. See
|
|
173
|
+
* imageMode() for other ways to position images.`let img;
|
|
174
|
+
*
|
|
175
|
+
* async function setup() {
|
|
176
|
+
* // Load the image.
|
|
177
|
+
* img = await loadImage('assets/laDefense.jpg');
|
|
178
|
+
*
|
|
179
|
+
* createCanvas(100, 100);
|
|
180
|
+
*
|
|
181
|
+
* background(50);
|
|
182
|
+
*
|
|
183
|
+
* // Draw the image.
|
|
184
|
+
* image(img, 0, 0);
|
|
185
|
+
*
|
|
186
|
+
* describe('An image of the underside of a white umbrella with a gridded ceiling above.');
|
|
187
|
+
* }`Here's a diagram that explains how optional parameters work in `image()`:The fourth and fifth parameters, `dw` and `dh`, are optional. They set the
|
|
188
|
+
* the width and height to draw the destination image. By default, `image()`
|
|
189
|
+
* draws the full source image at its original size.The sixth and seventh parameters, `sx` and `sy`, are also optional.
|
|
190
|
+
* These coordinates define the top left corner of a subsection to draw from
|
|
191
|
+
* the source image.The eighth and ninth parameters, `sw` and `sh`, are also optional.
|
|
192
|
+
* They define the width and height of a subsection to draw from the source
|
|
193
|
+
* image. By default, `image()` draws the full subsection that begins at
|
|
194
|
+
* `(sx, sy)` and extends to the edges of the source image.The ninth parameter, `fit`, is also optional. It enables a subsection of
|
|
195
|
+
* the source image to be drawn without affecting its aspect ratio. If
|
|
196
|
+
* `CONTAIN` is passed, the full subsection will appear within the destination
|
|
197
|
+
* rectangle. If `COVER` is passed, the subsection will completely cover the
|
|
198
|
+
* destination rectangle. This may have the effect of zooming into the
|
|
199
|
+
* subsection.The tenth and eleventh paremeters, `xAlign` and `yAlign`, are also
|
|
200
|
+
* optional. They determine how to align the fitted subsection. `xAlign` can
|
|
201
|
+
* be set to either `LEFT`, `RIGHT`, or `CENTER`. `yAlign` can be set to
|
|
202
|
+
* either `TOP`, `BOTTOM`, or `CENTER`. By default, both `xAlign` and `yAlign`
|
|
203
|
+
* are set to `CENTER`.
|
|
204
|
+
*
|
|
205
|
+
* @param image to display.
|
|
206
|
+
* @param x-coordinate of the top-left corner of the image.
|
|
207
|
+
* @param y-coordinate of the top-left corner of the image.
|
|
208
|
+
* @param width to draw the image.
|
|
209
|
+
* @param height to draw the image.
|
|
210
|
+
* @example <div>
|
|
211
|
+
* <code>
|
|
212
|
+
* let img;
|
|
213
|
+
*
|
|
214
|
+
* async function setup() {
|
|
215
|
+
* // Load the image.
|
|
216
|
+
* img = await loadImage('assets/laDefense.jpg');
|
|
217
|
+
*
|
|
218
|
+
* createCanvas(100, 100);
|
|
219
|
+
*
|
|
220
|
+
* background(50);
|
|
221
|
+
*
|
|
222
|
+
* // Draw the image.
|
|
223
|
+
* image(img, 10, 10);
|
|
224
|
+
*
|
|
225
|
+
* describe('An image of the underside of a white umbrella with a gridded ceiling above. The image has dark gray borders on its left and top.');
|
|
226
|
+
* }
|
|
227
|
+
* </code>
|
|
228
|
+
* </div>
|
|
229
|
+
*
|
|
230
|
+
* <div>
|
|
231
|
+
* <code>
|
|
232
|
+
* let img;
|
|
233
|
+
*
|
|
234
|
+
* async function setup() {
|
|
235
|
+
* // Load the image.
|
|
236
|
+
* img = await loadImage('assets/laDefense.jpg');
|
|
237
|
+
*
|
|
238
|
+
* createCanvas(100, 100);
|
|
239
|
+
*
|
|
240
|
+
* background(50);
|
|
241
|
+
*
|
|
242
|
+
* // Draw the image 50x50.
|
|
243
|
+
* image(img, 0, 0, 50, 50);
|
|
244
|
+
*
|
|
245
|
+
* describe('An image of the underside of a white umbrella with a gridded ceiling above. The image is drawn in the top left corner of a dark gray square.');
|
|
246
|
+
* }
|
|
247
|
+
* </code>
|
|
248
|
+
* </div>
|
|
249
|
+
*
|
|
250
|
+
* <div>
|
|
251
|
+
* <code>
|
|
252
|
+
* let img;
|
|
253
|
+
*
|
|
254
|
+
* async function setup() {
|
|
255
|
+
* // Load the image.
|
|
256
|
+
* img = await loadImage('assets/laDefense.jpg');
|
|
257
|
+
*
|
|
258
|
+
* createCanvas(100, 100);
|
|
259
|
+
*
|
|
260
|
+
* background(50);
|
|
261
|
+
*
|
|
262
|
+
* // Draw the center of the image.
|
|
263
|
+
* image(img, 25, 25, 50, 50, 25, 25, 50, 50);
|
|
264
|
+
*
|
|
265
|
+
* describe('An image of a gridded ceiling drawn in the center of a dark gray square.');
|
|
266
|
+
* }
|
|
267
|
+
* </code>
|
|
268
|
+
* </div>
|
|
269
|
+
*
|
|
270
|
+
* <div>
|
|
271
|
+
* <code>
|
|
272
|
+
* let img;
|
|
273
|
+
*
|
|
274
|
+
* async function setup() {
|
|
275
|
+
* // Load the image.
|
|
276
|
+
* img = await loadImage('assets/moonwalk.jpg');
|
|
277
|
+
* createCanvas(100, 100);
|
|
278
|
+
*
|
|
279
|
+
* background(50);
|
|
280
|
+
*
|
|
281
|
+
* // Draw the image and scale it to fit within the canvas.
|
|
282
|
+
* image(img, 0, 0, width, height, 0, 0, img.width, img.height, CONTAIN);
|
|
283
|
+
*
|
|
284
|
+
* describe('An image of an astronaut on the moon. The top and bottom borders of the image are dark gray.');
|
|
285
|
+
* }
|
|
286
|
+
* </code>
|
|
287
|
+
* </div>
|
|
288
|
+
*
|
|
289
|
+
* <div>
|
|
290
|
+
* <code>
|
|
291
|
+
* let img;
|
|
292
|
+
*
|
|
293
|
+
* async function setup() {
|
|
294
|
+
* // Load the image.
|
|
295
|
+
* img = await loadImage('assets/laDefense50.png');
|
|
296
|
+
*
|
|
297
|
+
* createCanvas(100, 100);
|
|
298
|
+
*
|
|
299
|
+
* background(50);
|
|
300
|
+
*
|
|
301
|
+
* // Draw the image and scale it to cover the canvas.
|
|
302
|
+
* image(img, 0, 0, width, height, 0, 0, img.width, img.height, COVER);
|
|
303
|
+
*
|
|
304
|
+
* describe('A pixelated image of the underside of a white umbrella with a gridded ceiling above.');
|
|
305
|
+
* }
|
|
306
|
+
* </code>
|
|
307
|
+
* </div>
|
|
308
|
+
*/
|
|
309
|
+
function image(img: p5.Image | p5.Element | p5.Texture | p5.Framebuffer | p5.FramebufferTexture | p5.Renderer | p5.Graphics, x: number, y: number, width?: number, height?: number): void;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* @param the x-coordinate of the destination
|
|
313
|
+
* rectangle in which to draw the source image
|
|
314
|
+
* @param the y-coordinate of the destination
|
|
315
|
+
* rectangle in which to draw the source image
|
|
316
|
+
* @param the width of the destination rectangle
|
|
317
|
+
* @param the height of the destination rectangle
|
|
318
|
+
* @param the x-coordinate of the subsection of the source
|
|
319
|
+
* image to draw into the destination rectangle
|
|
320
|
+
* @param the y-coordinate of the subsection of the source
|
|
321
|
+
* image to draw into the destination rectangle
|
|
322
|
+
* @param the width of the subsection of the
|
|
323
|
+
* source image to draw into the destination
|
|
324
|
+
* rectangle
|
|
325
|
+
* @param the height of the subsection of the
|
|
326
|
+
* source image to draw into the destination rectangle
|
|
327
|
+
* @param either CONTAIN or COVER
|
|
328
|
+
* @param either LEFT, RIGHT or CENTER default is CENTER
|
|
329
|
+
* @param either TOP, BOTTOM or CENTER default is CENTER
|
|
330
|
+
*/
|
|
331
|
+
function image(img: p5.Image | p5.Element | p5.Texture | p5.Framebuffer | p5.FramebufferTexture, dx: number, dy: number, dWidth: number, dHeight: number, sx: number, sy: number, sWidth?: number, sHeight?: number, fit?: CONTAIN | COVER, xAlign: LEFT | RIGHT | CENTER, yAlign: TOP | BOTTOM | CENTER): void;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Tints images using a color.The version of `tint()` with one parameter interprets it one of four ways.
|
|
335
|
+
* If the parameter is a number, it's interpreted as a grayscale value. If the
|
|
336
|
+
* parameter is a string, it's interpreted as a CSS color string. An array of
|
|
337
|
+
* `[R, G, B, A]` values or a p5.Color object can
|
|
338
|
+
* also be used to set the tint color.The version of `tint()` with two parameters uses the first one as a
|
|
339
|
+
* grayscale value and the second as an alpha value. For example, calling
|
|
340
|
+
* `tint(255, 128)` will make an image 50% transparent.The version of `tint()` with three parameters interprets them as RGB or
|
|
341
|
+
* HSB values, depending on the current
|
|
342
|
+
* colorMode(). The optional fourth parameter
|
|
343
|
+
* sets the alpha value. For example, `tint(255, 0, 0, 100)` will give images
|
|
344
|
+
* a red tint and make them transparent.
|
|
345
|
+
*
|
|
346
|
+
* @param red or hue value.
|
|
347
|
+
* @param green or saturation value.
|
|
348
|
+
* @param blue or brightness.
|
|
349
|
+
* @example <div>
|
|
350
|
+
* <code>
|
|
351
|
+
* let img;
|
|
352
|
+
*
|
|
353
|
+
* async function setup() {
|
|
354
|
+
* // Load the image.
|
|
355
|
+
* img = await loadImage('assets/laDefense.jpg');
|
|
356
|
+
*
|
|
357
|
+
* createCanvas(100, 100);
|
|
358
|
+
*
|
|
359
|
+
* // Left image.
|
|
360
|
+
* image(img, 0, 0);
|
|
361
|
+
*
|
|
362
|
+
* // Right image.
|
|
363
|
+
* // Tint with a CSS color string.
|
|
364
|
+
* tint('red');
|
|
365
|
+
* image(img, 50, 0);
|
|
366
|
+
*
|
|
367
|
+
* describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a red tint.');
|
|
368
|
+
* }
|
|
369
|
+
* </code>
|
|
370
|
+
* </div>
|
|
371
|
+
*
|
|
372
|
+
* <div>
|
|
373
|
+
* <code>
|
|
374
|
+
* let img;
|
|
375
|
+
*
|
|
376
|
+
* async function setup() {
|
|
377
|
+
* // Load the image.
|
|
378
|
+
* img = await loadImage('assets/laDefense.jpg');
|
|
379
|
+
*
|
|
380
|
+
* createCanvas(100, 100);
|
|
381
|
+
*
|
|
382
|
+
* // Left image.
|
|
383
|
+
* image(img, 0, 0);
|
|
384
|
+
*
|
|
385
|
+
* // Right image.
|
|
386
|
+
* // Tint with RGB values.
|
|
387
|
+
* tint(255, 0, 0);
|
|
388
|
+
* image(img, 50, 0);
|
|
389
|
+
*
|
|
390
|
+
* describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a red tint.');
|
|
391
|
+
* }
|
|
392
|
+
* </code>
|
|
393
|
+
* </div>
|
|
394
|
+
*
|
|
395
|
+
* <div>
|
|
396
|
+
* <code>
|
|
397
|
+
* let img;
|
|
398
|
+
* *
|
|
399
|
+
* async function setup() {
|
|
400
|
+
* // Load the image.
|
|
401
|
+
* img = await loadImage('assets/laDefense.jpg');
|
|
402
|
+
*
|
|
403
|
+
* createCanvas(100, 100);
|
|
404
|
+
*
|
|
405
|
+
* // Left.
|
|
406
|
+
* image(img, 0, 0);
|
|
407
|
+
*
|
|
408
|
+
* // Right.
|
|
409
|
+
* // Tint with RGBA values.
|
|
410
|
+
* tint(255, 0, 0, 100);
|
|
411
|
+
* image(img, 50, 0);
|
|
412
|
+
*
|
|
413
|
+
* describe('Two images of an umbrella and a ceiling side-by-side. The image on the right has a transparent red tint.');
|
|
414
|
+
* }
|
|
415
|
+
* </code>
|
|
416
|
+
* </div>
|
|
417
|
+
*
|
|
418
|
+
* <div>
|
|
419
|
+
* <code>
|
|
420
|
+
* let img;
|
|
421
|
+
*
|
|
422
|
+
* async function setup() {
|
|
423
|
+
* // Load the image.
|
|
424
|
+
* img = await loadImage('assets/laDefense.jpg');
|
|
425
|
+
*
|
|
426
|
+
* createCanvas(100, 100);
|
|
427
|
+
*
|
|
428
|
+
* // Left.
|
|
429
|
+
* image(img, 0, 0);
|
|
430
|
+
*
|
|
431
|
+
* // Right.
|
|
432
|
+
* // Tint with grayscale and alpha values.
|
|
433
|
+
* tint(255, 180);
|
|
434
|
+
* image(img, 50, 0);
|
|
435
|
+
*
|
|
436
|
+
* describe('Two images of an umbrella and a ceiling side-by-side. The image on the right is transparent.');
|
|
437
|
+
* }
|
|
438
|
+
* </code>
|
|
439
|
+
* </div>
|
|
440
|
+
*/
|
|
441
|
+
function tint(v1: number, v2: number, v3: number, alpha?: number): void;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* @param CSS color string.
|
|
445
|
+
*/
|
|
446
|
+
function tint(value: string): void;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* @param grayscale value.
|
|
450
|
+
*/
|
|
451
|
+
function tint(gray: number, alpha?: number): void;
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* @param array containing the red, green, blue &
|
|
455
|
+
* alpha components of the color.
|
|
456
|
+
*/
|
|
457
|
+
function tint(values: number[]): void;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* @param the tint color
|
|
461
|
+
*/
|
|
462
|
+
function tint(color: p5.Color): void;
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Removes the current tint set by tint().`noTint()` restores images to their original colors.
|
|
466
|
+
*
|
|
467
|
+
* @example <div>
|
|
468
|
+
* <code>
|
|
469
|
+
* let img;
|
|
470
|
+
*
|
|
471
|
+
* async function setup() {
|
|
472
|
+
* // Load the image.
|
|
473
|
+
* img = await loadImage('assets/laDefense.jpg');
|
|
474
|
+
*
|
|
475
|
+
* createCanvas(100, 100);
|
|
476
|
+
*
|
|
477
|
+
* // Left.
|
|
478
|
+
* // Tint with a CSS color string.
|
|
479
|
+
* tint('red');
|
|
480
|
+
* image(img, 0, 0);
|
|
481
|
+
*
|
|
482
|
+
* // Right.
|
|
483
|
+
* // Remove the tint.
|
|
484
|
+
* noTint();
|
|
485
|
+
* image(img, 50, 0);
|
|
486
|
+
*
|
|
487
|
+
* describe('Two images of an umbrella and a ceiling side-by-side. The image on the left has a red tint.');
|
|
488
|
+
* }
|
|
489
|
+
* </code>
|
|
490
|
+
* </div>
|
|
491
|
+
*/
|
|
492
|
+
function noTint(): void;
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Changes the location from which images are drawn when
|
|
496
|
+
* image() is called.By default, the first
|
|
497
|
+
* two parameters of image() are the x- and
|
|
498
|
+
* y-coordinates of the image's upper-left corner. The next parameters are
|
|
499
|
+
* its width and height. This is the same as calling `imageMode(CORNER)`.`imageMode(CORNERS)` also uses the first two parameters of
|
|
500
|
+
* image() as the x- and y-coordinates of the image's
|
|
501
|
+
* top-left corner. The third and fourth parameters are the coordinates of its
|
|
502
|
+
* bottom-right corner.`imageMode(CENTER)` uses the first two parameters of
|
|
503
|
+
* image() as the x- and y-coordinates of the image's
|
|
504
|
+
* center. The next parameters are its width and height.
|
|
505
|
+
*
|
|
506
|
+
* @param either CORNER, CORNERS, or CENTER.
|
|
507
|
+
* @example <div>
|
|
508
|
+
* <code>
|
|
509
|
+
* let img;
|
|
510
|
+
*
|
|
511
|
+
* async function setup() {
|
|
512
|
+
* // Load the image.
|
|
513
|
+
* img = await loadImage('assets/bricks.jpg');
|
|
514
|
+
*
|
|
515
|
+
* createCanvas(100, 100);
|
|
516
|
+
*
|
|
517
|
+
* background(200);
|
|
518
|
+
*
|
|
519
|
+
* // Use CORNER mode.
|
|
520
|
+
* imageMode(CORNER);
|
|
521
|
+
*
|
|
522
|
+
* // Display the image.
|
|
523
|
+
* image(img, 10, 10, 50, 50);
|
|
524
|
+
*
|
|
525
|
+
* describe('A square image of a brick wall is drawn at the top left of a gray square.');
|
|
526
|
+
* }
|
|
527
|
+
* </code>
|
|
528
|
+
* </div>
|
|
529
|
+
*
|
|
530
|
+
* <div>
|
|
531
|
+
* <code>
|
|
532
|
+
* let img;
|
|
533
|
+
*
|
|
534
|
+
* async function setup() {
|
|
535
|
+
* // Load the image.
|
|
536
|
+
* img = await loadImage('assets/bricks.jpg');
|
|
537
|
+
*
|
|
538
|
+
* createCanvas(100, 100);
|
|
539
|
+
*
|
|
540
|
+
* background(200);
|
|
541
|
+
*
|
|
542
|
+
* // Use CORNERS mode.
|
|
543
|
+
* imageMode(CORNERS);
|
|
544
|
+
*
|
|
545
|
+
* // Display the image.
|
|
546
|
+
* image(img, 10, 10, 90, 40);
|
|
547
|
+
*
|
|
548
|
+
* describe('An image of a brick wall is drawn on a gray square. The image is squeezed into a small rectangular area.');
|
|
549
|
+
* }
|
|
550
|
+
* </code>
|
|
551
|
+
* </div>
|
|
552
|
+
*
|
|
553
|
+
* <div>
|
|
554
|
+
* <code>
|
|
555
|
+
* let img;
|
|
556
|
+
*
|
|
557
|
+
* async function setup() {
|
|
558
|
+
* // Load the image.
|
|
559
|
+
* img = await loadImage('assets/bricks.jpg');
|
|
560
|
+
*
|
|
561
|
+
* createCanvas(100, 100);
|
|
562
|
+
*
|
|
563
|
+
* background(200);
|
|
564
|
+
*
|
|
565
|
+
* // Use CENTER mode.
|
|
566
|
+
* imageMode(CENTER);
|
|
567
|
+
*
|
|
568
|
+
* // Display the image.
|
|
569
|
+
* image(img, 50, 50, 80, 80);
|
|
570
|
+
*
|
|
571
|
+
* describe('A square image of a brick wall is drawn on a gray square.');
|
|
572
|
+
* }
|
|
573
|
+
* </code>
|
|
574
|
+
* </div>
|
|
575
|
+
*/
|
|
576
|
+
function imageMode(mode: CORNER | CORNERS | CENTER): void;
|
|
577
|
+
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
export default function loading_displaying(p5: any, fn: any): void;
|