Skip to content

Commit 7bfa789

Browse files
takyanolimzykenneth
authored andcommitted
Remove uneeded index_x and index_y
Remove uneeded index_x and index_y variables. End of line to linefeeds
1 parent 7a7bf35 commit 7bfa789

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/data/examples/en/08_Math/15_Noise2D.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,24 @@
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

1111
function setup() {
1212
createCanvas(640, 360);
1313
}
1414

1515
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;
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);

0 commit comments

Comments
 (0)