chess.ps


NAME

      chess.ps - Some useful chess-handling stuff in PostScript


SYNOPSIS

 (/home/wherever/ps/lib/chess.ps) run
 % to send it to a printer see include_run . . .

 gsave 100 200 translate
 (1rbq1rk1/1pp1ppbp/p1np1np1/8/2PPP3/2N1BP2/PP1QN1PP/R3KB1R w) false fen2board
 5 2 0 true  (X)  Marker
 grestore


DESCRIPTION

This module implements in PostScript a few simple procedures for drawing chess diagrams,

This code is rolled into the fen2img application, written in Lua


PROCEDURES

position_array  flip   Board

This procedure is evolved from the original by Joao Pedro Neto in homepages.di.fc.ul.pt/~jpn/gv/pstools.htm and homepages.di.fc.ul.pt/~jpn/gv/tabs/chess-template.eps

The position_array has 64 elements. When laid out in rows of 8, it looks like the board seen from White's side:

  [ -4 -2 -3 -5 -6  0  0 -4
    -1  0  0  0  0 -1  0  0
     0  0  0  0 -1  0  0 -1
     0 -1  0 -2  1  0  2  5
     0 -3 -1  1  0  0  0  3
     0  0  2  0  0  0  0  0
     0  1  0  0  0  1  1  1  
     4  0  0  0  6  3  0  4 ] false Board
where 0 means the square is empty, the positive numbers are White pieces, and their negatives the Black pieces. 1=pawn, 2=knight, 3=bishop, 4=rook, 5=queen and 6=king.

If the boolean flip is true then the board will be shown rotated 180 degrees, ie: as Black sees it.

fen_str  flip   fen2board

This procedure wraps the above Board procedure to accept the position in FEN syntax, see wikipedia.
Only the first two fields of the FEN string are used.

If the boolean flip is true then the board will be shown rotated 180 degrees, ie: as Black sees it.

row  col  grey_ratio  outline_only  str   Marker

A grey_ratio of 0.0 means black, of 1.0 means white. Often, a grey_ratio of about 0.4 when charpath is false seems visually balanced against a grey_ratio of 0.0 when charpath is true

If the boolean outline_only is true then the character is printed in outline only, giving a much lighter visual impression.

Unlike in Joao Pedro Neto's original, the text is automatically centered in the square, and the font (Helvetica-Bold) is made narrower according to the length of the string, so no separate MarkerSm procedure is necessary. Strings longer than three characters tend not to fit in their squares.


VARIABLES

/Chess.dx   40   def
The size of the square, in point.   The default is 40
/Chess.markersize   0.7   def
The relative size of marker-letters inside the squares.
The default is 0.7, but if you wish, eg: to number a dozen or more 'corresponding' squares in an endgame analysis, then /Chess.markersize 0.4 def may be more appropriate.

INSTALL

To install: go to www.pjb.com.au/comp/free/chess.ps.txt and save the file to your local disc.
Rename it to chess.ps and move it into some appropriate directory such as ~/ps/lib . . .

Or, first change directory to where you keep your PostScript libraries:
    cd /home/wherever/ps/lib/
(or wherever)   and then either:
    wget -O chess.ps http://www.pjb.com.au/comp/free/chess.ps.txt
or:
    curl http://www.pjb.com.au/comp/free/chess.ps.txt -o chess.ps

It also needs a particular TrueType font to be installed:
    homepages.di.fc.ul.pt/~jpn/gv/tabs/chessfont.zip
This unzips to reveal the  CHEQ_TT.TTF  font,
which you can install on linux by moving it into /usr/share/fonts/truetype/


AUTHOR

Peter J Billam   www.pjb.com.au/comp/contact.html


CHANGES

 20180415 first released version

SEE ALSO

    en.wikipedia.org/wiki/Forsyth-Edwards_Notation
    homepages.di.fc.ul.pt/~jpn/gv/pstools.htm
    homepages.di.fc.ul.pt/~jpn/gv/tabs/chessfont.zip
    include_run
    http://www.pjb.com.au/
    the PostScript Language Reference Manual (Adobe).


Back to P J B Computing or to www.pjb.com.au . . .