Perl extension to convert games::go::diagrams to postscript.
use Games::Go::Dg2Ps
my $dg2ps = B<Games::Go::Dg2Ps-E<gt>new> (options); $dg2ps->convertDiagram($diagram);
Games::Go::Dg2Ps converts a Games::Go::Diagram into PostScript.
A new Games::Go::Dg2Ps takes the following options:
Sets the size of the board. Default: 19
Numbers on stones are wrapped back to 1 after they reach 100. Numbers associated with comments and diagram titles are not affected. Default: false
Generates a coordinate grid. Default: false
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. This callback defines a subroutine to convert coordinates from $x, $y to whatever coordinates are used in the Games::Go::Diagram object. The default diaCoords converts 1-based $x, $y to the same coordinates used in \s-1SGF\s0 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(\*(L"$x$y\*(R"); }, # concatenate two letters
A user defined subroutine to replace the default printing method. This callback is called from the print method (below) with the reference to the Dg2TeX object and a list of lines that are part of the TeX diagram source.
May be one of:
Default: 'Letter'
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 and stone fonts names may be one of these (case sensitive):
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
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 doubleDigits is specified, the stones and board are slightly smaller (stone 100 may look a bit cramped). Default: 5
The stone_width and stone_height determine the size of the stones and diagrams. If stone_width is not explicitly set, it is calculated from the stone_fontSize 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 doubleDigits is specified, the stones and board are slightly smaller (stone 100 may look a bit cramped). If stone_height is not explicitly set, it will be 1.05 * stone_width, creating a slightly rectangular diagram. Default: undef - determined from stone_fontSize
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 Change Dg2Ps options from values passed at new time. prints raw PostScript code to file as defined at new time. Adds $text to the diagram comments. Inserts the PostScript comment character ('%') in front of each line of each comment and prints it to file. Note that this is not the same as the printComment method. Converts a Games::Go::Diagram into PostScript. Converts $text into text for display (handles PostScript escape sequences). Returns the converted text. convertProperties takes a reference to a hash of properties as extracted from an \s-1SGF\s0 file. Each hash key is a property \s-1ID\s0 and the hash value is a reference to an array of property values: $hash->{propertyId}->[values]. The following \s-1SGF\s0 properties are recognized:
Both long and short property names are recognized, and all unrecognized properties are ignored with no warnings. Note that these properties are all intended as game-level notations.
prints final PostScript code to the output file and closes the file.
Script to convert \s-1SGF\s0 format files to Go diagrams
Bugs? In my code?
Reid Augustin, <[email protected]>
Copyright (C) 2005 by Reid Augustin
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.