xxxxxxxxxx
53
let nombre;
let tableau_x = [];
let tableau_y = [];
let tableau_w = [];
let tableau_h = [];
let tableau_c = [];
function dessinerFantome(a, b, c, d, e) {
fill(255);
ellipse(a, b, c, d);
fill(255);
let tH = d * 1.2;
let tW = c * 0.8;
triangle(a - tW / 2, b, a + tW / 2, b, a, b + tH);
fill(e);
ellipse(a - c * 0.2, b, 8, 8);
ellipse(a + c * 0.2, b, 8, 8);
fill(0);
ellipse(a, b + c * 0.2, 4, 9);
}
function setup() {
createCanvas(800, 800);
noStroke();
nombre = 10;
for (let i = 0; i < nombre; i = i + 1) {
tableau_x[i] = random(0, 800);
tableau_y[i] = random(0, 800);
tableau_w[i] = random(30, 80);
tableau_h[i] = random(30, 80);
tableau_c[i] = "black";
}
}
function draw() {
background("black");
if (mouseIsPressed == true) {
for (let i = 0; i < nombre; i = i + 1) {
tableau_c[i] = color(random(0, 255), random(0, 255), random(0, 255));
}
}
for (let i = 0; i < nombre; i = i + 1) {
dessinerFantome(tableau_x[i], tableau_y[i], tableau_w[i], tableau_h[i], tableau_c[i]);
}
}