here is a Sketch that adds cells as discussed (almost)
Chrisir
ArrayList<PVector>resizeableGrid = new ArrayList();
float tile;
void setup() {
size (600, 600);
tile = width/3;
for (float x = 0; x <= width; x+=tile) {
for (float y = 0; y <= height; y+=tile) {
PVector pv = new PVector(x, y);
resizeableGrid.add(pv);
}
}
}
void draw() {
background(255);
for (PVector pv : resizeableGrid) {
stroke(0);
rect(pv.x, pv.y, tile, tile);
}
}
void mousePressed() {
// *** count thru array
for (int i = 0; i < resizeableGrid.size(); i++) {
PVector pv = resizeableGrid.get(i);
if (mouseX>pv.x&&
mouseX<pv.x+tile&&
mouseY>pv.y&&
mouseY<pv.y+tile) {
// add a cell
PVector pvNew = new PVector (pv.x+tile/2, pv.y);
resizeableGrid.add (pvNew);
return;
}//if
}//for
}//func
//