Provided by: sgf2dg_4.252-1_amd64
NAME
Games::Go::Sgf2Dg::Dg2ASCII - convert Games::Go::Sgf2Dg::Diagrams to ASCII diagrams
SYNOPSIS
use Games::Go::Sgf2Dg::Dg2ASCII my $dg2ascii = B<Games::Go::Sgf2Dg::Dg2ASCII-E<gt>new> (options); my $ascii = $dg2ascii->convertDiagram($diagram);
DESCRIPTION
A Games::Go::Sgf2Dg::Dg2ASCII object converts a Games::Go::Sgf2Dg::Diagram object into ASCII diagrams.
NEW
my $dg2ascii = Games::Go::Sgf2Dg::Dg2ASCII->new (?options?) A new Games::Go::Sgf2Dg::Dg2ASCII 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 Games::Go::Sgf2Dg::Diagram coordinates } This callback defines a subroutine to convert coordinates from $x, $y to whatever coordinates are used in the Games::Go::Sgf2Dg::Diagram object. The default diaCoords converts 1-based $x, $y to 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 letters See also the diaCoords method below. file => 'filename' | $descriptor | \$string | \@array If file is defined, the ASCII diagram is dumped into the target. The target can be any of: filename The filename will be opened using IO::File->new. The filename should include the '>' or '>>' operator as described in 'perldoc IO::File'. The ASCII diagram is written into the file. descriptor A file descriptor as returned by IO::File->new, or a \*FILE descriptor. The ASCII diagram is written into the file. reference to a string scalar The ASCII diagram is concatenated to the end of the string. reference to an array The ASCII diagram is split on "\n" and each line is pushed onto the array. Default: undef print => sub { my ($dg2ascii, @lines) = @_; ... } A user defined subroutine to replace the default printing method. This callback is called from the print method (below) with the reference to the Dg2ASCII object and a list of lines that are part of the ASCII diagram lines.
METHODS
$dg2tex->configure (option => value, ?...?) Change Dg2TeX options from values passed at new time. my $coord = $dg2mp->diaCoords ($x, $y) Provides access to the diaCoords option (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)); $dg2ascii->print ($text ? , ... ?) prints the input $text directly to file as defined at new time. Whether or not file was defined, print accumulates the $text for later retrieval with converted. my $ascii = $dg2ascii->converted ($replacement) Returns the entire ASCII diagram converted so far for the Dg2ASCII object. If $replacement is defined, the accumulated ASCII is replaced by $replacement. $dg2ascii->comment ($comment ? , ... ?) Inserts the comment character (which is nothing for ASCII) in front of each line of each comment and prints it to file. my $dg2ascii->convertDiagram ($diagram) Converts a Games::Go::Sgf2Dg::Diagram into ASCII. If file was defined in the new method, the ASCII is dumped into the file. In any case, the ASCII is returned as a string scalar. Labels are restricted to one character (any characters after the first are discarded). my $ascii = $dg2ascii->convertText ($text) Converts $text into ASCII code - gee, that's not very hard. In fact, this method simply returns whatever is passed to it. This is really just a place-holder for more complicated converters. Returns the converted text. $dg2ascii->close prints any final text to the diagram (currently none) and closes the dg2ascii object. Also closes file if appropriate.
SEE ALSO
sgf2dg(1) Script to convert SGF format files to Go diagrams
BUGS
Seems unlikely.