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,492 @@
|
|
|
1
|
+
// This file is auto-generated from JSDoc documentation
|
|
2
|
+
|
|
3
|
+
import p5 from 'p5';
|
|
4
|
+
|
|
5
|
+
declare module 'p5' {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new sketch in "instance" mode.All p5.js sketches are instances of the `p5` class. Put another way, all
|
|
8
|
+
* p5.js sketches are objects with methods including `pInst.setup()`,
|
|
9
|
+
* `pInst.draw()`, `pInst.circle()`, and `pInst.fill()`. By default, sketches
|
|
10
|
+
* run in "global mode" to hide some of this complexity.In global mode, a default instance of the `p5` class is created
|
|
11
|
+
* automatically. The default `p5` instance searches the web page's source
|
|
12
|
+
* code for declarations of system functions such as `setup()`, `draw()`,
|
|
13
|
+
* and `mousePressed()`, then attaches those functions to itself as methods.
|
|
14
|
+
* Calling a function such as `circle()` in global mode actually calls the
|
|
15
|
+
* default `p5` object's `pInst.circle()` method.It's often helpful to isolate the code within sketches from the rest of the
|
|
16
|
+
* code on a web page. Two common use cases are web pages that use other
|
|
17
|
+
* JavaScript libraries and web pages with multiple sketches. "Instance mode"
|
|
18
|
+
* makes it easy to support both of these scenarios.Instance mode sketches support the same API as global mode sketches. They
|
|
19
|
+
* use a function to bundle, or encapsulate, an entire sketch. The function
|
|
20
|
+
* containing the sketch is then passed to the `p5()` constructor.The first parameter, `sketch`, is a function that contains the sketch. For
|
|
21
|
+
* example, the statement `new p5(mySketch)` would create a new instance mode
|
|
22
|
+
* sketch from a function named `mySketch`. The function should have one
|
|
23
|
+
* parameter, `p`, that's a `p5` object.The second parameter, `node`, is optional. If a string is passed, as in
|
|
24
|
+
* `new p5(mySketch, 'sketch-one')` the new instance mode sketch will become a
|
|
25
|
+
* child of the HTML element with the id `sketch-one`. If an HTML element is
|
|
26
|
+
* passed, as in `new p5(mySketch, myElement)`, then the new instance mode
|
|
27
|
+
* sketch will become a child of the `Element` object called `myElement`.
|
|
28
|
+
*
|
|
29
|
+
* @param function containing the sketch.
|
|
30
|
+
* @param ID or reference to the HTML element that will contain the sketch.
|
|
31
|
+
* @example <div class='norender notest'>
|
|
32
|
+
* <code>
|
|
33
|
+
* // Declare the function containing the sketch.
|
|
34
|
+
* function sketch(p) {
|
|
35
|
+
*
|
|
36
|
+
* // Declare the setup() method.
|
|
37
|
+
* p.setup = function () {
|
|
38
|
+
* p.createCanvas(100, 100);
|
|
39
|
+
*
|
|
40
|
+
* p.describe('A white circle drawn on a gray background.');
|
|
41
|
+
* };
|
|
42
|
+
*
|
|
43
|
+
* // Declare the draw() method.
|
|
44
|
+
* p.draw = function () {
|
|
45
|
+
* p.background(200);
|
|
46
|
+
*
|
|
47
|
+
* // Draw the circle.
|
|
48
|
+
* p.circle(50, 50, 20);
|
|
49
|
+
* };
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* // Initialize the sketch.
|
|
53
|
+
* new p5(sketch);
|
|
54
|
+
* </code>
|
|
55
|
+
* </div>
|
|
56
|
+
*
|
|
57
|
+
* <div class='norender notest'>
|
|
58
|
+
* <code>
|
|
59
|
+
* // Declare the function containing the sketch.
|
|
60
|
+
* function sketch(p) {
|
|
61
|
+
* // Create the sketch's variables within its scope.
|
|
62
|
+
* let x = 50;
|
|
63
|
+
* let y = 50;
|
|
64
|
+
*
|
|
65
|
+
* // Declare the setup() method.
|
|
66
|
+
* p.setup = function () {
|
|
67
|
+
* p.createCanvas(100, 100);
|
|
68
|
+
*
|
|
69
|
+
* p.describe('A white circle moves randomly on a gray background.');
|
|
70
|
+
* };
|
|
71
|
+
*
|
|
72
|
+
* // Declare the draw() method.
|
|
73
|
+
* p.draw = function () {
|
|
74
|
+
* p.background(200);
|
|
75
|
+
*
|
|
76
|
+
* // Update x and y.
|
|
77
|
+
* x += p.random(-1, 1);
|
|
78
|
+
* y += p.random(-1, 1);
|
|
79
|
+
*
|
|
80
|
+
* // Draw the circle.
|
|
81
|
+
* p.circle(x, y, 20);
|
|
82
|
+
* };
|
|
83
|
+
* }
|
|
84
|
+
*
|
|
85
|
+
* // Initialize the sketch.
|
|
86
|
+
* new p5(sketch);
|
|
87
|
+
* </code>
|
|
88
|
+
* </div>
|
|
89
|
+
*
|
|
90
|
+
* <div class='norender notest'>
|
|
91
|
+
* <code>
|
|
92
|
+
* // Declare the function containing the sketch.
|
|
93
|
+
* function sketch(p) {
|
|
94
|
+
*
|
|
95
|
+
* // Declare the setup() method.
|
|
96
|
+
* p.setup = function () {
|
|
97
|
+
* p.createCanvas(100, 100);
|
|
98
|
+
*
|
|
99
|
+
* p.describe('A white circle drawn on a gray background.');
|
|
100
|
+
* };
|
|
101
|
+
*
|
|
102
|
+
* // Declare the draw() method.
|
|
103
|
+
* p.draw = function () {
|
|
104
|
+
* p.background(200);
|
|
105
|
+
*
|
|
106
|
+
* // Draw the circle.
|
|
107
|
+
* p.circle(50, 50, 20);
|
|
108
|
+
* };
|
|
109
|
+
* }
|
|
110
|
+
*
|
|
111
|
+
* // Select the web page's body element.
|
|
112
|
+
* let body = document.querySelector('body');
|
|
113
|
+
*
|
|
114
|
+
* // Initialize the sketch and attach it to the web page's body.
|
|
115
|
+
* new p5(sketch, body);
|
|
116
|
+
* </code>
|
|
117
|
+
* </div>
|
|
118
|
+
*
|
|
119
|
+
* <div class='norender notest'>
|
|
120
|
+
* <code>
|
|
121
|
+
* // Declare the function containing the sketch.
|
|
122
|
+
* function sketch(p) {
|
|
123
|
+
*
|
|
124
|
+
* // Declare the setup() method.
|
|
125
|
+
* p.setup = function () {
|
|
126
|
+
* p.createCanvas(100, 100);
|
|
127
|
+
*
|
|
128
|
+
* p.describe(
|
|
129
|
+
* 'A white circle drawn on a gray background. The circle follows the mouse as the user moves.'
|
|
130
|
+
* );
|
|
131
|
+
* };
|
|
132
|
+
*
|
|
133
|
+
* // Declare the draw() method.
|
|
134
|
+
* p.draw = function () {
|
|
135
|
+
* p.background(200);
|
|
136
|
+
*
|
|
137
|
+
* // Draw the circle.
|
|
138
|
+
* p.circle(p.mouseX, p.mouseY, 20);
|
|
139
|
+
* };
|
|
140
|
+
* }
|
|
141
|
+
*
|
|
142
|
+
* // Initialize the sketch.
|
|
143
|
+
* new p5(sketch);
|
|
144
|
+
* </code>
|
|
145
|
+
* </div>
|
|
146
|
+
*
|
|
147
|
+
* <div class='norender notest'>
|
|
148
|
+
* <code>
|
|
149
|
+
* // Declare the function containing the sketch.
|
|
150
|
+
* function sketch(p) {
|
|
151
|
+
*
|
|
152
|
+
* // Declare the setup() method.
|
|
153
|
+
* p.setup = function () {
|
|
154
|
+
* p.createCanvas(100, 100);
|
|
155
|
+
*
|
|
156
|
+
* p.describe(
|
|
157
|
+
* 'A white circle drawn on a gray background. The circle follows the mouse as the user moves. The circle becomes black when the user double-clicks.'
|
|
158
|
+
* );
|
|
159
|
+
* };
|
|
160
|
+
*
|
|
161
|
+
* // Declare the draw() method.
|
|
162
|
+
* p.draw = function () {
|
|
163
|
+
* p.background(200);
|
|
164
|
+
*
|
|
165
|
+
* // Draw the circle.
|
|
166
|
+
* p.circle(p.mouseX, p.mouseY, 20);
|
|
167
|
+
* };
|
|
168
|
+
*
|
|
169
|
+
* // Declare the doubleClicked() method.
|
|
170
|
+
* p.doubleClicked = function () {
|
|
171
|
+
* // Change the fill color when the user double-clicks.
|
|
172
|
+
* p.fill(0);
|
|
173
|
+
* };
|
|
174
|
+
* }
|
|
175
|
+
*
|
|
176
|
+
* // Initialize the sketch.
|
|
177
|
+
* new p5(sketch);
|
|
178
|
+
* </code>
|
|
179
|
+
* </div>
|
|
180
|
+
*/
|
|
181
|
+
function p5: typeof p5
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Stops the code in draw() from running repeatedly.By default, draw() tries to run 60 times per
|
|
185
|
+
* second. Calling `noLoop()` stops draw() from
|
|
186
|
+
* repeating. The draw loop can be restarted by calling
|
|
187
|
+
* loop(). draw() can be run
|
|
188
|
+
* once by calling redraw().The isLooping() function can be used to check
|
|
189
|
+
* whether a sketch is looping, as in `isLooping() === true`.
|
|
190
|
+
*
|
|
191
|
+
* @example <div>
|
|
192
|
+
* <code>
|
|
193
|
+
* function setup() {
|
|
194
|
+
* createCanvas(100, 100);
|
|
195
|
+
*
|
|
196
|
+
* // Turn off the draw loop.
|
|
197
|
+
* noLoop();
|
|
198
|
+
*
|
|
199
|
+
* describe('A white half-circle on the left edge of a gray square.');
|
|
200
|
+
* }
|
|
201
|
+
*
|
|
202
|
+
* function draw() {
|
|
203
|
+
* background(200);
|
|
204
|
+
*
|
|
205
|
+
* // Calculate the circle's x-coordinate.
|
|
206
|
+
* let x = frameCount;
|
|
207
|
+
*
|
|
208
|
+
* // Draw the circle.
|
|
209
|
+
* // Normally, the circle would move from left to right.
|
|
210
|
+
* circle(x, 50, 20);
|
|
211
|
+
* }
|
|
212
|
+
* </code>
|
|
213
|
+
* </div>
|
|
214
|
+
*
|
|
215
|
+
* <div>
|
|
216
|
+
* <code>
|
|
217
|
+
* // Double-click to stop the draw loop.
|
|
218
|
+
*
|
|
219
|
+
* function setup() {
|
|
220
|
+
* createCanvas(100, 100);
|
|
221
|
+
*
|
|
222
|
+
* // Slow the frame rate.
|
|
223
|
+
* frameRate(5);
|
|
224
|
+
*
|
|
225
|
+
* describe('A white circle moves randomly on a gray background. It stops moving when the user double-clicks.');
|
|
226
|
+
* }
|
|
227
|
+
*
|
|
228
|
+
* function draw() {
|
|
229
|
+
* background(200);
|
|
230
|
+
*
|
|
231
|
+
* // Calculate the circle's coordinates.
|
|
232
|
+
* let x = random(0, 100);
|
|
233
|
+
* let y = random(0, 100);
|
|
234
|
+
*
|
|
235
|
+
* // Draw the circle.
|
|
236
|
+
* // Normally, the circle would move from left to right.
|
|
237
|
+
* circle(x, y, 20);
|
|
238
|
+
* }
|
|
239
|
+
*
|
|
240
|
+
* // Stop the draw loop when the user double-clicks.
|
|
241
|
+
* function doubleClicked() {
|
|
242
|
+
* noLoop();
|
|
243
|
+
* }
|
|
244
|
+
* </code>
|
|
245
|
+
* </div>
|
|
246
|
+
*
|
|
247
|
+
* <div>
|
|
248
|
+
* <code>
|
|
249
|
+
* let startButton;
|
|
250
|
+
* let stopButton;
|
|
251
|
+
*
|
|
252
|
+
* function setup() {
|
|
253
|
+
* createCanvas(100, 100);
|
|
254
|
+
*
|
|
255
|
+
* // Create the button elements and place them
|
|
256
|
+
* // beneath the canvas.
|
|
257
|
+
* startButton = createButton('▶');
|
|
258
|
+
* startButton.position(0, 100);
|
|
259
|
+
* startButton.size(50, 20);
|
|
260
|
+
* stopButton = createButton('◾');
|
|
261
|
+
* stopButton.position(50, 100);
|
|
262
|
+
* stopButton.size(50, 20);
|
|
263
|
+
*
|
|
264
|
+
* // Set functions to call when the buttons are pressed.
|
|
265
|
+
* startButton.mousePressed(loop);
|
|
266
|
+
* stopButton.mousePressed(noLoop);
|
|
267
|
+
*
|
|
268
|
+
* // Slow the frame rate.
|
|
269
|
+
* frameRate(5);
|
|
270
|
+
*
|
|
271
|
+
* describe(
|
|
272
|
+
* 'A white circle moves randomly on a gray background. Play and stop buttons are shown beneath the canvas. The circle stops or starts moving when the user presses a button.'
|
|
273
|
+
* );
|
|
274
|
+
* }
|
|
275
|
+
*
|
|
276
|
+
* function draw() {
|
|
277
|
+
* background(200);
|
|
278
|
+
*
|
|
279
|
+
* // Calculate the circle's coordinates.
|
|
280
|
+
* let x = random(0, 100);
|
|
281
|
+
* let y = random(0, 100);
|
|
282
|
+
*
|
|
283
|
+
* // Draw the circle.
|
|
284
|
+
* // Normally, the circle would move from left to right.
|
|
285
|
+
* circle(x, y, 20);
|
|
286
|
+
* }
|
|
287
|
+
* </code>
|
|
288
|
+
* </div>
|
|
289
|
+
*/
|
|
290
|
+
function noLoop(): void;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Resumes the draw loop after noLoop() has been
|
|
294
|
+
* called.By default, draw() tries to run 60 times per
|
|
295
|
+
* second. Calling noLoop() stops
|
|
296
|
+
* draw() from repeating. The draw loop can be
|
|
297
|
+
* restarted by calling `loop()`.The isLooping() function can be used to check
|
|
298
|
+
* whether a sketch is looping, as in `isLooping() === true`.
|
|
299
|
+
*
|
|
300
|
+
* @example <div>
|
|
301
|
+
* <code>
|
|
302
|
+
* function setup() {
|
|
303
|
+
* createCanvas(100, 100);
|
|
304
|
+
*
|
|
305
|
+
* // Turn off the draw loop.
|
|
306
|
+
* noLoop();
|
|
307
|
+
*
|
|
308
|
+
* describe(
|
|
309
|
+
* 'A white half-circle on the left edge of a gray square. The circle starts moving to the right when the user double-clicks.'
|
|
310
|
+
* );
|
|
311
|
+
* }
|
|
312
|
+
*
|
|
313
|
+
* function draw() {
|
|
314
|
+
* background(200);
|
|
315
|
+
*
|
|
316
|
+
* // Calculate the circle's x-coordinate.
|
|
317
|
+
* let x = frameCount;
|
|
318
|
+
*
|
|
319
|
+
* // Draw the circle.
|
|
320
|
+
* circle(x, 50, 20);
|
|
321
|
+
* }
|
|
322
|
+
*
|
|
323
|
+
* // Resume the draw loop when the user double-clicks.
|
|
324
|
+
* function doubleClicked() {
|
|
325
|
+
* loop();
|
|
326
|
+
* }
|
|
327
|
+
* </code>
|
|
328
|
+
* </div>
|
|
329
|
+
*
|
|
330
|
+
* <div>
|
|
331
|
+
* <code>
|
|
332
|
+
* let startButton;
|
|
333
|
+
* let stopButton;
|
|
334
|
+
*
|
|
335
|
+
* function setup() {
|
|
336
|
+
* createCanvas(100, 100);
|
|
337
|
+
*
|
|
338
|
+
* // Create the button elements and place them
|
|
339
|
+
* // beneath the canvas.
|
|
340
|
+
* startButton = createButton('▶');
|
|
341
|
+
* startButton.position(0, 100);
|
|
342
|
+
* startButton.size(50, 20);
|
|
343
|
+
* stopButton = createButton('◾');
|
|
344
|
+
* stopButton.position(50, 100);
|
|
345
|
+
* stopButton.size(50, 20);
|
|
346
|
+
*
|
|
347
|
+
* // Set functions to call when the buttons are pressed.
|
|
348
|
+
* startButton.mousePressed(loop);
|
|
349
|
+
* stopButton.mousePressed(noLoop);
|
|
350
|
+
*
|
|
351
|
+
* // Slow the frame rate.
|
|
352
|
+
* frameRate(5);
|
|
353
|
+
*
|
|
354
|
+
* describe(
|
|
355
|
+
* 'A white circle moves randomly on a gray background. Play and stop buttons are shown beneath the canvas. The circle stops or starts moving when the user presses a button.'
|
|
356
|
+
* );
|
|
357
|
+
* }
|
|
358
|
+
*
|
|
359
|
+
* function draw() {
|
|
360
|
+
* background(200);
|
|
361
|
+
*
|
|
362
|
+
* // Calculate the circle's coordinates.
|
|
363
|
+
* let x = random(0, 100);
|
|
364
|
+
* let y = random(0, 100);
|
|
365
|
+
*
|
|
366
|
+
* // Draw the circle.
|
|
367
|
+
* // Normally, the circle would move from left to right.
|
|
368
|
+
* circle(x, y, 20);
|
|
369
|
+
* }
|
|
370
|
+
* </code>
|
|
371
|
+
* </div>
|
|
372
|
+
*/
|
|
373
|
+
function loop(): void;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Returns `true` if the draw loop is running and `false` if not.By default, draw() tries to run 60 times per
|
|
377
|
+
* second. Calling noLoop() stops
|
|
378
|
+
* draw() from repeating. The draw loop can be
|
|
379
|
+
* restarted by calling loop().The `isLooping()` function can be used to check whether a sketch is
|
|
380
|
+
* looping, as in `isLooping() === true`.
|
|
381
|
+
*
|
|
382
|
+
* @example <div>
|
|
383
|
+
* <code>
|
|
384
|
+
* function setup() {
|
|
385
|
+
* createCanvas(100, 100);
|
|
386
|
+
*
|
|
387
|
+
* describe('A white circle drawn against a gray background. When the user double-clicks, the circle stops or resumes following the mouse.');
|
|
388
|
+
* }
|
|
389
|
+
*
|
|
390
|
+
* function draw() {
|
|
391
|
+
* background(200);
|
|
392
|
+
*
|
|
393
|
+
* // Draw the circle at the mouse's position.
|
|
394
|
+
* circle(mouseX, mouseY, 20);
|
|
395
|
+
* }
|
|
396
|
+
*
|
|
397
|
+
* // Toggle the draw loop when the user double-clicks.
|
|
398
|
+
* function doubleClicked() {
|
|
399
|
+
* if (isLooping() === true) {
|
|
400
|
+
* noLoop();
|
|
401
|
+
* } else {
|
|
402
|
+
* loop();
|
|
403
|
+
* }
|
|
404
|
+
* }
|
|
405
|
+
* </code>
|
|
406
|
+
* </div>
|
|
407
|
+
*/
|
|
408
|
+
function isLooping(): boolean;
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Runs the code in draw() once.By default, draw() tries to run 60 times per
|
|
412
|
+
* second. Calling noLoop() stops
|
|
413
|
+
* draw() from repeating. Calling `redraw()` will
|
|
414
|
+
* execute the code in the draw() function a set
|
|
415
|
+
* number of times.The parameter, `n`, is optional. If a number is passed, as in `redraw(5)`,
|
|
416
|
+
* then the draw loop will run the given number of times. By default, `n` is
|
|
417
|
+
* 1.
|
|
418
|
+
*
|
|
419
|
+
* @param number of times to run <a href="#/p5/draw">draw()</a>. Defaults to 1.
|
|
420
|
+
* @example <div>
|
|
421
|
+
* <code>
|
|
422
|
+
* // Double-click the canvas to move the circle.
|
|
423
|
+
*
|
|
424
|
+
* let x = 0;
|
|
425
|
+
*
|
|
426
|
+
* function setup() {
|
|
427
|
+
* createCanvas(100, 100);
|
|
428
|
+
*
|
|
429
|
+
* // Turn off the draw loop.
|
|
430
|
+
* noLoop();
|
|
431
|
+
*
|
|
432
|
+
* describe(
|
|
433
|
+
* 'A white half-circle on the left edge of a gray square. The circle moves a little to the right when the user double-clicks.'
|
|
434
|
+
* );
|
|
435
|
+
* }
|
|
436
|
+
*
|
|
437
|
+
* function draw() {
|
|
438
|
+
* background(200);
|
|
439
|
+
*
|
|
440
|
+
* // Draw the circle.
|
|
441
|
+
* circle(x, 50, 20);
|
|
442
|
+
*
|
|
443
|
+
* // Increment x.
|
|
444
|
+
* x += 5;
|
|
445
|
+
* }
|
|
446
|
+
*
|
|
447
|
+
* // Run the draw loop when the user double-clicks.
|
|
448
|
+
* function doubleClicked() {
|
|
449
|
+
* redraw();
|
|
450
|
+
* }
|
|
451
|
+
* </code>
|
|
452
|
+
* </div>
|
|
453
|
+
*
|
|
454
|
+
* <div>
|
|
455
|
+
* <code>
|
|
456
|
+
* // Double-click the canvas to move the circle.
|
|
457
|
+
*
|
|
458
|
+
* let x = 0;
|
|
459
|
+
*
|
|
460
|
+
* function setup() {
|
|
461
|
+
* createCanvas(100, 100);
|
|
462
|
+
*
|
|
463
|
+
* // Turn off the draw loop.
|
|
464
|
+
* noLoop();
|
|
465
|
+
*
|
|
466
|
+
* describe(
|
|
467
|
+
* 'A white half-circle on the left edge of a gray square. The circle hops to the right when the user double-clicks.'
|
|
468
|
+
* );
|
|
469
|
+
* }
|
|
470
|
+
*
|
|
471
|
+
* function draw() {
|
|
472
|
+
* background(200);
|
|
473
|
+
*
|
|
474
|
+
* // Draw the circle.
|
|
475
|
+
* circle(x, 50, 20);
|
|
476
|
+
*
|
|
477
|
+
* // Increment x.
|
|
478
|
+
* x += 5;
|
|
479
|
+
* }
|
|
480
|
+
*
|
|
481
|
+
* // Run the draw loop three times when the user double-clicks.
|
|
482
|
+
* function doubleClicked() {
|
|
483
|
+
* redraw(3);
|
|
484
|
+
* }
|
|
485
|
+
* </code>
|
|
486
|
+
* </div>
|
|
487
|
+
*/
|
|
488
|
+
function redraw(n?: number): void;
|
|
489
|
+
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
export default function structure(p5: any, fn: any): void;
|