xxxxxxxxxx
20
let img;
function setup() {
createCanvas(300, 300);
img = loadImage("https://happycoding.io/images/stanley-1.jpg");
}
function draw() {
// Get a random position in the image
let x = floor(random(img.width));
let y = floor(random(img.height));
// Set that pixel to black
let black = color(0);
img.loadPixels();
img.set(x, y, black);
img.updatePixels();
image(img, 0, 0);
}