xxxxxxxxxx
31
// Re-draw the rectangle using line(). Challenge: Write it so that you can easily change the location and size relationship with the canvas.
//weight and height of canvas, change here!
let width=800;
let height=400;
//middle point of the rectangle
let leftX=width/4;
let topY=height/4;
let rightX=3*width/4;
let bottomY=3*height/4;
function setup() {
createCanvas(width, height);
}
function draw() {
background(20);
stroke(255);
strokeWeight(5);
//can recognize easily
line(leftX,topY,rightX,topY);
line(rightX,topY,rightX,bottomY);
line(leftX,bottomY,rightX,bottomY);
line(leftX,topY,leftX,bottomY);
}