xxxxxxxxxx
40
//https://p5js.org/examples/input-mouse-1d.html
function setup() {
createCanvas(600, 600);
//rectMode(CENTER);
noFill();
}
function draw() {
background(255);
fill(0);
ellipse(0,0,20,20);//haut gauche
ellipse(width,0,20,20);//haut droit
ellipse(width,height,20,20);//bas droit
ellipse(0,height,20,20);//bas gauche
let r1 = map(mouseX, 0, width, 0, height);
let r2 = height - r1;
stroke('red');
line(width-r1/2, height-r1/2, 0, 0);//OK haut gauche
line(width-r1/2, height-r1/2, width, 0);//haut droit
line(width-r1/2, height-r1/2, width, height);//ok bas droit
line(width-r1/2, height-r1/2, 0, height);//bas gauche
rectMode(CENTER);
stroke('black');
fill(255);
rect(width / 2, height / 2, r2, r2);
}