xxxxxxxxxx
31
const nl = 0.02;
const density = 10;
let c1;
let c2;
function setup() {
createCanvas(windowWidth, windowHeight);
colorMode(HSL, 100);
c1 = color('#2727e6');
c2 = color('#ffffff');
let x = 0;
let y = 0;
let n, rn, d, finalColor;
for(x; x < width; x++){
y = 0;
for(y; y < height; y++){
n = noise(x*nl, y*nl);
rn = n * density - floor(n * density);
d = rn > 0.5 ? map(rn, 0.5, 1, 1, 0) : map(rn, 0, 0.5, 0, 1);
finalColor = lerpColor(c1, c2, d);
set(x, y, finalColor);
}
}
updatePixels();
}