I need to draw a Hex board. I would like to be able to mark each hexagon and mark the size. Being able to control the thickness of the lines would be nice, but it is not something I need to have. Could anyone suggest a simple way of doing this?
Here is a picture of what I had in mind:
EDIT: Cmhughes brought up some pointers on making this post better, so here it goes!
I have found very little material to help me through this. However, I found this on the stackexchange forum. I have tried modifying the code (from the first answer) to fit my needs (as shown in the picture), but every time I change something the graph does some very weird things, like creating a large line of hexagons in what appears to be a random direction.
My problem, then, is that I have no idea how I would modify the code to make it a Hex board, rather than a Hex map.
This is the code I am referring to:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}[
hexa/.style={
shape=regular polygon,
regular polygon sides=6,
minimum size=1cm,
draw,
inner sep=0,
anchor=south,
fill=lightgray!85!blue,
rotate=30
}
]
\foreach \j in {0,...,5}{%
\pgfmathsetmacro\end{5+\j}
\foreach \i in {0,...,\end}{%
\node[hexa] (h\i;\j) at ({(\i-\j/2)*sin(60)},{\j*0.75}) {};
}
}
\foreach \j in {0,...,4}{%
\pgfmathsetmacro\end{9-\j}
\foreach \i in {0,...,\end}{%
\pgfmathtruncatemacro\k{\j+6}
\node[hexa] (h\i;\k) at ({(\i+\j/2-2)*sin(60)},{4.5+\j*0.75}) {};
}
}
\foreach \k in {0,...,10} {%
\node[circle,red,minimum size=1cm] at (h3;\k) {3;\k};
}
\foreach \k in {0,...,10} {%
\node[circle,blue,minimum size=1cm] at (h1;\k) {1;\k};
}
\end{tikzpicture}
\end{document}
Does anyone have any pointers on how to modify the code?
Further, does anyone know how to mark the sides, like in the picture, and how to create a random-looking marking of the hexagons (although I this may have to simply be a lot of copying and pasting)?
Best Answer
This
MWE
withAsymptote
usesstruct hexboard
fromhexboard.asy
module (attached). The boardhb
is created with the commandhexboard hb=hexboard(11,xo);
is11
cells wide, the marks are prepared in the array of stringsstring[] xo
;Cell nodes and directions are as follows (direction is named after the node of destination):
The thick line is constructed by the start cell, optional prefix and suffix (if the line goes outside the grid), the node number to start with and a sequence of the directions. For example a command
uses the node
3
of the bottom cell(-10,0)
as a starting point, prepends it with the line from below point(0,-1)
and continue with directions4
,5
and0
(4
segments in total).Position of the leftmost cell is
(0,0)
, rightmost cell is(n-1,0)
the top is at(0,n-1)
, and the bottom is at(0,-(n-1))
.