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,90 @@
|
|
|
1
|
+
// This file is auto-generated from JSDoc documentation
|
|
2
|
+
|
|
3
|
+
import p5 from 'p5';
|
|
4
|
+
import { Vector } from '../math/p5.Vector';
|
|
5
|
+
|
|
6
|
+
declare module 'p5' {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new p5.Vector object.A vector can be thought of in different ways. In one view, a vector is like
|
|
9
|
+
* an arrow pointing in space. Vectors have both magnitude (length) and
|
|
10
|
+
* direction. This view is helpful for programming motion.A vector's components determine its magnitude and direction. For example,
|
|
11
|
+
* calling `createVector(3, 4)` creates a new
|
|
12
|
+
* p5.Vector object with an x-component of 3 and a
|
|
13
|
+
* y-component of 4. From the origin, this vector's tip is 3 units to the
|
|
14
|
+
* right and 4 units down.You can also pass N dimensions to the `createVector` function. For example,
|
|
15
|
+
* calling `createVector(1, 2, 3, 4)` creates a vector with four components.
|
|
16
|
+
* This allows for flexibility in representing vectors in higher-dimensional
|
|
17
|
+
* spaces.p5.Vector objects are often used to program
|
|
18
|
+
* motion because they simplify the math. For example, a moving ball has a
|
|
19
|
+
* position and a velocity. Position describes where the ball is in space. The
|
|
20
|
+
* ball's position vector extends from the origin to the ball's center.
|
|
21
|
+
* Velocity describes the ball's speed and the direction it's moving. If the
|
|
22
|
+
* ball is moving straight up, its velocity vector points straight up. Adding
|
|
23
|
+
* the ball's velocity vector to its position vector moves it, as in
|
|
24
|
+
* `pos.add(vel)`. Vector math relies on methods inside the
|
|
25
|
+
* p5.Vector class.
|
|
26
|
+
*
|
|
27
|
+
* @param Zero or more numbers, representing each component of the vector.
|
|
28
|
+
* @return new <a href="#/p5.Vector">p5.Vector</a> object.
|
|
29
|
+
* @example <div>
|
|
30
|
+
* <code>
|
|
31
|
+
* function setup() {
|
|
32
|
+
* createCanvas(100, 100);
|
|
33
|
+
*
|
|
34
|
+
* background(200);
|
|
35
|
+
*
|
|
36
|
+
* // Create p5.Vector objects.
|
|
37
|
+
* let p1 = createVector(25, 25);
|
|
38
|
+
* let p2 = createVector(50, 50);
|
|
39
|
+
* let p3 = createVector(75, 75);
|
|
40
|
+
*
|
|
41
|
+
* // Draw the dots.
|
|
42
|
+
* strokeWeight(5);
|
|
43
|
+
* point(p1);
|
|
44
|
+
* point(p2);
|
|
45
|
+
* point(p3);
|
|
46
|
+
*
|
|
47
|
+
* describe('Three black dots form a diagonal line from top left to bottom right.');
|
|
48
|
+
* }
|
|
49
|
+
* </code>
|
|
50
|
+
* </div>
|
|
51
|
+
*
|
|
52
|
+
* <div>
|
|
53
|
+
* <code>
|
|
54
|
+
* let pos;
|
|
55
|
+
* let vel;
|
|
56
|
+
*
|
|
57
|
+
* function setup() {
|
|
58
|
+
* createCanvas(100, 100);
|
|
59
|
+
*
|
|
60
|
+
* // Create p5.Vector objects.
|
|
61
|
+
* pos = createVector(50, 100);
|
|
62
|
+
* vel = createVector(0, -1);
|
|
63
|
+
*
|
|
64
|
+
* describe('A black dot moves from bottom to top on a gray square. The dot reappears at the bottom when it reaches the top.');
|
|
65
|
+
* }
|
|
66
|
+
*
|
|
67
|
+
* function draw() {
|
|
68
|
+
* background(200);
|
|
69
|
+
*
|
|
70
|
+
* // Add velocity to position.
|
|
71
|
+
* pos.add(vel);
|
|
72
|
+
*
|
|
73
|
+
* // If the dot reaches the top of the canvas,
|
|
74
|
+
* // restart from the bottom.
|
|
75
|
+
* if (pos.y < 0) {
|
|
76
|
+
* pos.y = 100;
|
|
77
|
+
* }
|
|
78
|
+
*
|
|
79
|
+
* // Draw the dot.
|
|
80
|
+
* strokeWeight(5);
|
|
81
|
+
* point(pos);
|
|
82
|
+
* }
|
|
83
|
+
* </code>
|
|
84
|
+
* </div>
|
|
85
|
+
*/
|
|
86
|
+
function createVector(...x: number[]): p5.Vector;
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default function math(p5: any, fn: any): void;
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
// This file is auto-generated from JSDoc documentation
|
|
2
|
+
|
|
3
|
+
import p5 from 'p5';
|
|
4
|
+
|
|
5
|
+
declare module 'p5' {
|
|
6
|
+
/**
|
|
7
|
+
* Returns random numbers that can be tuned to feel organic.Values returned by random() and
|
|
8
|
+
* randomGaussian() can change by large
|
|
9
|
+
* amounts between function calls. By contrast, values returned by `noise()`
|
|
10
|
+
* can be made "smooth". Calls to `noise()` with similar inputs will produce
|
|
11
|
+
* similar outputs. `noise()` is used to create textures, motion, shapes,
|
|
12
|
+
* terrains, and so on. Ken Perlin invented `noise()` while animating the
|
|
13
|
+
* original Tron film in the 1980s.`noise()` always returns values between 0 and 1. It returns the same value
|
|
14
|
+
* for a given input while a sketch is running. `noise()` produces different
|
|
15
|
+
* results each time a sketch runs. The
|
|
16
|
+
* noiseSeed() function can be used to generate
|
|
17
|
+
* the same sequence of Perlin noise values each time a sketch runs.The character of the noise can be adjusted in two ways. The first way is to
|
|
18
|
+
* scale the inputs. `noise()` interprets inputs as coordinates. The sequence
|
|
19
|
+
* of noise values will be smoother when the input coordinates are closer. The
|
|
20
|
+
* second way is to use the noiseDetail()
|
|
21
|
+
* function.The version of `noise()` with one parameter computes noise values in one
|
|
22
|
+
* dimension. This dimension can be thought of as space, as in `noise(x)`, or
|
|
23
|
+
* time, as in `noise(t)`.The version of `noise()` with two parameters computes noise values in two
|
|
24
|
+
* dimensions. These dimensions can be thought of as space, as in
|
|
25
|
+
* `noise(x, y)`, or space and time, as in `noise(x, t)`.The version of `noise()` with three parameters computes noise values in
|
|
26
|
+
* three dimensions. These dimensions can be thought of as space, as in
|
|
27
|
+
* `noise(x, y, z)`, or space and time, as in `noise(x, y, t)`.
|
|
28
|
+
*
|
|
29
|
+
* @param x-coordinate in noise space.
|
|
30
|
+
* @param y-coordinate in noise space.
|
|
31
|
+
* @param z-coordinate in noise space.
|
|
32
|
+
* @return Perlin noise value at specified coordinates.
|
|
33
|
+
* @example <div>
|
|
34
|
+
* <code>
|
|
35
|
+
* function setup() {
|
|
36
|
+
* createCanvas(100, 100);
|
|
37
|
+
*
|
|
38
|
+
* describe('A black dot moves randomly on a gray square.');
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* function draw() {
|
|
42
|
+
* background(200);
|
|
43
|
+
*
|
|
44
|
+
* // Calculate the coordinates.
|
|
45
|
+
* let x = 100 * noise(0.005 * frameCount);
|
|
46
|
+
* let y = 100 * noise(0.005 * frameCount + 10000);
|
|
47
|
+
*
|
|
48
|
+
* // Draw the point.
|
|
49
|
+
* strokeWeight(5);
|
|
50
|
+
* point(x, y);
|
|
51
|
+
* }
|
|
52
|
+
* </code>
|
|
53
|
+
* </div>
|
|
54
|
+
*
|
|
55
|
+
* <div>
|
|
56
|
+
* <code>
|
|
57
|
+
* function setup() {
|
|
58
|
+
* createCanvas(100, 100);
|
|
59
|
+
*
|
|
60
|
+
* describe('A black dot moves randomly on a gray square.');
|
|
61
|
+
* }
|
|
62
|
+
*
|
|
63
|
+
* function draw() {
|
|
64
|
+
* background(200);
|
|
65
|
+
*
|
|
66
|
+
* // Set the noise level and scale.
|
|
67
|
+
* let noiseLevel = 100;
|
|
68
|
+
* let noiseScale = 0.005;
|
|
69
|
+
*
|
|
70
|
+
* // Scale the input coordinate.
|
|
71
|
+
* let nt = noiseScale * frameCount;
|
|
72
|
+
*
|
|
73
|
+
* // Compute the noise values.
|
|
74
|
+
* let x = noiseLevel * noise(nt);
|
|
75
|
+
* let y = noiseLevel * noise(nt + 10000);
|
|
76
|
+
*
|
|
77
|
+
* // Draw the point.
|
|
78
|
+
* strokeWeight(5);
|
|
79
|
+
* point(x, y);
|
|
80
|
+
* }
|
|
81
|
+
* </code>
|
|
82
|
+
* </div>
|
|
83
|
+
*
|
|
84
|
+
* <div>
|
|
85
|
+
* <code>
|
|
86
|
+
* function setup() {
|
|
87
|
+
* createCanvas(100, 100);
|
|
88
|
+
*
|
|
89
|
+
* describe('A hilly terrain drawn in gray against a black sky.');
|
|
90
|
+
* }
|
|
91
|
+
*
|
|
92
|
+
* function draw() {
|
|
93
|
+
* // Set the noise level and scale.
|
|
94
|
+
* let noiseLevel = 100;
|
|
95
|
+
* let noiseScale = 0.02;
|
|
96
|
+
*
|
|
97
|
+
* // Scale the input coordinate.
|
|
98
|
+
* let x = frameCount;
|
|
99
|
+
* let nx = noiseScale * x;
|
|
100
|
+
*
|
|
101
|
+
* // Compute the noise value.
|
|
102
|
+
* let y = noiseLevel * noise(nx);
|
|
103
|
+
*
|
|
104
|
+
* // Draw the line.
|
|
105
|
+
* line(x, 0, x, y);
|
|
106
|
+
* }
|
|
107
|
+
* </code>
|
|
108
|
+
* </div>
|
|
109
|
+
*
|
|
110
|
+
* <div>
|
|
111
|
+
* <code>
|
|
112
|
+
* function setup() {
|
|
113
|
+
* createCanvas(100, 100);
|
|
114
|
+
*
|
|
115
|
+
* describe('A calm sea drawn in gray against a black sky.');
|
|
116
|
+
* }
|
|
117
|
+
*
|
|
118
|
+
* function draw() {
|
|
119
|
+
* background(200);
|
|
120
|
+
*
|
|
121
|
+
* // Set the noise level and scale.
|
|
122
|
+
* let noiseLevel = 100;
|
|
123
|
+
* let noiseScale = 0.002;
|
|
124
|
+
*
|
|
125
|
+
* // Iterate from left to right.
|
|
126
|
+
* for (let x = 0; x < 100; x += 1) {
|
|
127
|
+
* // Scale the input coordinates.
|
|
128
|
+
* let nx = noiseScale * x;
|
|
129
|
+
* let nt = noiseScale * frameCount;
|
|
130
|
+
*
|
|
131
|
+
* // Compute the noise value.
|
|
132
|
+
* let y = noiseLevel * noise(nx, nt);
|
|
133
|
+
*
|
|
134
|
+
* // Draw the line.
|
|
135
|
+
* line(x, 0, x, y);
|
|
136
|
+
* }
|
|
137
|
+
* }
|
|
138
|
+
* </code>
|
|
139
|
+
* </div>
|
|
140
|
+
*
|
|
141
|
+
* <div>
|
|
142
|
+
* <code>
|
|
143
|
+
* function setup() {
|
|
144
|
+
* createCanvas(100, 100);
|
|
145
|
+
*
|
|
146
|
+
* background(200);
|
|
147
|
+
*
|
|
148
|
+
* // Set the noise level and scale.
|
|
149
|
+
* let noiseLevel = 255;
|
|
150
|
+
* let noiseScale = 0.01;
|
|
151
|
+
*
|
|
152
|
+
* // Iterate from top to bottom.
|
|
153
|
+
* for (let y = 0; y < 100; y += 1) {
|
|
154
|
+
* // Iterate from left to right.
|
|
155
|
+
* for (let x = 0; x < 100; x += 1) {
|
|
156
|
+
* // Scale the input coordinates.
|
|
157
|
+
* let nx = noiseScale * x;
|
|
158
|
+
* let ny = noiseScale * y;
|
|
159
|
+
*
|
|
160
|
+
* // Compute the noise value.
|
|
161
|
+
* let c = noiseLevel * noise(nx, ny);
|
|
162
|
+
*
|
|
163
|
+
* // Draw the point.
|
|
164
|
+
* stroke(c);
|
|
165
|
+
* point(x, y);
|
|
166
|
+
* }
|
|
167
|
+
* }
|
|
168
|
+
*
|
|
169
|
+
* describe('A gray cloudy pattern.');
|
|
170
|
+
* }
|
|
171
|
+
* </code>
|
|
172
|
+
* </div>
|
|
173
|
+
*
|
|
174
|
+
* <div>
|
|
175
|
+
* <code>
|
|
176
|
+
* function setup() {
|
|
177
|
+
* createCanvas(100, 100);
|
|
178
|
+
*
|
|
179
|
+
* describe('A gray cloudy pattern that changes.');
|
|
180
|
+
* }
|
|
181
|
+
*
|
|
182
|
+
* function draw() {
|
|
183
|
+
* // Set the noise level and scale.
|
|
184
|
+
* let noiseLevel = 255;
|
|
185
|
+
* let noiseScale = 0.009;
|
|
186
|
+
*
|
|
187
|
+
* // Iterate from top to bottom.
|
|
188
|
+
* for (let y = 0; y < 100; y += 1) {
|
|
189
|
+
* // Iterate from left to right.
|
|
190
|
+
* for (let x = 0; x < width; x += 1) {
|
|
191
|
+
* // Scale the input coordinates.
|
|
192
|
+
* let nx = noiseScale * x;
|
|
193
|
+
* let ny = noiseScale * y;
|
|
194
|
+
* let nt = noiseScale * frameCount;
|
|
195
|
+
*
|
|
196
|
+
* // Compute the noise value.
|
|
197
|
+
* let c = noiseLevel * noise(nx, ny, nt);
|
|
198
|
+
*
|
|
199
|
+
* // Draw the point.
|
|
200
|
+
* stroke(c);
|
|
201
|
+
* point(x, y);
|
|
202
|
+
* }
|
|
203
|
+
* }
|
|
204
|
+
* }
|
|
205
|
+
* </code>
|
|
206
|
+
* </div>
|
|
207
|
+
*/
|
|
208
|
+
function noise(x: number, y?: number, z?: number): number;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Adjusts the character of the noise produced by the
|
|
212
|
+
* noise() function.Perlin noise values are created by adding layers of noise together. The
|
|
213
|
+
* noise layers, called octaves, are similar to harmonics in music. Lower
|
|
214
|
+
* octaves contribute more to the output signal. They define the overall
|
|
215
|
+
* intensity of the noise. Higher octaves create finer-grained details.By default, noise values are created by combining four octaves. Each higher
|
|
216
|
+
* octave contributes half as much (50% less) compared to its predecessor.
|
|
217
|
+
* `noiseDetail()` changes the number of octaves and the falloff amount. For
|
|
218
|
+
* example, calling `noiseDetail(6, 0.25)` ensures that
|
|
219
|
+
* noise() will use six octaves. Each higher octave
|
|
220
|
+
* will contribute 25% as much (75% less) compared to its predecessor. Falloff
|
|
221
|
+
* values between 0 and 1 are valid. However, falloff values greater than 0.5
|
|
222
|
+
* might result in noise values greater than 1.
|
|
223
|
+
*
|
|
224
|
+
* @param number of octaves to be used by the noise.
|
|
225
|
+
* @param falloff factor for each octave.
|
|
226
|
+
* @example <div>
|
|
227
|
+
* <code>
|
|
228
|
+
* function setup() {
|
|
229
|
+
* createCanvas(100, 100);
|
|
230
|
+
*
|
|
231
|
+
* // Set the noise level and scale.
|
|
232
|
+
* let noiseLevel = 255;
|
|
233
|
+
* let noiseScale = 0.02;
|
|
234
|
+
*
|
|
235
|
+
* // Iterate from top to bottom.
|
|
236
|
+
* for (let y = 0; y < 100; y += 1) {
|
|
237
|
+
* // Iterate from left to right.
|
|
238
|
+
* for (let x = 0; x < 50; x += 1) {
|
|
239
|
+
* // Scale the input coordinates.
|
|
240
|
+
* let nx = noiseScale * x;
|
|
241
|
+
* let ny = noiseScale * y;
|
|
242
|
+
*
|
|
243
|
+
* // Compute the noise value with six octaves
|
|
244
|
+
* // and a low falloff factor.
|
|
245
|
+
* noiseDetail(6, 0.25);
|
|
246
|
+
* let c = noiseLevel * noise(nx, ny);
|
|
247
|
+
*
|
|
248
|
+
* // Draw the left side.
|
|
249
|
+
* stroke(c);
|
|
250
|
+
* point(x, y);
|
|
251
|
+
*
|
|
252
|
+
* // Compute the noise value with four octaves
|
|
253
|
+
* // and a high falloff factor.
|
|
254
|
+
* noiseDetail(4, 0.5);
|
|
255
|
+
* c = noiseLevel * noise(nx, ny);
|
|
256
|
+
*
|
|
257
|
+
* // Draw the right side.
|
|
258
|
+
* stroke(c);
|
|
259
|
+
* point(x + 50, y);
|
|
260
|
+
* }
|
|
261
|
+
* }
|
|
262
|
+
*
|
|
263
|
+
* describe('Two gray cloudy patterns. The pattern on the right is cloudier than the pattern on the left.');
|
|
264
|
+
* }
|
|
265
|
+
* </code>
|
|
266
|
+
* </div>
|
|
267
|
+
*/
|
|
268
|
+
function noiseDetail(lod: number, falloff: number): void;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Sets the seed value for the noise() function.By default, noise() produces different results
|
|
272
|
+
* each time a sketch is run. Calling `noiseSeed()` with a constant argument,
|
|
273
|
+
* such as `noiseSeed(99)`, makes noise() produce the
|
|
274
|
+
* same results each time a sketch is run.
|
|
275
|
+
*
|
|
276
|
+
* @param seed value.
|
|
277
|
+
* @example <div>
|
|
278
|
+
* <code>
|
|
279
|
+
* function setup() {
|
|
280
|
+
* createCanvas(100, 100);
|
|
281
|
+
*
|
|
282
|
+
* background(200);
|
|
283
|
+
*
|
|
284
|
+
* // Set the noise seed for consistent results.
|
|
285
|
+
* noiseSeed(99);
|
|
286
|
+
*
|
|
287
|
+
* describe('A black rectangle that grows randomly, first to the right and then to the left.');
|
|
288
|
+
* }
|
|
289
|
+
*
|
|
290
|
+
* function draw() {
|
|
291
|
+
* // Set the noise level and scale.
|
|
292
|
+
* let noiseLevel = 100;
|
|
293
|
+
* let noiseScale = 0.005;
|
|
294
|
+
*
|
|
295
|
+
* // Scale the input coordinate.
|
|
296
|
+
* let nt = noiseScale * frameCount;
|
|
297
|
+
*
|
|
298
|
+
* // Compute the noise value.
|
|
299
|
+
* let x = noiseLevel * noise(nt);
|
|
300
|
+
*
|
|
301
|
+
* // Draw the line.
|
|
302
|
+
* line(x, 0, x, height);
|
|
303
|
+
* }
|
|
304
|
+
* </code>
|
|
305
|
+
* </div>
|
|
306
|
+
*/
|
|
307
|
+
function noiseSeed(seed: number): void;
|
|
308
|
+
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export default function noise(p5: any, fn: any): void;
|