Paul Miller > Games-Go-SGF2misc > GD::SGF


Annotate this POD


Open  1
View/Report Bugs
Source   Latest Release: Games-Go-SGF2misc-0.9782


GD::SGF - Package to simplify SGF game rendering using GD::Image;


    use Games::Go::SGF2misc::GD;

    my $image = new Games::Go::SGF2misc::GD('imagesize' => 256,
                                            'boardsize' => 19, 
                                            'antialias' => 1    );





Games::Go::SGF2misc::GD is a Perl Wrapper for the 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.

imagesize is the width and height of the image created and defaults to 64 if not specified. boardsize is the number of lines horizontally and vertically across the board, with a default of 19. antialias is a boolean value which controls whether the resulting image is fed through a slight blur filter to remove jaggies. antialias defaults to on, but can be overly slow on very large renders.


These functions set the colors used for rendering the game. $red, $green, and $blue are integers between 0 and 255;


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.


This command puts a stone into the image at the position specified. $color is one of /[BbWw]/ and controls whether a black or white stone is added. $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).


This command adds either a circle, square or triange around the coordinates specified by $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 $onStone, to tell the module to render the shape in an inverse color from what is below it.


This command renders a letter above the coordinates specified by $position. The processing performed is very similar to the other add* functions defined above, with one major difference. If $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.


Saves the in memory image into the filename specified in $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 $format. If no format is specified the module defaults to PNG. The image is then returned to the calling function for storage.


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.


Orien Vandenbergh <>


Games::Go::SGF2misc, GD, GD::Image

syntax highlighting: