I’m beginning to explore p5.js web editor, and I was wondering if there is a way to create multiple custom rectangles with mouse in canvas.That’s the only way I can think of. I want it be like Illustrator’s rectangle tool.
let clickX, clickY;
function setup() {
createCanvas(600, 600);
}
function draw() {
background(0);
fill(255);
stroke(255, 0, 0);
rect(clickX, clickY, mouseX - clickX, mouseY - clickY);
}
function mouseMoved() {
clickX = mouseX;
clickY = mouseY;
}