summaryrefslogtreecommitdiff
path: root/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-sgf-library.tex
blob: 972f24e718cc91bbc316bb624ba8acea526bf5c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
%D \module
%D   [       file=t-go-library,
%D        version=2007.08.15,
%D          title=\CONTEXT\ User Module,
%D       subtitle=Go extensions,
%D         author={Zhichu Chen \& Wolfgang Schuster},
%D           date=\currentdate,
%D      copyright=Public Domain]

\writestatus{loading}{Context User Module / Go extensions}

\unprotect

\startMPinitializations
  StoneUnit=\the\stoneunit ;
  BoardSize=\the\boardsize ;
  BoardUnit=\the\boardunit ;
  BoardColumns=\@@@@bdn ;

  GridWidth=.7pt ;

  defaultfont := "cmss10" ;
  defaultscale := .05*BoardUnit ;

  vardef Alph (expr n) =
    if (n = 1) : "A"
    elseif (n = 2) : "B"
    elseif (n = 3) : "C"
    elseif (n = 4) : "D"
    elseif (n = 5) : "E"
    elseif (n = 6) : "F"
    elseif (n = 7) : "G"
    elseif (n = 8) : "H"
    elseif (n = 9) : "J"
    elseif (n = 10) : "K"
    elseif (n = 11) : "L"
    elseif (n = 12) : "M"
    elseif (n = 13) : "N"
    elseif (n = 14) : "O"
    elseif (n = 15) : "P"
    elseif (n = 16) : "Q"
    elseif (n = 17) : "R"
    elseif (n = 18) : "S"
    elseif (n = 19) : "T"
    fi
  enddef ;
\stopMPinitializations

%D Stone set 1, simple black and white stones:

\startreusableMPgraphic{blackstone pure}
drawfill fullcircle scaled StoneUnit withcolor black ;
\stopreusableMPgraphic

\startreusableMPgraphic{whitestone pure}
fill fullcircle scaled StoneUnit withcolor white ;
draw fullcircle scaled StoneUnit withcolor black ;
\stopreusableMPgraphic

%D Stone set 2, shaded black and white stones:

\startreusableMPgraphic{blackstone shade}
circular_shade ( fullcircle scaled StoneUnit , 4 , \MPcolor{gray} , black ) ;
\stopreusableMPgraphic

\startreusableMPgraphic{whitestone shade}
circular_shade ( fullcircle scaled StoneUnit , 2 , .8white , white ) ;
\stopreusableMPgraphic

%D The board, one for all stone sets.

\startuseMPgraphic{board}
numeric u , v ;
if "\@@@@bdalternative"="a" :
  u = OverlayWidth/(BoardSize+2) ;
  v = (OverlayHeight-BoardColumns*2*BoardUnit)/(BoardSize+2) ;
elseif "\@@@@bdalternative"="b":
  u = (OverlayWidth-BoardColumns*4*BoardUnit)/(BoardSize+2) ;
  v = OverlayHeight/(BoardSize+2) ;
elseif "\@@@@bdalternative"="c":
  u = OverlayWidth/(BoardSize+2) ;
  v = OverlayHeight/(BoardSize+2) ;
fi

for i=3 upto BoardSize :
  draw ((2u,-i*v)--((BoardSize+1)*u,-i*v))
    if "\@@@@bdalternative"="a" :
      shifted (-.5u,.5v)
    elseif "\@@@@bdalternative"="b" :
      shifted (BoardColumns*2*BoardUnit-.5u,.5v)
    elseif "\@@@@bdalternative"="c" :
      shifted (-.5u,.5v)
    fi withpen pencircle scaled GridWidth ;
  draw ((i*u,-2v)--(i*u,(BoardSize+1)*-v))
    if "\@@@@bdalternative"="a" :
      shifted (-.5u,.5v)
    elseif "\@@@@bdalternative"="b" :
      shifted (BoardColumns*2*BoardUnit-.5u,.5v)
    elseif "\@@@@bdalternative"="c" :
      shifted (-.5u,.5v)
    fi withpen pencircle scaled GridWidth ;
endfor

draw if "\@@@@bdalternative"="b" : ( fi
  (1.5u,-1.5v)--(1.5u,(-.5-BoardSize)*v)--
  ((BoardSize+.5)*u,(-.5-BoardSize)*v)--
  ((BoardSize+.5)*u,-1.5v)--cycle
  if "\@@@@bdalternative"="b" : ) shifted (BoardColumns*2*BoardUnit,0) fi
  withpen pencircle scaled (2*GridWidth) ;

if BoardSize=19 :
  for i=4,10,16 :
    for j=4,10,16 :
      drawdot ((i+.5)*u , -(j+.5)*v)
        if "\@@@@bdalternative"="b" : shifted (BoardColumns*2*BoardUnit,0) fi
        withpen pencircle scaled (6*GridWidth) ;
    endfor
  endfor
elseif BoardSize=13 :
  for i=4,7,10 :
    for j=4,7,10 :
      drawdot ((i+.5)*u , -(j+.5)*v)
        if "\@@@@bdalternative"="b" : shifted (BoardColumns*2*BoardUnit,0) fi
        withpen pencircle scaled (6*GridWidth) ;
    endfor
  endfor
elseif BoardSize=9 :
  for i=3,7 :
    for j=3,7 :
      drawdot ((i+.5)*u , -(j+.5)*v)
        if "\@@@@bdalternative"="b" : shifted (BoardColumns*2*BoardUnit,0) fi
        withpen pencircle scaled (6*GridWidth) ;
    endfor
  endfor
  drawdot ((5.5)*u , -(5.5)*v)
    if "\@@@@bdalternative"="b" : shifted (BoardColumns*2*BoardUnit,0) fi
    withpen pencircle scaled (6*GridWidth) ;
fi

%D Draw labels on the edge of the board
for i=1 upto BoardSize :
  label ( Alph(i) , ( if "\@@@@bdalternative"="b" : (i+2.5)*u else : (i+.5)*u fi , -.5*v ) )
    if "\@@@@bdalternative"="b" : shifted ((BoardColumns-1)*2*BoardUnit,0) fi ;
  label ( decimal i, ( if "\@@@@bdalternative"="b" : 2.5*u else : .5*u fi , ( BoardSize - i + 1.5 ) * (-v) ) )
    if "\@@@@bdalternative"="b" : shifted ((BoardColumns-1)*2*BoardUnit,0) fi ;
endfor

setbounds currentpicture to (0,0)--(OverlayWidth,0)--(OverlayWidth,-OverlayHeight)--(0,-OverlayHeight)--cycle;
\stopuseMPgraphic

%D Here we define a conversion set for our two stone sets.

\defineconversion
  [stone 1]
  [\reuseMPgraphic{blackstone pure},
   \reuseMPgraphic{whitestone pure}]

\defineconversion
  [stone 2]
  [\reuseMPgraphic{blackstone shade},
   \reuseMPgraphic{whitestone shade}]

\protect \endinput