VERSION

This document describes version 2.20 of PostScript::File::Functions, released February 11, 2012 as part of PostScript-File version 2.20.

SYNOPSIS

  use PostScript::File;

  my $ps = PostScript::File->new;
  $ps->use_functions(qw( setColor showCenter ));
  $ps->add_to_page("1 setColor\n" .
                   "400 400 (Hello, World!) showCenter\n");

DESCRIPTION

PostScript::File::Functions provides a library of handy PostScript functions that can be used in documents created with PostScript::File. You don't normally use this module directly; PostScript::File's \*(C`use_functions\*(C' method loads it automatically.

POSTSCRIPT FUNCTIONS

boxPath

LEFT TOP RIGHT BOTTOM boxPath

Given the coordinates of the sides of a box, this creates a new, closed path starting at the bottom right corner, across to the bottom left, up to the top left, over to the top right, and then back to the bottom right.

clipBox

LEFT TOP RIGHT BOTTOM clipBox

This clips to the box defined by the coordinates.

drawBox

LEFT TOP RIGHT BOTTOM drawBox

This calls boxPath to and then strokes the path using the current pen.

fillBox

LEFT TOP RIGHT BOTTOM COLOR fillBox

This fills the path created by boxPath with \*(C`COLOR\*(C', which can be anything accepted by setColor.

hLine

WIDTH X Y hline

Stroke a horizontal line with the current pen with the left endpoint at position \*(C`X, Y\*(C', extending \*(C`WIDTH\*(C' points rightwards.

setColor

RGB-ARRAY|BW-NUMBER setColor

This combines \*(C`setgray\*(C' and \*(C`setrgbcolor\*(C' into a single function. You can provide either an array of 3 numbers for \*(C`setrgbcolor\*(C', or a single number for \*(C`setgray\*(C'. The \*(L"str\*(R" in PostScript::File function was designed to format the parameter to this function.

showCenter

X Y STRING showCenter

This prints \*(C`STRING\*(C' centered horizontally at position X using baseline Y and the current font.

showLeft

X Y STRING showLeft

This prints \*(C`STRING\*(C' left justified at position X using baseline Y and the current font.

showLines

X Y LINES SPACING FUNC showLines

This calls \*(C`FUNC\*(C' for each element of \*(C`LINES\*(C', which should be an array of strings. \*(C`FUNC\*(C' is called with \*(C`X Y STRING\*(C' on the stack, and it must pop those off. \*(C`SPACING\*(C' is subtracted from \*(C`Y\*(C' after every line. \*(C`FUNC\*(C' will normally be \*(C`showCenter\*(C', \*(C`showLeft\*(C', or \*(C`showRight\*(C'.

showRight

X Y STRING showRight

This prints \*(C`STRING\*(C' right justified at position X using baseline Y and the current font.

vLine

HEIGHT X Y vline

Stroke a vertical line with the current pen with the bottom endpoint at position \*(C`X, Y\*(C', extending \*(C`HEIGHT\*(C' points upwards.

METHODS

While you don't normally deal with PostScript::File::Functions objects directly, it is possible. The following methods are available:

new

$funcs = PostScript::File::Functions->new;

The constructor takes no parameters.

add

$funcs->add('functionRequested', ...);

Add one or more functions to the procset to be generated. All dependencies of the requsted functions are added automatically. See \*(L"\s-1POSTSCRIPT\s0 \s-1FUNCTIONS\s0\*(R" for the list of available functions.

add_to_file

$funcs->add_to_file($ps, $basename);

This is short for

$ps->add_procset( $funcs->generate_procset($basename) );

$ps should normally be a PostScript::File object. See \*(L"add_procset\*(R" in PostScript::File.

generate_procset

($name, $code, $version) = $funcs->generate_procset($basename);

This collects the requsted functions into a block of PostScript code.

$name is a suitable name for the procset, created by appending the ids of the requsted functions to $basename. If $basename is omitted, it defaults to the class name with \*(C`::\*(C' replaced by \*(C`_\*(C'.

$code is a block of PostScript code that defines the functions. It contains no comments or excess whitespace.

$version is the version number of the procset.

In scalar context, returns $code.

DIAGNOSTICS

You requsted a function that this version of PostScript::File::Functions doesn't provide.

CONFIGURATION AND ENVIRONMENT

PostScript::File::Functions requires no configuration files or environment variables.

INCOMPATIBILITIES

None reported.

BUGS AND LIMITATIONS

No bugs have been reported.

AUTHOR

Christopher J. Madsen \*(C`<perl AT cjmweb.net>\*(C'

Please report any bugs or feature requests to \*(C`<bug-PostScript-File AT rt.cpan.org>\*(C' or through the web interface at http://rt.cpan.org/Public/Bug/Report.html?Queue=PostScript-File <http://rt.cpan.org/Public/Bug/Report.html?Queue=PostScript-File>.

You can follow or contribute to PostScript-File's development at http://github.com/madsen/postscript-file <http://github.com/madsen/postscript-file>.

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Christopher J. Madsen.

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

DISCLAIMER OF WARRANTY

\s-1BECAUSE\s0 \s-1THIS\s0 \s-1SOFTWARE\s0 \s-1IS\s0 \s-1LICENSED\s0 \s-1FREE\s0 \s-1OF\s0 \s-1CHARGE\s0, \s-1THERE\s0 \s-1IS\s0 \s-1NO\s0 \s-1WARRANTY\s0 \s-1FOR\s0 \s-1THE\s0 \s-1SOFTWARE\s0, \s-1TO\s0 \s-1THE\s0 \s-1EXTENT\s0 \s-1PERMITTED\s0 \s-1BY\s0 \s-1APPLICABLE\s0 \s-1LAW\s0. \s-1EXCEPT\s0 \s-1WHEN\s0 \s-1OTHERWISE\s0 \s-1STATED\s0 \s-1IN\s0 \s-1WRITING\s0 \s-1THE\s0 \s-1COPYRIGHT\s0 \s-1HOLDERS\s0 \s-1AND/OR\s0 \s-1OTHER\s0 \s-1PARTIES\s0 \s-1PROVIDE\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \*(L"\s-1AS\s0 \s-1IS\s0\*(R" \s-1WITHOUT\s0 \s-1WARRANTY\s0 \s-1OF\s0 \s-1ANY\s0 \s-1KIND\s0, \s-1EITHER\s0 \s-1EXPRESSED\s0 \s-1OR\s0 \s-1IMPLIED\s0, \s-1INCLUDING\s0, \s-1BUT\s0 \s-1NOT\s0 \s-1LIMITED\s0 \s-1TO\s0, \s-1THE\s0 \s-1IMPLIED\s0 \s-1WARRANTIES\s0 \s-1OF\s0 \s-1MERCHANTABILITY\s0 \s-1AND\s0 \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. \s-1THE\s0 \s-1ENTIRE\s0 \s-1RISK\s0 \s-1AS\s0 \s-1TO\s0 \s-1THE\s0 \s-1QUALITY\s0 \s-1AND\s0 \s-1PERFORMANCE\s0 \s-1OF\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1IS\s0 \s-1WITH\s0 \s-1YOU\s0. \s-1SHOULD\s0 \s-1THE\s0 \s-1SOFTWAR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