[comp.lang.postscript] Shogi Set in PostScript

jansteen@cwi.nl (Jan van der Steen) (11/01/90)

The following PostScriptfile contains the definitions of
a Western style shogi (Japanese chess) set.
Print it twice for a complete shogi set.

	Jan van der Steen

-=-=-=-=-=-=-=-=-=-=-=-=-= cut, cut, cut... =-=-=-=-=-=-=-=-=-=-=-=-=-
%!
%%Title: Shogi Game Pieces Toolkit (Western style)
%%Creator: Jan van der Steen
%%Date: Thu Nov  1 10:49:24 MET 1990
%%Documentfonts: Times-Roman
%%Pages: 1

%%StartPrologue

/tombstone {
    %
    % The piece border
    %
    .5 setlinewidth
    newpath
	  0  0  moveto
	 30  0 rlineto
	 -5 25 rlineto
	-10  5 rlineto
	-10 -5 rlineto
    closepath
    stroke
    .2 setlinewidth
} def

/normal {
    /Times-Roman findfont 8 scalefont setfont
    15 19.5 moveto dup stringwidth pop 2 div neg 0 rmoveto show
} def

/promoted {
    15 22 5 0 360 arc stroke
    /Times-Roman findfont 8 scalefont setfont
    15 19.5 moveto dup stringwidth pop 2 div neg 0 rmoveto show
} def

/arrow {
    newpath
	 0  0   moveto
	 0  6  rlineto
	-1 -2  rlineto
	 2  0  rlineto
	-1  2  rlineto
    gsave
	fill
    grestore
    stroke
} def

%
% King, Gold, Silver, Pawn, (Horse) and (Dragon) movements
%
/up { gsave 15 10 translate 0 0 moveto  0  5 lineto stroke grestore } def
/dn { gsave 15 10 translate 0 0 moveto  0 -5 lineto stroke grestore } def
/lt { gsave 15 10 translate 0 0 moveto -5  0 lineto stroke grestore } def
/rt { gsave 15 10 translate 0 0 moveto  5  0 lineto stroke grestore } def
/ul { gsave 15 10 translate 0 0 moveto -5  5 lineto stroke grestore } def
/ur { gsave 15 10 translate 0 0 moveto  5  5 lineto stroke grestore } def
/ll { gsave 15 10 translate 0 0 moveto -5 -5 lineto stroke grestore } def
/lr { gsave 15 10 translate 0 0 moveto  5 -5 lineto stroke grestore } def

%
% Night movements
%
/nl {
    newpath
	 15   10     moveto
	  0    3.75 rlineto
	 -3.75 3.75 rlineto
    stroke
} def

/nr {
    newpath
	15   10     moveto
	 0    3.75 rlineto
	 3.75 3.75 rlineto
    stroke
} def

%
% Rook, (Dragon) and Lance movements
%
/aup	{ gsave 15 10 translate   0 rotate arrow grestore } def
/adn	{ gsave 15 10 translate 180 rotate arrow grestore } def
/alt	{ gsave 15 10 translate 270 rotate arrow grestore } def
/art	{ gsave 15 10 translate  90 rotate arrow grestore } def

%
% Bishop and (Horse) movements
%
/aul	{ gsave 15 10 translate   45 rotate arrow grestore } def
/aur	{ gsave 15 10 translate  -45 rotate arrow grestore } def
/all	{ gsave 15 10 translate  135 rotate arrow grestore } def
/alr	{ gsave 15 10 translate -135 rotate arrow grestore } def

/king	{ 
    gsave
	kingsize dup scale
	tombstone
	(K) normal
	up dn lt rt ul ur ll lr
    grestore
    gsave
	140 0 translate
	kingsize dup scale
	tombstone
    grestore
} def

/rook	{
    gsave
	rooksize dup scale
	tombstone
	(R) normal
	aup adn alt art
    grestore
    gsave
	140 0 translate
	rooksize dup scale
	tombstone
	(R) promoted
	aup adn alt art ul ur ll lr
    grestore
} def

/bishop	{
    gsave
	bishopsize dup scale
	tombstone
	(B) normal
	aul aur all alr
    grestore
    gsave
	140 0 translate
	bishopsize dup scale
	tombstone
	(B) promoted
	aul aur all alr up dn lt rt
    grestore
} def

/gold	{
    gsave
	goldsize dup scale
	tombstone
	(G) normal
	ul up ur lt rt dn
    grestore
    gsave
	140 0 translate
	goldsize dup scale
	tombstone
    grestore
} def

/silver	{
    gsave
	silversize dup scale
	tombstone
	(S) normal
	ul up ur ll lr
    grestore
    gsave
	140 0 translate
	silversize dup scale
	tombstone
	(S) promoted
	ul up ur lt rt dn
    grestore
} def

/knight	{
    gsave
	knightsize dup scale
	tombstone
	(N) normal 
	0 -5 translate
	nl nr
    grestore
    gsave
	140 0 translate
	knightsize dup scale
	tombstone
	(N) promoted 
	ul up ur lt rt dn
    grestore
} def

/lance	{
    gsave
	lancesize dup scale
	tombstone
	(L) normal
	0 -5 translate
	aup
    grestore
    gsave
	140 0 translate
	lancesize dup scale
	tombstone
	(L) promoted
	ul up ur lt rt dn
    grestore
} def

/pawn	{
    gsave
	pawnsize dup scale
	tombstone
	(P) normal
	0 -5 translate
	up
    grestore
    gsave
	140 0 translate
	pawnsize dup scale
	tombstone
	(P) promoted
	ul up ur lt rt dn
    grestore
} def

%%EndPrologue

%
% Sizes of the pieces
%
/kingsize   1.0  def
/rooksize   0.95 def
/bishopsize 0.95 def
/goldsize   0.9  def
/silversize 0.9  def
/knightsize 0.8  def
/lancesize  0.8  def
/pawnsize   0.75 def

%
% Print the pieces
%
72 25.4 div dup scale		% change to mm axes
0 280 translate -90 rotate	% landscape mode

% first row
    gsave  0 20 add 150 translate bishop grestore
    gsave 35 20 add 150 translate king   grestore
    gsave 70 20 add 150 translate rook   grestore
% second row
    gsave 28 0 mul 15 add 120 translate pawn   grestore
    gsave 28 1 mul 15 add 120 translate pawn   grestore
    gsave 28 2 mul 15 add 120 translate pawn   grestore
    gsave 28 3 mul 15 add 120 translate pawn   grestore
% third row
    gsave 30 0 mul 10 add  90 translate knight grestore
    gsave 30 1 mul 10 add  90 translate knight grestore
    gsave 30 2 mul 10 add  90 translate lance  grestore
    gsave 30 3 mul 10 add  90 translate lance  grestore
% fourth row
    gsave 32 0 mul  5 add  60 translate gold   grestore
    gsave 32 1 mul  5 add  60 translate gold   grestore
    gsave 32 2 mul  5 add  60 translate silver grestore
    gsave 32 3 mul  5 add  60 translate silver grestore
% fifth row
    gsave 28 0 mul  0 add  30 translate pawn   grestore
    gsave 28 1 mul  0 add  30 translate pawn   grestore
    gsave 28 2 mul  0 add  30 translate pawn   grestore
    gsave 28 3 mul  0 add  30 translate pawn   grestore
    gsave 28 4 mul  0 add  30 translate pawn   grestore

showpage
--
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
     Jan van der Steen                 jansteen@cwi.nl
     Centre for Mathematics and Computer Science (CWI)
     Kruislaan 413, 1098 SJ Amsterdam, The Netherlands