NAME
GD::SGF - Package to simplify SGF game rendering using GD::Image;
SYNOPSIS
use Games::Go::SGF2misc::GD;
my $image = new Games::Go::SGF2misc::GD('imagesize' => 256,'boardsize' => 19, 'antialias' => 1);
$image->gobanColor(127,127,127);
$image->drawGoban();
$image->placeStone('b','cd');
$image->placeStone('w',[4,2]);
$image->placeStone('b','db');
$image->placeStone('w','dc');
$image->placeStone('b','cc');
$image->placeStone('w','eb');
$image->placeStone('b','cb');
$image->addCircle('cb',1);
$image->save($filename);
DESCRIPTION
Games::Go::SGF2misc::GD is a Perl Wrapper for the GD.pm module. It simplifies the process of rendering an image from an SGF file. It is however still a primitive interface, in that it does not contain any internal intellegence about how to process an SGF file, this is merely designed to be used in conjunction with an SGF reader such as Games::Go::SGF2misc or Games::Go::SGF.
$image = Games::Go::SGF2misc::GD-new(['imagesize' => 64],['boardsize' => 19],['antialias' => 1])>
To create a new image, call the new() function. It's three
arguments are optional, but if specified will override the defaults.
B<imagesize> is the width and height of the image created and
defaults to 64 if not specified. B<boardsize> is the number of
lines horizontally and vertically across the board, with a default
of 19. B<antialias> is a boolean value which controls whether the
resulting image is fed through a slight blur filter to remove
jaggies. B<antialias> defaults to on, but can be overly slow on
very large renders.
$image-gobanColor($red,$green,$blue)> $image-whiteColor($red,$green,$blue)> $image-blackColor($red,$green,$blue)>
These functions set the colors used for rendering the game.
B<$red>, B<$green>, and B<$blue> are integers between 0 and 255;
$image-drawGoban()>
This command does all the initial setup of rendering the Goban. It
sets the background color, and draws lines and star points. If you
don't call this before any of the other drawing functions, you can
expect your output to be a little weird.
$image-placeStone($color,$position)>
This command puts a stone into the image at the position specified.
B<$color> is one of /[BbWw]/ and controls whether a black or white
stone is added. B<$position> is either an array of x,y coordinates
with 0,0 in the upper left corner, or a string of letters
representing coordinates at which the stone should be placed, in
standard SGF format. 'aa' is the upper left corner, and 'ss' is the
lower right (of a 19x19 game).
$image-addCircle($position,[$onStone])> $image-addSquare($position,[$onStone])> $image-addTriangle($position,[$onStone])>
This command adds either a circle, square or triange around the
coordinates specified by B<$position>. Be default GD::SGF renders
the shape in black. If you want to render the shape on top of a
stone, supply a true value for B<$onStone>, to tell the module to
render the shape in an inverse color from what is below it.
$image-addLetter($position,$letter,[$onStone])>
This command renders a letter above the coordinates specified by
B<$position>. The processing performed is very similar to the other
add* functions defined above, with one major difference. If
B<$onStone> does not evaluate to true, then the area under the
letter will also be cleared (to removed the intersection of the two
lines) before rendering.
$image-save($filename)>
Saves the in memory image into the filename specified in
B<$filename>. The module will attempt to guess the format of the
output image based upon the extension of the filename. Supported
file formats are [ PNG, JPEG, GD2, GD ]. If the module is unable to
determine the desired output format, the image will be output as a
PNG.
$png = $image-dump($format)>
Converts the in memory image into an image of the format specified
in B<$format>. If no format is specified the module defaults to
PNG. The image is then returned to the calling function for
storage.
TODO
Remove the need to specify whether the marks are being rendered above a stone or not. Probably by implementing some sort of in memory array of placed
stones, and checking position of the mark against that.
Presently the hoshi points are defined in a massive hash struct. I know the 19x19 hoshi's are correct but similarly I am sure that that rest are wrong, or simply not listed. Check with someone to find the correct hoshi points for oddball goban sizes.
AUTHOR
Orien Vandenbergh orien@icecode.com