Games::Go::Sgf2Dg::Dg2Ps3pm
Convert games::go::sgf2dg::diagrams to postscript
Usage
use Games::Go::Sgf2Dg::Dg2Ps
my $dg2ps = B<Games::Go::Sgf2Dg::Dg2Ps-E<gt>new> (options);$dg2ps->convertDiagram($diagram);
Overview
Games::Go::Sgf2Dg::Dg2Ps converts a Games::Go::Sgf2Dg::Diagram into PostScript.
New
- my $dg2ps =
Games::Go::Sgf2Dg::Dg2Ps->new(?options?)
A new Games::Go::Sgf2Dg::Dg2Ps takes the following options:
boardSizeX=> number
boardSizeY=> number-
Sets the size of the board.
Default: 19
doubleDigits=> true | false-
Numbers on stones are wrapped back to 1 after they reach 100. Numbers associated with comments and diagram titles are not affected.
Default: false
coords=> true | false-
Generates a coordinate grid.
Default: false
topLine=> number (Default: 1)
bottomLine=> number (Default: 19)
leftLine=> number (Default: 1)
rightLine=> number (Default: 19)-
The edges of the board that should be displayed. Any portion of the board that extends beyond these numbers is not included in the output.
diaCoords=> sub { # convert $x, $y to Diagram coordinates }-
This callback defines a subroutine to convert coordinates from
$x,$yto whatever coordinates are used in the Games::Go::Sgf2Dg::Diagram object. The defaultdiaCoordsconverts 1-based$x,$yto the same coordinates used in SGF format files. You only need to define this if you're using a different coordinate system in the Diagram.Default:
sub { my ($x,$y) =@_;
$x= chr($x - 1 + ord('a')); # convert 1 to 'a', etc
$y= chr($y - 1 + ord('a'));
return("$x$y"); }, # concatenate two lettersSee also the
diaCoordsmethod below.
print=> sub { my ($dg2tex, @tex) = @_; ... }-
A user defined subroutine to replace the default printing method. This callback is called from the
printmethod (below) with the reference to theDg2TeXobject and a list of lines that are part of the TeX diagram source.
Dg2Ps-specific options:
pageSize=> 'page size'-
May be one of:
- . 'A0' - 'A9'
- . 'B0' - 'B10'
- . 'Executive'
- . 'Folio'
- . 'Half-Letter'
- . 'Letter'
- . 'US-Letter'
- . 'Legal'
- . 'US-Legal'
- . 'Tabloid'
- . 'SuperB'
- . 'Ledger'
- . 'Comm #10 Envelope'
- . 'Envelope-Monarch'
- . 'Envelope-DL'
- . 'Envelope-C5'
- . 'EuroPostcard'
Default: 'Letter'
topMargin=> points
bottomMargin=> points
leftMargin=> points
rightMargin=> points-
Margins are set in PostScript 'user space units' which are approximately equivilent to points (1/72 of an inch).
Default for all margins: 72 * .70 (7/10s of an inch)
text_fontName=> 'font' Default: 'Times-Roman',
stone_fontName=> 'font' Default: 'Courier-Bold'-
Text and stone fonts names may be one of these (case sensitive):
- Courier
- Courier-Bold
- Courier-BoldOblique
- Courier-Oblique
- Helvetica
- Helvetica-Bold
- Helvetica-BoldOblique
- Helvetica-Oblique
- Times-Roman
- Times-Bold
- Times-Italic
- Times-BoldItalic
text_fontSize=> points-
The point size for the comment text. Diagram titles use this size plus 4, and the game title uses this size plus 6.
Default: 11
stone_fontSize=> points-
The stone_fontSize determines the size of the stones and diagrams. Stone size is chosen to allow up to three digits on a stone . The default stone_fontSize allows for three diagrams (with -coords) per 'letter' page if comments don't take up extra space below diagrams.
If
doubleDigitsis specified, the stones and board are slightly smaller (stone 100 may look a bit cramped).Default: 5
lineWidth=> points
lineHeight=> points-
The
lineWidthandlineHeightdetermine the size of the stones and diagrams.If
lineWidthis not explicitly set, it is calculated from thestone_fontSizeto allow up to three digits on a stone . The defaultstone_fontSizeallows for three diagrams (with -coords) per 'letter' page if comments don't take up extra space below diagrams. IfdoubleDigitsis specified, the stones and board are slightly smaller (stone 100 may look a bit cramped).If
lineHeightis not explicitly set, it will be 1.05 *lineWidth, creating a slightly rectangular diagram.Default: undef - determined from
stone_fontSize
ps_debug=#<gt> number from 0 to 2-
When non-zero, code and subroutines are added to the PostScript output to help debug the PostScript file. This is very slightly documented in PostScript::File, but you'll probably need to read through the PostScript output to make any use of it.
Default: 0
Methods
- $dg2ps->
configure(option => value, ?...?) -
Change Dg2Ps options from values passed at
newtime.
- my $coord = $dg2mp->
diaCoords($x, $y) -
Provides access to the
diaCoordsoption (see above). Returns coordinates in the converter's coordinate system for board coordinates ($x,$y). For example, to get a specific intersection structure:my $int = $diagram->get($dg2mp->diaCoords(3, 4));
- $dg2ps->
print($text ? , ... ?) -
prints raw PostScript code tofileas defined atnewtime.
- $dg2ps->
printComment($text ? , ... ?) -
Adds
$textto the diagram comments.
- $dg2ps->
comment($comment ? , ... ?) -
Inserts the PostScript comment character ('%') in front of each line of each comment and
prints it tofile.Note that this is not the same as the
printCommentmethod.
- my $canvas = $dg2ps->
convertDiagram($diagram) -
Converts a Games::Go::Sgf2Dg::Diagram into PostScript.
- my $converted_text = $dg2ps->
convertText($text) -
Converts
$textinto text for display (handles PostScript escape sequences).Returns the converted text.
- $dg2ps->
close -
prints final PostScript code to the output file and closes the file.
Releases
Unchanged in 3 releases since Debian 11 (Bullseye).