xxxxxxxxxx
// define an array variable with all of the files you want to load
let sources = [
"duck.png",
"daisy.png",
"puppies.png",
"lovebirddd.png",
"flowerss.png",
"dog.png"
];
// Define an empty array to assign all of the loaded images
let imgs = [];
// Define an image id
let imgID = 0;
function preload() {
// load all images through loop into imgs array
for (let i = 0; i < sources.length; i++) {
imgs[i] = loadImage(sources[i]);
}
}
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
noLoop();
}
function draw() {
background(255);
imageMode(CENTER);
//blendMode(DIFFERENCE);
// Loop through images
for (let i = 0; i < sources.length; i++) {
let x = width / 2 + random(-200,200);
let y = height / 2 + random(-200,200);
image(imgs[i], x, y);
}
}
function keyPressed() {
if (key == 'a') {
draw();
}
if (key == 's') {
save("export.jpg");
}
}