xxxxxxxxxx
89
/*
Voir notes.txt pour les sources d'images et d'inspiration
ici je constitue un array de 4 images et je suis capable de les montrer
mais je n'utilise pas les images "bubble"
*/
let tranches = [];
let nbTranches = 0 ;
let pictures = [];
let maxH = 0 ;
let posX = 0 ;
function preload() {
for (let i = 0; i < 4; i++) {
pictures[i] = loadImage(`assets/personne${i}.jpg`);
}
}
function setup() {
createCanvas(600, 400);
nbTranches = pictures.length ;
print("nombre de tranches : ", nbTranches) ;
for (let i = 0; i < pictures.length; i++) {
// let r = random(50, 150);
// print( width/(pictures.length ) ) ;
pictures[i].resize( width/(pictures.length), 0 );
maxH = max( maxH, pictures[i].height ) ;
let b = new Tranche( posX, 0, pictures[i], i );
tranches.push(b);
posX += width/(pictures.length) ;
nbTranches = max( nbTranches, tranches[i].nbSlices ) ;
print("indice : ", i, "nombre de tranches : ", nbTranches) ;
}
// noLoop() ;
}
function mousePressed() {
/*
for (let i = 0; i < tranches.length; i++) {
photos[i].clicked(mouseX, mouseY);
}
*/
}
function draw() {
background(240);
posX = 0 ;
// montrer les images telles qu'à l'origine
for (let j = 0; j < pictures.length; j++) {
image( pictures[j], posX, 0 ) ;
posX += width/(pictures.length) ;
// maxH = max( maxH, pictures[j].height ) ;
// image( pictures[j], posX, maxH ) ;
}
for (let i = 0; i < tranches.length; i++) {
tranches[i].move();
tranches[i].show();
}
posX = 0 ;
for (let i = 0; i < nbTranches; i++) {
for (let j = 0; j < tranches.length; j++) {
tranches[j].montreSlice(posX,maxH + maxH + random(20),i)
posX += 10 ;
}
}
}