p5 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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-tYr0tCl8.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 +41 -75
- 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 +1 -2
- 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-CAxvgiOV.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-Swjl9HQO.js} +5 -5
- package/dist/{rendering--aAe5aq3.js → rendering-B5TRR7aY.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 +4 -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 +273 -225
- package/lib/p5.js +273 -225
- 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 +5996 -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 +499 -0
- package/types/events/pointer.d.ts +782 -0
- package/types/global.d.ts +5542 -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 +6663 -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 +481 -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,668 @@
|
|
|
1
|
+
// This file is auto-generated from JSDoc documentation
|
|
2
|
+
|
|
3
|
+
import p5 from 'p5';
|
|
4
|
+
|
|
5
|
+
declare module 'p5' {
|
|
6
|
+
/**
|
|
7
|
+
* Displays text in the web browser's console.`print()` is helpful for printing values while debugging. Each call to
|
|
8
|
+
* `print()` creates a new line of text.Note: Call `print('\n')` to print a blank line. Calling `print()` without
|
|
9
|
+
* an argument opens the browser's dialog for printing documents.
|
|
10
|
+
*
|
|
11
|
+
* @param content to print to the console.
|
|
12
|
+
* @example <div class="norender">
|
|
13
|
+
* <code>
|
|
14
|
+
* function setup() {
|
|
15
|
+
* // Prints "hello, world" to the console.
|
|
16
|
+
* print('hello, world');
|
|
17
|
+
* }
|
|
18
|
+
* </code>
|
|
19
|
+
* </div>
|
|
20
|
+
*
|
|
21
|
+
* <div class="norender">
|
|
22
|
+
* <code>
|
|
23
|
+
* function setup() {
|
|
24
|
+
* let name = 'ada';
|
|
25
|
+
* // Prints "hello, ada" to the console.
|
|
26
|
+
* print(`hello, ${name}`);
|
|
27
|
+
* }
|
|
28
|
+
* </code>
|
|
29
|
+
* </div>
|
|
30
|
+
*/
|
|
31
|
+
function print(contents: Any): void;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Called upon each p5 instantiation instead of module import due to the
|
|
35
|
+
* possibility of the window being resized when no sketch is active.
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
function _updateWindowSize(): void;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Changes the cursor's appearance.The first parameter, `type`, sets the type of cursor to display. The
|
|
42
|
+
* built-in options are `ARROW`, `CROSS`, `HAND`, `MOVE`, `TEXT`, and `WAIT`.
|
|
43
|
+
* `cursor()` also recognizes standard CSS cursor properties passed as
|
|
44
|
+
* strings: `'help'`, `'wait'`, `'crosshair'`, `'not-allowed'`, `'zoom-in'`,
|
|
45
|
+
* and `'grab'`. If the path to an image is passed, as in
|
|
46
|
+
* `cursor('assets/target.png')`, then the image will be used as the cursor.
|
|
47
|
+
* Images must be in .cur, .gif, .jpg, .jpeg, or .png format and should be at most 32 by 32 pixels large.The parameters `x` and `y` are optional. If an image is used for the
|
|
48
|
+
* cursor, `x` and `y` set the location pointed to within the image. They are
|
|
49
|
+
* both 0 by default, so the cursor points to the image's top-left corner. `x`
|
|
50
|
+
* and `y` must be less than the image's width and height, respectively.
|
|
51
|
+
*
|
|
52
|
+
* @param Built-in: either ARROW, CROSS, HAND, MOVE, TEXT, or WAIT.
|
|
53
|
+
* Native CSS properties: 'grab', 'progress', and so on.
|
|
54
|
+
* Path to cursor image.
|
|
55
|
+
* @param horizontal active spot of the cursor.
|
|
56
|
+
* @param vertical active spot of the cursor.
|
|
57
|
+
* @example <div>
|
|
58
|
+
* <code>
|
|
59
|
+
* function setup() {
|
|
60
|
+
* createCanvas(100, 100);
|
|
61
|
+
*
|
|
62
|
+
* describe('A gray square. The cursor appears as crosshairs.');
|
|
63
|
+
* }
|
|
64
|
+
*
|
|
65
|
+
* function draw() {
|
|
66
|
+
* background(200);
|
|
67
|
+
*
|
|
68
|
+
* // Set the cursor to crosshairs: +
|
|
69
|
+
* cursor(CROSS);
|
|
70
|
+
* }
|
|
71
|
+
* </code>
|
|
72
|
+
* </div>
|
|
73
|
+
*
|
|
74
|
+
* <div>
|
|
75
|
+
* <code>
|
|
76
|
+
* function setup() {
|
|
77
|
+
* createCanvas(100, 100);
|
|
78
|
+
*
|
|
79
|
+
* describe('A gray square divided into quadrants. The cursor image changes when the mouse moves to each quadrant.');
|
|
80
|
+
* }
|
|
81
|
+
*
|
|
82
|
+
* function draw() {
|
|
83
|
+
* background(200);
|
|
84
|
+
*
|
|
85
|
+
* // Divide the canvas into quadrants.
|
|
86
|
+
* line(50, 0, 50, 100);
|
|
87
|
+
* line(0, 50, 100, 50);
|
|
88
|
+
*
|
|
89
|
+
* // Change cursor based on mouse position.
|
|
90
|
+
* if (mouseX < 50 && mouseY < 50) {
|
|
91
|
+
* cursor(CROSS);
|
|
92
|
+
* } else if (mouseX > 50 && mouseY < 50) {
|
|
93
|
+
* cursor('progress');
|
|
94
|
+
* } else if (mouseX > 50 && mouseY > 50) {
|
|
95
|
+
* cursor('https://avatars0.githubusercontent.com/u/1617169?s=16');
|
|
96
|
+
* } else {
|
|
97
|
+
* cursor('grab');
|
|
98
|
+
* }
|
|
99
|
+
* }
|
|
100
|
+
* </code>
|
|
101
|
+
* </div>
|
|
102
|
+
*
|
|
103
|
+
* <div>
|
|
104
|
+
* <code>
|
|
105
|
+
* function setup() {
|
|
106
|
+
* createCanvas(100, 100);
|
|
107
|
+
*
|
|
108
|
+
* describe('An image of three purple curves follows the mouse. The image shifts when the mouse is pressed.');
|
|
109
|
+
* }
|
|
110
|
+
*
|
|
111
|
+
* function draw() {
|
|
112
|
+
* background(200);
|
|
113
|
+
*
|
|
114
|
+
* // Change the cursor's active spot
|
|
115
|
+
* // when the mouse is pressed.
|
|
116
|
+
* if (mouseIsPressed === true) {
|
|
117
|
+
* cursor('https://avatars0.githubusercontent.com/u/1617169?s=16', 8, 8);
|
|
118
|
+
* } else {
|
|
119
|
+
* cursor('https://avatars0.githubusercontent.com/u/1617169?s=16');
|
|
120
|
+
* }
|
|
121
|
+
* }
|
|
122
|
+
* </code>
|
|
123
|
+
* </div>
|
|
124
|
+
*/
|
|
125
|
+
function cursor(type: ARROW | CROSS | HAND | MOVE | TEXT | WAIT | string, x?: number, y?: number): void;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Sets the number of frames to draw per second.Calling `frameRate()` with one numeric argument, as in `frameRate(30)`,
|
|
129
|
+
* attempts to draw 30 frames per second (FPS). The target frame rate may not
|
|
130
|
+
* be achieved depending on the sketch's processing needs. Most computers
|
|
131
|
+
* default to a frame rate of 60 FPS. Frame rates of 24 FPS and above are
|
|
132
|
+
* fast enough for smooth animations.Calling `frameRate()` without an argument returns the current frame rate.
|
|
133
|
+
* The value returned is an approximation.
|
|
134
|
+
*
|
|
135
|
+
* @param number of frames to draw per second.
|
|
136
|
+
* @example <div>
|
|
137
|
+
* <code>
|
|
138
|
+
* function setup() {
|
|
139
|
+
* createCanvas(100, 100);
|
|
140
|
+
*
|
|
141
|
+
* describe('A white circle on a gray background. The circle moves from left to right in a loop. It slows down when the mouse is pressed.');
|
|
142
|
+
* }
|
|
143
|
+
*
|
|
144
|
+
* function draw() {
|
|
145
|
+
* background(200);
|
|
146
|
+
*
|
|
147
|
+
* // Set the x variable based
|
|
148
|
+
* // on the current frameCount.
|
|
149
|
+
* let x = frameCount % 100;
|
|
150
|
+
*
|
|
151
|
+
* // If the mouse is pressed,
|
|
152
|
+
* // decrease the frame rate.
|
|
153
|
+
* if (mouseIsPressed === true) {
|
|
154
|
+
* frameRate(10);
|
|
155
|
+
* } else {
|
|
156
|
+
* frameRate(60);
|
|
157
|
+
* }
|
|
158
|
+
*
|
|
159
|
+
* // Use x to set the circle's
|
|
160
|
+
* // position.
|
|
161
|
+
* circle(x, 50, 20);
|
|
162
|
+
* }
|
|
163
|
+
* </code>
|
|
164
|
+
* </div>
|
|
165
|
+
*
|
|
166
|
+
* <div>
|
|
167
|
+
* <code>
|
|
168
|
+
* function setup() {
|
|
169
|
+
* createCanvas(100, 100);
|
|
170
|
+
*
|
|
171
|
+
* describe('A number written in black on a gray background. The number decreases when the mouse is pressed.');
|
|
172
|
+
* }
|
|
173
|
+
*
|
|
174
|
+
* function draw() {
|
|
175
|
+
* background(200);
|
|
176
|
+
*
|
|
177
|
+
* // If the mouse is pressed, do lots
|
|
178
|
+
* // of math to slow down drawing.
|
|
179
|
+
* if (mouseIsPressed === true) {
|
|
180
|
+
* for (let i = 0; i < 1000000; i += 1) {
|
|
181
|
+
* random();
|
|
182
|
+
* }
|
|
183
|
+
* }
|
|
184
|
+
*
|
|
185
|
+
* // Get the current frame rate
|
|
186
|
+
* // and display it.
|
|
187
|
+
* let fps = frameRate();
|
|
188
|
+
* text(fps, 50, 50);
|
|
189
|
+
* }
|
|
190
|
+
* </code>
|
|
191
|
+
* </div>
|
|
192
|
+
*/
|
|
193
|
+
function frameRate(fps: number): void;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @return current frame rate.
|
|
197
|
+
*/
|
|
198
|
+
function frameRate(): number;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Returns the target frame rate.The value is either the system frame rate or the last value passed to
|
|
202
|
+
* frameRate().
|
|
203
|
+
*
|
|
204
|
+
* @return _targetFrameRate
|
|
205
|
+
* @example <div>
|
|
206
|
+
* <code>
|
|
207
|
+
* function setup() {
|
|
208
|
+
* createCanvas(100, 100);
|
|
209
|
+
*
|
|
210
|
+
* describe('The number 20 written in black on a gray background.');
|
|
211
|
+
* }
|
|
212
|
+
*
|
|
213
|
+
* function draw() {
|
|
214
|
+
* background(200);
|
|
215
|
+
*
|
|
216
|
+
* // Set the frame rate to 20.
|
|
217
|
+
* frameRate(20);
|
|
218
|
+
*
|
|
219
|
+
* // Get the target frame rate and
|
|
220
|
+
* // display it.
|
|
221
|
+
* let fps = getTargetFrameRate();
|
|
222
|
+
* text(fps, 43, 54);
|
|
223
|
+
* }
|
|
224
|
+
* </code>
|
|
225
|
+
* </div>
|
|
226
|
+
*/
|
|
227
|
+
function getTargetFrameRate(): number;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Hides the cursor from view.
|
|
231
|
+
*
|
|
232
|
+
* @example <div>
|
|
233
|
+
* <code>
|
|
234
|
+
* function setup() {
|
|
235
|
+
* // Hide the cursor.
|
|
236
|
+
* noCursor();
|
|
237
|
+
* }
|
|
238
|
+
*
|
|
239
|
+
* function draw() {
|
|
240
|
+
* background(200);
|
|
241
|
+
*
|
|
242
|
+
* circle(mouseX, mouseY, 10);
|
|
243
|
+
*
|
|
244
|
+
* describe('A white circle on a gray background. The circle follows the mouse as it moves. The cursor is hidden.');
|
|
245
|
+
* }
|
|
246
|
+
* </code>
|
|
247
|
+
* </div>
|
|
248
|
+
*/
|
|
249
|
+
function noCursor(): void;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* A function that's called when the browser window is resized.Code placed in the body of `windowResized()` will run when the
|
|
253
|
+
* browser window's size changes. It's a good place to call
|
|
254
|
+
* resizeCanvas() or make other
|
|
255
|
+
* adjustments to accommodate the new window size.The `event` parameter is optional. If added to the function declaration, it
|
|
256
|
+
* can be used for debugging or other purposes.
|
|
257
|
+
*
|
|
258
|
+
* @param optional resize Event.
|
|
259
|
+
* @example <div class="norender">
|
|
260
|
+
* <code>
|
|
261
|
+
* function setup() {
|
|
262
|
+
* createCanvas(windowWidth, windowHeight);
|
|
263
|
+
*
|
|
264
|
+
* describe('A gray canvas with a white circle at its center. The canvas takes up the entire browser window. It changes size to match the browser window.');
|
|
265
|
+
* }
|
|
266
|
+
*
|
|
267
|
+
* function draw() {
|
|
268
|
+
* background(200);
|
|
269
|
+
*
|
|
270
|
+
* // Draw a circle at the center.
|
|
271
|
+
* circle(width / 2, height / 2, 50);
|
|
272
|
+
* }
|
|
273
|
+
*
|
|
274
|
+
* // Resize the canvas when the
|
|
275
|
+
* // browser's size changes.
|
|
276
|
+
* function windowResized() {
|
|
277
|
+
* resizeCanvas(windowWidth, windowHeight);
|
|
278
|
+
* }
|
|
279
|
+
* </code>
|
|
280
|
+
* </div>
|
|
281
|
+
* @alt This example does not render anything.
|
|
282
|
+
*
|
|
283
|
+
* <div class="norender">
|
|
284
|
+
* <code>
|
|
285
|
+
* function setup() {
|
|
286
|
+
* createCanvas(windowWidth, windowHeight);
|
|
287
|
+
* }
|
|
288
|
+
*
|
|
289
|
+
* function draw() {
|
|
290
|
+
* background(200);
|
|
291
|
+
*
|
|
292
|
+
* describe('A gray canvas that takes up the entire browser window. It changes size to match the browser window.');
|
|
293
|
+
* }
|
|
294
|
+
*
|
|
295
|
+
* function windowResized(event) {
|
|
296
|
+
* // Resize the canvas when the
|
|
297
|
+
* // browser's size changes.
|
|
298
|
+
* resizeCanvas(windowWidth, windowHeight);
|
|
299
|
+
*
|
|
300
|
+
* // Print the resize event to the console for debugging.
|
|
301
|
+
* print(event);
|
|
302
|
+
* }
|
|
303
|
+
* </code>
|
|
304
|
+
* </div>
|
|
305
|
+
* @alt This example does not render anything.
|
|
306
|
+
*/
|
|
307
|
+
function windowResized(event?: UIEvent): void;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Toggles full-screen mode or returns the current mode.Calling `fullscreen(true)` makes the sketch full-screen. Calling
|
|
311
|
+
* `fullscreen(false)` makes the sketch its original size.Calling `fullscreen()` without an argument returns `true` if the sketch
|
|
312
|
+
* is in full-screen mode and `false` if not.Note: Due to browser restrictions, `fullscreen()` can only be called with
|
|
313
|
+
* user input such as a mouse press.
|
|
314
|
+
*
|
|
315
|
+
* @param whether the sketch should be in fullscreen mode.
|
|
316
|
+
* @return current fullscreen state.
|
|
317
|
+
* @example <div>
|
|
318
|
+
* <code>
|
|
319
|
+
* function setup() {
|
|
320
|
+
* background(200);
|
|
321
|
+
*
|
|
322
|
+
* describe('A gray canvas that switches between default and full-screen display when clicked.');
|
|
323
|
+
* }
|
|
324
|
+
*
|
|
325
|
+
* // If the mouse is pressed,
|
|
326
|
+
* // toggle full-screen mode.
|
|
327
|
+
* function mousePressed() {
|
|
328
|
+
* if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {
|
|
329
|
+
* let fs = fullscreen();
|
|
330
|
+
* fullscreen(!fs);
|
|
331
|
+
* }
|
|
332
|
+
* }
|
|
333
|
+
* </code>
|
|
334
|
+
* </div>
|
|
335
|
+
*/
|
|
336
|
+
function fullscreen(val?: boolean): boolean;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Sets the pixel density or returns the current density.Computer displays are grids of little lights called pixels. A
|
|
340
|
+
* display's pixel density describes how many pixels it packs into an
|
|
341
|
+
* area. Displays with smaller pixels have a higher pixel density and create
|
|
342
|
+
* sharper images.`pixelDensity()` sets the pixel scaling for high pixel density displays.
|
|
343
|
+
* By default, the pixel density is set to match the display's density.
|
|
344
|
+
* Calling `pixelDensity(1)` turn this off.Calling `pixelDensity()` without an argument returns the current pixel
|
|
345
|
+
* density.
|
|
346
|
+
*
|
|
347
|
+
* @param desired pixel density.
|
|
348
|
+
* @example <div>
|
|
349
|
+
* <code>
|
|
350
|
+
* function setup() {
|
|
351
|
+
* // Set the pixel density to 1.
|
|
352
|
+
* pixelDensity(1);
|
|
353
|
+
*
|
|
354
|
+
* // Create a canvas and draw
|
|
355
|
+
* // a circle.
|
|
356
|
+
* createCanvas(100, 100);
|
|
357
|
+
* background(200);
|
|
358
|
+
* circle(50, 50, 70);
|
|
359
|
+
*
|
|
360
|
+
* describe('A fuzzy white circle on a gray canvas.');
|
|
361
|
+
* }
|
|
362
|
+
* </code>
|
|
363
|
+
* </div>
|
|
364
|
+
*
|
|
365
|
+
* <div>
|
|
366
|
+
* <code>
|
|
367
|
+
* function setup() {
|
|
368
|
+
* // Set the pixel density to 3.
|
|
369
|
+
* pixelDensity(3);
|
|
370
|
+
*
|
|
371
|
+
* // Create a canvas, paint the
|
|
372
|
+
* // background, and draw a
|
|
373
|
+
* // circle.
|
|
374
|
+
* createCanvas(100, 100);
|
|
375
|
+
* background(200);
|
|
376
|
+
* circle(50, 50, 70);
|
|
377
|
+
*
|
|
378
|
+
* describe('A sharp white circle on a gray canvas.');
|
|
379
|
+
* }
|
|
380
|
+
* </code>
|
|
381
|
+
* </div>
|
|
382
|
+
*/
|
|
383
|
+
function pixelDensity(val?: number): void;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* @returns current pixel density of the sketch.
|
|
387
|
+
*/
|
|
388
|
+
function pixelDensity(): number;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Returns the display's current pixel density.
|
|
392
|
+
*
|
|
393
|
+
* @returns current pixel density of the display.
|
|
394
|
+
* @example <div>
|
|
395
|
+
* <code>
|
|
396
|
+
* function setup() {
|
|
397
|
+
* // Set the pixel density to 1.
|
|
398
|
+
* pixelDensity(1);
|
|
399
|
+
*
|
|
400
|
+
* // Create a canvas and draw
|
|
401
|
+
* // a circle.
|
|
402
|
+
* createCanvas(100, 100);
|
|
403
|
+
* background(200);
|
|
404
|
+
* circle(50, 50, 70);
|
|
405
|
+
*
|
|
406
|
+
* describe('A fuzzy white circle drawn on a gray background. The circle becomes sharper when the mouse is pressed.');
|
|
407
|
+
* }
|
|
408
|
+
*
|
|
409
|
+
* function mousePressed() {
|
|
410
|
+
* // Get the current display density.
|
|
411
|
+
* let d = displayDensity();
|
|
412
|
+
*
|
|
413
|
+
* // Use the display density to set
|
|
414
|
+
* // the sketch's pixel density.
|
|
415
|
+
* pixelDensity(d);
|
|
416
|
+
*
|
|
417
|
+
* // Paint the background and
|
|
418
|
+
* // draw a circle.
|
|
419
|
+
* background(200);
|
|
420
|
+
* circle(50, 50, 70);
|
|
421
|
+
* }
|
|
422
|
+
* </code>
|
|
423
|
+
* </div>
|
|
424
|
+
*/
|
|
425
|
+
function displayDensity(): number;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Returns the sketch's current
|
|
429
|
+
* URL
|
|
430
|
+
* as a `String`.
|
|
431
|
+
*
|
|
432
|
+
* @return url
|
|
433
|
+
* @example <div>
|
|
434
|
+
* <code>
|
|
435
|
+
* function setup() {
|
|
436
|
+
* background(200);
|
|
437
|
+
*
|
|
438
|
+
* // Get the sketch's URL
|
|
439
|
+
* // and display it.
|
|
440
|
+
* let url = getURL();
|
|
441
|
+
* textWrap(CHAR);
|
|
442
|
+
* text(url, 0, 40, 100);
|
|
443
|
+
*
|
|
444
|
+
* describe('The URL "https://p5js.org/reference/p5/getURL" written in black on a gray background.');
|
|
445
|
+
* }
|
|
446
|
+
* </code>
|
|
447
|
+
* </div>
|
|
448
|
+
*/
|
|
449
|
+
function getURL(): string;
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Returns the current
|
|
453
|
+
* URL
|
|
454
|
+
* path as an `Array` of `String`s.For example, consider a sketch hosted at the URL
|
|
455
|
+
* `https://example.com/sketchbook`. Calling `getURLPath()` returns
|
|
456
|
+
* `['sketchbook']`. For a sketch hosted at the URL
|
|
457
|
+
* `https://example.com/sketchbook/monday`, `getURLPath()` returns
|
|
458
|
+
* `['sketchbook', 'monday']`.
|
|
459
|
+
*
|
|
460
|
+
* @return path components.
|
|
461
|
+
* @example <div>
|
|
462
|
+
* <code>
|
|
463
|
+
* function setup() {
|
|
464
|
+
* background(200);
|
|
465
|
+
*
|
|
466
|
+
* // Get the sketch's URL path
|
|
467
|
+
* // and display the first
|
|
468
|
+
* // part.
|
|
469
|
+
* let path = getURLPath();
|
|
470
|
+
* text(path[0], 25, 54);
|
|
471
|
+
*
|
|
472
|
+
* describe('The word "reference" written in black on a gray background.');
|
|
473
|
+
* }
|
|
474
|
+
* </code>
|
|
475
|
+
* </div>
|
|
476
|
+
*/
|
|
477
|
+
function getURLPath(): string[];
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Returns the current
|
|
481
|
+
* URL parameters
|
|
482
|
+
* in an `Object`.For example, calling `getURLParams()` in a sketch hosted at the URL
|
|
483
|
+
* `https://p5js.org?year=2014&month=May&day=15` returns
|
|
484
|
+
* `{ year: 2014, month: 'May', day: 15 }`.
|
|
485
|
+
*
|
|
486
|
+
* @return URL params
|
|
487
|
+
* @example <div class='norender notest'>
|
|
488
|
+
* <code>
|
|
489
|
+
* // Imagine this sketch is hosted at the following URL:
|
|
490
|
+
* // https://p5js.org?year=2014&month=May&day=15
|
|
491
|
+
*
|
|
492
|
+
* function setup() {
|
|
493
|
+
* background(200);
|
|
494
|
+
*
|
|
495
|
+
* // Get the sketch's URL
|
|
496
|
+
* // parameters and display
|
|
497
|
+
* // them.
|
|
498
|
+
* let params = getURLParams();
|
|
499
|
+
* text(params.day, 10, 20);
|
|
500
|
+
* text(params.month, 10, 40);
|
|
501
|
+
* text(params.year, 10, 60);
|
|
502
|
+
*
|
|
503
|
+
* describe('The text "15", "May", and "2014" written in black on separate lines.');
|
|
504
|
+
* }
|
|
505
|
+
* </code>
|
|
506
|
+
* </div>
|
|
507
|
+
* @alt This example does not render anything.
|
|
508
|
+
*/
|
|
509
|
+
function getURLParams(): object;
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Converts 3D world coordinates to 2D screen coordinates.This function takes a 3D vector and converts its coordinates
|
|
513
|
+
* from the world space to screen space. This can be useful for placing
|
|
514
|
+
* 2D elements in a 3D scene or for determining the screen position
|
|
515
|
+
* of 3D objects.
|
|
516
|
+
*
|
|
517
|
+
* @param The x coordinate in world space. (Or a vector for all three coordinates.)
|
|
518
|
+
* @param The y coordinate in world space.
|
|
519
|
+
* @param The z coordinate in world space.
|
|
520
|
+
* @return A vector containing the 2D screen coordinates.
|
|
521
|
+
* @example <div>
|
|
522
|
+
* <code>
|
|
523
|
+
*
|
|
524
|
+
* function setup() {
|
|
525
|
+
* createCanvas(150, 150);
|
|
526
|
+
* let vertices = [
|
|
527
|
+
* createVector(-20, -20),
|
|
528
|
+
* createVector(20, -20),
|
|
529
|
+
* createVector(20, 20),
|
|
530
|
+
* createVector(-20, 20)
|
|
531
|
+
* ];
|
|
532
|
+
*
|
|
533
|
+
* push();
|
|
534
|
+
* translate(75, 55);
|
|
535
|
+
* rotate(PI / 4);
|
|
536
|
+
*
|
|
537
|
+
* // Convert world coordinates to screen coordinates
|
|
538
|
+
* let screenPos = vertices.map(v => worldToScreen(v));
|
|
539
|
+
* pop();
|
|
540
|
+
*
|
|
541
|
+
* background(200);
|
|
542
|
+
*
|
|
543
|
+
* stroke(0);
|
|
544
|
+
* fill(100, 150, 255, 100);
|
|
545
|
+
* beginShape();
|
|
546
|
+
* screenPos.forEach(pos => vertex(pos.x, pos.y));
|
|
547
|
+
* endShape(CLOSE);
|
|
548
|
+
*
|
|
549
|
+
* screenPos.forEach((pos, i) => {
|
|
550
|
+
* fill(0);
|
|
551
|
+
* textSize(10);
|
|
552
|
+
* if (i === 0) {
|
|
553
|
+
* text(i + 1, pos.x + 3, pos.y - 7);
|
|
554
|
+
* } else if (i === 1) {
|
|
555
|
+
* text(i + 1, pos.x + 7, pos.y + 2);
|
|
556
|
+
* } else if (i === 2) {
|
|
557
|
+
* text(i + 1, pos.x - 2, pos.y + 12);
|
|
558
|
+
* } else if (i === 3) {
|
|
559
|
+
* text(i + 1, pos.x - 12, pos.y - 2);
|
|
560
|
+
* }
|
|
561
|
+
* });
|
|
562
|
+
*
|
|
563
|
+
* fill(0);
|
|
564
|
+
* noStroke();
|
|
565
|
+
* textSize(10);
|
|
566
|
+
* let legendY = height - 35;
|
|
567
|
+
* screenPos.forEach((pos, i) => {
|
|
568
|
+
* text(`Vertex ${i + 1}: (${pos.x.toFixed(1)}, ${pos.y.toFixed(1)})`, 5, legendY + i * 10);
|
|
569
|
+
* });
|
|
570
|
+
*
|
|
571
|
+
* describe('A rotating square is transformed and drawn using screen coordinates.');
|
|
572
|
+
*
|
|
573
|
+
* }
|
|
574
|
+
* </code>
|
|
575
|
+
* </div>
|
|
576
|
+
* @example <div>
|
|
577
|
+
* <code>
|
|
578
|
+
* let vertices;
|
|
579
|
+
*
|
|
580
|
+
* function setup() {
|
|
581
|
+
* createCanvas(100, 100, WEBGL);
|
|
582
|
+
* vertices = [
|
|
583
|
+
* createVector(-25, -25, -25),
|
|
584
|
+
* createVector(25, -25, -25),
|
|
585
|
+
* createVector(25, 25, -25),
|
|
586
|
+
* createVector(-25, 25, -25),
|
|
587
|
+
* createVector(-25, -25, 25),
|
|
588
|
+
* createVector(25, -25, 25),
|
|
589
|
+
* createVector(25, 25, 25),
|
|
590
|
+
* createVector(-25, 25, 25)
|
|
591
|
+
* ];
|
|
592
|
+
*
|
|
593
|
+
* describe('A rotating cube with points mapped to 2D screen space and displayed as ellipses.');
|
|
594
|
+
*
|
|
595
|
+
* }
|
|
596
|
+
*
|
|
597
|
+
* function draw() {
|
|
598
|
+
* background(200);
|
|
599
|
+
*
|
|
600
|
+
* // Animate rotation
|
|
601
|
+
* let rotationX = millis() / 1000;
|
|
602
|
+
* let rotationY = millis() / 1200;
|
|
603
|
+
*
|
|
604
|
+
* push();
|
|
605
|
+
*
|
|
606
|
+
* rotateX(rotationX);
|
|
607
|
+
* rotateY(rotationY);
|
|
608
|
+
*
|
|
609
|
+
* // Convert world coordinates to screen coordinates
|
|
610
|
+
* let screenPos = vertices.map(v => worldToScreen(v));
|
|
611
|
+
*
|
|
612
|
+
* pop();
|
|
613
|
+
*
|
|
614
|
+
* screenPos.forEach((pos, i) => {
|
|
615
|
+
*
|
|
616
|
+
* let screenX = pos.x - width / 2;
|
|
617
|
+
* let screenY = pos.y - height / 2;
|
|
618
|
+
* fill(0);
|
|
619
|
+
* noStroke();
|
|
620
|
+
* ellipse(screenX, screenY, 3, 3);
|
|
621
|
+
* });
|
|
622
|
+
* }
|
|
623
|
+
* </code>
|
|
624
|
+
* </div>
|
|
625
|
+
*/
|
|
626
|
+
function worldToScreen(x: number | p5.Vector, y: number, z?: number): p5.Vector;
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Converts 2D screen coordinates to 3D world coordinates.This function takes a vector and converts its coordinates from coordinates
|
|
630
|
+
* on the screen to coordinates in the currently drawn object. This can be
|
|
631
|
+
* useful for determining the mouse position relative to a 2D or 3D object.If given, the Z component of the input coordinates is treated as "depth",
|
|
632
|
+
* or distance from the camera.
|
|
633
|
+
*
|
|
634
|
+
* @param The x coordinate in screen space. (Or a vector for all three coordinates.)
|
|
635
|
+
* @param The y coordinate in screen space.
|
|
636
|
+
* @param The z coordinate in screen space.
|
|
637
|
+
* @return A vector containing the 3D world space coordinates.
|
|
638
|
+
* @example <div>
|
|
639
|
+
* <code>
|
|
640
|
+
*
|
|
641
|
+
* function setup() {
|
|
642
|
+
* createCanvas(100, 100);
|
|
643
|
+
* describe('A rotating square with a line passing through the mouse drawn across it.');
|
|
644
|
+
* }
|
|
645
|
+
*
|
|
646
|
+
* function draw() {
|
|
647
|
+
* background(220);
|
|
648
|
+
*
|
|
649
|
+
* // Move to center and rotate
|
|
650
|
+
* translate(width/2, height/2);
|
|
651
|
+
* rotate(millis() / 1000);
|
|
652
|
+
* rect(-30, -30, 60);
|
|
653
|
+
*
|
|
654
|
+
* // Compute the location of the mouse in the coordinates of the square
|
|
655
|
+
* let localMouse = screenToWorld(createVector(mouseX, mouseY));
|
|
656
|
+
*
|
|
657
|
+
* // Draw a line parallel to the local Y axis, passing through the mouse
|
|
658
|
+
* line(localMouse.x, -30, localMouse.x, 30);
|
|
659
|
+
* }
|
|
660
|
+
*
|
|
661
|
+
* </code>
|
|
662
|
+
* </div>
|
|
663
|
+
*/
|
|
664
|
+
function screenToWorld(x: number | p5.Vector, y: number, z?: number): p5.Vector;
|
|
665
|
+
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
export default function environment(p5: any, fn: any): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
* This is a helper function that generates Zod schemas for a function based on
|
|
9
|
+
* the parameter data from `docs/parameterData.json`.Example parameter data for function `background`:
|
|
10
|
+
* "background": {
|
|
11
|
+
* "overloads": [
|
|
12
|
+
* ["p5.Color"],
|
|
13
|
+
* ["String", "Number?"],
|
|
14
|
+
* ["Number", "Number?"],
|
|
15
|
+
* ["Number", "Number", "Number", "Number?"],
|
|
16
|
+
* ["Number[]"],
|
|
17
|
+
* ["p5.Image", "Number?"]
|
|
18
|
+
* ]
|
|
19
|
+
* }
|
|
20
|
+
* Where each array in `overloads` represents a set of valid overloaded
|
|
21
|
+
* parameters, and `?` is a shorthand for `Optional`.
|
|
22
|
+
*
|
|
23
|
+
* @param Name of the function. Expect global functions like `sin` and class methods like `p5.Vector.add`
|
|
24
|
+
* @returns Zod schema
|
|
25
|
+
*/
|
|
26
|
+
function generateZodSchemasForFunc(func: string): z.ZodSchema;
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default function param_validator(p5: any, fn: any): void;
|