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 55 * @description Create a 2D noise with different parameters.
66 */
77
8- let noiseVal ;
9- let noiseScale = 0.02 ;
8+ let noise_val ;
9+ let noise_scale = 0.02 ;
1010
1111function setup ( ) {
1212 createCanvas ( 640 , 360 ) ;
1313}
1414
1515function 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 ;
2726 pixels [ index + 3 ] = 255 ;
2827 }
2928 }
@@ -44,7 +43,7 @@ function draw() {
4443
4544 updatePixels ( ) ;
4645
47- //Show the details of each partition
46+ //Show the details of two partitions
4847 textSize ( 18 ) ;
4948 fill ( 255 , 255 , 255 ) ;
5049 text ( "Noise2D with 2 octaves and 0.2 falloff" , 10 , 350 ) ;
You can’t perform that action at this time.
0 commit comments