Scroll to navigation

Games::Go::Sgf2Dg::Dg2PDF(3pm) User Contributed Perl Documentation Games::Go::Sgf2Dg::Dg2PDF(3pm)

NAME

Games::Go::Sgf2Dg::Dg2PDF - convert Games::Go::Sgf2Dg::Diagrams to PDF

SYNOPSIS

use Games::Go::Sgf2Dg::Dg2PDF

 my $dg2pdf = B<Games::Go::Sgf2Dg::Dg2PDF-E<gt>new> (options);
 $dg2pdf->convertDiagram($diagram);

DESCRIPTION

A Games::Go::Sgf2Dg::Dg2PDF object converts a Games::Go::Sgf2Dg::Diagram object into a PDF file.

NEW

A new Games::Go::Sgf2Dg::Dg2PDF 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::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.

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:
. a0 - a6
. letter
. broadsheet
. ledger
. tabloid
. legal
. executive
. 36x36

Default: 'letter'

Margins are set in PDF '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):
. Courier
. Courier-Bold
. Courier-BoldOblique
. Courier-Oblique
. Helvetica
. Helvetica-Bold
. Helvetica-BoldOblique
. Helvetica-Oblique
. Times-Roman
. Times-Bold
. Times-Italic
. Times-BoldItalic
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 text inside stones, and may also determine the size of the stones and diagrams (see lineHeight and lineWidth below).

Default: 5

The lineWidth and lineHeight determine the size of the stones and diagrams.

If lineWidth 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 lineHeight is not explicitly set, it will be 1.05 * lineWidth, creating a slightly rectangular diagram.

Default: undef - determined from stone_fontSize

METHODS

$dg2pdf->configure (option => value, ?...?)
Change Dg2PDF options from values passed at new time.
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));
    
$dg2pdf->print ($text ? , ... ?)
prints raw PDF code to file as defined at new time. Whether or not file was defined, print accumulates the PDF code for later retrieval with converted.
$dg2pdf->printComment ($text ? , ... ?)
Adds $text to the diagram comments.
$dg2pdf->comment ($comment ? , ... ?)
Inserts the PDF 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::Sgf2Dg::Diagram into PDF.
Converts $text into text for display.

Returns the converted text.

$title = $dg2pdf->convertGameProps (\%sgfHash)
convertGameProps takes a reference to a hash of properties as extracted from an SGF file. Each hash key is a property ID and the hash value is a reference to an array of property values: $hash->{propertyId}->[values]. The following SGF properties are recognized:
. GN GameName
. EV EVent
. RO ROund
. DT DaTe
. PW PlayerWhite
. WR WhiteRank
. PB PlayerBlack
. BR BlackRank
. PC PlaCe
. KM KoMi
. RU RUles
. TM TiMe
. OT OverTime (byo-yomi)
. RE REsult
. AN ANnotator
. SO Source
. US USer (entered by)
. CP CoPyright
. GC GameComment

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.

$dg2pdf->close
prints some final PDF code to the diagram and closes the pdf object (file).

SEE ALSO

sgf2dg(1)
Script to convert SGF format files to Go diagrams

BUGS

You think I'd admit it?

2019-10-27 perl v5.30.0