xxxxxxxxxx
61
var xpos = 0;//variable de la position x
var speed = 3;//variable de la vitesse
var xpos3 = 0;
let img;//variable de l'image
//chargement de l'image
function preload() {
img1 = loadImage('img1.png');
img2 = loadImage('img2.png');
}
function setup() {
createCanvas(600, 600);//taille du canvas
VideoRecorder.addButton();
}
function draw() {
background(255);
// increment x variable
xpos = xpos + speed;
// if the circle moves off screen, change the speed's polarity
if((xpos > 580) || (xpos < 0))
{
speed = speed * -1;
}
// increment x variable
xpos3 = xpos3 + speed;
// if the circle moves off screen, change the speed's polarity
if((xpos3 > 580) || (xpos3 < 0))
{
speed = speed * -1;
}
image(img1, 0, 0, 5+xpos, 400);//l'image 1 déformation largeur
image(img2, -3+xpos, 0, width-xpos, 400);//image 2 déformation largeur
image(img1, width-100, height-3, 100, -xpos+10);//deformation hauteur
}