I created a hexagon by using a function, I intend to mousePress when the cursor is inside the hexagon and drag it around similar to the object shown in this sketch; https://editor.p5js.org/enickles/sketches/H1n19TObz
Please help achieve my objective. Many thanks.
This is what I’ve done so far. You can check them out using p5.js online editor.
function setup() { createCanvas(400, 400); }
function draw() { background(200,110,145); stroke(255); strokeWeight(5) noFill(); regularPolygon(180,200,6,100,PI*0.245); }
function regularPolygon(x,y,n,radius,rotation){ beginShape(); for(let i=0; i < n; i++){ vertex(x+cos(i*TAU/n+rotation)*radius,y+sin(i*TAU/n+rotation)*radius); } endShape(CLOSE); }