The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Postscript::HTML::Map

SYNOPSIS

 use Postscript::HTML::Map;

 my $ps2map = Postscript::HTML::Map->new({
     postscript     => "car.ps",
     html_handler   => sub {
         my ($self, $element) = @_;

         $element->attr(href => 'javascript:alert("'.$self->comment.'");');

         return;
         },
     });

 my $map = $ps2map->render();
 $map->attr(name => 'car');

 print $map->as_HTML(undef, '    ');

DESCRIPTION

Postscript::HTML::Map takes a Postscript definition of an image and turns it into an HTML map, with areas for each closed path. This module was created for a very specific task: Taking a simply defined postscript image and turning it into a set of areas. The b<LIMITATIONS> are well defined. Patches welcome for any of the large number of things it doesn't handle. Nethertheless, perhaps it will be useful to someone else.

For each closed shape found in the postscript, a new area map is created as an b<HTML::Element>. $ps2map->html_handler, if specified, is called to transform the area as required, presumably using past comments (see b<comment>).

This is expected to be used in conjunction with a gif generated from the postscript, without margins or cropping.

METHODS

new(html_handler => \&handler, postscript => 'some_file.ps')

Constructs a new Postscript::HTML::Map object. See below for arguments.

postscript('some_file.ps')

Sets the file from which to read the postscript to be interpretted. The file should contain a line to state the boundries of the image map required. % BoundingBox: 0 0 450 300

html_handler(\&sub_reference)

Called after each area is added, and passed the ps2map object and the HTML::Element for the new area.

Should modify the HTML::Element as required, probably using b<comment>.

The return is igorned.

render()

Performs the actual rendering of the map, and returns an HTML::Element for further coersion or simple printing.

comment($comment)

Returns the last comment from a stack of comments seen. This is for when a section has a comment at the top outlining the geometry below, which is intended to be used for the href for that area.

LIMITATIONS

The postscript operators understood are limited (stroke, arc, newpath, moveto, lineto, curveto, closepath). It will not understand predefined abbreviations. It only handles closed shapes. Anything it

COPYRIGHT

Copyright 2008 Thermeon Europe.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

AUTHOR

Gareth Kirwan <gbjk@thermeon.com>

1 POD Error

The following errors were encountered while parsing the POD:

Around line 372:

=back without =over