Skip to main content
1 of 3
kglr
  • 400.5k
  • 18
  • 488
  • 929

###Translate

ClearAll[triHex];
triHex[w_, h_] := Module[{hex = {FaceForm[White], EdgeForm[Black], Polygon@#, 
   Red, PointSize[Large], Point@#} &@ Table[{Cos[2 Pi k /6], Sin[2 Pi k /6]}, {k, 6}]}, 
 Fold[Translate[#, {{0, 0}, ## & @@ #2}] &, hex, 
  {Table[{4 k Cos[Pi/3], 0}, {k, 1, w }], Table[2 k {Cos[Pi/3], Sin[Pi/3]}, {k, 1, h }]}]]

Examples:

Graphics[triHex[10, 5], ImageSize -> 600]

enter image description here

Graphics[triHex[7, 7] /. White -> LightBlue, ImageSize -> 600]

enter image description here

kglr
  • 400.5k
  • 18
  • 488
  • 929