nature-of-code/noc-examples-p5.js

JS code for "Example I.6: 2D Perlin noise" is not available

masakudamatsu opened this issue · 1 comments

The original Processing code (source) is as follows:

loadPixels();

float xoff = 0.0;
 
for (int x = 0; x < width; x++) {
  float yoff = 0.0;
 
  for (int y = 0; y < height; y++) {
    float bright = map(noise(xoff,yoff),0,1,0,255);
    pixels[x+y*width] = color(bright);
    yoff += 0.01;
  }
  xoff += 0.01;
}

updatePixels();

I tried myself to convert this code into p5.js. But I cannot tell where to put this set of code. Inside setup() or draw()? Does anyone have a clue? I'll then code it up and send a pull request.

Oops, I just found the answer in one of the pending pull requests. See: 7f133e7#diff-57fc6b7143f64009deeaf7105eeb0b3b