xxxxxxxxxx
51
let x,y;
let w,h;
let tlx, tly;
let trx, trry;
let brx, bry;
let blx, bly;
function setup() {
createCanvas(windowWidth, windowHeight);
rectMode(CENTER);
x= width/2;
y= height/2;
w= width/2;
h= height/2
}
function draw() {
background(220);
tlx= x- w/2;
tly= y- h/2;
trx= x+ w/2;
trry= y-h/2;
brx= x+ w/2;
bry= y+ h/2;
blx= x- w/2;
bly= y+ h/2;
x= x+(mouseX-x)*0.1;
y= y+(mouseY-y)*0.1;
// TL to TR
//line(width/2 - width/20, height/2 - height/20, width/2 + width/20, height/2 - height/20);
line(tlx, tly, trx, trry);
// TR to BR
//line(width/2 - width/20, height/2 - height/20, width/2 + width/20, height/2 + height/20);
line(trx, trry, brx, bry);
// BR to BL
//line(width/2 + width/20, height/2 + height/20, width/2 - width/20, height/2 + height/20);
line(brx, bry, blx, bly);
// BL to TL
//line(width/2 - width/20, height/2 + height/20, width/2 - width/20, height/2 - height/20);
line(blx, bly, tlx, tly);
}