xxxxxxxxxx
55
let img = [];
let randImage = 0;
let showImage = false
let randomImage = false
let h = 1920;
let w = 1080;
let scaleFactor = 0.35;
function preload() {
for (let i = 0; i < 9; i++) {
img[i] = loadImage('abc/' + i + '.jpg')
}
}
function setup() {
// image(img[3], 0, 0);
createCanvas(windowWidth, windowHeight);
frameRate(12);
}
function draw() {
//background(220);
//image(img[randImage],0,0);
background(225);
textSize(60);
imageMode (CENTER)
image(img[randImage], width/2, height/2, w*scaleFactor, h*scaleFactor);
text(randImage, width/2, 100);
if (showImage) {
randImage = int(random(1, 8));
}
if (randomImage) {
randImage = int(random(1, 8));
}
}
function touchStarted() {
randomImage = !randomImage
// image(img[i],0,0)
}
function keyPressed() {
showImage = !showImage
// randImage = int(random(1, 3));
// if (keyCode === LEFT_ARROW) {
// randImage = 0;
// } else if (keyCode === RIGHT_ARROW) {
// randImage = 1;
// }
}