%! % Draw a go game recording board % WJHansen, November, 1988 % % Copyright WJHansen, 1988, 1994, 2003 % Permission is hereby granted to use and redistribute % this code. Modification for personal and (physically) % local club use is permitted, provided that the copyright % notice is retained both within the file and on the % printed output. Contact the author for permission to % redistribute modified code or sell copies of the % image produced by the code, % % Modified on 03-04-2003 by David Fifield % % No copyright claim is made on these modifications. /boardsize 19 def % number of lines /paperwidth 8.5 def % outside width of paper, inches /paperheight 11.0 def % total height of paper, inches /borderwidth .25 def % whitespace to left and right of board, inches /boardcolor .85 def % background grey .72 is dark .85 is ok .99 is light /hoshicolor 0 def % color of hoshi points /aspectratio 1.07 def % distances in y are this much bigger than those in x % the following are fractions of the xspacing value /whiterad .49 def % size white stone /edgewidth .07 def % thickness of grey around outer stones /hoshirad .08 def % radius of hashi dot /boxborder .1 def % size of white space around index letters and numbers /watermark (P) def % large darker area in background % parameters for legend area /clubname (Pittsburgh Go Club) def /dateblank .85 def % lenght of blank for date /timeblank .5 def % length of blank for time % xspacing: center to center horizontal spacing of cells % yspacing: center to center vertical spacing of cells % the coordinate space is the board grid, ranging from 1 to boardsize in each % direction from lower left corner % scaling is done so there is a device dot at the center of each stone cell /initboard { paperwidth borderwidth 2 mul sub % horizontal space to use, inches boardsize edgewidth 2 mul add div % xspacing, inches 72 mul % x grid spacing, points dup aspectratio mul % y grid spacing, points dtransform round exch round exch idtransform % round to device coords /yspacing exch def % vertical spacing in points /xspacing exch def % horizontal spacing in points borderwidth 72 mul % left margin, white, points xspacing edgewidth mul add % left margin, white & grey, points dup aspectratio mul % top margin, white & grey, points exch xspacing 2 div sub % coord of 0th line on left, points exch yspacing boardsize .5 add mul % down from top for 0th horizontal line paperheight 72 mul exch sub exch sub % coord of 0th horiz line transform round exch round exch itransform % round to device coords translate xspacing yspacing scale % set coordinate space to board grid } def /drawhoshi { % fill the hoshi points hoshicolor setgray newpath mark /corner boardsize 13 lt { 3 } { 4 } ifelse def boardsize 2 mod 0 ne { % If odd boardsize 5 ge { boardsize 2 idiv 1 add dup } if boardsize 19 ge { dup dup corner dup 3 -1 roll dup dup boardsize corner sub 1 add dup 3 -1 roll } if } if boardsize 9 ge { corner dup dup boardsize corner sub 1 add dup dup 3 index exch dup } if { dup mark eq { pop exit } if hoshirad 0 360 arc fill } loop } def %set board background /drawbackground { gsave .5 edgewidth sub dup translate boardsize edgewidth 2 mul add dup scale newpath 0 0 moveto 0 1 lineto 1 1 lineto 1 0 lineto boardcolor setgray fill /Helvetica-Bold findfont 1.1 scalefont setfont boardcolor .9 mul setgray % a little darker newpath 0 0 moveto watermark false charpath flattenpath pathbbox % llx lly urx ury 3 -1 roll % llx urx ury lly add 1 exch sub 2 div 3 1 roll % yoffset llx urx add 1 exch sub 2 div exch % xoffset yoffset moveto watermark show grestore } def % draw white stone bodies everywhere /drawwhitestones { 1 setgray newpath 1 1 boardsize { /y exch def 1 1 boardsize { y whiterad 0 360 arc fill } for } for } def % these are redefined inside drawindices /spacehalfheight .03 def /spacehalfwidth .04 def % draw string centered at x,y % in box of size spacewidth,spaceheight also centered at x,y /drawindex { % stack: x y string ==> void gsave 3 1 roll % string x y translate % center at x, y newpath spacehalfwidth neg spacehalfheight neg moveto spacehalfwidth neg spacehalfheight lineto spacehalfwidth spacehalfheight lineto spacehalfwidth spacehalfheight neg lineto 1 setgray fill % blank the box dup % copy the string stringwidth pop 2 div neg % x center spacehalfheight boxborder 2 div sub neg % y center moveto % center the string 0 setgray show grestore } def /drawindices { /Helvetica findfont 8 xspacing div scalefont setfont newpath 0 0 moveto (W) false charpath flattenpath pathbbox % llx lly urx ury 3 -1 roll % llx urx ury lly add boxborder add 2 div /spacehalfheight exch def add boxborder add 2 div /spacehalfwidth exch def /temp 2 string def 1 1 boardsize 50 gt { 50 } { boardsize } ifelse { /inx exch def inx .5 edgewidth 2 div sub % x y (ABCDEFGHJKLMNOPQRSTUVWXYZabcdefghjklmnopqrstuvwxyz) inx 1 sub 1 getinterval % the letter drawindex .5 edgewidth 2 div sub inx % x y inx temp cvs % the integer as a string drawindex } for /Times-Roman findfont 7.5 xspacing div scalefont setfont % 7.5 pts /cspace (.c.) stringwidth pop def boardsize .5 add edgewidth add (2003, Wilfred J. Hansen) stringwidth pop sub .1 moveto gsave (2003, Wilfred J. Hansen) show grestore cspace neg 0 rmoveto gsave /Symbol findfont 7.5 xspacing div scalefont setfont % 7.5 pts (\343) show grestore (Copyright ) stringwidth pop neg 0 rmoveto (Copyright ) show } def /whiteline 0.68 def /blackline 0.40 def /beforeline 0.06 def /beforeword 0.10 def /leftedge 0.50 def /rightedge 0.50 def /printlegend { gsave 72 72 scale 0 setgray /Times-Roman findfont 18 72 div scalefont setfont clubname leftedge blackline .12 add moveto show /col2loc leftedge .3 add clubname stringwidth pop add def /Times-Roman findfont 10 72 div scalefont setfont % 10 pt font /col4loc paperwidth rightedge sub timeblank sub beforeline sub (Time) stringwidth pop sub def /col3loc col4loc beforeword sub dateblank sub beforeline sub (Date) stringwidth pop sub def .004 setlinewidth 0 setgray (Black) col2loc blackline moveto show beforeline 0 rmoveto col3loc beforeword sub blackline lineto (Date) col3loc blackline moveto show beforeline 0 rmoveto col4loc beforeword sub blackline lineto (Time) col4loc blackline moveto show beforeline 0 rmoveto paperwidth rightedge sub blackline lineto (White) col2loc whiteline moveto show beforeline 0 rmoveto col3loc beforeword sub whiteline lineto (Handicap) col3loc whiteline moveto show beforeline 0 rmoveto col4loc beforeword sub whiteline lineto (Komi) col4loc whiteline moveto show beforeline 0 rmoveto paperwidth rightedge sub whiteline lineto 0 1 4 { .2 mul 1.0 add dup % two copies of y leftedge exch moveto paperwidth rightedge sub exch lineto } for stroke grestore } def % !!! execution starts here !!! gsave initboard drawbackground drawwhitestones drawhoshi drawindices grestore printlegend showpage