xxxxxxxxxx
let mots = [];
let nbmots;
let count;
let bord, nbLignes, intermots, interLigne, rectHautMax, rectHautMin, rectHautplus, rectLargMax, rectLargMin, rectLargPlus;
let t;
function setup(){
createCanvas(802, 802);
background(255);
frameRate(24);
nbmots = 12
bord = 80;
nbmots = 12
nbLignes = 12;
intermots = 40;
interLigne = height/nbLignes;
rectHautMax = 40;
rectHautMin = 10;
rectHautplus = 4;
rectLargMax = 40;
rectLargMin = 10;
rectLargPlus = 4;
count = 0;
t = 0;
for (var i=0 ; i < nbmots; i++) {
mots[i] = new Mot();
mots[i].ptx = bord;
mots[i].numMot = 1;
mots[i].numLigne = 1;
mots[i].rectLarg = 6;
mots[i].rectHaut = random(12, 40);
mots[i].rectHautOld = mots[i].rectHaut;
mots[i].pty = interLigne;
mots[i].rectCorn = 30;
mots[i].fond = 153;
mots[i].fondPlus = 5;
}
}
function draw(){
rectMode(CORNER); strokeWeight(6); stroke(0); noFill(); rect(0, 0, 802, 802);
//t++;
//if (t > 90){
for (let i = 0; i < nbmots; i++){
mots[i].ecrit();
}
//}
}
class Mot {
constructor (ptx, pty, oldptx, oldpty, numMot, nbmots, nbLignes, rectLarg, rectHaut, rectCorn, fond, fondPlus){
}
ecrit(){
count++;
if (count % 24 == 0){
if (this.numLigne < nbLignes){
if (this.ptx <= width - bord){
this.fond -= this.fondPlus;
if (this.fond >= 255 || this.fond <= 0){
this.fondPlus *= -1;
}
this.pty = 20 + this.numLigne * interLigne - this.rectHaut/2;
rectMode(CENTER); strokeWeight(2); stroke(0, 80); fill(this.fond, 80); rect(this.ptx , this.pty, this.rectLarg, this.rectHaut);
this.ptx += intermots;
this.rectHaut -= rectHautplus;
if (this.rectHaut >= rectHautMax || this.rectHaut <= rectHautMin){
rectHautplus *= -1;
}
this.rectLarg += rectLargPlus;
if (this.rectLarg >= rectLargMax || this.rectLarg <= rectLargMin){
rectLargPlus *= -1;
}
} else if (this.ptx > width - bord){
this.numLigne++;
this.ptx = bord;
}
} else if (this.numLigne >= nbLignes){
this.numLigne = 1;
}
}
}
}