This code does run. And is starting to do what I want but not exactly.
- The subdivided cells only remain during mousePressed, but I want the subdivisions to remain after mouse is pressed.
Code changes are in the mousePressed section.
ArrayList<PVector>resizeableGrid = new ArrayList();
ArrayList<PVector>subGrid = 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
ArrayList<PVector>subGrid = new ArrayList();
for (int i = 0; i < resizeableGrid.size(); i++) {
PVector pv = resizeableGrid.get(i);
// add a cell
for (float x = 0; x <= width; x+=tile/2) {
for (float y = 0; y <= height; y+=tile/2) {
PVector pv2 = new PVector(x, y);
subGrid.add(pv2);
}
}
rect (pv.x/2, pv.y/2, tile/2, tile/2);
}//for
}//func
//