# I need to make a Hexolnikov grid from a 2-D array AND in the row and column refer to the corresponding hexagon by painting over it

I'm new to mathematika. I need to access the hexagon by the index of the two-dimensional array that I set. This hexagon needs to be painted over, I was able to find how to set the grid only with a one-dimensional array, please help. I need to either make a two-dimensional array out of this one-dimensional array or even find another function to create a grid with the ability to access the desired hexagon

hexes = Keys@
ResourceFunction["HextileBins"][
Flatten[Table[{x, y}, {x, 0, 15}, {y, 0, 15}], 1], 2];
Graphics[{Red, Polygon[hexes[[80, 1]]], EdgeForm[Blue],
FaceForm[None], hexes}]
Polygon[hexes[[80, 1]]]


that's just where the problem is that the array is one-dimensional

Clear["Global*"]

\$Version

(* "12.3.1 for Mac OS X x86 (64-bit) (June 19, 2021)" *)

hexes = Keys@
ResourceFunction["HextileBins"][
Flatten[Table[{x, y}, {x, 0, 15}, {y, 0, 15}], 1], 2];

Manipulate[
Graphics[{
Red, Polygon[hexes[[10*(column - 1) + row, 1]]],
EdgeForm[Blue], FaceForm[None], hexes},
ImageSize -> Small],
{{row, 1}, Range[10, 1, -1],
ControlType -> SetterBar,
Appearance -> "Vertical",
ControlPlacement -> Left},
Row[{
Spacer,
Control[{{column, 1}, Range,
ControlType -> SetterBar}]}]] If I understand correctly, you'd like to be able to enter some 2D integer indices and return the Polygon on a hexagonal grid? Using HextileBins to do this is interesting (and in-fact there's a similar example of making hexagonal grids under Applications in the Resource Function's documentation).

Your code above can be massaged into achieving this, for example something like this:

xBins=8;
yBins=8;

hexes=Join@@@(Transpose/@Partition[GatherBy[
First@*Mean@*PolygonCoordinates],2]);
Graphics[{Red,hexes[],Green,hexes[[7,3]],EdgeForm[Blue],FaceForm[None],hexes}] However, the main problem is that the hexagonal grid does not live on the cartesian grid, but rather uses hexagonal lattice vectors.

This is perhaps a more 'rigorous' way of achieving what you want:

• First, define the hexagonal vectors
hexagonalLatticeVectors = {{1/2, Sqrt/2}, {1/2, -Sqrt/2}};

• Then, we write a simple function to return a Polygon at a particular Cartesian location
hexagonAt[{x_, y_}] := Polygon[CirclePoints[{x, y}, {Sqrt/3, \[Pi]/6}, 6]]

• We can then loop over integer linear combinations of these lattice vectors to obtain a 2D hexagonal grid (note these are indexed using the hexagonal lattice vectors)
newHexes=Table[hexagonAt[{i,j}.hexagonalLatticeVectors],{i,8},{j,8}];
Graphics[{Red,newHexes[],Green,newHexes[[7,2]],EdgeForm[Blue],FaceForm[None],Flatten[newHexes]}]
` 