NAME

SVG::Rasterize::Cairo - rasterize output using Cairo

VERSION

Version 0.002003

SYNOPSIS

# explicit construction (unusual)
use SVG::Rasterize::Cairo;
my $engine = SVG::Rasterize::Cairo->new(width  => 640,
                                        height => 480);

DESCRIPTION

This class provides a rasterization backend for SVG::Rasterize based on the Cairo library. At the same time, it defines the interface that alternative backends have to provide.

This class is only instantiated by the rasterize method of SVG::Rasterize.

INTERFACE

Constructors

new

SVG::Rasterize::Cairo->new(%args)

Creates a new SVG::Rasterize::Cairo object and calls init(%args). If you subclass SVG::Rasterize::Cairo overload init, not new.

init

$cairo->init(%args)

If you overload init, your method should also call this one. It initializes the attributes width and height which are mandatory parameters and have to be non-negative integers.

Other backends are also required to validate their init parameters because the engine_args hash given by the user to SVG::Rasterize is handed over to the new constructor of the engine class without validation.

Public Attributes

These are the attributes which alternative rasterization engines have to implement.

width

Can only be set and construction time. Saves the width of the output image.

height

Can only be set and construction time. Saves the height of the output image.

Methods for Developers

These are the methods which alternative rasterization engines have to implement.

draw_path

Expects a SVG::Rasterize::State object and a list of instructions.None of the parameters are validated, it is expected that this has happened before. Each instruction must be an ARRAY reference with one of the following sets of entries (the first entry is always a letter, the rest are numbers):

  • M or m, followed by two numbers

  • Z

  • L or l, followed by two numbers

  • H or h, followed by one number

  • V or v, followed by one number

  • C or c, followed by six numbers

  • S or s, followed by four numbers

  • Q or q, followed by four numbers

  • T or t, followed by two numbers

  • A or a, followed by seven numbers

write

$engine->write(%args)

Writes the rendered image to a file.

Example:

$engine->write(type => 'png', file_name => 'foo.png');

type and file_name are the only supported parameters at the moment and the only supported type is "png". If file_name has a false value, no output is written and a warning is issued. Besides that file_name is not validated at all. Make sure that you provide a sane value (whatever that means to you).

DIAGNOSTICS

Exceptions

Warnings

BUGS AND LIMITATIONS

No bugs have been reported. Please report any bugs or feature requests to bug-svg-rasterize at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SVG-Rasterize. I will be notified, and then you will automatically be notified of progress on your bug as I make changes.

AUTHOR

Lutz Gehlen, <perl at lutzgehlen.de>

LICENSE AND COPYRIGHT

Copyright 2010 Lutz Gehlen.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.