View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Orien Vandenbergh > Games-Go-SGF2misc-SVG-1.00 > Games::Go::SGF2misc::SVG



Annotate this POD

View/Report Bugs
Module Version: 1.00   Source  


Games::Go::SGF2misc::SVG - Package to simplify SGF game rendering using Image::LibrSVG


    use Games::Go::SGF2misc::SVG;

    my $image = new Games::Go::SGF2misc::SVG('imagesize' => '3in',
                                             'boardsize' => 19, 
                                             'gobanColor'=> 'white' );



    $image->save($filename);    # As a .svg
    $image->export($filename);  # As a .png


This module provides and SVG rendering backend for Games::Go::SVG2misc and other SGF parsers.


Games::Go::SGF2misc::SVG 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::SVG-new(['imagesize' => 1in],['boardsize' => 19],['gobanColor' => 'white'])>

    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 2in if not specified.  B<boardsize> is the number of
    lines horizontally and vertically across the board, with a default
    of 19.  
    B<gobanColor>, b<whiteColor> and b<blackColor> are either an array of 
    integers between 0 and 255, and SVG color keyword name, or an SVG
    hextriplet in the form #FFFFFF, much like html.


    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.
    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)> $image-addSquare($position)> $image-addTriangle($position)>

    This command adds either a circle, square or triange around the
    coordinates specified by B<$position>.


    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.


    Saves the in memory image into the filename specified in
    B<$filename>.  The image will be saved as an uncompressed SVG file.


    Exports the in memory image into the filename specified in
    B<$filename> as an image in PNG format.

$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
    SVG.  The image is then returned to the calling function for
    storage.  The possible formats are 'SVG', and 'PNG'.

    ** dump as PNG Not currently supported **
    This function will be supported once it is supported by Image::LibRSVG
    which is, in turn, waiting for necessary support from gdk-pixbuf.


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, Image::LibRSVG, XML::LibXML

syntax highlighting: