Polytext

Table of Contents

NAME
Synopsis
Description
Distributions
Constructor and initialization
Method: annotate()
Method: draw({options})
Method: highlight_data_points({options})
Example code
Required Modules
Changes
Author
Copyright

Polytext

NAME

Image::Magick::PolyText - Draw text along a polyline

Synopsis

	my $polytext = Image::Magick::PolyText -> new
	({
	debug        => 0,
	fill         => 'Red',
	image        => $image,
	pointsize    => 16,
	rotate       => 1,
	slide        => 0.1,
	stroke       => 'Red',
	strokewidth  => 1,
	text         => 'Draw text along a polyline',
	x            => [0, 1, 2, 3, 4],
	'y'          => [0, 1, 2, 3, 4], # y eq tr so emacs' syntax highlighting is stuffed without ''.
	});
	$polytext -> annotate();

Description

Image::Magick::PolyText is a pure Perl module.

It is a convenient wrapper around Image::Magick's Annotate() method, for drawing text along a polyline.

Distributions

This module is available both as a Unix-style distro (*.tgz) and an ActiveState-style distro (*.ppd). The latter is shipped in a *.zip file.

See http://savage.net.au/Perl-modules.html for details.

See http://savage.net.au/Perl-modules/html/installing-a-module.html for help on unpacking and installing each type of distro.

Constructor and initialization

new(...) returns an Image::Magick::PolyText object.

This is the class's contructor.

Usage: Image::Magick::PolyText -> new({...}).

This method takes a hashref of parameters.

For each parameter you wish to use, call new as new({param_1 => value_1, ...}).

  • debug

    Takes either 0 or 1 as its value.

    The default value is 0.

    When set to 1, the module writes to STDOUT, and plots various stuff on your image.

    This parameter is optional.

  • fill

    Takes an Image::Magick color as its value.

    The default value is 'Red'.

    The value is passed to Image::Magick's Annotate() method.

    This parameter is optional.

  • image

    Takes an Image::Magick object as its value.

    There is no default value.

    This parameter is mandatory.

  • pointsize

    Takes an integer as its value.

    The default value is 16.

    The value is passed to Image::Magick's Annotate() method.

    This parameter is optional.

  • rotate

    Takes either 0 or 1 as its value.

    The default value is 1.

    When set to 0, the module does not rotate any characters in the text.

    When set to 1, the module rotates each character in the text to match the tangent of the polyline at the 'current' (x, y) position.

    This parameter is optional.

  • slide

    Takes a real number in the range 0.0 to 1.0 as its value.

    The default value is 0.0.

    The value represents how far along the polyline (0.0 = 0%, 1.0 = 100%) to slide the first character of the text.

    The parameter is optional.

  • stroke

    Takes an Image::Magick color as its value.

    The default value is 'Red'.

    The value is passed to Image::Magick's Annotate() method.

    This parameter is optional.

  • strokewidth

    Takes an integer as its value.

    The default value is 1.

    The value is passed to Image::Magick's Annotate() method.

    This parameter is optional.

  • text

    Takes a string of characters as its value.

    There is no default value.

    This text is split character by character, and each character is drawn with a separate call to Image::Magick's Annotate() method. This is a very slow process. You have been warned.

    This parameter is mandatory.

  • x

    Takes an array ref of x (co-ordinate) values as its value.

    There is no default value.

    These co-ordinates are the x-axis values of the known points along the polyline.

    This parameter is mandatory.

  • y

    Takes an array ref of y (abcissa) values as its value.

    There is no default value.

    These abcissae are the y-axis values of the known points along the polyline.

    This parameter is mandatory.

Method: annotate()

This method writes the text on to your image.

Method: draw({options})

This method draws straight lines from data point to data point.

The default line color is Green.

The options are a hash ref which is passed to Image::Magick's Draw() method, so any option acceptable to Draw() is acceptable here.

A typical usage would be $polytext -> draw({stroke => 'Blue'});

Method: highlight_data_points({options})

This method draws little (5x5 pixel) rectangles centered on the data points.

The default rectangle color is Red.

The options are a hash ref which is passed to Image::Magick's Draw() method, so any option acceptable to Draw() is acceptable here.

A typical usage would be $polytext -> highlight_data_points({stroke => 'Black'});

Example code

See the file examples/pt.pl in the distro.

Required Modules

  • Class::Std
  • Math::Bezier
  • Math::Interpolate
  • Readonly

Changes

See the ChangeLog file.

Author

Image::Magick::PolyText was written by Ron Savage <ron@savage.net.au> in 2007.

Home page: http://savage.net.au/index.html

Copyright

Australian copyright © 2007, Ron Savage. All rights reserved.

	All Programs of mine are 'OSI Certified Open Source Software';
	you can redistribute them and/or modify them under the terms of
	The Artistic License, a copy of which is available at:
	http://www.opensource.org/licenses/index.html
 
Top of page