xxxxxxxxxx
36
let noize;
function setup() {
createCanvas(400, 400);
noize = new Noise();
}
function draw() {
background(220);
for(i = 0 ; i < width ; i++){
for(j = 0; j < height; j++){
let col = noize.generateNoise(i,j) * 255;
set(i, j, col);
}
}
updatePixels();
}
class Noise{
constructor(){
this.type = "perlin";
this.frequency = 0.05;
this.lacunarity = 1;
this.octaves = 3;
}
generateNoise(x,y){
let n = 0;
for(let i = 0; i < this.octaves ; i++){
n += noise(x * this.frequency + i * 0.72354,y * this.frequency + i * 0.72354);
}
return n/this.octaves;
}
}