Is there a method for generating multiple irregular polygons and/or irregular blobs of equal surface area using p5.js?

Viewed 27

For neuroscience research I'm attempting to train rats to press shapes on a touch screen. Ideally, these shapes would be highly distinct polygons or blobs to make it easier for the rats to discriminate. However, to limit some biases toward certain shapes, I'd like to keep the area of each shape equivalent. I've been trying to achieve this on p5.js, but I'm very new to this.

The code I've got so far provides some of the shape randomness, but not the consitency in area:

function setup() {

createCanvas(500, 500);  
background(255);
fill(0);

translate(width/2, height/2);
beginShape();

for(let i = 0; i < 5; i++) {
const x = random(-250, 250);
const y = random(-250, 250);
vertex(x, y);
endShape();
}   
}

Any help achieving this would be very appreciated

0 Answers
Related