I'm drawing stones on a Go (game) board with SGF coordinates (which I only managed to do from the the help people gave me on this question) like this \drawStoneFromSgfCoords{ab}.
However, there might be many stones per diagram, so it would be practical to also have another macro like this: \drawStonesFromSgfCoords{{black, ab}, {white, cd}} (the colors typically alternate, but sometimes it's more practical to have a list of black coordinates and then white's).
Here's what I'm trying right now, though it doesn't work (I mean, it does work, just not with the new macro):
\documentclass{article}
\usepackage{tikz}
% From this answer by @DavidCarlisle.
\newcommand\notwhite{black}
\newcommand\notblack{white}
% From this answer by @DavidCarlisle.
\ExplSyntaxOn
\cs_generate_variant:Nn \int_from_alph:n {e}
\newcommand\stringToCoordX[1]{
\int_from_alph:e{\use_i:nn#1}
}
\newcommand\stringToCoordY[1]{
~\int_from_alph:e{\use_ii:nn#1}
}
\ExplSyntaxOff
\newcommand{\drawStoneFromSgfCoords}[2]{
\pgfmathsetmacro{\x}{\stringToCoordX{#2} - 1}
\pgfmathsetmacro{\y}{\stringToCoordY{#2} - 1}
\draw[draw = \UseName{not#1}, fill = #1, line width = 0.1mm]
(\x * 10cm / 18, \y * 10cm / 18)
circle [radius = 0.2575cm];
node[color = white] {1};
}
% Example usage: drawStonesFromSgfCoords{{black, ab}, {white, cd}}
\newcommand{\drawStonesFromSgfCoords}[1]{
\foreach \coords in {#1}{
\drawStoneFromSgfCoords{{\coords}[0]}{{\coords}[1]}
}
}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\step}{10 / 18}
\draw[step=\step] (0, 0) grid (10, 10);
\drawStoneFromSgfCoords{black}{ab}
\drawStoneFromSgfCoords{white}{cd}
% \drawStonesFromSgfCoords{{black, ab}, {white, cd}}
\end{tikzpicture}
\end{document}
What's the proper way of accessing or passing arrays (within a loop)?
(I'm using PGF's \foreach because that's what I know.)
