Postscript::HTML::Map
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, ' ');
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.
Constructs a new Postscript::HTML::Map object. See below for arguments.
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
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.
Performs the actual rendering of the map, and returns an HTML::Element for further coersion or simple printing.
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.
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 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.
Gareth Kirwan <gbjk@thermeon.com>
1 POD Error
The following errors were encountered while parsing the POD:
=back without =over
To install Postscript::HTML::Map, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Postscript::HTML::Map
CPAN shell
perl -MCPAN -e shell install Postscript::HTML::Map
For more information on module installation, please visit the detailed CPAN module installation guide.