[comp.lang.postscript] Postscript board drawing routine?

cosell@bbn.com (Bernie Cosell) (03/17/88)

Does anyone have PostScript code for drawing a GO board (pushing my luck:
including, if possible, code to draw stones with numbers superimposed in the
usual way)?  Thanks!
   __
  /  )                              Bernie Cosell
 /--<  _  __  __   o _              BBN Labs, Cambridge, MA 02238
/___/_(<_/ (_/) )_(_(<_             cosell@bbn.com

ron@topaz.rutgers.edu (Ron Natalie) (03/18/88)

Do you have NeWS?  The demonstration program in the tutorial is
a thing that draws a go board and adds stones to it.  The machine
readable code is included in the release.

-Ron

rainero@rocksanne.UUCP (Emil Rainero) (03/19/88)

In article <22210@bbn.COM> cosell@bbn.com (Bernie Cosell) writes:
>Does anyone have PostScript code for drawing a GO board (pushing my luck:
>including, if possible, code to draw stones with numbers superimposed in the
>usual way)?  Thanks!
>   __
>  /  )                              Bernie Cosell
> /--<  _  __  __   o _              BBN Labs, Cambridge, MA 02238
>/___/_(<_/ (_/) )_(_(<_             cosell@bbn.com

There was a problem with the NeWS go program.  They forgot to set the line 
width correctly (it was pretty ugly on the LW).  This greatly modified go
drawing program should work nicely. Enjoy.


%!PSAdobe-1.0
%%Creator: Emil Rainero, Webster Research Center, Xerox Corporation
%%Title: go board

/gridsize 39 def		% how big a grid for the board

% translate the appropriate amount
clippath pathbbox pop pop translate

% set the scale
clippath pathbbox gridsize div exch gridsize div exch 
/yscale exch def /xscale exch def clear
xscale xscale scale 

% mustn't forget to set the line width
1 xscale div setlinewidth

% set the font
/Helvetica findfont 0.4 scalefont setfont


-.4 -.4 translate

% clear the clipping region to white
1 setgray clippath fill 0 setgray

% fill the contents of the go board with a color
1 1 moveto 1 gridsize lineto gridsize gridsize lineto gridsize 1 lineto
closepath 
.745 .478 .314 setrgbcolor %Brown (looks like wood, get it?)
fill 

/drawgrid {
	0 setgray
	1 1 gridsize { 
		dup 1 moveto dup gridsize lineto
		dup 1 exch moveto gridsize
		exch lineto 
	} for
	stroke
} bind def

/centershow 
{
	dup stringwidth -2.0 div exch -2.0 div exch pop -.1 rmoveto 
	show
} bind def

/black { 
	moveto 
	gsave
		currentpoint
		newpath
		.5 0 360 arc 0 setgray fill 
	grestore 
	1 setgray (     ) cvs 
	centershow
} bind def

/white { 
	moveto 
	gsave
		currentpoint
		newpath
		.5 0 360 arc gsave 1 setgray fill grestore 0 setgray stroke 
	grestore
	0 setgray  (     ) cvs
	centershow

} bind def


% draw the grid
drawgrid

% draw the stones
1 1 1 white
2 3 3 black
10 5 1 black
100 5 2 white
1000 5 3 white

% all done
showpage

-- 
Emil Rainero -- Xerox Webster Research Center
UUCP:           {seismo,allegra,decvax,cmcl2,topaz}!rochester!rocksanne!rainero
Arpa Internet:   Rainero.wbst@xerox.arpa