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,663 @@
|
|
|
1
|
+
// This file is auto-generated from JSDoc documentation
|
|
2
|
+
|
|
3
|
+
import p5 from 'p5';
|
|
4
|
+
|
|
5
|
+
declare module 'p5' {
|
|
6
|
+
/**
|
|
7
|
+
* Calculates the arc cosine of a number.`acos()` is the inverse of cos(). It expects
|
|
8
|
+
* arguments in the range -1 to 1. By default, `acos()` returns values in the
|
|
9
|
+
* range 0 to π (about 3.14). If the
|
|
10
|
+
* angleMode() is `DEGREES`, then values are
|
|
11
|
+
* returned in the range 0 to 180.
|
|
12
|
+
*
|
|
13
|
+
* @param value whose arc cosine is to be returned.
|
|
14
|
+
* @return arc cosine of the given value.
|
|
15
|
+
* @example <div>
|
|
16
|
+
* <code>
|
|
17
|
+
* function setup() {
|
|
18
|
+
* createCanvas(100, 100);
|
|
19
|
+
*
|
|
20
|
+
* background(200);
|
|
21
|
+
*
|
|
22
|
+
* // Calculate cos() and acos() values.
|
|
23
|
+
* let a = PI;
|
|
24
|
+
* let c = cos(a);
|
|
25
|
+
* let ac = acos(c);
|
|
26
|
+
*
|
|
27
|
+
* // Display the values.
|
|
28
|
+
* text(`${round(a, 3)}`, 35, 25);
|
|
29
|
+
* text(`${round(c, 3)}`, 35, 50);
|
|
30
|
+
* text(`${round(ac, 3)}`, 35, 75);
|
|
31
|
+
*
|
|
32
|
+
* describe('The numbers 3.142, -1, and 3.142 written on separate rows.');
|
|
33
|
+
* }
|
|
34
|
+
* </code>
|
|
35
|
+
* </div>
|
|
36
|
+
*
|
|
37
|
+
* <div>
|
|
38
|
+
* <code>
|
|
39
|
+
* function setup() {
|
|
40
|
+
* createCanvas(100, 100);
|
|
41
|
+
*
|
|
42
|
+
* background(200);
|
|
43
|
+
*
|
|
44
|
+
* // Calculate cos() and acos() values.
|
|
45
|
+
* let a = PI + QUARTER_PI;
|
|
46
|
+
* let c = cos(a);
|
|
47
|
+
* let ac = acos(c);
|
|
48
|
+
*
|
|
49
|
+
* // Display the values.
|
|
50
|
+
* text(`${round(a, 3)}`, 35, 25);
|
|
51
|
+
* text(`${round(c, 3)}`, 35, 50);
|
|
52
|
+
* text(`${round(ac, 3)}`, 35, 75);
|
|
53
|
+
*
|
|
54
|
+
* describe('The numbers 3.927, -0.707, and 2.356 written on separate rows.');
|
|
55
|
+
* }
|
|
56
|
+
* </code>
|
|
57
|
+
* </div>
|
|
58
|
+
*/
|
|
59
|
+
function acos(value: number): number;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Calculates the arc sine of a number.`asin()` is the inverse of sin(). It expects input
|
|
63
|
+
* values in the range of -1 to 1. By default, `asin()` returns values in the
|
|
64
|
+
* range -π ÷ 2 (about -1.57) to π ÷ 2 (about 1.57). If
|
|
65
|
+
* the angleMode() is `DEGREES` then values are
|
|
66
|
+
* returned in the range -90 to 90.
|
|
67
|
+
*
|
|
68
|
+
* @param value whose arc sine is to be returned.
|
|
69
|
+
* @return arc sine of the given value.
|
|
70
|
+
* @example <div>
|
|
71
|
+
* <code>
|
|
72
|
+
* function setup() {
|
|
73
|
+
* createCanvas(100, 100);
|
|
74
|
+
*
|
|
75
|
+
* background(200);
|
|
76
|
+
*
|
|
77
|
+
* // Calculate sin() and asin() values.
|
|
78
|
+
* let a = PI / 3;
|
|
79
|
+
* let s = sin(a);
|
|
80
|
+
* let as = asin(s);
|
|
81
|
+
*
|
|
82
|
+
* // Display the values.
|
|
83
|
+
* text(`${round(a, 3)}`, 35, 25);
|
|
84
|
+
* text(`${round(s, 3)}`, 35, 50);
|
|
85
|
+
* text(`${round(as, 3)}`, 35, 75);
|
|
86
|
+
*
|
|
87
|
+
* describe('The numbers 1.047, 0.866, and 1.047 written on separate rows.');
|
|
88
|
+
* }
|
|
89
|
+
* </code>
|
|
90
|
+
* </div>
|
|
91
|
+
*
|
|
92
|
+
* <div>
|
|
93
|
+
* <code>
|
|
94
|
+
* function setup() {
|
|
95
|
+
* createCanvas(100, 100);
|
|
96
|
+
*
|
|
97
|
+
* background(200);
|
|
98
|
+
*
|
|
99
|
+
* // Calculate sin() and asin() values.
|
|
100
|
+
* let a = PI + PI / 3;
|
|
101
|
+
* let s = sin(a);
|
|
102
|
+
* let as = asin(s);
|
|
103
|
+
*
|
|
104
|
+
* // Display the values.
|
|
105
|
+
* text(`${round(a, 3)}`, 35, 25);
|
|
106
|
+
* text(`${round(s, 3)}`, 35, 50);
|
|
107
|
+
* text(`${round(as, 3)}`, 35, 75);
|
|
108
|
+
*
|
|
109
|
+
* describe('The numbers 4.189, -0.866, and -1.047 written on separate rows.');
|
|
110
|
+
* }
|
|
111
|
+
* </code>
|
|
112
|
+
* </div>
|
|
113
|
+
*/
|
|
114
|
+
function asin(value: number): number;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Calculates the arc tangent of a number.`atan()` is the inverse of tan(). It expects input
|
|
118
|
+
* values in the range of -Infinity to Infinity. By default, `atan()` returns
|
|
119
|
+
* values in the range -π ÷ 2 (about -1.57) to π ÷ 2
|
|
120
|
+
* (about 1.57). If the angleMode() is `DEGREES`
|
|
121
|
+
* then values are returned in the range -90 to 90.
|
|
122
|
+
*
|
|
123
|
+
* @param value whose arc tangent is to be returned.
|
|
124
|
+
* @return arc tangent of the given value.
|
|
125
|
+
* @example <div>
|
|
126
|
+
* <code>
|
|
127
|
+
* function setup() {
|
|
128
|
+
* createCanvas(100, 100);
|
|
129
|
+
*
|
|
130
|
+
* background(200);
|
|
131
|
+
*
|
|
132
|
+
* // Calculate tan() and atan() values.
|
|
133
|
+
* let a = PI / 3;
|
|
134
|
+
* let t = tan(a);
|
|
135
|
+
* let at = atan(t);
|
|
136
|
+
*
|
|
137
|
+
* // Display the values.
|
|
138
|
+
* text(`${round(a, 3)}`, 35, 25);
|
|
139
|
+
* text(`${round(t, 3)}`, 35, 50);
|
|
140
|
+
* text(`${round(at, 3)}`, 35, 75);
|
|
141
|
+
*
|
|
142
|
+
* describe('The numbers 1.047, 1.732, and 1.047 written on separate rows.');
|
|
143
|
+
* }
|
|
144
|
+
* </code>
|
|
145
|
+
* </div>
|
|
146
|
+
*
|
|
147
|
+
* <div>
|
|
148
|
+
* <code>
|
|
149
|
+
* function setup() {
|
|
150
|
+
* createCanvas(100, 100);
|
|
151
|
+
*
|
|
152
|
+
* background(200);
|
|
153
|
+
*
|
|
154
|
+
* // Calculate tan() and atan() values.
|
|
155
|
+
* let a = PI + PI / 3;
|
|
156
|
+
* let t = tan(a);
|
|
157
|
+
* let at = atan(t);
|
|
158
|
+
*
|
|
159
|
+
* // Display the values.
|
|
160
|
+
* text(`${round(a, 3)}`, 35, 25);
|
|
161
|
+
* text(`${round(t, 3)}`, 35, 50);
|
|
162
|
+
* text(`${round(at, 3)}`, 35, 75);
|
|
163
|
+
*
|
|
164
|
+
* describe('The numbers 4.189, 1.732, and 1.047 written on separate rows.');
|
|
165
|
+
* }
|
|
166
|
+
* </code>
|
|
167
|
+
* </div>
|
|
168
|
+
*/
|
|
169
|
+
function atan(value: number): number;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Calculates the angle formed by a point, the origin, and the positive
|
|
173
|
+
* x-axis.`atan2()` is most often used for orienting geometry to the mouse's
|
|
174
|
+
* position, as in `atan2(mouseY, mouseX)`. The first parameter is the point's
|
|
175
|
+
* y-coordinate and the second parameter is its x-coordinate.By default, `atan2()` returns values in the range
|
|
176
|
+
* -π (about -3.14) to π (3.14). If the
|
|
177
|
+
* angleMode() is `DEGREES`, then values are
|
|
178
|
+
* returned in the range -180 to 180.
|
|
179
|
+
*
|
|
180
|
+
* @param y-coordinate of the point.
|
|
181
|
+
* @param x-coordinate of the point.
|
|
182
|
+
* @return arc tangent of the given point.
|
|
183
|
+
* @example <div>
|
|
184
|
+
* <code>
|
|
185
|
+
* function setup() {
|
|
186
|
+
* createCanvas(100, 100);
|
|
187
|
+
*
|
|
188
|
+
* describe('A rectangle at the top-left of the canvas rotates with mouse movements.');
|
|
189
|
+
* }
|
|
190
|
+
*
|
|
191
|
+
* function draw() {
|
|
192
|
+
* background(200);
|
|
193
|
+
*
|
|
194
|
+
* // Calculate the angle between the mouse
|
|
195
|
+
* // and the origin.
|
|
196
|
+
* let a = atan2(mouseY, mouseX);
|
|
197
|
+
*
|
|
198
|
+
* // Rotate.
|
|
199
|
+
* rotate(a);
|
|
200
|
+
*
|
|
201
|
+
* // Draw the shape.
|
|
202
|
+
* rect(0, 0, 60, 10);
|
|
203
|
+
* }
|
|
204
|
+
* </code>
|
|
205
|
+
* </div>
|
|
206
|
+
*
|
|
207
|
+
* <div>
|
|
208
|
+
* <code>
|
|
209
|
+
* function setup() {
|
|
210
|
+
* createCanvas(100, 100);
|
|
211
|
+
*
|
|
212
|
+
* describe('A rectangle at the center of the canvas rotates with mouse movements.');
|
|
213
|
+
* }
|
|
214
|
+
*
|
|
215
|
+
* function draw() {
|
|
216
|
+
* background(200);
|
|
217
|
+
*
|
|
218
|
+
* // Translate the origin to the center.
|
|
219
|
+
* translate(50, 50);
|
|
220
|
+
*
|
|
221
|
+
* // Get the mouse's coordinates relative to the origin.
|
|
222
|
+
* let x = mouseX - 50;
|
|
223
|
+
* let y = mouseY - 50;
|
|
224
|
+
*
|
|
225
|
+
* // Calculate the angle between the mouse and the origin.
|
|
226
|
+
* let a = atan2(y, x);
|
|
227
|
+
*
|
|
228
|
+
* // Rotate.
|
|
229
|
+
* rotate(a);
|
|
230
|
+
*
|
|
231
|
+
* // Draw the shape.
|
|
232
|
+
* rect(-30, -5, 60, 10);
|
|
233
|
+
* }
|
|
234
|
+
* </code>
|
|
235
|
+
* </div>
|
|
236
|
+
*/
|
|
237
|
+
function atan2(y: number, x: number): number;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Calculates the cosine of an angle.`cos()` is useful for many geometric tasks in creative coding. The values
|
|
241
|
+
* returned oscillate between -1 and 1 as the input angle increases. `cos()`
|
|
242
|
+
* calculates the cosine of an angle, using radians by default, or according
|
|
243
|
+
* to if angleMode() setting (RADIANS or DEGREES).
|
|
244
|
+
*
|
|
245
|
+
* @param the angle, in radians by default, or according to if <a href="/reference/p5/angleMode/">angleMode()</a> setting (RADIANS or DEGREES).
|
|
246
|
+
* @return cosine of the angle.
|
|
247
|
+
* @example <div>
|
|
248
|
+
* <code>
|
|
249
|
+
* function setup() {
|
|
250
|
+
* createCanvas(100, 100);
|
|
251
|
+
*
|
|
252
|
+
* describe('A white ball on a string oscillates left and right.');
|
|
253
|
+
* }
|
|
254
|
+
*
|
|
255
|
+
* function draw() {
|
|
256
|
+
* background(200);
|
|
257
|
+
*
|
|
258
|
+
* // Calculate the coordinates.
|
|
259
|
+
* let x = 30 * cos(frameCount * 0.05) + 50;
|
|
260
|
+
* let y = 50;
|
|
261
|
+
*
|
|
262
|
+
* // Draw the oscillator.
|
|
263
|
+
* line(50, y, x, y);
|
|
264
|
+
* circle(x, y, 20);
|
|
265
|
+
* }
|
|
266
|
+
* </code>
|
|
267
|
+
* </div>
|
|
268
|
+
*
|
|
269
|
+
* <div>
|
|
270
|
+
* <code>
|
|
271
|
+
* function setup() {
|
|
272
|
+
* createCanvas(100, 100);
|
|
273
|
+
*
|
|
274
|
+
* background(200);
|
|
275
|
+
*
|
|
276
|
+
* describe('A series of black dots form a wave pattern.');
|
|
277
|
+
* }
|
|
278
|
+
*
|
|
279
|
+
* function draw() {
|
|
280
|
+
* // Calculate the coordinates.
|
|
281
|
+
* let x = frameCount;
|
|
282
|
+
* let y = 30 * cos(x * 0.1) + 50;
|
|
283
|
+
*
|
|
284
|
+
* // Draw the point.
|
|
285
|
+
* point(x, y);
|
|
286
|
+
* }
|
|
287
|
+
* </code>
|
|
288
|
+
* </div>
|
|
289
|
+
*
|
|
290
|
+
* <div>
|
|
291
|
+
* <code>
|
|
292
|
+
* function setup() {
|
|
293
|
+
* createCanvas(100, 100);
|
|
294
|
+
*
|
|
295
|
+
* background(200);
|
|
296
|
+
*
|
|
297
|
+
* describe('A series of black dots form an infinity symbol.');
|
|
298
|
+
* }
|
|
299
|
+
*
|
|
300
|
+
* function draw() {
|
|
301
|
+
* // Calculate the coordinates.
|
|
302
|
+
* let x = 30 * cos(frameCount * 0.1) + 50;
|
|
303
|
+
* let y = 10 * sin(frameCount * 0.2) + 50;
|
|
304
|
+
*
|
|
305
|
+
* // Draw the point.
|
|
306
|
+
* point(x, y);
|
|
307
|
+
* }
|
|
308
|
+
* </code>
|
|
309
|
+
* </div>
|
|
310
|
+
*/
|
|
311
|
+
function cos(angle: number): number;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Calculates the sine of an angle.`sin()` is useful for many geometric tasks in creative coding. The values
|
|
315
|
+
* returned oscillate between -1 and 1 as the input angle increases. `sin()`
|
|
316
|
+
* calculates the sine of an angle, using radians by default, or according to
|
|
317
|
+
* if angleMode() setting (RADIANS or DEGREES).
|
|
318
|
+
*
|
|
319
|
+
* @param the angle, in radians by default, or according to if <a href="/reference/p5/angleMode/">angleMode()</a> setting (RADIANS or DEGREES).
|
|
320
|
+
* @return sine of the angle.
|
|
321
|
+
* @example <div>
|
|
322
|
+
* <code>
|
|
323
|
+
* function setup() {
|
|
324
|
+
* createCanvas(100, 100);
|
|
325
|
+
*
|
|
326
|
+
* describe('A white ball on a string oscillates up and down.');
|
|
327
|
+
* }
|
|
328
|
+
*
|
|
329
|
+
* function draw() {
|
|
330
|
+
* background(200);
|
|
331
|
+
*
|
|
332
|
+
* // Calculate the coordinates.
|
|
333
|
+
* let x = 50;
|
|
334
|
+
* let y = 30 * sin(frameCount * 0.05) + 50;
|
|
335
|
+
*
|
|
336
|
+
* // Draw the oscillator.
|
|
337
|
+
* line(50, y, x, y);
|
|
338
|
+
* circle(x, y, 20);
|
|
339
|
+
* }
|
|
340
|
+
* </code>
|
|
341
|
+
* </div>
|
|
342
|
+
*
|
|
343
|
+
* <div>
|
|
344
|
+
* <code>
|
|
345
|
+
* function setup() {
|
|
346
|
+
* createCanvas(100, 100);
|
|
347
|
+
*
|
|
348
|
+
* background(200);
|
|
349
|
+
*
|
|
350
|
+
* describe('A series of black dots form a wave pattern.');
|
|
351
|
+
* }
|
|
352
|
+
*
|
|
353
|
+
* function draw() {
|
|
354
|
+
* // Calculate the coordinates.
|
|
355
|
+
* let x = frameCount;
|
|
356
|
+
* let y = 30 * sin(x * 0.1) + 50;
|
|
357
|
+
*
|
|
358
|
+
* // Draw the point.
|
|
359
|
+
* point(x, y);
|
|
360
|
+
* }
|
|
361
|
+
* </code>
|
|
362
|
+
* </div>
|
|
363
|
+
*
|
|
364
|
+
* <div>
|
|
365
|
+
* <code>
|
|
366
|
+
* function setup() {
|
|
367
|
+
* createCanvas(100, 100);
|
|
368
|
+
*
|
|
369
|
+
* background(200);
|
|
370
|
+
*
|
|
371
|
+
* describe('A series of black dots form an infinity symbol.');
|
|
372
|
+
* }
|
|
373
|
+
*
|
|
374
|
+
* function draw() {
|
|
375
|
+
* // Calculate the coordinates.
|
|
376
|
+
* let x = 30 * cos(frameCount * 0.1) + 50;
|
|
377
|
+
* let y = 10 * sin(frameCount * 0.2) + 50;
|
|
378
|
+
*
|
|
379
|
+
* // Draw the point.
|
|
380
|
+
* point(x, y);
|
|
381
|
+
* }
|
|
382
|
+
* </code>
|
|
383
|
+
* </div>
|
|
384
|
+
*/
|
|
385
|
+
function sin(angle: number): number;
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Calculates the tangent of an angle.`tan()` is useful for many geometric tasks in creative coding. The values
|
|
389
|
+
* returned range from -Infinity to Infinity and repeat periodically as the
|
|
390
|
+
* input angle increases. `tan()` calculates the tan of an angle, using radians
|
|
391
|
+
* by default, or according to
|
|
392
|
+
* if angleMode() setting (RADIANS or DEGREES).
|
|
393
|
+
*
|
|
394
|
+
* @param the angle, in radians by default, or according to if <a href="/reference/p5/angleMode/">angleMode()</a> setting (RADIANS or DEGREES).
|
|
395
|
+
* @return tangent of the angle.
|
|
396
|
+
* @example <div>
|
|
397
|
+
* <code>
|
|
398
|
+
* function setup() {
|
|
399
|
+
* createCanvas(100, 100);
|
|
400
|
+
*
|
|
401
|
+
* background(200);
|
|
402
|
+
*
|
|
403
|
+
* describe('A series of identical curves drawn with black dots. Each curve starts from the top of the canvas, continues down at a slight angle, flattens out at the middle of the canvas, then continues to the bottom.');
|
|
404
|
+
* }
|
|
405
|
+
*
|
|
406
|
+
* function draw() {
|
|
407
|
+
* // Calculate the coordinates.
|
|
408
|
+
* let x = frameCount;
|
|
409
|
+
* let y = 5 * tan(x * 0.1) + 50;
|
|
410
|
+
*
|
|
411
|
+
* // Draw the point.
|
|
412
|
+
* point(x, y);
|
|
413
|
+
* }
|
|
414
|
+
* </code>
|
|
415
|
+
* </div>
|
|
416
|
+
*/
|
|
417
|
+
function tan(angle: number): number;
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Converts an angle measured in radians to its value in degrees.Degrees and radians are both units for measuring angles. There are 360˚ in
|
|
421
|
+
* one full rotation. A full rotation is 2 × π (about 6.28) radians.The same angle can be expressed in with either unit. For example, 90° is a
|
|
422
|
+
* quarter of a full rotation. The same angle is 2 × π ÷ 4
|
|
423
|
+
* (about 1.57) radians.
|
|
424
|
+
*
|
|
425
|
+
* @param radians value to convert to degrees.
|
|
426
|
+
* @return converted angle.
|
|
427
|
+
* @example <div>
|
|
428
|
+
* <code>
|
|
429
|
+
* function setup() {
|
|
430
|
+
* createCanvas(100, 100);
|
|
431
|
+
*
|
|
432
|
+
* background(200);
|
|
433
|
+
*
|
|
434
|
+
* // Calculate the angle conversion.
|
|
435
|
+
* let rad = QUARTER_PI;
|
|
436
|
+
* let deg = degrees(rad);
|
|
437
|
+
*
|
|
438
|
+
* // Display the conversion.
|
|
439
|
+
* text(`${round(rad, 2)} rad = ${deg}˚`, 10, 50);
|
|
440
|
+
*
|
|
441
|
+
* describe('The text "0.79 rad = 45˚".');
|
|
442
|
+
* }
|
|
443
|
+
* </code>
|
|
444
|
+
* </div>
|
|
445
|
+
*/
|
|
446
|
+
function degrees(radians: number): number;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Converts an angle measured in degrees to its value in radians.Degrees and radians are both units for measuring angles. There are 360˚ in
|
|
450
|
+
* one full rotation. A full rotation is 2 × π (about 6.28) radians.The same angle can be expressed in with either unit. For example, 90° is a
|
|
451
|
+
* quarter of a full rotation. The same angle is 2 × π ÷ 4
|
|
452
|
+
* (about 1.57) radians.
|
|
453
|
+
*
|
|
454
|
+
* @param degree value to convert to radians.
|
|
455
|
+
* @return converted angle.
|
|
456
|
+
* @example <div>
|
|
457
|
+
* <code>
|
|
458
|
+
* function setup() {
|
|
459
|
+
* createCanvas(100, 100);
|
|
460
|
+
*
|
|
461
|
+
* background(200);
|
|
462
|
+
*
|
|
463
|
+
* // Caclulate the angle conversion.
|
|
464
|
+
* let deg = 45;
|
|
465
|
+
* let rad = radians(deg);
|
|
466
|
+
*
|
|
467
|
+
* // Display the angle conversion.
|
|
468
|
+
* text(`${deg}˚ = ${round(rad, 3)} rad`, 10, 50);
|
|
469
|
+
*
|
|
470
|
+
* describe('The text "45˚ = 0.785 rad".');
|
|
471
|
+
* }
|
|
472
|
+
* </code>
|
|
473
|
+
* </div>
|
|
474
|
+
*/
|
|
475
|
+
function radians(degrees: number): number;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Changes the unit system used to measure angles.Degrees and radians are both units for measuring angles. There are 360˚ in
|
|
479
|
+
* one full rotation. A full rotation is 2 × π (about 6.28) radians.Functions such as rotate() and
|
|
480
|
+
* sin() expect angles measured radians by default.
|
|
481
|
+
* Calling `angleMode(DEGREES)` switches to degrees. Calling
|
|
482
|
+
* `angleMode(RADIANS)` switches back to radians.Calling `angleMode()` with no arguments returns current angle mode, which
|
|
483
|
+
* is either `RADIANS` or `DEGREES`.
|
|
484
|
+
*
|
|
485
|
+
* @param either RADIANS or DEGREES.
|
|
486
|
+
* @example <div>
|
|
487
|
+
* <code>
|
|
488
|
+
* function setup() {
|
|
489
|
+
* createCanvas(100, 100);
|
|
490
|
+
*
|
|
491
|
+
* background(200);
|
|
492
|
+
*
|
|
493
|
+
* // Rotate 1/8 turn.
|
|
494
|
+
* rotate(QUARTER_PI);
|
|
495
|
+
*
|
|
496
|
+
* // Draw a line.
|
|
497
|
+
* line(0, 0, 80, 0);
|
|
498
|
+
*
|
|
499
|
+
* describe('A diagonal line radiating from the top-left corner of a square.');
|
|
500
|
+
* }
|
|
501
|
+
* </code>
|
|
502
|
+
* </div>
|
|
503
|
+
*
|
|
504
|
+
* <div>
|
|
505
|
+
* <code>
|
|
506
|
+
* function setup() {
|
|
507
|
+
* createCanvas(100, 100);
|
|
508
|
+
*
|
|
509
|
+
* background(200);
|
|
510
|
+
*
|
|
511
|
+
* // Use degrees.
|
|
512
|
+
* angleMode(DEGREES);
|
|
513
|
+
*
|
|
514
|
+
* // Rotate 1/8 turn.
|
|
515
|
+
* rotate(45);
|
|
516
|
+
*
|
|
517
|
+
* // Draw a line.
|
|
518
|
+
* line(0, 0, 80, 0);
|
|
519
|
+
*
|
|
520
|
+
* describe('A diagonal line radiating from the top-left corner of a square.');
|
|
521
|
+
* }
|
|
522
|
+
* </code>
|
|
523
|
+
* </div>
|
|
524
|
+
*
|
|
525
|
+
* <div>
|
|
526
|
+
* <code>
|
|
527
|
+
* function setup() {
|
|
528
|
+
* createCanvas(100, 100);
|
|
529
|
+
*
|
|
530
|
+
* background(50);
|
|
531
|
+
*
|
|
532
|
+
* // Calculate the angle to rotate.
|
|
533
|
+
* let angle = TWO_PI / 7;
|
|
534
|
+
*
|
|
535
|
+
* // Move the origin to the center.
|
|
536
|
+
* translate(50, 50);
|
|
537
|
+
*
|
|
538
|
+
* // Style the flower.
|
|
539
|
+
* noStroke();
|
|
540
|
+
* fill(255, 50);
|
|
541
|
+
*
|
|
542
|
+
* // Draw the flower.
|
|
543
|
+
* for (let i = 0; i < 7; i += 1) {
|
|
544
|
+
* ellipse(0, 0, 80, 20);
|
|
545
|
+
* rotate(angle);
|
|
546
|
+
* }
|
|
547
|
+
*
|
|
548
|
+
* describe('A translucent white flower on a dark background.');
|
|
549
|
+
* }
|
|
550
|
+
* </code>
|
|
551
|
+
* </div>
|
|
552
|
+
*
|
|
553
|
+
* <div>
|
|
554
|
+
* <code>
|
|
555
|
+
* function setup() {
|
|
556
|
+
* createCanvas(100, 100);
|
|
557
|
+
*
|
|
558
|
+
* background(50);
|
|
559
|
+
*
|
|
560
|
+
* // Use degrees.
|
|
561
|
+
* angleMode(DEGREES);
|
|
562
|
+
*
|
|
563
|
+
* // Calculate the angle to rotate.
|
|
564
|
+
* let angle = 360 / 7;
|
|
565
|
+
*
|
|
566
|
+
* // Move the origin to the center.
|
|
567
|
+
* translate(50, 50);
|
|
568
|
+
*
|
|
569
|
+
* // Style the flower.
|
|
570
|
+
* noStroke();
|
|
571
|
+
* fill(255, 50);
|
|
572
|
+
*
|
|
573
|
+
* // Draw the flower.
|
|
574
|
+
* for (let i = 0; i < 7; i += 1) {
|
|
575
|
+
* ellipse(0, 0, 80, 20);
|
|
576
|
+
* rotate(angle);
|
|
577
|
+
* }
|
|
578
|
+
*
|
|
579
|
+
* describe('A translucent white flower on a dark background.');
|
|
580
|
+
* }
|
|
581
|
+
* </code>
|
|
582
|
+
* </div>
|
|
583
|
+
*
|
|
584
|
+
* <div>
|
|
585
|
+
* <code>
|
|
586
|
+
* function setup() {
|
|
587
|
+
* createCanvas(100, 100);
|
|
588
|
+
*
|
|
589
|
+
* describe('A white ball on a string oscillates left and right.');
|
|
590
|
+
* }
|
|
591
|
+
*
|
|
592
|
+
* function draw() {
|
|
593
|
+
* background(200);
|
|
594
|
+
*
|
|
595
|
+
* // Calculate the coordinates.
|
|
596
|
+
* let x = 30 * cos(frameCount * 0.05) + 50;
|
|
597
|
+
* let y = 50;
|
|
598
|
+
*
|
|
599
|
+
* // Draw the oscillator.
|
|
600
|
+
* line(50, y, x, y);
|
|
601
|
+
* circle(x, y, 20);
|
|
602
|
+
* }
|
|
603
|
+
* </code>
|
|
604
|
+
* </div>
|
|
605
|
+
*
|
|
606
|
+
* <div>
|
|
607
|
+
* <code>
|
|
608
|
+
* function setup() {
|
|
609
|
+
* createCanvas(100, 100);
|
|
610
|
+
*
|
|
611
|
+
* // Use degrees.
|
|
612
|
+
* angleMode(DEGREES);
|
|
613
|
+
*
|
|
614
|
+
* describe('A white ball on a string oscillates left and right.');
|
|
615
|
+
* }
|
|
616
|
+
*
|
|
617
|
+
* function draw() {
|
|
618
|
+
* background(200);
|
|
619
|
+
*
|
|
620
|
+
* // Calculate the coordinates.
|
|
621
|
+
* let x = 30 * cos(frameCount * 2.86) + 50;
|
|
622
|
+
* let y = 50;
|
|
623
|
+
*
|
|
624
|
+
* // Draw the oscillator.
|
|
625
|
+
* line(50, y, x, y);
|
|
626
|
+
* circle(x, y, 20);
|
|
627
|
+
* }
|
|
628
|
+
* </code>
|
|
629
|
+
* </div>
|
|
630
|
+
*
|
|
631
|
+
* <div>
|
|
632
|
+
* <code>
|
|
633
|
+
* function setup() {
|
|
634
|
+
* createCanvas(100, 100);
|
|
635
|
+
*
|
|
636
|
+
* background(200);
|
|
637
|
+
*
|
|
638
|
+
* // Draw the upper line.
|
|
639
|
+
* rotate(PI / 6);
|
|
640
|
+
* line(0, 0, 80, 0);
|
|
641
|
+
*
|
|
642
|
+
* // Use degrees.
|
|
643
|
+
* angleMode(DEGREES);
|
|
644
|
+
*
|
|
645
|
+
* // Draw the lower line.
|
|
646
|
+
* rotate(30);
|
|
647
|
+
* line(0, 0, 80, 0);
|
|
648
|
+
*
|
|
649
|
+
* describe('Two diagonal lines radiating from the top-left corner of a square. The lines are oriented 30 degrees from the edges of the square and 30 degrees apart from each other.');
|
|
650
|
+
* }
|
|
651
|
+
* </code>
|
|
652
|
+
* </div>
|
|
653
|
+
*/
|
|
654
|
+
function angleMode(mode: RADIANS | DEGREES): void;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* @return mode either RADIANS or DEGREES
|
|
658
|
+
*/
|
|
659
|
+
function angleMode(): RADIANS | DEGREES;
|
|
660
|
+
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
export default function trigonometry(p5: any, fn: any): void;
|