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,484 @@
|
|
|
1
|
+
// This file is auto-generated from JSDoc documentation
|
|
2
|
+
|
|
3
|
+
import p5 from 'p5';
|
|
4
|
+
|
|
5
|
+
declare module 'p5' {
|
|
6
|
+
class Graphics extends Element {
|
|
7
|
+
constructor(w: number, h: number, renderer: P2D | WEBGL | P2DHDR, pInst?: p5, canvas?: HTMLCanvasElement);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Resets the graphics buffer's transformations and lighting.By default, the main canvas resets certain transformation and lighting
|
|
11
|
+
* values each time draw() executes. `p5.Graphics`
|
|
12
|
+
* objects must reset these values manually by calling `myGraphics.reset()`.
|
|
13
|
+
*/
|
|
14
|
+
reset(): void;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Removes the graphics buffer from the web page.Calling `myGraphics.remove()` removes the graphics buffer's
|
|
18
|
+
* `<canvas>` element from the web page. The graphics buffer also uses
|
|
19
|
+
* a bit of memory on the CPU that can be freed like so:`// Remove the graphics buffer from the web page.
|
|
20
|
+
* myGraphics.remove();
|
|
21
|
+
*
|
|
22
|
+
* // Delete the graphics buffer from CPU memory.
|
|
23
|
+
* myGraphics = undefined;`Note: All variables that reference the graphics buffer must be assigned
|
|
24
|
+
* the value `undefined` to delete the graphics buffer from CPU memory. If any
|
|
25
|
+
* variable still refers to the graphics buffer, then it won't be garbage
|
|
26
|
+
* collected.
|
|
27
|
+
*/
|
|
28
|
+
remove(): void;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new p5.Framebuffer object with
|
|
32
|
+
* the same WebGL context as the graphics buffer.p5.Framebuffer objects are separate drawing
|
|
33
|
+
* surfaces that can be used as textures in WebGL mode. They're similar to
|
|
34
|
+
* p5.Graphics objects and generally run much
|
|
35
|
+
* faster when used as textures. Creating a
|
|
36
|
+
* p5.Framebuffer object in the same context
|
|
37
|
+
* as the graphics buffer makes this speedup possible.The parameter, `options`, is optional. An object can be passed to configure
|
|
38
|
+
* the p5.Framebuffer object. The available
|
|
39
|
+
* properties are:If the `width`, `height`, or `density` attributes are set, they won't
|
|
40
|
+
* automatically match the graphics buffer and must be changed manually.
|
|
41
|
+
*
|
|
42
|
+
* @param
|
|
43
|
+
*/
|
|
44
|
+
createFramebuffer(options: object): p5.Framebuffer;
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Resets the graphics buffer's transformations and lighting.By default, the main canvas resets certain transformation and lighting
|
|
50
|
+
* values each time draw() executes. `p5.Graphics`
|
|
51
|
+
* objects must reset these values manually by calling `myGraphics.reset()`.
|
|
52
|
+
*
|
|
53
|
+
* @example <div>
|
|
54
|
+
* <code>
|
|
55
|
+
* let pg;
|
|
56
|
+
*
|
|
57
|
+
* function setup() {
|
|
58
|
+
* createCanvas(100, 100);
|
|
59
|
+
*
|
|
60
|
+
* // Create a p5.Graphics object.
|
|
61
|
+
* pg = createGraphics(60, 60);
|
|
62
|
+
*
|
|
63
|
+
* describe('A white circle moves downward slowly within a dark square. The circle resets at the top of the dark square when the user presses the mouse.');
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* function draw() {
|
|
67
|
+
* background(200);
|
|
68
|
+
*
|
|
69
|
+
* // Translate the p5.Graphics object's coordinate system.
|
|
70
|
+
* // The translation accumulates; the white circle moves.
|
|
71
|
+
* pg.translate(0, 0.1);
|
|
72
|
+
*
|
|
73
|
+
* // Draw to the p5.Graphics object.
|
|
74
|
+
* pg.background(100);
|
|
75
|
+
* pg.circle(30, 0, 10);
|
|
76
|
+
*
|
|
77
|
+
* // Display the p5.Graphics object.
|
|
78
|
+
* image(pg, 20, 20);
|
|
79
|
+
*
|
|
80
|
+
* // Translate the main canvas' coordinate system.
|
|
81
|
+
* // The translation doesn't accumulate; the dark
|
|
82
|
+
* // square is always in the same place.
|
|
83
|
+
* translate(0, 0.1);
|
|
84
|
+
*
|
|
85
|
+
* // Reset the p5.Graphics object when the
|
|
86
|
+
* // user presses the mouse.
|
|
87
|
+
* if (mouseIsPressed === true) {
|
|
88
|
+
* pg.reset();
|
|
89
|
+
* }
|
|
90
|
+
* }
|
|
91
|
+
* </code>
|
|
92
|
+
* </div>
|
|
93
|
+
*
|
|
94
|
+
* <div>
|
|
95
|
+
* <code>
|
|
96
|
+
* let pg;
|
|
97
|
+
*
|
|
98
|
+
* function setup() {
|
|
99
|
+
* createCanvas(100, 100);
|
|
100
|
+
*
|
|
101
|
+
* // Create a p5.Graphics object.
|
|
102
|
+
* pg = createGraphics(60, 60);
|
|
103
|
+
*
|
|
104
|
+
* describe('A white circle at the center of a dark gray square. The image is drawn on a light gray background.');
|
|
105
|
+
* }
|
|
106
|
+
*
|
|
107
|
+
* function draw() {
|
|
108
|
+
* background(200);
|
|
109
|
+
*
|
|
110
|
+
* // Translate the p5.Graphics object's coordinate system.
|
|
111
|
+
* pg.translate(30, 30);
|
|
112
|
+
*
|
|
113
|
+
* // Draw to the p5.Graphics object.
|
|
114
|
+
* pg.background(100);
|
|
115
|
+
* pg.circle(0, 0, 10);
|
|
116
|
+
*
|
|
117
|
+
* // Display the p5.Graphics object.
|
|
118
|
+
* image(pg, 20, 20);
|
|
119
|
+
*
|
|
120
|
+
* // Reset the p5.Graphics object automatically.
|
|
121
|
+
* pg.reset();
|
|
122
|
+
* }
|
|
123
|
+
* </code>
|
|
124
|
+
* </div>
|
|
125
|
+
*
|
|
126
|
+
* <div>
|
|
127
|
+
* <code>
|
|
128
|
+
* let pg;
|
|
129
|
+
*
|
|
130
|
+
* function setup() {
|
|
131
|
+
* createCanvas(100, 100);
|
|
132
|
+
*
|
|
133
|
+
* // Create a p5.Graphics object using WebGL mode.
|
|
134
|
+
* pg = createGraphics(100, 100, WEBGL);
|
|
135
|
+
*
|
|
136
|
+
* describe("A sphere lit from above with a red light. The sphere's surface becomes glossy while the user clicks and holds the mouse.");
|
|
137
|
+
* }
|
|
138
|
+
*
|
|
139
|
+
* function draw() {
|
|
140
|
+
* background(200);
|
|
141
|
+
*
|
|
142
|
+
* // Add a red point light from the top-right.
|
|
143
|
+
* pg.pointLight(255, 0, 0, 50, -100, 50);
|
|
144
|
+
*
|
|
145
|
+
* // Style the sphere.
|
|
146
|
+
* // It should appear glossy when the
|
|
147
|
+
* // lighting values are reset.
|
|
148
|
+
* pg.noStroke();
|
|
149
|
+
* pg.specularMaterial(255);
|
|
150
|
+
* pg.shininess(100);
|
|
151
|
+
*
|
|
152
|
+
* // Draw the sphere.
|
|
153
|
+
* pg.sphere(30);
|
|
154
|
+
*
|
|
155
|
+
* // Display the p5.Graphics object.
|
|
156
|
+
* image(pg, -50, -50);
|
|
157
|
+
*
|
|
158
|
+
* // Reset the p5.Graphics object when
|
|
159
|
+
* // the user presses the mouse.
|
|
160
|
+
* if (mouseIsPressed === true) {
|
|
161
|
+
* pg.reset();
|
|
162
|
+
* }
|
|
163
|
+
* }
|
|
164
|
+
* </code>
|
|
165
|
+
* </div>
|
|
166
|
+
*
|
|
167
|
+
* <div>
|
|
168
|
+
* <code>
|
|
169
|
+
* let pg;
|
|
170
|
+
*
|
|
171
|
+
* function setup() {
|
|
172
|
+
* createCanvas(100, 100);
|
|
173
|
+
*
|
|
174
|
+
* // Create a p5.Graphics object using WebGL mode.
|
|
175
|
+
* pg = createGraphics(100, 100, WEBGL);
|
|
176
|
+
*
|
|
177
|
+
* describe('A sphere with a glossy surface is lit from the top-right by a red light.');
|
|
178
|
+
* }
|
|
179
|
+
*
|
|
180
|
+
* function draw() {
|
|
181
|
+
* background(200);
|
|
182
|
+
*
|
|
183
|
+
* // Add a red point light from the top-right.
|
|
184
|
+
* pg.pointLight(255, 0, 0, 50, -100, 50);
|
|
185
|
+
*
|
|
186
|
+
* // Style the sphere.
|
|
187
|
+
* pg.noStroke();
|
|
188
|
+
* pg.specularMaterial(255);
|
|
189
|
+
* pg.shininess(100);
|
|
190
|
+
*
|
|
191
|
+
* // Draw the sphere.
|
|
192
|
+
* pg.sphere(30);
|
|
193
|
+
*
|
|
194
|
+
* // Display the p5.Graphics object.
|
|
195
|
+
* image(pg, 0, 0);
|
|
196
|
+
*
|
|
197
|
+
* // Reset the p5.Graphics object automatically.
|
|
198
|
+
* pg.reset();
|
|
199
|
+
* }
|
|
200
|
+
* </code>
|
|
201
|
+
* </div>
|
|
202
|
+
*/
|
|
203
|
+
function reset(): void;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Removes the graphics buffer from the web page.Calling `myGraphics.remove()` removes the graphics buffer's
|
|
207
|
+
* `<canvas>` element from the web page. The graphics buffer also uses
|
|
208
|
+
* a bit of memory on the CPU that can be freed like so:`// Remove the graphics buffer from the web page.
|
|
209
|
+
* myGraphics.remove();
|
|
210
|
+
*
|
|
211
|
+
* // Delete the graphics buffer from CPU memory.
|
|
212
|
+
* myGraphics = undefined;`Note: All variables that reference the graphics buffer must be assigned
|
|
213
|
+
* the value `undefined` to delete the graphics buffer from CPU memory. If any
|
|
214
|
+
* variable still refers to the graphics buffer, then it won't be garbage
|
|
215
|
+
* collected.
|
|
216
|
+
*
|
|
217
|
+
* @example <div>
|
|
218
|
+
* <code>
|
|
219
|
+
* // Double-click to remove the p5.Graphics object.
|
|
220
|
+
*
|
|
221
|
+
* let pg;
|
|
222
|
+
*
|
|
223
|
+
* function setup() {
|
|
224
|
+
* createCanvas(100, 100);
|
|
225
|
+
*
|
|
226
|
+
* // Create a p5.Graphics object.
|
|
227
|
+
* pg = createGraphics(60, 60);
|
|
228
|
+
*
|
|
229
|
+
* // Draw to the p5.Graphics object.
|
|
230
|
+
* pg.background(100);
|
|
231
|
+
* pg.circle(30, 30, 20);
|
|
232
|
+
*
|
|
233
|
+
* describe('A white circle at the center of a dark gray square disappears when the user double-clicks.');
|
|
234
|
+
* }
|
|
235
|
+
*
|
|
236
|
+
* function draw() {
|
|
237
|
+
* background(200);
|
|
238
|
+
*
|
|
239
|
+
* // Display the p5.Graphics object if
|
|
240
|
+
* // it's available.
|
|
241
|
+
* if (pg) {
|
|
242
|
+
* image(pg, 20, 20);
|
|
243
|
+
* }
|
|
244
|
+
* }
|
|
245
|
+
*
|
|
246
|
+
* // Remove the p5.Graphics object when the
|
|
247
|
+
* // the user double-clicks.
|
|
248
|
+
* function doubleClicked() {
|
|
249
|
+
* // Remove the p5.Graphics object from the web page.
|
|
250
|
+
* pg.remove();
|
|
251
|
+
* pg = undefined;
|
|
252
|
+
* }
|
|
253
|
+
* </code>
|
|
254
|
+
* </div>
|
|
255
|
+
*/
|
|
256
|
+
function remove(): void;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Creates a new p5.Framebuffer object with
|
|
260
|
+
* the same WebGL context as the graphics buffer.p5.Framebuffer objects are separate drawing
|
|
261
|
+
* surfaces that can be used as textures in WebGL mode. They're similar to
|
|
262
|
+
* p5.Graphics objects and generally run much
|
|
263
|
+
* faster when used as textures. Creating a
|
|
264
|
+
* p5.Framebuffer object in the same context
|
|
265
|
+
* as the graphics buffer makes this speedup possible.The parameter, `options`, is optional. An object can be passed to configure
|
|
266
|
+
* the p5.Framebuffer object. The available
|
|
267
|
+
* properties are:If the `width`, `height`, or `density` attributes are set, they won't
|
|
268
|
+
* automatically match the graphics buffer and must be changed manually.
|
|
269
|
+
*
|
|
270
|
+
* @param configuration options.
|
|
271
|
+
* @return new framebuffer.
|
|
272
|
+
* @example <div>
|
|
273
|
+
* <code>
|
|
274
|
+
* // Click and hold a mouse button to change shapes.
|
|
275
|
+
*
|
|
276
|
+
* let pg;
|
|
277
|
+
* let torusLayer;
|
|
278
|
+
* let boxLayer;
|
|
279
|
+
*
|
|
280
|
+
* function setup() {
|
|
281
|
+
* createCanvas(100, 100);
|
|
282
|
+
*
|
|
283
|
+
* // Create a p5.Graphics object using WebGL mode.
|
|
284
|
+
* pg = createGraphics(100, 100, WEBGL);
|
|
285
|
+
*
|
|
286
|
+
* // Create the p5.Framebuffer objects.
|
|
287
|
+
* torusLayer = pg.createFramebuffer();
|
|
288
|
+
* boxLayer = pg.createFramebuffer();
|
|
289
|
+
*
|
|
290
|
+
* describe('A grid of white toruses rotating against a dark gray background. The shapes become boxes while the user holds a mouse button.');
|
|
291
|
+
* }
|
|
292
|
+
*
|
|
293
|
+
* function draw() {
|
|
294
|
+
* // Update and draw the layers offscreen.
|
|
295
|
+
* drawTorus();
|
|
296
|
+
* drawBox();
|
|
297
|
+
*
|
|
298
|
+
* // Choose the layer to display.
|
|
299
|
+
* let layer;
|
|
300
|
+
* if (mouseIsPressed === true) {
|
|
301
|
+
* layer = boxLayer;
|
|
302
|
+
* } else {
|
|
303
|
+
* layer = torusLayer;
|
|
304
|
+
* }
|
|
305
|
+
*
|
|
306
|
+
* // Draw to the p5.Graphics object.
|
|
307
|
+
* pg.background(50);
|
|
308
|
+
*
|
|
309
|
+
* // Iterate from left to right.
|
|
310
|
+
* for (let x = -50; x < 50; x += 25) {
|
|
311
|
+
* // Iterate from top to bottom.
|
|
312
|
+
* for (let y = -50; y < 50; y += 25) {
|
|
313
|
+
* // Draw the layer to the p5.Graphics object
|
|
314
|
+
* pg.image(layer, x, y, 25, 25);
|
|
315
|
+
* }
|
|
316
|
+
* }
|
|
317
|
+
*
|
|
318
|
+
* // Display the p5.Graphics object.
|
|
319
|
+
* image(pg, 0, 0);
|
|
320
|
+
* }
|
|
321
|
+
*
|
|
322
|
+
* // Update and draw the torus layer offscreen.
|
|
323
|
+
* function drawTorus() {
|
|
324
|
+
* // Start drawing to the torus p5.Framebuffer.
|
|
325
|
+
* torusLayer.begin();
|
|
326
|
+
*
|
|
327
|
+
* // Clear the drawing surface.
|
|
328
|
+
* pg.clear();
|
|
329
|
+
*
|
|
330
|
+
* // Turn on the lights.
|
|
331
|
+
* pg.lights();
|
|
332
|
+
*
|
|
333
|
+
* // Rotate the coordinate system.
|
|
334
|
+
* pg.rotateX(frameCount * 0.01);
|
|
335
|
+
* pg.rotateY(frameCount * 0.01);
|
|
336
|
+
*
|
|
337
|
+
* // Style the torus.
|
|
338
|
+
* pg.noStroke();
|
|
339
|
+
*
|
|
340
|
+
* // Draw the torus.
|
|
341
|
+
* pg.torus(20);
|
|
342
|
+
*
|
|
343
|
+
* // Start drawing to the torus p5.Framebuffer.
|
|
344
|
+
* torusLayer.end();
|
|
345
|
+
* }
|
|
346
|
+
*
|
|
347
|
+
* // Update and draw the box layer offscreen.
|
|
348
|
+
* function drawBox() {
|
|
349
|
+
* // Start drawing to the box p5.Framebuffer.
|
|
350
|
+
* boxLayer.begin();
|
|
351
|
+
*
|
|
352
|
+
* // Clear the drawing surface.
|
|
353
|
+
* pg.clear();
|
|
354
|
+
*
|
|
355
|
+
* // Turn on the lights.
|
|
356
|
+
* pg.lights();
|
|
357
|
+
*
|
|
358
|
+
* // Rotate the coordinate system.
|
|
359
|
+
* pg.rotateX(frameCount * 0.01);
|
|
360
|
+
* pg.rotateY(frameCount * 0.01);
|
|
361
|
+
*
|
|
362
|
+
* // Style the box.
|
|
363
|
+
* pg.noStroke();
|
|
364
|
+
*
|
|
365
|
+
* // Draw the box.
|
|
366
|
+
* pg.box(30);
|
|
367
|
+
*
|
|
368
|
+
* // Start drawing to the box p5.Framebuffer.
|
|
369
|
+
* boxLayer.end();
|
|
370
|
+
* }
|
|
371
|
+
* </code>
|
|
372
|
+
* </div>
|
|
373
|
+
*
|
|
374
|
+
* <div>
|
|
375
|
+
* <code>
|
|
376
|
+
* // Click and hold a mouse button to change shapes.
|
|
377
|
+
*
|
|
378
|
+
* let pg;
|
|
379
|
+
* let torusLayer;
|
|
380
|
+
* let boxLayer;
|
|
381
|
+
*
|
|
382
|
+
* function setup() {
|
|
383
|
+
* createCanvas(100, 100);
|
|
384
|
+
*
|
|
385
|
+
* // Create an options object.
|
|
386
|
+
* let options = { width: 25, height: 25 };
|
|
387
|
+
*
|
|
388
|
+
* // Create a p5.Graphics object using WebGL mode.
|
|
389
|
+
* pg = createGraphics(100, 100, WEBGL);
|
|
390
|
+
*
|
|
391
|
+
* // Create the p5.Framebuffer objects.
|
|
392
|
+
* // Use options for configuration.
|
|
393
|
+
* torusLayer = pg.createFramebuffer(options);
|
|
394
|
+
* boxLayer = pg.createFramebuffer(options);
|
|
395
|
+
*
|
|
396
|
+
* describe('A grid of white toruses rotating against a dark gray background. The shapes become boxes while the user holds a mouse button.');
|
|
397
|
+
* }
|
|
398
|
+
*
|
|
399
|
+
* function draw() {
|
|
400
|
+
* // Update and draw the layers offscreen.
|
|
401
|
+
* drawTorus();
|
|
402
|
+
* drawBox();
|
|
403
|
+
*
|
|
404
|
+
* // Choose the layer to display.
|
|
405
|
+
* let layer;
|
|
406
|
+
* if (mouseIsPressed === true) {
|
|
407
|
+
* layer = boxLayer;
|
|
408
|
+
* } else {
|
|
409
|
+
* layer = torusLayer;
|
|
410
|
+
* }
|
|
411
|
+
*
|
|
412
|
+
* // Draw to the p5.Graphics object.
|
|
413
|
+
* pg.background(50);
|
|
414
|
+
*
|
|
415
|
+
* // Iterate from left to right.
|
|
416
|
+
* for (let x = -50; x < 50; x += 25) {
|
|
417
|
+
* // Iterate from top to bottom.
|
|
418
|
+
* for (let y = -50; y < 50; y += 25) {
|
|
419
|
+
* // Draw the layer to the p5.Graphics object
|
|
420
|
+
* pg.image(layer, x, y);
|
|
421
|
+
* }
|
|
422
|
+
* }
|
|
423
|
+
*
|
|
424
|
+
* // Display the p5.Graphics object.
|
|
425
|
+
* image(pg, 0, 0);
|
|
426
|
+
* }
|
|
427
|
+
*
|
|
428
|
+
* // Update and draw the torus layer offscreen.
|
|
429
|
+
* function drawTorus() {
|
|
430
|
+
* // Start drawing to the torus p5.Framebuffer.
|
|
431
|
+
* torusLayer.begin();
|
|
432
|
+
*
|
|
433
|
+
* // Clear the drawing surface.
|
|
434
|
+
* pg.clear();
|
|
435
|
+
*
|
|
436
|
+
* // Turn on the lights.
|
|
437
|
+
* pg.lights();
|
|
438
|
+
*
|
|
439
|
+
* // Rotate the coordinate system.
|
|
440
|
+
* pg.rotateX(frameCount * 0.01);
|
|
441
|
+
* pg.rotateY(frameCount * 0.01);
|
|
442
|
+
*
|
|
443
|
+
* // Style the torus.
|
|
444
|
+
* pg.noStroke();
|
|
445
|
+
*
|
|
446
|
+
* // Draw the torus.
|
|
447
|
+
* pg.torus(5, 2.5);
|
|
448
|
+
*
|
|
449
|
+
* // Start drawing to the torus p5.Framebuffer.
|
|
450
|
+
* torusLayer.end();
|
|
451
|
+
* }
|
|
452
|
+
*
|
|
453
|
+
* // Update and draw the box layer offscreen.
|
|
454
|
+
* function drawBox() {
|
|
455
|
+
* // Start drawing to the box p5.Framebuffer.
|
|
456
|
+
* boxLayer.begin();
|
|
457
|
+
*
|
|
458
|
+
* // Clear the drawing surface.
|
|
459
|
+
* pg.clear();
|
|
460
|
+
*
|
|
461
|
+
* // Turn on the lights.
|
|
462
|
+
* pg.lights();
|
|
463
|
+
*
|
|
464
|
+
* // Rotate the coordinate system.
|
|
465
|
+
* pg.rotateX(frameCount * 0.01);
|
|
466
|
+
* pg.rotateY(frameCount * 0.01);
|
|
467
|
+
*
|
|
468
|
+
* // Style the box.
|
|
469
|
+
* pg.noStroke();
|
|
470
|
+
*
|
|
471
|
+
* // Draw the box.
|
|
472
|
+
* pg.box(7.5);
|
|
473
|
+
*
|
|
474
|
+
* // Start drawing to the box p5.Framebuffer.
|
|
475
|
+
* boxLayer.end();
|
|
476
|
+
* }
|
|
477
|
+
* </code>
|
|
478
|
+
* </div>
|
|
479
|
+
*/
|
|
480
|
+
function createFramebuffer(options?: object): p5.Framebuffer;
|
|
481
|
+
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
export default function p5_Graphics(p5: any, fn: any): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// This file is auto-generated from JSDoc documentation
|
|
2
|
+
|
|
3
|
+
import p5 from 'p5';
|
|
4
|
+
|
|
5
|
+
declare module 'p5' {
|
|
6
|
+
/**
|
|
7
|
+
* Resize our canvas element.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
function resize(w: any, h: any): void;
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default function p5_Renderer(p5: any, fn: any): void;
|