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,1247 @@
|
|
|
1
|
+
// This file is auto-generated from JSDoc documentation
|
|
2
|
+
|
|
3
|
+
import p5 from 'p5';
|
|
4
|
+
|
|
5
|
+
declare module 'p5' {
|
|
6
|
+
class Table {
|
|
7
|
+
constructor(rows?: p5.TableRow[]);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Use addRow() to add a new row of data to a p5.Table object. By default,
|
|
11
|
+
* an empty row is created. Typically, you would store a reference to
|
|
12
|
+
* the new row in a TableRow object (see newRow in the example above),
|
|
13
|
+
* and then set individual values using set().If a p5.TableRow object is included as a parameter, then that row is
|
|
14
|
+
* duplicated and added to the table.
|
|
15
|
+
*
|
|
16
|
+
* @param
|
|
17
|
+
*/
|
|
18
|
+
addRow(row: p5.TableRow): p5.TableRow;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Removes a row from the table object.
|
|
22
|
+
*
|
|
23
|
+
* @param
|
|
24
|
+
*/
|
|
25
|
+
removeRow(id: number): void;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns a reference to the specified p5.TableRow. The reference
|
|
29
|
+
* can then be used to get and set values of the selected row.
|
|
30
|
+
*
|
|
31
|
+
* @param
|
|
32
|
+
* @param
|
|
33
|
+
*/
|
|
34
|
+
getRow(r: any, rowID: number): p5.TableRow;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Gets all rows from the table. Returns an array of p5.TableRows.
|
|
38
|
+
*/
|
|
39
|
+
getRows(): p5.TableRow[];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Finds the first row in the Table that contains the value
|
|
43
|
+
* provided, and returns a reference to that row. Even if
|
|
44
|
+
* multiple rows are possible matches, only the first matching
|
|
45
|
+
* row is returned. The column to search may be specified by
|
|
46
|
+
* either its ID or title.
|
|
47
|
+
*
|
|
48
|
+
* @param
|
|
49
|
+
* @param
|
|
50
|
+
*/
|
|
51
|
+
findRow(value: string, column: number | string): p5.TableRow;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Finds the rows in the Table that contain the value
|
|
55
|
+
* provided, and returns references to those rows. Returns an
|
|
56
|
+
* Array, so for must be used to iterate through all the rows,
|
|
57
|
+
* as shown in the example above. The column to search may be
|
|
58
|
+
* specified by either its ID or title.
|
|
59
|
+
*
|
|
60
|
+
* @param
|
|
61
|
+
* @param
|
|
62
|
+
*/
|
|
63
|
+
findRows(value: string, column: number | string): p5.TableRow[];
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Finds the first row in the Table that matches the regular
|
|
67
|
+
* expression provided, and returns a reference to that row.
|
|
68
|
+
* Even if multiple rows are possible matches, only the first
|
|
69
|
+
* matching row is returned. The column to search may be
|
|
70
|
+
* specified by either its ID or title.
|
|
71
|
+
*
|
|
72
|
+
* @param
|
|
73
|
+
* @param
|
|
74
|
+
*/
|
|
75
|
+
matchRow(regexp: string | RegExp, column: string | number): p5.TableRow;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Finds the rows in the Table that match the regular expression provided,
|
|
79
|
+
* and returns references to those rows. Returns an array, so for must be
|
|
80
|
+
* used to iterate through all the rows, as shown in the example. The
|
|
81
|
+
* column to search may be specified by either its ID or title.
|
|
82
|
+
*
|
|
83
|
+
* @param
|
|
84
|
+
* @param
|
|
85
|
+
*/
|
|
86
|
+
matchRows(regexp: string, column: string | number): p5.TableRow[];
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Retrieves all values in the specified column, and returns them
|
|
90
|
+
* as an array. The column may be specified by either its ID or title.
|
|
91
|
+
*
|
|
92
|
+
* @param
|
|
93
|
+
* @param
|
|
94
|
+
*/
|
|
95
|
+
getColumn(value: any, column: string | number): Array;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Removes all rows from a Table. While all rows are removed,
|
|
99
|
+
* columns and column titles are maintained.
|
|
100
|
+
*/
|
|
101
|
+
clearRows(): void;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Use addColumn() to add a new column to a Table object.
|
|
105
|
+
* Typically, you will want to specify a title, so the column
|
|
106
|
+
* may be easily referenced later by name. (If no title is
|
|
107
|
+
* specified, the new column's title will be null.)
|
|
108
|
+
*
|
|
109
|
+
* @param
|
|
110
|
+
*/
|
|
111
|
+
addColumn(title: string): void;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Returns the total number of columns in a Table.
|
|
115
|
+
*/
|
|
116
|
+
getColumnCount(): number;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Returns the total number of rows in a Table.
|
|
120
|
+
*/
|
|
121
|
+
getRowCount(): number;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Removes any of the specified characters (or "tokens").If no column is specified, then the values in all columns and
|
|
125
|
+
* rows are processed. A specific column may be referenced by
|
|
126
|
+
* either its ID or title.
|
|
127
|
+
*
|
|
128
|
+
* @param
|
|
129
|
+
* @param
|
|
130
|
+
*/
|
|
131
|
+
removeTokens(chars: string, column: string | number): void;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Trims leading and trailing whitespace, such as spaces and tabs,
|
|
135
|
+
* from String table values. If no column is specified, then the
|
|
136
|
+
* values in all columns and rows are trimmed. A specific column
|
|
137
|
+
* may be referenced by either its ID or title.
|
|
138
|
+
*
|
|
139
|
+
* @param
|
|
140
|
+
*/
|
|
141
|
+
trim(column: string | number): void;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Use removeColumn() to remove an existing column from a Table
|
|
145
|
+
* object. The column to be removed may be identified by either
|
|
146
|
+
* its title (a String) or its index value (an int).
|
|
147
|
+
* removeColumn(0) would remove the first column, removeColumn(1)
|
|
148
|
+
* would remove the second column, and so on.
|
|
149
|
+
*
|
|
150
|
+
* @param
|
|
151
|
+
* @param
|
|
152
|
+
*/
|
|
153
|
+
removeColumn(c: any, column: string | number): void;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Stores a value in the Table's specified row and column.
|
|
157
|
+
* The row is specified by its ID, while the column may be specified
|
|
158
|
+
* by either its ID or title.
|
|
159
|
+
*
|
|
160
|
+
* @param
|
|
161
|
+
* @param
|
|
162
|
+
* @param
|
|
163
|
+
*/
|
|
164
|
+
set(row: number, column: string | number, value: string | number): void;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Stores a Float value in the Table's specified row and column.
|
|
168
|
+
* The row is specified by its ID, while the column may be specified
|
|
169
|
+
* by either its ID or title.
|
|
170
|
+
*
|
|
171
|
+
* @param
|
|
172
|
+
* @param
|
|
173
|
+
* @param
|
|
174
|
+
*/
|
|
175
|
+
setNum(row: number, column: string | number, value: number): void;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Stores a String value in the Table's specified row and column.
|
|
179
|
+
* The row is specified by its ID, while the column may be specified
|
|
180
|
+
* by either its ID or title.
|
|
181
|
+
*
|
|
182
|
+
* @param
|
|
183
|
+
* @param
|
|
184
|
+
* @param
|
|
185
|
+
*/
|
|
186
|
+
setString(row: number, column: string | number, value: string): void;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Retrieves a value from the Table's specified row and column.
|
|
190
|
+
* The row is specified by its ID, while the column may be specified by
|
|
191
|
+
* either its ID or title.
|
|
192
|
+
*
|
|
193
|
+
* @param
|
|
194
|
+
* @param
|
|
195
|
+
*/
|
|
196
|
+
get(row: number, column: string | number): string | number;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Retrieves a Float value from the Table's specified row and column.
|
|
200
|
+
* The row is specified by its ID, while the column may be specified by
|
|
201
|
+
* either its ID or title.
|
|
202
|
+
*
|
|
203
|
+
* @param
|
|
204
|
+
* @param
|
|
205
|
+
*/
|
|
206
|
+
getNum(row: number, column: string | number): number;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Retrieves a String value from the Table's specified row and column.
|
|
210
|
+
* The row is specified by its ID, while the column may be specified by
|
|
211
|
+
* either its ID or title.
|
|
212
|
+
*
|
|
213
|
+
* @param
|
|
214
|
+
* @param
|
|
215
|
+
*/
|
|
216
|
+
getString(row: number, column: string | number): string;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Retrieves all table data and returns as an object. If a column name is
|
|
220
|
+
* passed in, each row object will be stored with that attribute as its
|
|
221
|
+
* title.
|
|
222
|
+
*
|
|
223
|
+
* @param
|
|
224
|
+
*/
|
|
225
|
+
getObject(headerColumn: string): object;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Retrieves all table data and returns it as a multidimensional array.
|
|
229
|
+
*/
|
|
230
|
+
getArray(): Array;
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Use addRow() to add a new row of data to a p5.Table object. By default,
|
|
236
|
+
* an empty row is created. Typically, you would store a reference to
|
|
237
|
+
* the new row in a TableRow object (see newRow in the example above),
|
|
238
|
+
* and then set individual values using set().If a p5.TableRow object is included as a parameter, then that row is
|
|
239
|
+
* duplicated and added to the table.
|
|
240
|
+
*
|
|
241
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
242
|
+
* @param row to be added to the table
|
|
243
|
+
* @return the row that was added
|
|
244
|
+
* @example <div>
|
|
245
|
+
* <code>
|
|
246
|
+
* // Given the CSV file "mammals.csv"
|
|
247
|
+
* // in the project's "assets" folder:
|
|
248
|
+
* //
|
|
249
|
+
* // id,species,name
|
|
250
|
+
* // 0,Capra hircus,Goat
|
|
251
|
+
* // 1,Panthera pardus,Leopard
|
|
252
|
+
* // 2,Equus zebra,Zebra
|
|
253
|
+
*
|
|
254
|
+
* let table;
|
|
255
|
+
*
|
|
256
|
+
* async function setup() {
|
|
257
|
+
* // Create a 300x300 canvas
|
|
258
|
+
* createCanvas(300, 300);
|
|
259
|
+
*
|
|
260
|
+
* // Load the CSV file from the assets folder with a header row
|
|
261
|
+
* table = await loadTable('assets/mammals.csv', ',', 'header');
|
|
262
|
+
*
|
|
263
|
+
* // Add a new row for "Wolf"
|
|
264
|
+
* let newRow = table.addRow();
|
|
265
|
+
* newRow.setString('id', table.getRowCount() - 1);
|
|
266
|
+
* newRow.setString('species', 'Canis Lupus');
|
|
267
|
+
* newRow.setString('name', 'Wolf');
|
|
268
|
+
*
|
|
269
|
+
* // Set text properties
|
|
270
|
+
* fill(0); // Text color: black
|
|
271
|
+
* textSize(12); // Adjust text size as needed
|
|
272
|
+
*
|
|
273
|
+
* // Display the table data on the canvas
|
|
274
|
+
* // Each cell is positioned based on its row and column
|
|
275
|
+
* for (let r = 0; r < table.getRowCount(); r++) {
|
|
276
|
+
* for (let c = 0; c < table.getColumnCount(); c++) {
|
|
277
|
+
* let x = c * 50 + 10; // Horizontal spacing for each column
|
|
278
|
+
* let y = r * 30 + 20; // Vertical spacing for each row
|
|
279
|
+
* text(table.getString(r, c), x * c, y);
|
|
280
|
+
* }
|
|
281
|
+
* }
|
|
282
|
+
*
|
|
283
|
+
* describe('no image displayed');
|
|
284
|
+
* }
|
|
285
|
+
* </code>
|
|
286
|
+
* </div>
|
|
287
|
+
*/
|
|
288
|
+
function addRow(row?: p5.TableRow): p5.TableRow;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Removes a row from the table object.
|
|
292
|
+
*
|
|
293
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
294
|
+
* @param ID number of the row to remove
|
|
295
|
+
* @example <div>
|
|
296
|
+
* <code>
|
|
297
|
+
* let table;
|
|
298
|
+
*
|
|
299
|
+
* async function setup() {
|
|
300
|
+
* // Create a 200x200 canvas and set a white background
|
|
301
|
+
* createCanvas(200, 200);
|
|
302
|
+
* background(255);
|
|
303
|
+
*
|
|
304
|
+
* // Load the CSV file with a header row
|
|
305
|
+
* table = await loadTable('assets/mammals.csv', ',', 'header');
|
|
306
|
+
*
|
|
307
|
+
* // Remove the first row from the table
|
|
308
|
+
* table.removeRow(0);
|
|
309
|
+
*
|
|
310
|
+
* // Set text properties for drawing on the canvas
|
|
311
|
+
* fill(0); // Set text color to black
|
|
312
|
+
* textSize(12); // Adjust text size as needed
|
|
313
|
+
*
|
|
314
|
+
* // Display the table values on the canvas:
|
|
315
|
+
* // Each row's cell values are joined into a single string and drawn on a new line.
|
|
316
|
+
* let y = 20; // Starting vertical position
|
|
317
|
+
* for (let r = 0; r < table.getRowCount(); r++) {
|
|
318
|
+
* let rowText = "";
|
|
319
|
+
* for (let c = 0; c < table.getColumnCount(); c++) {
|
|
320
|
+
* rowText += table.getString(r, c) + " ";
|
|
321
|
+
* }
|
|
322
|
+
* text(rowText, 18, y * 3);
|
|
323
|
+
* y += 20;
|
|
324
|
+
* }
|
|
325
|
+
*
|
|
326
|
+
* describe('no image displayed');
|
|
327
|
+
* }
|
|
328
|
+
* </code>
|
|
329
|
+
* </div>
|
|
330
|
+
*/
|
|
331
|
+
function removeRow(id: number): void;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Returns a reference to the specified p5.TableRow. The reference
|
|
335
|
+
* can then be used to get and set values of the selected row.
|
|
336
|
+
*
|
|
337
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
338
|
+
* @param ID number of the row to get
|
|
339
|
+
* @return <a href="#/p5.TableRow">p5.TableRow</a> object
|
|
340
|
+
* @example <div>
|
|
341
|
+
* <code>
|
|
342
|
+
* let table;
|
|
343
|
+
*
|
|
344
|
+
* async function setup() {
|
|
345
|
+
* // Create a 200x200 canvas
|
|
346
|
+
* createCanvas(200, 200);
|
|
347
|
+
* background(255); // Set background to white
|
|
348
|
+
*
|
|
349
|
+
* // Load the CSV file with a header row
|
|
350
|
+
* table = await loadTable('assets/mammals.csv', ',', 'header');
|
|
351
|
+
*
|
|
352
|
+
* // Get the row at index 1 (second row)
|
|
353
|
+
* let row = table.getRow(1);
|
|
354
|
+
*
|
|
355
|
+
* // Set text properties for drawing on the canvas
|
|
356
|
+
* fill(0); // Set text color to black
|
|
357
|
+
* textSize(12); // Set the text size
|
|
358
|
+
*
|
|
359
|
+
* // Loop over each column in the row and display its value on the canvas
|
|
360
|
+
* for (let c = 0; c < table.getColumnCount(); c++) {
|
|
361
|
+
* text(row.getString(c), 10, 20 + c * 50 + 20);
|
|
362
|
+
* }
|
|
363
|
+
*
|
|
364
|
+
* describe('no image displayed');
|
|
365
|
+
* }
|
|
366
|
+
* </code>
|
|
367
|
+
* </div>
|
|
368
|
+
*/
|
|
369
|
+
function getRow(r: any, rowID: number): p5.TableRow;
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Gets all rows from the table. Returns an array of p5.TableRows.
|
|
373
|
+
*
|
|
374
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
375
|
+
* @return Array of <a href="#/p5.TableRow">p5.TableRow</a>s
|
|
376
|
+
* @example <div>
|
|
377
|
+
* <code>
|
|
378
|
+
* let table;
|
|
379
|
+
*
|
|
380
|
+
* async function setup() {
|
|
381
|
+
* // Create a 200x200 canvas and set a white background
|
|
382
|
+
* createCanvas(200, 200);
|
|
383
|
+
* background(255);
|
|
384
|
+
*
|
|
385
|
+
* // Load the CSV file with a header row
|
|
386
|
+
* table = await loadTable('assets/mammals.csv', ',', 'header');
|
|
387
|
+
*
|
|
388
|
+
* let rows = table.getRows();
|
|
389
|
+
*
|
|
390
|
+
* // Warning: rows is an array of objects.
|
|
391
|
+
* // Set the 'name' of each row to 'Unicorn'
|
|
392
|
+
* for (let r = 0; r < rows.length; r++) {
|
|
393
|
+
* rows[r].set('name', 'Unicorn');
|
|
394
|
+
* }
|
|
395
|
+
*
|
|
396
|
+
* // Set text properties
|
|
397
|
+
* fill(0); // Set text color to black
|
|
398
|
+
* textSize(12); // Adjust text size as needed
|
|
399
|
+
*
|
|
400
|
+
* // Display the modified table values on the canvas
|
|
401
|
+
* // We'll join each row's values with a space and display each row on a new line.
|
|
402
|
+
* let y = 20; // Starting y position
|
|
403
|
+
* for (let r = 0; r < table.getRowCount(); r++) {
|
|
404
|
+
* let rowText = "";
|
|
405
|
+
* for (let c = 0; c < table.getColumnCount(); c++) {
|
|
406
|
+
* rowText += table.getString(r, c) + " ";
|
|
407
|
+
* }
|
|
408
|
+
* text(rowText, 10, y * 2);
|
|
409
|
+
* y += 20; // Move to next line
|
|
410
|
+
* }
|
|
411
|
+
*
|
|
412
|
+
* describe('no image displayed');
|
|
413
|
+
* }
|
|
414
|
+
* </code>
|
|
415
|
+
* </div>
|
|
416
|
+
*/
|
|
417
|
+
function getRows(): p5.TableRow[];
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Finds the first row in the Table that contains the value
|
|
421
|
+
* provided, and returns a reference to that row. Even if
|
|
422
|
+
* multiple rows are possible matches, only the first matching
|
|
423
|
+
* row is returned. The column to search may be specified by
|
|
424
|
+
* either its ID or title.
|
|
425
|
+
*
|
|
426
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
427
|
+
* @param The value to match
|
|
428
|
+
* @param ID number or title of the
|
|
429
|
+
* column to search
|
|
430
|
+
* @example <div>
|
|
431
|
+
* <code>
|
|
432
|
+
* let table;
|
|
433
|
+
*
|
|
434
|
+
* async function setup() {
|
|
435
|
+
* // Create a 100x100 canvas
|
|
436
|
+
* createCanvas(100, 100);
|
|
437
|
+
* background(255); // Set background to white
|
|
438
|
+
*
|
|
439
|
+
* // Load the CSV file with a header row
|
|
440
|
+
* table = await loadTable('assets/mammals.csv', ',', 'header');
|
|
441
|
+
*
|
|
442
|
+
* // Find the row with the animal named "Zebra"
|
|
443
|
+
* let row = table.findRow('Zebra', 'name');
|
|
444
|
+
*
|
|
445
|
+
* // Get the species from the found row
|
|
446
|
+
* let species = row.getString('species');
|
|
447
|
+
*
|
|
448
|
+
* // Set text properties and display the species on the canvas
|
|
449
|
+
* fill(0); // Set text color to black
|
|
450
|
+
* textSize(12); // Adjust text size as needed
|
|
451
|
+
* text(species, 10, 30);
|
|
452
|
+
*
|
|
453
|
+
* describe('no image displayed');
|
|
454
|
+
* }
|
|
455
|
+
* </code>
|
|
456
|
+
* </div>
|
|
457
|
+
*/
|
|
458
|
+
function findRow(value: string, column: number | string): p5.TableRow;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Finds the rows in the Table that contain the value
|
|
462
|
+
* provided, and returns references to those rows. Returns an
|
|
463
|
+
* Array, so for must be used to iterate through all the rows,
|
|
464
|
+
* as shown in the example above. The column to search may be
|
|
465
|
+
* specified by either its ID or title.
|
|
466
|
+
*
|
|
467
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
468
|
+
* @param The value to match
|
|
469
|
+
* @param ID number or title of the
|
|
470
|
+
* column to search
|
|
471
|
+
* @return An Array of TableRow objects
|
|
472
|
+
* @example <div>
|
|
473
|
+
* <code>
|
|
474
|
+
* let table;
|
|
475
|
+
*
|
|
476
|
+
* async function setup() {
|
|
477
|
+
* // Create a 200x200 canvas
|
|
478
|
+
* createCanvas(200, 200);
|
|
479
|
+
* background(255); // Set background to white
|
|
480
|
+
*
|
|
481
|
+
* // Load the CSV file with a header row
|
|
482
|
+
* table = await loadTable('assets/mammals.csv', ',', 'header');
|
|
483
|
+
*
|
|
484
|
+
* // Add another goat entry
|
|
485
|
+
* let newRow = table.addRow();
|
|
486
|
+
* newRow.setString('id', table.getRowCount() - 1);
|
|
487
|
+
* newRow.setString('species', 'Scape Goat');
|
|
488
|
+
* newRow.setString('name', 'Goat');
|
|
489
|
+
*
|
|
490
|
+
* // Find rows where the name is "Goat"
|
|
491
|
+
* let rows = table.findRows('Goat', 'name');
|
|
492
|
+
*
|
|
493
|
+
* // Set text properties
|
|
494
|
+
* fill(0); // Set text color to black
|
|
495
|
+
* textSize(12); // Adjust text size as needed
|
|
496
|
+
*
|
|
497
|
+
* // Display the result on the canvas
|
|
498
|
+
* text(rows.length + ' Goats found', 10, 30);
|
|
499
|
+
*
|
|
500
|
+
* describe('no image displayed');
|
|
501
|
+
* }
|
|
502
|
+
* </code>
|
|
503
|
+
* </div>
|
|
504
|
+
*/
|
|
505
|
+
function findRows(value: string, column: number | string): p5.TableRow[];
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Finds the first row in the Table that matches the regular
|
|
509
|
+
* expression provided, and returns a reference to that row.
|
|
510
|
+
* Even if multiple rows are possible matches, only the first
|
|
511
|
+
* matching row is returned. The column to search may be
|
|
512
|
+
* specified by either its ID or title.
|
|
513
|
+
*
|
|
514
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
515
|
+
* @param The regular expression to match
|
|
516
|
+
* @param The column ID (number) or
|
|
517
|
+
* title (string)
|
|
518
|
+
* @return TableRow object
|
|
519
|
+
* @example <div>
|
|
520
|
+
* <code>
|
|
521
|
+
* let table;
|
|
522
|
+
*
|
|
523
|
+
* async function setup() {
|
|
524
|
+
* // Create a 200x200 canvas
|
|
525
|
+
* createCanvas(200, 200);
|
|
526
|
+
* background(255); // Set background to white
|
|
527
|
+
*
|
|
528
|
+
* // Load the CSV file with a header row
|
|
529
|
+
* table = await loadTable('assets/mammals.csv', ',', 'header');
|
|
530
|
+
*
|
|
531
|
+
* // Search using the specified regex on column index 1 (species)
|
|
532
|
+
* let mammal = table.matchRow(new RegExp('ant'), 1);
|
|
533
|
+
* let species = mammal.getString(1); // "Panthera pardus"
|
|
534
|
+
*
|
|
535
|
+
* // Set text properties for drawing on the canvas
|
|
536
|
+
* fill(0); // Text color: black
|
|
537
|
+
* textSize(12); // Adjust text size as needed
|
|
538
|
+
*
|
|
539
|
+
* // Display the species on the canvas
|
|
540
|
+
* text(species, 10, 30);
|
|
541
|
+
*
|
|
542
|
+
* describe('no image displayed');
|
|
543
|
+
* }
|
|
544
|
+
* </code>
|
|
545
|
+
* </div>
|
|
546
|
+
*/
|
|
547
|
+
function matchRow(regexp: string | RegExp, column: string | number): p5.TableRow;
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Finds the rows in the Table that match the regular expression provided,
|
|
551
|
+
* and returns references to those rows. Returns an array, so for must be
|
|
552
|
+
* used to iterate through all the rows, as shown in the example. The
|
|
553
|
+
* column to search may be specified by either its ID or title.
|
|
554
|
+
*
|
|
555
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
556
|
+
* @param The regular expression to match
|
|
557
|
+
* @param The column ID (number) or
|
|
558
|
+
* title (string)
|
|
559
|
+
* @return An Array of TableRow objects
|
|
560
|
+
* @example <div>
|
|
561
|
+
* <code>
|
|
562
|
+
* let table;
|
|
563
|
+
*
|
|
564
|
+
* function setup() {
|
|
565
|
+
* // Create a 200x200 canvas and set a white background
|
|
566
|
+
* createCanvas(200, 200);
|
|
567
|
+
* background(255);
|
|
568
|
+
*
|
|
569
|
+
* // Create a new p5.Table and add columns
|
|
570
|
+
* table = new p5.Table();
|
|
571
|
+
* table.addColumn('name');
|
|
572
|
+
* table.addColumn('type');
|
|
573
|
+
*
|
|
574
|
+
* // Add rows to the table
|
|
575
|
+
* let newRow = table.addRow();
|
|
576
|
+
* newRow.setString('name', 'Lion');
|
|
577
|
+
* newRow.setString('type', 'Mammal');
|
|
578
|
+
*
|
|
579
|
+
* newRow = table.addRow();
|
|
580
|
+
* newRow.setString('name', 'Snake');
|
|
581
|
+
* newRow.setString('type', 'Reptile');
|
|
582
|
+
*
|
|
583
|
+
* newRow = table.addRow();
|
|
584
|
+
* newRow.setString('name', 'Mosquito');
|
|
585
|
+
* newRow.setString('type', 'Insect');
|
|
586
|
+
*
|
|
587
|
+
* newRow = table.addRow();
|
|
588
|
+
* newRow.setString('name', 'Lizard');
|
|
589
|
+
* newRow.setString('type', 'Reptile');
|
|
590
|
+
*
|
|
591
|
+
* // Search for rows where the "type" starts with "R"
|
|
592
|
+
* let rows = table.matchRows('R.*', 'type');
|
|
593
|
+
*
|
|
594
|
+
* // Set text properties for drawing on the canvas
|
|
595
|
+
* fill(0); // Text color: black
|
|
596
|
+
* textSize(12); // Text size
|
|
597
|
+
*
|
|
598
|
+
* // Display each matching row on the canvas
|
|
599
|
+
* let y = 20;
|
|
600
|
+
* for (let i = 0; i < rows.length; i++) {
|
|
601
|
+
* let output = rows[i].getString('name') + ': ' + rows[i].getString('type');
|
|
602
|
+
* text(output, 10, y);
|
|
603
|
+
* y += 20;
|
|
604
|
+
* }
|
|
605
|
+
* }
|
|
606
|
+
* </code>
|
|
607
|
+
* </div>
|
|
608
|
+
*/
|
|
609
|
+
function matchRows(regexp: string, column?: string | number): p5.TableRow[];
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Retrieves all values in the specified column, and returns them
|
|
613
|
+
* as an array. The column may be specified by either its ID or title.
|
|
614
|
+
*
|
|
615
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
616
|
+
* @param String or Number of the column to return
|
|
617
|
+
* @return Array of column values
|
|
618
|
+
* @example <div class="norender">
|
|
619
|
+
* <code>
|
|
620
|
+
* // Given the CSV file "mammals.csv"
|
|
621
|
+
* // in the project's "assets" folder:
|
|
622
|
+
* //
|
|
623
|
+
* // id,species,name
|
|
624
|
+
* // 0,Capra hircus,Goat
|
|
625
|
+
* // 1,Panthera pardus,Leopard
|
|
626
|
+
* // 2,Equus zebra,Zebra
|
|
627
|
+
*
|
|
628
|
+
* let table;
|
|
629
|
+
* *
|
|
630
|
+
* async function setup() {
|
|
631
|
+
* // The table is comma separated value "csv"
|
|
632
|
+
* // and has a header specifying the columns labels.
|
|
633
|
+
* table = await loadTable('assets/mammals.csv', 'csv', 'header');
|
|
634
|
+
*
|
|
635
|
+
* //getColumn returns an array that can be printed directly
|
|
636
|
+
* print(table.getColumn('species'));
|
|
637
|
+
* //outputs ["Capra hircus", "Panthera pardus", "Equus zebra"]
|
|
638
|
+
* describe('no image displayed');
|
|
639
|
+
* }
|
|
640
|
+
* </code>
|
|
641
|
+
* </div>
|
|
642
|
+
*/
|
|
643
|
+
function getColumn(value: any, column: string | number): Array;
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Removes all rows from a Table. While all rows are removed,
|
|
647
|
+
* columns and column titles are maintained.
|
|
648
|
+
*
|
|
649
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
650
|
+
* @example <div>
|
|
651
|
+
* <code>
|
|
652
|
+
* // Given the CSV file "mammals.csv"
|
|
653
|
+
* // in the project's "assets" folder:
|
|
654
|
+
* //
|
|
655
|
+
* // id,species,name
|
|
656
|
+
* // 0,Capra hircus,Goat
|
|
657
|
+
* // 1,Panthera pardus,Leopard
|
|
658
|
+
* // 2,Equus zebra,Zebra
|
|
659
|
+
*
|
|
660
|
+
* let table;
|
|
661
|
+
*
|
|
662
|
+
* async function setup() {
|
|
663
|
+
* // Create a 200x200 canvas
|
|
664
|
+
* createCanvas(200, 200);
|
|
665
|
+
*
|
|
666
|
+
* // Load the CSV file with a header row
|
|
667
|
+
* table = await loadTable('assets/mammals.csv', ',', 'header');
|
|
668
|
+
*
|
|
669
|
+
* // Clear all rows from the table
|
|
670
|
+
* table.clearRows();
|
|
671
|
+
*
|
|
672
|
+
* // Set text properties
|
|
673
|
+
* fill(0); // Text color: black
|
|
674
|
+
* textSize(12); // Adjust text size as needed
|
|
675
|
+
*
|
|
676
|
+
* // Display the number of rows and columns on the canvas
|
|
677
|
+
* text(table.getRowCount() + ' total rows in table', 10, 30);
|
|
678
|
+
* text(table.getColumnCount() + ' total columns in table', 10, 60);
|
|
679
|
+
*
|
|
680
|
+
* describe('no image displayed');
|
|
681
|
+
* }
|
|
682
|
+
* </code>
|
|
683
|
+
* </div>
|
|
684
|
+
*/
|
|
685
|
+
function clearRows(): void;
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* Use addColumn() to add a new column to a Table object.
|
|
689
|
+
* Typically, you will want to specify a title, so the column
|
|
690
|
+
* may be easily referenced later by name. (If no title is
|
|
691
|
+
* specified, the new column's title will be null.)
|
|
692
|
+
*
|
|
693
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
694
|
+
* @param title of the given column
|
|
695
|
+
* @example <div>
|
|
696
|
+
* <code>
|
|
697
|
+
* let table;
|
|
698
|
+
*
|
|
699
|
+
* async function setup() {
|
|
700
|
+
* createCanvas(300, 300);
|
|
701
|
+
* table = await loadTable('/assets/mammals.csv', ',', 'header');
|
|
702
|
+
*
|
|
703
|
+
* table.addColumn('carnivore');
|
|
704
|
+
* table.set(0, 'carnivore', 'no');
|
|
705
|
+
* table.set(1, 'carnivore', 'yes');
|
|
706
|
+
* table.set(2, 'carnivore', 'no');
|
|
707
|
+
*
|
|
708
|
+
* fill(0); // Set text color to black
|
|
709
|
+
* textSize(11); // Adjust text size as needed
|
|
710
|
+
*
|
|
711
|
+
* for (let r = 0; r < table.getRowCount(); r++) {
|
|
712
|
+
* for (let c = 0; c < table.getColumnCount(); c++) {
|
|
713
|
+
* // Keep column spacing consistent (e.g. 80 pixels apart).
|
|
714
|
+
* let x = c * 80 + 10;
|
|
715
|
+
* let y = r * 30 + 20;
|
|
716
|
+
* // Use x directly, rather than multiplying by c again
|
|
717
|
+
* text(table.getString(r, c), x, y);
|
|
718
|
+
* }
|
|
719
|
+
* }
|
|
720
|
+
*
|
|
721
|
+
* describe('no image displayed');
|
|
722
|
+
* }
|
|
723
|
+
* </code>
|
|
724
|
+
* </div>
|
|
725
|
+
*/
|
|
726
|
+
function addColumn(title?: string): void;
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* Returns the total number of columns in a Table.
|
|
730
|
+
*
|
|
731
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
732
|
+
* @return Number of columns in this table
|
|
733
|
+
* @example <div>
|
|
734
|
+
* <code>
|
|
735
|
+
* // given the cvs file "blobs.csv" in /assets directory
|
|
736
|
+
* // ID, Name, Flavor, Shape, Color
|
|
737
|
+
* // Blob1, Blobby, Sweet, Blob, Pink
|
|
738
|
+
* // Blob2, Saddy, Savory, Blob, Blue
|
|
739
|
+
*
|
|
740
|
+
* let table;
|
|
741
|
+
*
|
|
742
|
+
* async function setup() {
|
|
743
|
+
* table = await loadTable('assets/blobs.csv');
|
|
744
|
+
*
|
|
745
|
+
* createCanvas(200, 100);
|
|
746
|
+
* textAlign(CENTER);
|
|
747
|
+
* background(255);
|
|
748
|
+
* }
|
|
749
|
+
*
|
|
750
|
+
* function draw() {
|
|
751
|
+
* let numOfColumn = table.getColumnCount();
|
|
752
|
+
* text('There are ' + numOfColumn + ' columns in the table.', 100, 50);
|
|
753
|
+
* }
|
|
754
|
+
* </code>
|
|
755
|
+
* </div>
|
|
756
|
+
*/
|
|
757
|
+
function getColumnCount(): number;
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Returns the total number of rows in a Table.
|
|
761
|
+
*
|
|
762
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
763
|
+
* @return Number of rows in this table
|
|
764
|
+
* @example <div>
|
|
765
|
+
* <code>
|
|
766
|
+
* // given the cvs file "blobs.csv" in /assets directory
|
|
767
|
+
* //
|
|
768
|
+
* // ID, Name, Flavor, Shape, Color
|
|
769
|
+
* // Blob1, Blobby, Sweet, Blob, Pink
|
|
770
|
+
* // Blob2, Saddy, Savory, Blob, Blue
|
|
771
|
+
*
|
|
772
|
+
* let table;
|
|
773
|
+
*
|
|
774
|
+
* async function setup() {
|
|
775
|
+
* table = await loadTable('assets/blobs.csv');
|
|
776
|
+
*
|
|
777
|
+
* createCanvas(200, 100);
|
|
778
|
+
* textAlign(CENTER);
|
|
779
|
+
* background(255);
|
|
780
|
+
* }
|
|
781
|
+
*
|
|
782
|
+
* function draw() {
|
|
783
|
+
* text('There are ' + table.getRowCount() + ' rows in the table.', 100, 50);
|
|
784
|
+
* }
|
|
785
|
+
* </code>
|
|
786
|
+
* </div>
|
|
787
|
+
*/
|
|
788
|
+
function getRowCount(): number;
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Removes any of the specified characters (or "tokens").If no column is specified, then the values in all columns and
|
|
792
|
+
* rows are processed. A specific column may be referenced by
|
|
793
|
+
* either its ID or title.
|
|
794
|
+
*
|
|
795
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
796
|
+
* @param String listing characters to be removed
|
|
797
|
+
* @param Column ID (number)
|
|
798
|
+
* or name (string)
|
|
799
|
+
* @example <div class="norender"><code>
|
|
800
|
+
* function setup() {
|
|
801
|
+
* let table = new p5.Table();
|
|
802
|
+
*
|
|
803
|
+
* table.addColumn('name');
|
|
804
|
+
* table.addColumn('type');
|
|
805
|
+
*
|
|
806
|
+
* let newRow = table.addRow();
|
|
807
|
+
* newRow.setString('name', ' $Lion ,');
|
|
808
|
+
* newRow.setString('type', ',,,Mammal');
|
|
809
|
+
*
|
|
810
|
+
* newRow = table.addRow();
|
|
811
|
+
* newRow.setString('name', '$Snake ');
|
|
812
|
+
* newRow.setString('type', ',,,Reptile');
|
|
813
|
+
*
|
|
814
|
+
* table.removeTokens(',$ ');
|
|
815
|
+
* print(table.getArray());
|
|
816
|
+
* }
|
|
817
|
+
*
|
|
818
|
+
* // prints:
|
|
819
|
+
* // 0 "Lion" "Mamal"
|
|
820
|
+
* // 1 "Snake" "Reptile"
|
|
821
|
+
* </code></div>
|
|
822
|
+
*/
|
|
823
|
+
function removeTokens(chars: string, column?: string | number): void;
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* Trims leading and trailing whitespace, such as spaces and tabs,
|
|
827
|
+
* from String table values. If no column is specified, then the
|
|
828
|
+
* values in all columns and rows are trimmed. A specific column
|
|
829
|
+
* may be referenced by either its ID or title.
|
|
830
|
+
*
|
|
831
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
832
|
+
* @param Column ID (number)
|
|
833
|
+
* or name (string)
|
|
834
|
+
* @example <div class="norender"><code>
|
|
835
|
+
* function setup() {
|
|
836
|
+
* let table = new p5.Table();
|
|
837
|
+
*
|
|
838
|
+
* table.addColumn('name');
|
|
839
|
+
* table.addColumn('type');
|
|
840
|
+
*
|
|
841
|
+
* let newRow = table.addRow();
|
|
842
|
+
* newRow.setString('name', ' Lion ,');
|
|
843
|
+
* newRow.setString('type', ' Mammal ');
|
|
844
|
+
*
|
|
845
|
+
* newRow = table.addRow();
|
|
846
|
+
* newRow.setString('name', ' Snake ');
|
|
847
|
+
* newRow.setString('type', ' Reptile ');
|
|
848
|
+
*
|
|
849
|
+
* table.trim();
|
|
850
|
+
* print(table.getArray());
|
|
851
|
+
* }
|
|
852
|
+
*
|
|
853
|
+
* // prints:
|
|
854
|
+
* // 0 "Lion" "Mamal"
|
|
855
|
+
* // 1 "Snake" "Reptile"
|
|
856
|
+
* </code></div>
|
|
857
|
+
*/
|
|
858
|
+
function trim(column?: string | number): void;
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* Use removeColumn() to remove an existing column from a Table
|
|
862
|
+
* object. The column to be removed may be identified by either
|
|
863
|
+
* its title (a String) or its index value (an int).
|
|
864
|
+
* removeColumn(0) would remove the first column, removeColumn(1)
|
|
865
|
+
* would remove the second column, and so on.
|
|
866
|
+
*
|
|
867
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
868
|
+
* @param columnName (string) or ID (number)
|
|
869
|
+
* @example <div>
|
|
870
|
+
* <code>
|
|
871
|
+
* let table;
|
|
872
|
+
*
|
|
873
|
+
* async function setup() {
|
|
874
|
+
* // Create a 100x100 canvas
|
|
875
|
+
* createCanvas(100, 100);
|
|
876
|
+
* background(255); // Set background to white
|
|
877
|
+
*
|
|
878
|
+
* // Load the CSV file with a header row
|
|
879
|
+
* table = await loadTable('assets/mammals.csv', ',', 'header');
|
|
880
|
+
*
|
|
881
|
+
* // Remove the "id" column
|
|
882
|
+
* table.removeColumn('id');
|
|
883
|
+
*
|
|
884
|
+
* // Get the remaining column count
|
|
885
|
+
* let colCount = table.getColumnCount();
|
|
886
|
+
*
|
|
887
|
+
* // Set text properties
|
|
888
|
+
* fill(0); // Text color: black
|
|
889
|
+
* textSize(12); // Adjust text size as needed
|
|
890
|
+
*
|
|
891
|
+
* // Display the column count on the canvas
|
|
892
|
+
* text(colCount, 40, 50);
|
|
893
|
+
*
|
|
894
|
+
* describe('no image displayed');
|
|
895
|
+
* }
|
|
896
|
+
* </code>
|
|
897
|
+
* </div>
|
|
898
|
+
*/
|
|
899
|
+
function removeColumn(c: any, column: string | number): void;
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Stores a value in the Table's specified row and column.
|
|
903
|
+
* The row is specified by its ID, while the column may be specified
|
|
904
|
+
* by either its ID or title.
|
|
905
|
+
*
|
|
906
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
907
|
+
* @param row ID
|
|
908
|
+
* @param column ID (Number)
|
|
909
|
+
* or title (String)
|
|
910
|
+
* @param value to assign
|
|
911
|
+
* @example <div>
|
|
912
|
+
* <code>
|
|
913
|
+
* let table;
|
|
914
|
+
*
|
|
915
|
+
* async function setup() {
|
|
916
|
+
* // Create a 200x200 canvas and set a white background
|
|
917
|
+
* createCanvas(200, 200);
|
|
918
|
+
* background(255);
|
|
919
|
+
*
|
|
920
|
+
* // Load the CSV file with a header row
|
|
921
|
+
* table = await loadTable('assets/mammals.csv', ',', 'header');
|
|
922
|
+
*
|
|
923
|
+
* // Update the first row: change species to "Canis Lupus" and name to "Wolf"
|
|
924
|
+
* table.set(0, 'species', 'Canis Lupus');
|
|
925
|
+
* table.set(0, 'name', 'Wolf');
|
|
926
|
+
*
|
|
927
|
+
* // Set text properties for drawing on the canvas
|
|
928
|
+
* fill(0); // Text color: black
|
|
929
|
+
* textSize(12); // Adjust text size as needed
|
|
930
|
+
*
|
|
931
|
+
* // Display the table values on the canvas:
|
|
932
|
+
* // Each row's values are concatenated into a single string and displayed on a new line.
|
|
933
|
+
* let y = 20; // Starting vertical position
|
|
934
|
+
* for (let r = 0; r < table.getRowCount(); r++) {
|
|
935
|
+
* let rowText = "";
|
|
936
|
+
* for (let c = 0; c < table.getColumnCount(); c++) {
|
|
937
|
+
* rowText += table.getString(r, c) + " ";
|
|
938
|
+
* }
|
|
939
|
+
* text(rowText, 10, y * 2.5);
|
|
940
|
+
* y += 20;
|
|
941
|
+
* }
|
|
942
|
+
*
|
|
943
|
+
* describe('no image displayed');
|
|
944
|
+
* }
|
|
945
|
+
* </code>
|
|
946
|
+
* </div>
|
|
947
|
+
*/
|
|
948
|
+
function set(row: number, column: string | number, value: string | number): void;
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* Stores a Float value in the Table's specified row and column.
|
|
952
|
+
* The row is specified by its ID, while the column may be specified
|
|
953
|
+
* by either its ID or title.
|
|
954
|
+
*
|
|
955
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
956
|
+
* @param row ID
|
|
957
|
+
* @param column ID (Number)
|
|
958
|
+
* or title (String)
|
|
959
|
+
* @param value to assign
|
|
960
|
+
* @example <div>
|
|
961
|
+
* <code>
|
|
962
|
+
* let table;
|
|
963
|
+
*
|
|
964
|
+
* async function setup() {
|
|
965
|
+
* // Create a 100x100 canvas and set a white background
|
|
966
|
+
* createCanvas(100, 100);
|
|
967
|
+
* background(255);
|
|
968
|
+
*
|
|
969
|
+
* // Load the CSV file with a header row
|
|
970
|
+
* table = await loadTable('assets/mammals.csv', ',', 'header');
|
|
971
|
+
*
|
|
972
|
+
* // Set the value in row 1, column "id" to the number 1
|
|
973
|
+
* table.setNum(1, 'id', 1);
|
|
974
|
+
*
|
|
975
|
+
* // Get the first column as an array and join its values into a string for display.
|
|
976
|
+
* let col0 = table.getColumn(0); // Expected output: ["0", 1, "2"]
|
|
977
|
+
* let output = col0.join(", ");
|
|
978
|
+
*
|
|
979
|
+
* // Set text properties and display the output on the canvas
|
|
980
|
+
* fill(0); // Text color: black
|
|
981
|
+
* textSize(12); // Adjust text size as needed
|
|
982
|
+
* text(output, 30, 50);
|
|
983
|
+
*
|
|
984
|
+
* describe('no image displayed');
|
|
985
|
+
* }
|
|
986
|
+
* </code>
|
|
987
|
+
* </div>
|
|
988
|
+
*/
|
|
989
|
+
function setNum(row: number, column: string | number, value: number): void;
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* Stores a String value in the Table's specified row and column.
|
|
993
|
+
* The row is specified by its ID, while the column may be specified
|
|
994
|
+
* by either its ID or title.
|
|
995
|
+
*
|
|
996
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
997
|
+
* @param row ID
|
|
998
|
+
* @param column ID (Number)
|
|
999
|
+
* or title (String)
|
|
1000
|
+
* @param value to assign
|
|
1001
|
+
* @example <div>
|
|
1002
|
+
* <code>
|
|
1003
|
+
* let table;
|
|
1004
|
+
*
|
|
1005
|
+
* async function setup() {
|
|
1006
|
+
* // Create a 200x200 canvas and set a white background
|
|
1007
|
+
* createCanvas(200, 200);
|
|
1008
|
+
* background(255);
|
|
1009
|
+
*
|
|
1010
|
+
* // Load the CSV file from the assets folder with a header row
|
|
1011
|
+
* table = await loadTable('assets/mammals.csv', ',', 'header');
|
|
1012
|
+
*
|
|
1013
|
+
* // Add a new row with the new animal data
|
|
1014
|
+
* let newRow = table.addRow();
|
|
1015
|
+
* newRow.setString('id', table.getRowCount() - 1);
|
|
1016
|
+
* newRow.setString('species', 'Canis Lupus');
|
|
1017
|
+
* newRow.setString('name', 'Wolf');
|
|
1018
|
+
*
|
|
1019
|
+
* // Convert the table to a 2D array
|
|
1020
|
+
* let tableArray = table.getArray();
|
|
1021
|
+
*
|
|
1022
|
+
* // Set text properties
|
|
1023
|
+
* fill(0); // Set text color to black
|
|
1024
|
+
* textSize(12); // Adjust text size as needed
|
|
1025
|
+
*
|
|
1026
|
+
* // Display each row of the table on the canvas
|
|
1027
|
+
* let y = 20; // Starting y position
|
|
1028
|
+
* for (let i = 0; i < tableArray.length; i++) {
|
|
1029
|
+
* // Join the values of each row with a comma separator
|
|
1030
|
+
* let rowText = tableArray[i].join(', ');
|
|
1031
|
+
* text(rowText, 15, y * 2);
|
|
1032
|
+
* y += 20; // Increment y position for the next row
|
|
1033
|
+
* }
|
|
1034
|
+
*
|
|
1035
|
+
* describe('no image displayed');
|
|
1036
|
+
* }
|
|
1037
|
+
* </code>
|
|
1038
|
+
* </div>
|
|
1039
|
+
*/
|
|
1040
|
+
function setString(row: number, column: string | number, value: string): void;
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* Retrieves a value from the Table's specified row and column.
|
|
1044
|
+
* The row is specified by its ID, while the column may be specified by
|
|
1045
|
+
* either its ID or title.
|
|
1046
|
+
*
|
|
1047
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
1048
|
+
* @param row ID
|
|
1049
|
+
* @param columnName (string) or
|
|
1050
|
+
* ID (number)
|
|
1051
|
+
* @example <div>
|
|
1052
|
+
* <code>
|
|
1053
|
+
* let table;
|
|
1054
|
+
*
|
|
1055
|
+
* async function setup() {
|
|
1056
|
+
* // Create a 100x100 canvas
|
|
1057
|
+
* createCanvas(100, 100);
|
|
1058
|
+
* background(255); // Set background to white
|
|
1059
|
+
*
|
|
1060
|
+
* // Load the CSV file from the assets folder with a header row
|
|
1061
|
+
* table = await loadTable('assets/mammals.csv', ',', 'header');
|
|
1062
|
+
*
|
|
1063
|
+
* // Set text properties for drawing on the canvas
|
|
1064
|
+
* fill(0); // Text color: black
|
|
1065
|
+
* textSize(12); // Adjust text size as needed
|
|
1066
|
+
*
|
|
1067
|
+
* // Get the values from the table
|
|
1068
|
+
* let value1 = table.get(0, 1); // Using column index (1) => "Capra hircus"
|
|
1069
|
+
* let value2 = table.get(0, 'species'); // Using column name => "Capra hircus"
|
|
1070
|
+
*
|
|
1071
|
+
* // Display the values on the canvas
|
|
1072
|
+
* text(value1, 10, 30);
|
|
1073
|
+
* text(value2, 10, 60);
|
|
1074
|
+
*
|
|
1075
|
+
* describe('no image displayed');
|
|
1076
|
+
* }
|
|
1077
|
+
* </code>
|
|
1078
|
+
* </div>
|
|
1079
|
+
*/
|
|
1080
|
+
function get(row: number, column: string | number): string | number;
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* Retrieves a Float value from the Table's specified row and column.
|
|
1084
|
+
* The row is specified by its ID, while the column may be specified by
|
|
1085
|
+
* either its ID or title.
|
|
1086
|
+
*
|
|
1087
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
1088
|
+
* @param row ID
|
|
1089
|
+
* @param columnName (string) or
|
|
1090
|
+
* ID (number)
|
|
1091
|
+
* @example <div>
|
|
1092
|
+
* <code>
|
|
1093
|
+
* let table;
|
|
1094
|
+
*
|
|
1095
|
+
* async function setup() {
|
|
1096
|
+
* // Create a 100x100 canvas
|
|
1097
|
+
* createCanvas(100, 100);
|
|
1098
|
+
* background(255); // Set background to white
|
|
1099
|
+
*
|
|
1100
|
+
* // Load the CSV file with a header row
|
|
1101
|
+
* table = await loadTable('assets/mammals.csv', ',', 'header');
|
|
1102
|
+
*
|
|
1103
|
+
* // Compute the result: id at row 1, column 0 plus 100 (i.e. 1 + 100 = 101)
|
|
1104
|
+
* let result = table.getNum(1, 0) + 100;
|
|
1105
|
+
*
|
|
1106
|
+
* // Set text properties and display the result on the canvas
|
|
1107
|
+
* fill(0); // Set text color to black
|
|
1108
|
+
* textSize(12); // Adjust text size as needed
|
|
1109
|
+
* text(result, 10, 30); // Display the result at position (10, 30)
|
|
1110
|
+
*
|
|
1111
|
+
* describe('no image displayed');
|
|
1112
|
+
* }
|
|
1113
|
+
* </code>
|
|
1114
|
+
* </div>
|
|
1115
|
+
*/
|
|
1116
|
+
function getNum(row: number, column: string | number): number;
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* Retrieves a String value from the Table's specified row and column.
|
|
1120
|
+
* The row is specified by its ID, while the column may be specified by
|
|
1121
|
+
* either its ID or title.
|
|
1122
|
+
*
|
|
1123
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
1124
|
+
* @param row ID
|
|
1125
|
+
* @param columnName (string) or
|
|
1126
|
+
* ID (number)
|
|
1127
|
+
* @example <div>
|
|
1128
|
+
* <code>
|
|
1129
|
+
* let table;
|
|
1130
|
+
*
|
|
1131
|
+
* async function setup() {
|
|
1132
|
+
* // Create a 200x200 canvas
|
|
1133
|
+
* createCanvas(200, 200);
|
|
1134
|
+
* background(255); // Set background to white
|
|
1135
|
+
*
|
|
1136
|
+
* // Load the CSV file with a header row
|
|
1137
|
+
* table = await loadTable('assets/mammals.csv', ',', 'header');
|
|
1138
|
+
*
|
|
1139
|
+
* // Set text properties
|
|
1140
|
+
* fill(0); // Text color: black
|
|
1141
|
+
* textSize(12); // Adjust text size as needed
|
|
1142
|
+
*
|
|
1143
|
+
* // Display each table cell value on the canvas one below the other.
|
|
1144
|
+
* // We use a variable 'y' to increment the vertical position.
|
|
1145
|
+
* let y = 20;
|
|
1146
|
+
* text(table.getString(0, 0), 10, y); // 0
|
|
1147
|
+
* y += 20;
|
|
1148
|
+
* text(table.getString(0, 1), 10, y); // Capra hircus
|
|
1149
|
+
* y += 20;
|
|
1150
|
+
* text(table.getString(0, 2), 10, y); // Goat
|
|
1151
|
+
* y += 20;
|
|
1152
|
+
* text(table.getString(1, 0), 10, y); // 1
|
|
1153
|
+
* y += 20;
|
|
1154
|
+
* text(table.getString(1, 1), 10, y); // Panthera pardus
|
|
1155
|
+
* y += 20;
|
|
1156
|
+
* text(table.getString(1, 2), 10, y); // Leopard
|
|
1157
|
+
* y += 20;
|
|
1158
|
+
* text(table.getString(2, 0), 10, y); // 2
|
|
1159
|
+
* y += 20;
|
|
1160
|
+
* text(table.getString(2, 1), 10, y); // Equus zebra
|
|
1161
|
+
* y += 20;
|
|
1162
|
+
* text(table.getString(2, 2), 10, y); // Zebra
|
|
1163
|
+
*
|
|
1164
|
+
* describe('no image displayed');
|
|
1165
|
+
* }
|
|
1166
|
+
* </code>
|
|
1167
|
+
* </div>
|
|
1168
|
+
*/
|
|
1169
|
+
function getString(row: number, column: string | number): string;
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* Retrieves all table data and returns as an object. If a column name is
|
|
1173
|
+
* passed in, each row object will be stored with that attribute as its
|
|
1174
|
+
* title.
|
|
1175
|
+
*
|
|
1176
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
1177
|
+
* @param Name of the column which should be used to
|
|
1178
|
+
* title each row object (optional)
|
|
1179
|
+
* @example <div class="norender">
|
|
1180
|
+
* <code>
|
|
1181
|
+
* // Given the CSV file "mammals.csv"
|
|
1182
|
+
* // in the project's "assets" folder:
|
|
1183
|
+
* //
|
|
1184
|
+
* // id,species,name
|
|
1185
|
+
* // 0,Capra hircus,Goat
|
|
1186
|
+
* // 1,Panthera pardus,Leopard
|
|
1187
|
+
* // 2,Equus zebra,Zebra
|
|
1188
|
+
*
|
|
1189
|
+
* let table;
|
|
1190
|
+
*
|
|
1191
|
+
* async function setup() {
|
|
1192
|
+
* // The table is comma separated value "csv"
|
|
1193
|
+
* // and has a header specifying the columns labels.
|
|
1194
|
+
* table = await loadTable('assets/mammals.csv', 'csv', 'header');
|
|
1195
|
+
*
|
|
1196
|
+
* let tableObject = table.getObject();
|
|
1197
|
+
*
|
|
1198
|
+
* print(tableObject);
|
|
1199
|
+
* //outputs an object
|
|
1200
|
+
*
|
|
1201
|
+
* describe('no image displayed');
|
|
1202
|
+
* }
|
|
1203
|
+
* </code>
|
|
1204
|
+
* </div>
|
|
1205
|
+
*/
|
|
1206
|
+
function getObject(headerColumn?: string): object;
|
|
1207
|
+
|
|
1208
|
+
/**
|
|
1209
|
+
* Retrieves all table data and returns it as a multidimensional array.
|
|
1210
|
+
*
|
|
1211
|
+
* @deprecated p5.Table will be removed in a future version of p5.js to make way for a new, friendlier version :)
|
|
1212
|
+
* @example <div>
|
|
1213
|
+
* <code>
|
|
1214
|
+
* let table;
|
|
1215
|
+
*
|
|
1216
|
+
* async function setup() {
|
|
1217
|
+
* // Create a 200x200 canvas and set a white background
|
|
1218
|
+
* createCanvas(200, 200);
|
|
1219
|
+
* background(255);
|
|
1220
|
+
*
|
|
1221
|
+
* // Load the CSV file with a header row
|
|
1222
|
+
* table = await loadTable('assets/mammals.csv', ',', 'header');
|
|
1223
|
+
*
|
|
1224
|
+
* // Get the CSV data as a 2D array
|
|
1225
|
+
* let tableArray = table.getArray();
|
|
1226
|
+
*
|
|
1227
|
+
* // Set text properties
|
|
1228
|
+
* fill(0); // Set text color to black
|
|
1229
|
+
* textSize(12); // Adjust text size as needed
|
|
1230
|
+
*
|
|
1231
|
+
* // Display each row of the CSV on the canvas
|
|
1232
|
+
* // Each row is displayed on a separate line
|
|
1233
|
+
* for (let i = 0; i < tableArray.length; i++) {
|
|
1234
|
+
* let rowText = tableArray[i].join(", ");
|
|
1235
|
+
* text(rowText, 10, 20 + i * 50 + 30);
|
|
1236
|
+
* }
|
|
1237
|
+
*
|
|
1238
|
+
* describe('no image displayed');
|
|
1239
|
+
* }
|
|
1240
|
+
* </code>
|
|
1241
|
+
* </div>
|
|
1242
|
+
*/
|
|
1243
|
+
function getArray(): Array;
|
|
1244
|
+
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
export default function p5_Table(p5: any, fn: any): void;
|