NAME

PDF::Cairo::Util - utility functions

SYNOPSIS

use PDF::Cairo::Util;

$points = cm(5);
$points = in(8.5);
$points = mm(300);
($width, $height) = paper_size('usletter');
$hex = regular_polygon(6);

DESCRIPTION

FUNCTIONS

cm $centimeters

Converts the arguments from centimeters to points. Importable.

in $inches

Converts the arguments from inches to points. Importable.

mm $millimeters

Converts the arguments from millimeters to points. Importable.

paper_size %options
paper => $paper_size
wide|landscape => 1
tall|portrait => 1

Return size in points of a paper type. The default is "US Letter" (8.5x11 inches). The wide/tall options can be used to ensure that the orientation of the page is as expected. Importable.

The supported paper sizes are listed in PDF::Cairo::Papers.

regular_polygon $sides

Calculate the vertices of a regular polygon with $sides sides with radius 1, along with the relative lengths of the inradius and edge.

Returns a hashref:

{
  points => [ [$x0, $y0], ... ],
  edge => $edge_length,
  inradius => $inradius_length,
  radius => 1,
}

Calling the polygon($cx, $cy, $radius, $sides) method is equivalent to:

$poly = regular_polygon($sides);
@points = map(@$_, @{$poly->{points}});
$pdf->save;
$pdf->translate($cx, $cy);
$pdf->scale($radius);
$pdf->poly(@points);
$pdf->close;
$pdf->restore;

BUGS

Gosh, none I hope.

AUTHOR

J Greely, <jgreely at cpan.org>