xxxxxxxxxx
37
let img;
function preload() {
img = loadImage("beach.jpg");
}
function setup() {
createCanvas(img.width, img.height);
let gfx = createGraphics(img.width, img.height);
img.loadPixels();
gfx.loadPixels();
for (let i = 0; i < img.pixels.length; i+=4) {
gfx.pixels[i] = img.pixels[i];
gfx.pixels[i+1] = img.pixels[i+1];
gfx.pixels[i+2] = img.pixels[i+2];
gfx.pixels[i+3] = img.pixels[i+3];
if (random() > 0.9) {
let j = i;
gfx.pixels[j] = 255;
gfx.pixels[j+1] = 255;
gfx.pixels[j+2] = 255;
gfx.pixels[j+3] = 255;
}
}
gfx.updatePixels();
image(gfx,0,0);
console.log("done");
noLoop();
}
function draw() {
// background(220);
}