August 2010

You are currently browsing the monthly archive for August 2010.

A question on tex.stackexchange got me to play around with TikZ a little bit, which resulted in the following picture:

goboard

On the way, I produced some commands for quickly drawing similar pictures (note that there is already a LaTeX package for drawing black-and-white diagrams):

usepackage{tikz,amsfonts}
usetikzlibrary{calc,shadows}

% The basic environment that draws the board
newenvironment{partialgoboard}[2]{%
 begin{tikzpicture}[
 scale=0.5,
 stone/.style={drop shadow={shadow xshift=0.03, shadow yshift=-0.05}},
 black-stone/.style={black!80},
 black-highlight/.style={outer color=black!80, inner color=black!30},
 black-number/.style={white},
 white-stone/.style={white!70!black},
 white-highlight/.style={outer color=white!70!black, inner color=white},
 white-number/.style={black},
 gomark/.style={black,fill=brown!80}]
 clip (#1) rectangle (#2);
 fill[brown!80] (0,0) rectangle (20,20);
 draw[black] (1,1) grid (19,19);
 draw[thick,black] (1,1) rectangle (19,19);
 fill (4,4) circle (0.1);
 fill (4,10) circle (0.1);
 fill (4,16) circle (0.1);
 fill (10,4) circle (0.1);
 fill (10,10) circle (0.1);
 fill (10,16) circle (0.1);
 fill (16,4) circle (0.1);
 fill (16,10) circle (0.1);
 fill (16,16) circle (0.1);
 }{%
 end{tikzpicture}
 }

% A shortcut for drawing a full board
newenvironment{goboard}{begin{partialgoboard}{0,0}{20,20}}{end{partialgoboard}}

% A stone
newcommandgostone[4][]{%
 begin{scope}
 fill[stone,#2-stone] (#3,#4) circle (0.45);
 clip (#3,#4) circle (0.45);
 shade[#2-highlight] (-0.15+#3,0.5+#4) circle (0.7);
 end{scope}
 node[#2-number] at (#3,#4) {sffamilybfseries{#1}};
}

% Some markers
newcommandgotrig{(mathbftriangle)}
newcommandgobox{(mathbfBox)}
newcommandgodia{(mathbfDiamond)}

% Marking a position on the board
newcommandgomark[3]{%
 node[gomark] at (#2,#3) {sffamilybfseries{#1}};
}

The above example is then produced with:

begin{partialgoboard}{0,0}{10.5,10.5}
 gostone{white}{4}{9}
 gostone{white}{3}{4}
 gostone[gotrig]{white}{5}{3}
 gostone{white}{10}{4}
 gostone[1]{white}{2}{6}
 gostone[3]{white}{3}{3}
 gostone[5]{white}{4}{5}
 gostone[7]{white}{2}{3}
 gostone{black}{2}{4}
 gostone{black}{3}{5}
 gostone[2]{black}{4}{4}
 gostone[4]{black}{4}{3}
 gostone[6]{black}{3}{2}
 gostone[8]{black}{5}{4}
 gomark{A}{5}{5}
 gomark{B}{2}{2}
end{partialgoboard}