here are two examples of a grid sketch
I use classes to simplify things visually.
class grid{
color [][]grid;
float x,y, xres,yres,flying;
int w,h,cols,rows;
PImage grid2,g1;
boolean update;
grid(float x,float y,int w,int h,int resx,int resy){
this.w = w;
this.h = h;
this.x = x;
this.y = y;
this.xres = resx;
this.yres = resy;
grid2 = createImage(w,h,RGB);
cols = floor((w-x)/resx);
rows = floor((h-y)/resy);
grid = new color[cols][rows];
for(int i=0;i<cols;i++){
for(int j=0;j<rows;j++){
grid[i][j] = color(random(255),random(255),random(255));
}}
};
void draw(){
if(mousePressed)update = true;
else update = false;
if(g1 == null||update){
for(int i=0;i<grid.length;i++){
for(int j=0;j<grid[0].length;j++){
if(update)grid[i][j] = color(random(255),random(255),random(255));
color a = grid[i][j];
fill(a);
noStroke();
rect(x + xres * i, y + yres * j,xres,yres);
}}
//g1 = createImage(g.w,g.h,RGB);
g1 = get(0,0,g.w,g.h);
//
}
else {
image(g1,x,y);
}
};
void drawPerlin(){
float yoff = flying;
if(g1==null||update){
for (int y = 0; y < rows; y++) {
float xoff = 0;
for (int x = 0; x < cols; x++) {
float d = map(noise(xoff, yoff), 0, 1, 0, 255);
xoff += 0.2;
color c = 0;
if(d<60)c = color(0,0,255);
if(d>60)c = color(189, 189, 23);
if(d>100)c = color(31, 138, 29);
if(d>160)c = color(84, 94, 84);
if(d>200)c = color(255);
noStroke();
fill(c);
rect(x*xres,y*yres,xres,yres);
}
yoff += 0.2;
}
g1 = get(0,0,w,h);
update = false;
}else image(g1,x,y);
};
};
grid g;
void setup(){
size(1200,600);
g = new grid(100,100,1200-100,600-100,10,10);
};
void draw(){
background(0);
g.drawPerlin();
//g.draw();
fill(255,0,0);
textSize(20);
text(frameRate,10,20);
};
try both methods in the sketch, ie uncomment the g.draw() method and see what it does.
Pressing the mouse with g.draw() will randomize the colours.
Is this the kind of thing you are looking for?