This is a library for making 2d shapes that are easy to move around within p5.js. It uses the 2dCollide library as well.
- Download the p5.draggableShape.js and p5.2dcollide.js files and add them to you sketch's libraries
- Link the libraries in the html in your p5 project folder.
- You're good to go.
You can find out more about installing p5 libraries here.
var circle, square, triangle;
function setup() {
circle = new draggableCircle(xPos,yPos,width,strokeColor,fillColor);
square = new draggableRect(xPos,yPos,width,height,strokeColor,fillColor);
triangle = new draggableTriangle(xPos,yPos,width,strokeColor,fillColor);
}
function draw() {
background(255);
circle.display();
square.display();
triangle.display();
}