xxxxxxxxxx
27
// Noise sample distance
//
// Shows the effect of changing the sample distance when using
// the noise function.
function setup() {
createCanvas(400, 400);
background(220);
noStroke();
let v1 = 0;
// Samples will be 0.05 apart
let inc1 = 0.05;
let v2 = 0;
// Samples will be 0.5 apart
let inc2 = 0.5;
for (let i = 0; i < width; i += 10) {
v1 += inc1;
fill(noise(v1) * 255);
rect(i, 0, 10, height / 2);
v2 += inc2;
fill(noise(v2) * 255);
rect(i, height / 2, 10, height / 2);
}
}