Debian Codegraph @

texmf-dist/doc/latex/pgf-go/en/pgfgo-board.tex

raw
1 \section{The Board}
2 \label{sec:board}
3
4 When we refer to the "board," we mean an environment or \emph{scope} in which both the goban (the game grid) and its contents—stones, coordinate labels, and other relevant information—are rendered. This environment is designed to be flexible and customizable, allowing users to adapt its appearance and functionality according to the needs of the diagram, whether to represent full games, specific sections, or even add visual annotations.
5
6 \begin{environment}{{goban}\opt{\oarg{options}}}
7
8 Initializes the goban environment. By default, it draws a square 9×9 intersection board with a visible border, white background, and no labels on the sides.
9
10 \begin{codeexample}[width=5cm]
11 \begin{goban}
12 \end{goban}
13 \end{codeexample}
14
15 Since the board is the only macro that utilizes the TikZ layer, each intersection can be accessed using its alphanumeric coordinate (as in \pgfname) or numeric values in the \tikzname\ coordinate system. This allows combining Go’s intuitive syntax with TikZ’s graphical capabilities, which is especially useful for adding custom elements, such as arrows or marks, directly onto the board.
16
17 \begin{codeexample}[width=5.85cm]
18 \begin{goban}[19, partial = {from = J1 to S9},
19 label = {at = {north, east}}]
20 \stones {K8,R8,Q5,R5,O4,Q4,L3,O3,M2,N2}
21 \mark[black, circle] {K8}
22 \stones[white] {K6,R4,R3,P3,N1,O2,Q2}
23
24 \tikzset{flecha/.style = {-{latex[]}, line width = 2pt, blue}}
25 \draw[flecha] (12,8)--(17,8);
26 \end{goban}
27 \end{codeexample}
28
29 \begin{key}{/pgfgo/goban/use i=\meta{boolean} (default true, initially true)}
30
31 Enables or disables the use of the letter "I" in the board’s coordinates and labels. When disabled ("false"), any reference to "I" is interpreted as "J".
32
33 \begin{codeexample}[]
34 \pgfgoset{goban = {13, label = {at = north}}}
35
36 \begin{goban}[label = {at = west}, partial = {from = H1 to M3}]
37 \stone[b]{J2}
38 \end{goban}
39
40 \begin{goban}[use i = false, partial = {from = H1 to N3}]
41 \stone[b]{J2}
42 \end{goban}
43
44 \begin{goban}[use i = false, label = {at = east}, partial = {from = H1 to N3}]
45 \stone[white, mark = {custom = !}] {I2} % If it’s I, it shifts to J.
46 \end{goban}
47 \end{codeexample}
48 \end{key}
49
50 \begin{key}{/pgfgo/goban/size=\meta{nlines or nlines |x| nlines} (initially 9)}
51
52 Defines the number of vertical and horizontal lines on the board. The word "size" can be omitted, and the value specified directly. If a single integer (e.g., |9|) is provided, the board will be square (9×9). If an expression like |5x3| is used, a rectangular board with 5 columns and 3 rows will be created.
53
54 \begin{codeexample}[width=6.5cm]
55 \begin{goban}[5]
56 \end{goban}
57
58 \begin{goban}[5x3]
59 \end{goban}
60 \end{codeexample}
61 \end{key}
62
63 \begin{key}{/pgfgo/goban/scale=\meta{float} (initially 1)}
64
65 Controls the global scale of the board, affecting both its overall dimensions and the thickness of certain elements (e.g., the "line width" of the lines).
66
67 \begin{codeexample}[width=5.5cm]
68 \begin{goban}[2, scale = 2]
69 \stone[b, mark]{A1}
70 \end{goban}
71
72 \begin{goban}[2, scale = 1]
73 \stone[b, mark]{A1}
74 \end{goban}
75
76 \begin{goban}[2, scale = 0.5]
77 \stone[b, mark]{A1}
78 \end{goban}
79 \end{codeexample}
80 \end{key}
81
82 \subsection{Grid}
83
84 The grid refers to the central lines that form the board’s intersections.
85
86 \begin{key}{/pgfgo/goban/grid=\meta{options}}
87 Controls the behavior and appearance of the board’s central lines. This set of options allows modifying their visibility, color, thickness, and spacing, offering a high degree of customization.
88 \end{key}
89
90 \begin{stylekey}{/pgfgo/goban/grid/false}
91
92 Disables the central lines, leaving only the border and stones visible.
93
94 \begin{codeexample}[]
95 \begin{goban}[3]
96 \stone[b]{A1}
97 \stone[w]{B2}
98 \end{goban}
99
100 \begin{goban}[3, grid = false]
101 \stone[b]{A1}
102 \stone[w]{B2}
103 \end{goban}
104 \end{codeexample}
105
106 The first board shows the default grid.
107 \end{stylekey}
108
109 \begin{key}{/pgfgo/goban/grid/line=\meta{options}}
110 Allows controlling the grid lines.
111 \end{key}
112
113 \begin{key}{/pgfgo/goban/grid/line/color =\meta{color} (initially black)}
114
115 Allows changing the color of the grid lines.
116
117 \begin{codeexample}[]
118 \pgfgoset{goban = {5, partial = {from = B2 to D4}}}
119
120 \begin{goban}[grid = {line = {color = blue}}, new remember]
121 \stones[b]{C2,D3}
122 \stone[w]{B4}
123 \end{goban}
124
125 \begin{goban}[grid = {line = {color = red}}, resume]
126 \end{goban}
127 \end{codeexample}
128 \end{key}
129
130 \begin{key}{/pgfgo/goban/grid/line/opacity =\meta{float} (initially 1)}
131
132 Sets the opacity of the grid lines, from 0 (transparent) to 1 (opaque).
133
134 \begin{codeexample}[]
135 \pgfgoset{goban = {5, partial = {from = B2 to D4}}}
136
137 \begin{goban}[new remember]
138 \stones[b]{C2,D3}
139 \stone[w]{B4}
140 \end{goban}
141
142 \begin{goban}[grid = {line = {opacity = 0.2}}, resume]
143 \end{goban}
144 \end{codeexample}
145 \end{key}
146
147 \begin{key}{/pgfgo/goban/grid/line/width =\meta{dimension} (initially 0.55pt)}
148
149 Defines the thickness of the grid lines.
150
151 \begin{codeexample}[]
152 \pgfgoset{goban = {5, partial = {from = B2 to D4}}}
153
154 \begin{goban}[new remember]
155 \stones[b]{C2,D3}
156 \stone[w]{B4}
157 \end{goban}
158
159 \begin{goban}[grid = {line = {width = 1.5pt}}, resume]
160 \end{goban}
161 \end{codeexample}
162 \end{key}
163
164 \begin{key}{/pgfgo/goban/grid/x sep =\meta{dimension} (initially 1.25em)}
165 Sets the spacing between vertical lines, adjusting the width of the board’s columns.
166 \end{key}
167
168 \begin{key}{/pgfgo/goban/grid/y sep =\meta{dimension} (initially 1.25em)}
169 Sets the spacing between horizontal lines, adjusting the height of the rows.
170 \end{key}
171
172 \begin{key}{/pgfgo/goban/grid/sep =\meta{dimension} (initially 1.25em)}
173 Simultaneously defines the vertical and horizontal spacing of the lines, ensuring uniform spacing in both directions. This is a convenient option for maintaining balanced proportions.
174 \end{key}
175
176 \subsection{Border}
177
178 The board’s border is the outline that frames the grid and stones, providing a clear visual boundary. By default, it is active, has a white background, and a black outline.
179
180 \begin{key}{/pgfgo/goban/background=\meta{options} (default true)}
181 Controls the properties of the board’s border, such as its visibility, color, thickness, and shape, allowing detailed customization.
182 \end{key}
183
184 \begin{stylekey}{/pgfgo/goban/background/false}
185
186 Completely disables the board’s border, removing both the outline and fill. This is useful for minimalist diagrams or when the document’s background already provides sufficient contrast.
187
188 \begin{codeexample}[]
189 \pgfgoset{goban = {5, partial = {from = B2 to D4}}}
190
191 \begin{goban}[new remember]
192 \stones[b]{C2,D3}
193 \stone[w]{B4}
194 \end{goban}
195
196 \begin{goban}[background = false, resume]
197 \end{goban}
198 \end{codeexample}
199 \end{stylekey}
200
201 \begin{key}{/pgfgo/goban/background/fill=\meta{options} (initially true)}
202 Controls options related to the board’s background fill.
203 \end{key}
204
205 \begin{key}{/pgfgo/goban/background/fill=\meta{boolean} (initially true)}
206
207 Determines whether the board’s background fill is active. If disabled, the area inside the border will be transparent, showing only the outline (if enabled).
208
209 \begin{codeexample}[]
210 \pgfgoset{goban = {5, partial = {from = B2 to D4}}}
211
212 \begin{goban}[background = {line = {color = red}}, new remember]
213 \stones[b]{C2,D3}
214 \stone[w]{B4}
215 \end{goban}
216
217 \begin{goban}[background = {line = false}, resume]
218 \end{goban}
219 \end{codeexample}
220 \end{key}
221
222 \begin{key}{/pgfgo/goban/background/fill/color =\meta{color} (default white)}
223
224 Defines the fill color of the board.
225
226 \begin{codeexample}[]
227 \pgfgoset{goban = {5, partial = {from = B2 to D4}}}
228
229 \begin{goban}[background = {fill = {color = orange!40}}, new remember]
230 \stones[b]{C2,D3}
231 \stone[w]{B4}
232 \end{goban}
233
234 \begin{goban}[background = {fill = {color = olive!30}}, resume]
235 \end{goban}
236 \end{codeexample}
237 \end{key}
238
239 \begin{key}{/pgfgo/goban/background/fill/opacity =\meta{float} (initially 1)}
240
241 Controls the opacity of the fill, from 0 (transparent) to 1 (opaque).
242
243 \begin{codeexample}[]
244 \pgfgoset{goban = {5, partial = {from = B2 to D4}}}
245
246 \begin{goban}[background = {fill = {color = orange!40}}, new remember]
247 \stones[b]{C2,D3}
248 \stone[w]{B4}
249 \end{goban}
250
251 \begin{goban}[background = {fill = {color = orange!40}, fill = {opacity = 0.5}}, resume]
252 \end{goban}
253 \end{codeexample}
254
255 \end{key}
256
257 \begin{key}{/pgfgo/goban/background/line=\meta{options} (default true)}
258 Controls the options for the background’s outline.
259 \end{key}
260
261 \begin{key}{/pgfgo/goban/background/line=\meta{boolean}}
262 Enables or disables the border line.
263
264 \begin{codeexample}[]
265 \pgfgoset{goban = {5, partial = {from = B2 to D4}}}
266
267 \begin{goban}[background = {line = {color = red}}, new remember]
268 \stones[b]{C2,D3}
269 \stone[w]{B4}
270 \end{goban}
271
272 \begin{goban}[background = {line = false}, resume]
273 \end{goban}
274 \end{codeexample}
275 \end{key}
276
277 \begin{key}{/pgfgo/goban/background/line/color =\meta{color} (default black)}
278
279 Defines the color of the border line, allowing it to stand out from the background or grid lines.
280
281 \begin{codeexample}[]
282 \pgfgoset{goban = {5, partial = {from = B2 to D4}}}
283
284 \begin{goban}[background = {line = {color = red}}, new remember]
285 \stones[b]{C2,D3}
286 \stone[w]{B4}
287 \end{goban}
288
289 \begin{goban}[background = {line = {color = blue}}, resume]
290 \end{goban}
291 \end{codeexample}
292 \end{key}
293
294 \begin{key}{/pgfgo/goban/background/line/opacity =\meta{float} (default 1)}
295
296 Adjusts the opacity of the border line.
297
298 \begin{codeexample}[]
299 \pgfgoset{goban = {5, partial = {from = B2 to D4}}}
300
301 \begin{goban}[background = {line = {color = red}}, new remember]
302 \stones[b]{C2,D3}
303 \stone[w]{B4}
304 \end{goban}
305
306 \begin{goban}[background = {line = {color = red}, line = {opacity = 0.5}}, resume]
307 \end{goban}
308 \end{codeexample}
309 \end{key}
310
311 \begin{key}{/pgfgo/goban/background/line/width =\meta{dimension} (default 0.75pt)}
312
313 Controls the thickness of the border line.
314
315 \begin{codeexample}[]
316 \pgfgoset{goban = {5, partial = {from = B2 to D4}}}
317
318 \begin{goban}[new remember]
319 \stones[b]{C2,D3}
320 \stone[w]{B4}
321 \end{goban}
322
323 \begin{goban}[background = {line = {width = 1.5pt}}, resume]
324 \end{goban}
325 \end{codeexample}
326 \end{key}
327
328 \begin{key}{/pgfgo/goban/background/rounded corners =\meta{dimension} (default 1pt)}
329
330 Adjusts the rounding of the border corners, from 0pt (straight corners) to larger values for a smoother, more stylized effect.
331
332 \begin{codeexample}[]
333 \pgfgoset{goban = {5, partial = {from = A1 to C3}}}
334
335 \begin{goban}[new remember]
336 \stones[b]{B1,C2}
337 \stone[w]{A3}
338 \end{goban}
339
340 \begin{goban}[background = {rounded corners = 10pt}, resume]
341 \end{goban}
342 \end{codeexample}
343 \end{key}
344
345 \begin{key}{/pgfgo/goban/background/rounded corners/outer =\meta{dimension} (default 1pt)}
346
347 Adjusts only the rounding of the outer corners of the border.
348
349 \begin{codeexample}[]
350 \pgfgoset{goban = {5, partial = {from = A1 to C3}}}
351
352 \begin{goban}[background = {rounded corners = 0pt}, new remember]
353 \stones[b]{B1,C2}
354 \stone[w]{A3}
355 \end{goban}
356
357 \begin{goban}[background = {rounded corners = {outer = 10pt}}, resume]
358 \end{goban}
359 \end{codeexample}
360 \end{key}
361
362 \begin{key}{/pgfgo/goban/background/rounded corners/inner =\meta{dimension} (default 1pt)}
363
364 Adjusts only the rounding of the inner corners of the board (only visible on partial boards).
365
366 \begin{codeexample}[]
367 \pgfgoset{goban = {5, partial = {from = A1 to C3}}}
368
369 \begin{goban}[background = {rounded corners = 0pt}, new remember]
370 \stones[b]{B1,C2}
371 \stone[w]{A3}
372 \end{goban}
373
374 \begin{goban}[background = {rounded corners = {outer = 8pt, inner = 2pt}}, resume]
375 \end{goban}
376 \end{codeexample}
377 \end{key}
378
379 \begin{key}{/pgfgo/goban/background/sep =\meta{dimension} (default /pgfgo/goban/stone/radius * 1.5)}
380
381 Defines the separation between the grid and the border, based by default on the stone radius multiplied by 1.5. This adjustment ensures that stones near the border do not overlap with it.
382
383 \begin{codeexample}[]
384 \pgfgoset{goban = {5, partial = {from = B2 to D4}}}
385
386 \begin{goban}[background = {sep = 0.625em}, new remember]
387 \stones[b]{C2,D3}
388 \stone[w]{B4}
389 \end{goban}
390
391 \begin{goban}[background = {sep = 1.5em}, resume]
392 \end{goban}
393 \end{codeexample}
394 \end{key}
395
396 \subsection{Partial Board}
397
398 In many cases, it’s not necessary to represent a full board, but rather just a rectangular section—whether due to space constraints, to focus attention on a specific area, or to simplify diagram creation. The |goban| environment includes the \emph{key} |partial|, which allows defining this region using the sub-\emph{key} |from|. This specifies the opposite vertices of a rectangle, regardless of the order in which they are provided, making it easy to use. For example, |from = A1 to D3| is equivalent to |from = D3 to A1|.
399
400 \begin{figure}[H]
401 \centering
402
403 \begin{tikzpicture}
404 \node[anchor=north] (X) {
405 \begin{goban}[label = {at = {north, west}}]
406 \coordinate (A) at (4,6);
407 \coordinate (B) at (9,9);
408 \coordinate (C) at (A|-B);
409 \coordinate (D) at (A-|B);
410
411 \tikzset{punto/.style = {circle, fill = #1, draw, inner sep=0.25em, fill opacity=0.5, anchor=center}}
412
413 \node[punto = red] at (A){};
414 \node[punto = red] at (B){};
415 \node[punto = blue] at (C){};
416 \node[punto = blue] at (D){};
417
418 \draw[red, {latex}-{latex}, shorten <=5pt, shorten >= 5pt] (A)--(B);
419 \draw[blue, {latex}-{latex}, shorten <=5pt, shorten >= 5pt] (C)--(D);
420
421 \node[fit=(A)(B), draw, inner sep=0.6em, rounded corners, line width=1pt, fill opacity=0.1, fill=orange] {};
422 \end{goban}
423 };
424
425 \node[anchor=north, xshift=15em] {
426 \tikz{
427 \node[inner sep=0] (Y) {
428 \begin{goban}[label = {at = {north, west}}, partial = {from = I9 to D6}]
429 \end{goban}
430 };
431 \node[align = left, anchor=north, inner sep=0, yshift=-1em] at (Y.south){
432 {\color{blue}|partial = {from = D9 to I6}|}\\
433 {\color{blue}|partial = {from = I6 to D9}|}\\
434 {\color{red} |partial = {from = D6 to I9}|}\\
435 {\color{red} |partial = {from = I9 to D6}|}\\
436 };
437 }
438 };
439 \end{tikzpicture}
440 \end{figure}
441
442 \begin{key}{/pgfgo/goban/partial=\meta{options}}
443
444 Controls options for representing partial boards, allowing the delimitation of a specific region of the goban.
445 \end{key}
446
447 \begin{key}{/pgfgo/goban/partial/from=\meta{intersection |to| intersection}}
448
449 Specifies the opposite vertices of the rectangle defining the partial board. These intersections can be any pair of points forming a diagonal of the desired area.
450
451 \end{key}
452
453 \begin{codeexample}[]
454 \tikzset{flecha/.style = {-{latex[]}, line width = 1pt, red}}
455
456 \begin{goban}[partial = {from = A1 to D3}]
457 \draw[flecha] (1,1)--(4,3); % From A1 to D3
458 \end{goban}
459
460 \begin{goban}[partial = {from = A9 to I6}]
461 \draw[flecha] (1,9)--(9,6); % From A9 to I6
462 \end{goban}
463
464 \begin{goban}[partial = {from = E2 to B4}]
465 \draw[flecha] (5,2)--(2,4); % From E2 to B4
466 \end{goban}
467 \end{codeexample}
468
469 \subsection{Board Labels}
470
471 Labels are the alphanumeric indicators (letters and numbers) that appear on the sides of the board to identify intersections.
472
473 \begin{key}{/pgfgo/goban/label=\meta{options}}
474 Controls the properties of the labels, such as their position and format.
475 \end{key}
476
477 \begin{key}{/pgfgo/goban/label/false}
478 Disables all labels.
479 \end{key}
480
481 \begin{key}{/pgfgo/goban/label/at =\meta{options}}
482
483 Defines on which sides of the board the labels appear. Options include combinations of cardinal positions or predefined values like "all" or "none".
484
485 \begin{stylekey}{/pgfgo/goban/label/at/all}
486
487 Displays labels on all sides of the board (north, south, east, and west).
488 \end{stylekey}
489
490 \begin{stylekey}{/pgfgo/goban/label/at/none}
491
492 Equivalent to |label=false|, removing all labels.
493 \end{stylekey}
494
495 \begin{stylekey}{/pgfgo/goban/label/at/east}
496 Places labels only on the right side (vertical numbers).
497 \end{stylekey}
498 \begin{stylekey}{/pgfgo/goban/label/at/right}
499 Equivalent to |east|.
500 \end{stylekey}
501
502 \begin{stylekey}{/pgfgo/goban/label/at/north}
503 Places labels only at the top (horizontal letters).
504 \end{stylekey}
505 \begin{stylekey}{/pgfgo/goban/label/at/above}
506 Equivalent to |north|.
507 \end{stylekey}
508
509 \begin{stylekey}{/pgfgo/goban/label/at/south}
510 Places labels only at the bottom (horizontal letters).
511 \end{stylekey}
512 \begin{stylekey}{/pgfgo/goban/label/at/below}
513 Equivalent to |south|.
514 \end{stylekey}
515
516 \begin{stylekey}{/pgfgo/goban/label/at/west}
517 Places labels only on the left side (vertical numbers).
518 \end{stylekey}
519 \begin{stylekey}{/pgfgo/goban/label/at/left}
520 Equivalent to |west|.
521 \end{stylekey}
522
523 \begin{codeexample}[]
524 \begin{goban}[12, label = {at = {all}}]
525 \end{goban}
526
527 \begin{goban}[partial = {from = A6 to I9}, label = {at = north}]
528 \end{goban}
529
530 \begin{goban}[partial = {from = B2 to E4}, label = {at = {north, east}}]
531 \end{goban}
532 \end{codeexample}
533 \end{key}
534
535 % \begin{key}{/pgfgo/goban/label/font size = \meta{dimension} (initially 0.75em)}
536 %
537 % Adjusts the font size of the labels.
538 % \end{key}
539
540 \begin{key}{/pgfgo/goban/label/sep = \meta{dimension} (initially 0.5em)}
541
542 Controls the distance between the labels and the board’s border.
543 \end{key}
544
545 \begin{key}{/pgfgo/goban/label/text color = \meta{color} (initially black)}
546
547 Defines the text color of the labels.
548 \end{key}
549
550 \subsection{Remembering a Board}
551 The "remember" system allows storing and reusing a board’s state across different |goban| environments. This functionality is highly experimental and, strictly speaking, should not yet be documented.
552
553 \begin{stylekey}{/pgfgo/goban/new remember}
554
555 Starts a new memory state, saving the current board’s stones and configurations for later use.
556 \end{stylekey}
557
558 \begin{stylekey}{/pgfgo/goban/add to remember}
559
560 Adds elements to the memorized state without erasing the previous content, allowing incremental diagram construction.
561 \end{stylekey}
562
563 \begin{stylekey}{/pgfgo/goban/forget}
564
565 Erases the memorized state, resetting the memory system.
566 \end{stylekey}
567
568 \begin{stylekey}{/pgfgo/goban/resume}
569
570 Retrieves and renders the memorized state, useful for continuing from a previous point without rewriting the code.
571
572 \end{stylekey}
573
574 \end{environment}