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

Port to p5.js of Nature of Code examples
MIT License
1.05k stars 552 forks source link

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

Closed masakudamatsu closed 4 years ago

masakudamatsu commented 4 years ago

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.

masakudamatsu commented 4 years ago

Oops, I just found the answer in one of the pending pull requests. See: https://github.com/nature-of-code/noc-examples-p5.js/pull/66/commits/7f133e7bbb2aafc1e7bc5ae4936dfb712ff99263#diff-57fc6b7143f64009deeaf7105eeb0b3b