I have been playing with this code I found with no luck.
void draw() {
background(200);
drawGrid(50, 50, 900, 900, 6, 5);
}
void drawGrid(float startX, float startY, float gridWidth, float gridHeight, float dimX, float dimY) {
float w = gridWidth / dimX;
float h = gridHeight / dimY;
noStroke();
for (int y=0; y<dimY; y++) {
for (int x=0; x<dimX; x++) {
float xPos = startX + x * w;
float yPos = startY + y * h;
fill((x+y)%2==0?255:0);
triangle(50,300,xPos, yPos, w, h);
}
}
}