Tiling a triangle with buttons/clickable areas

please format code with </> button * homework policy * asking questions

Hi

I’m trying to create Tiling a triangle with buttons/clickable areas like this


picture, but i cannot figure it out in a simple loop

an alternative would be 6 sliders (one for each stripe of cells)

Please show your attempt/ entire code

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);
}
}
}

For using this grid as mouse buttons you could make the same graphic invisible and use unique colors.

Then check the color of the mouse position on the invisible PGraphics and by the color determine the field the mouse is in. It’s an old trick.

Might be simpler than to calculate the mouse button area mathematical

Yours looks nice though!!!