File tree Expand file tree Collapse file tree 1 file changed +13
-14
lines changed
src/data/examples/en/08_Math Expand file tree Collapse file tree 1 file changed +13
-14
lines changed Original file line number Diff line number Diff line change 5
5
* @description Create a 2D noise with different parameters.
6
6
*/
7
7
8
- let noiseVal ;
9
- let noiseScale = 0.02 ;
8
+ let noise_val ;
9
+ let noise_scale = 0.02 ;
10
10
11
11
function setup ( ) {
12
12
createCanvas ( 640 , 360 ) ;
13
13
}
14
14
15
15
function drawNoise ( x , y , w , h ) {
16
- for ( let yp = y ; yp < y + h ; yp ++ ) {
17
- let yindex = yp * width ;
18
- for ( let xp = x ; xp < x + w ; xp ++ ) {
19
- let noiseVal =
20
- noise ( ( mouseX + xp ) * noiseScale , ( mouseY + yp ) * noiseScale ) * 255 ;
21
-
22
- let xindex = xp ;
23
- let index = 4 * ( yindex + xindex ) ;
24
- pixels [ index ] = noiseVal ;
25
- pixels [ index + 1 ] = noiseVal ;
26
- pixels [ index + 2 ] = noiseVal ;
16
+ for ( let pixel_y = y ; pixel_y < y + h ; pixel_y ++ ) {
17
+ for ( let pixel_x = x ; pixel_x < x + w ; pixel_x ++ ) {
18
+ let noise_val =
19
+ noise ( ( mouseX + pixel_x ) * noise_scale , ( mouseY + pixel_y ) * noise_scale ) * 255 ;
20
+
21
+ let index = 4 * ( pixel_y * width + pixel_x ) ;
22
+
23
+ pixels [ index ] = noise_val ;
24
+ pixels [ index + 1 ] = noise_val ;
25
+ pixels [ index + 2 ] = noise_val ;
27
26
pixels [ index + 3 ] = 255 ;
28
27
}
29
28
}
@@ -44,7 +43,7 @@ function draw() {
44
43
45
44
updatePixels ( ) ;
46
45
47
- //Show the details of each partition
46
+ //Show the details of two partitions
48
47
textSize ( 18 ) ;
49
48
fill ( 255 , 255 , 255 ) ;
50
49
text ( "Noise2D with 2 octaves and 0.2 falloff" , 10 , 350 ) ;
You can’t perform that action at this time.
0 commit comments