NAME
SVG::Rasterize::Cairo
- rasterize output using Cairo
VERSION
Version 0.003006
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
orm
, followed by two numbersZ
L
orl
, followed by two numbersH
orh
, followed by one numberV
orv
, followed by one numberC
orc
, followed by six numbersS
ors
, followed by four numbersQ
orq
, followed by four numbersT
ort
, followed by two numbersA
ora
, 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).
text_width
draw_text
DIAGNOSTICS
Exceptions
Warnings
INTERNALS
Internal Methods
These methods are just documented for myself. You can read on to satisfy your voyeuristic desires, but be aware of that they might change or vanish without notice in a future version.
_prepare_fill
_prepare_stroke
_fill
_stroke
_fill_and_stroke
make_ro_accessor
This piece of documentation is mainly here to make the
POD
coverage test happy.SVG::Rasterize::State
overloadsmake_ro_accessor
to make the readonly accessors throw an exception object (of classSVG::Rasterize::Exception::Attribute
) instead of just croaking.
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.