xxxxxxxxxx
//images
let sources = [
"1.png",
"0.png",
"3.png",
"4.png",
"5.png",
"6.png",
"7.png",
"8.png",
"9.png",
"10.png",
"11.png",
"12.png",
"13png.png",
"14.png",
"15.png",
"16.png",
"17.png",
"18.png",
"19.png",
"20.png"
];
//assign the images
let imgs = [];
let imgID = 0;
function preload() {
//load the images
for (let i = 0; i < sources.length; i++) {
imgs[i] = loadImage(sources[i]);
}
}
function setup() {
createCanvas(600,600);
background(100);
noLoop();
//center the images
imageMode(CENTER);
angleMode(DEGREES);
}
function draw() {
background(120, 0, 0,75);
// make a collage with images
for (let i = 0; i < sources.length; i++) {
let x = width / 2 + random(-120, 120);
let y = height / 2 + random(-120, 120);
push();
translate(x, y);
scale(0.8,0.8);
rotate(random(360));
tint(255,255,255,random(50,255));
image(imgs[i], 0, 0);
pop();
}
}
function keyPressed() {
if (key == 'r') {
draw();
}
if (key == 's') {
save("export.jpg");
}
}