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