xxxxxxxxxx
38
let pos, speed, imgPos, dvd_logo;
function preload() {
dvd_logo = loadImage("logo.png");
}
function setup() {
createCanvas(window.innerWidth, window.innerHeight);
pos = createVector(0, 0);
speed = createVector(2.5, 2.5);
imgPos = { height: 100, width: 200 };
getColorforImage();
}
function draw() {
background(0);
tint(r, g, b);
image(dvd_logo, pos.x, pos.y, imgPos.width, imgPos.height);
if (pos.x >= width - imgPos.width || pos.x < 0) {
speed.x *= -1;
getColorforImage();
}
if (pos.y >= height - imgPos.height || pos.y < 0) {
speed.y *= -1;
getColorforImage();
}
pos.add(speed);
}
function getColorforImage() {
r = random(100, 256);
g = random(100, 256);
b = random(100, 256);
}