xxxxxxxxxx
86
let vaporwave = ["#ff71ce", "#01cdfe", "#05ffa1", "#b967ff", "#fffb96"];
let cv;
let hsq;
function setup() {
cv = createCanvas(800, 800);
background(20);
pixelDensity(1);
noiseDetail(8, 0.75);
hsq = width * 0.01;
gy = hsq;
gx = 0;
step = 0;
}
let gx, gy, step;
function draw() {
const _density = pixelDensity();
if (step == 0) {
loadPixels();
// for (let y = hsq; y < height - hsq; y++) {
for (let x = hsq; x < width - hsq; x++) {
let idx = 4 * _density * (gy * _density * width + x);
let n = noise(x * 0.01, gy * 0.01);
let cidx = constrain(
int(map(n, 0.0, 1.0, 0, vaporwave.length - 1)),
0,
vaporwave.length - 1
);
let c = vaporwave[cidx];
pixels[idx] = red(c);
pixels[idx + 1] = green(c);
pixels[idx + 2] = blue(c);
pixels[idx + 3] = 255;
}
// }
updatePixels();
gy++;
if (gy > height - hsq) {
step++;
gy = height - 1;
}
} else if (step == 1) {
loadPixels();
let idx = 4 * _density * (gy * _density * width + gx);
//interpolate?
let col = color(pixels[idx], pixels[idx+1],pixels[idx+2],pixels[idx+3]);
for (let y = gy-1; y >= 0; y--) {
let idx2 = 4 * _density * (y * _density * width + gx);
let col2 = color(pixels[idx2], pixels[idx2+1],pixels[idx2+2],pixels[idx2+3]);
let d = abs(gy - y);
let col3 = lerpColor(col, col2, map(d, height, 0, 1.0, 0.0));
pixels[idx2] = red(col3);
pixels[idx2+1] = green(col3);
pixels[idx2+2] = blue(col3);
pixels[idx2+3] = alpha(col3);
}
// pixels[idx] =0
// pixels[idx+1] =0
// pixels[idx+2] =0
// pixels[idx+3] = alpha(col3);
updatePixels();
gx++;
if (random() > 0.2)
gy--;
if (gx > width-1 || gy <= 1)
step++;
} else {
console.log("done");
noLoop();
}
}