There are several ways you could approach this problem. One is to create a mask that tells you whether to draw a tile or not.
For example, you could use the circle-point collision algorithm to check whether or not a tile on your grid would fall inside a circle.
So, given this function:
// POINT/CIRCLE
boolean pointCircle(float px, float py, float cx, float cy, float r) {
// get distance between the point and circle's center
// using the Pythagorean Theorem
float distX = px - cx;
float distY = py - cy;
float distance = sqrt( (distX*distX) + (distY*distY) );
// if the distance is less than the circle's
// radius the point is inside!
if (distance <= r) {
return true;
}
return false;
}
…we are going to test each cell x,y against a circle of radius cellsX / 2.0.
So, for example, inside your i,j loop, wrap the rendering of a cell in something like this:
if (pointCircle(i, j, cellsX/2.0, cellsY/2.0, cellsX/2.0)) {
A different approach would be to not use a nested x,y loop for rending, and instead either use one loop that winds out from the center, or a loop for nested rings of hexagons. This however would change your render order, which would change your audio data mapping. For discussion of hex rings and winding, see:
Looks like this approach is to create a hexagon class, save an x,y in each hexagon object, and populate them manually in strips by marching through a series of offset for-loops.
The only thing I don’t like about this approach is that it is hard-coded for one exactly one size, and there is no way to change the board size without rewriting the whole function. That works great for Settlers of Catan, but not as well for a music visualizer.