Lutz Gehlen > SVG-Rasterize > SVG::Rasterize::Engine

Download:
SVG-Rasterize-0.003008.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.003008   Source  

NAME ^

SVG::Rasterize::Engine - rasterization engine base class

VERSION ^

Version 0.003008

SYNOPSIS ^

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

DESCRIPTION ^

This class defines the interface for rasterization backends. It does not do any rasterization itself. Implementations of rasterization backends should subclass this class.

Warning: Please be aware of that this interface has to be considered rather unstable at this state of the development.

This class is only instantiated by the rasterize method of SVG::Rasterize via one of its subclasses.

INTERFACE ^

Constructors

new

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

Creates a new SVG::Rasterize::Engine object and calls init(%args). If you subclass SVG::Rasterize::Engine 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.

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 following attributes are provided by this class.

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

Mandatory Methods

The following methods have to be overloaded by subclasses.

draw_path

Expects a SVG::Rasterize::State object and a list of instructions. None of the parameters must be 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):

draw_text

Expects the following parameters:

None of these parameters must be validated. It is assumed that this has been done before.

write

  $engine->write(%args)

Writes the rendered image to a file.

Example:

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

type and file_name must be accepted (but can be ignored, of course). If file_name has a false value, no output is written and a warning may be issued. Besides that, file_name must not validated at all. The user must provide a sane value (whatever that means to him or her).

Optional Methods

The following methods are part of the interface, but do not have to be provided.

text_width

Called with an SVG::Rasterize::State object and the text to render. Returns the width that the rendered text would occupy. The second argument may be undef in which case 0 should be returned.

NB: The base class method throws an exception. The exception is caught by SVG::Rasterize. This behaviour is used to determine if this method is implemented by the engine or not.

draw_rect

If this method is not implemented then an equivalent call to draw_path is used. If closed paths are implemented by the engine there is no real reason to provide this method. Called with the following parameters (for the exact meanings see the SVG specification):

None of these parameters must be validated. It is assumed that this has been done before.

draw_circle

If this method is not implemented then an equivalent call to draw_path is used. If closed paths are implemented by the engine there is no real reason to provide this method. Called with the following parameters (for the exact meanings see the SVG specification):

None of these parameters must be validated. It is assumed that this has been done before.

draw_ellipse

If this method is not implemented then an equivalent call to draw_path is used. If closed paths are implemented by the engine there is no real reason to provide this method. Called with the following parameters (for the exact meanings see the SVG specification):

None of these parameters must be validated. It is assumed that this has been done before.

draw_line

If this method is not implemented then an equivalent call to draw_path is used. If closed paths are implemented by the engine there is no real reason to provide this method. Called with the following parameters (for the exact meanings see the SVG specification):

None of these parameters must be validated. It is assumed that this has been done before.

draw_polyline

If this method is not implemented then an equivalent call to draw_path is used. If closed paths are implemented by the engine there is no real reason to provide this method. Called with the following parameters (for the exact meanings see the SVG specification):

None of these parameters must be validated. It is assumed that this has been done before.

draw_polygon

If this method is not implemented then an equivalent call to draw_path is used. If closed paths are implemented by the engine there is no real reason to provide this method. Called with the following parameters (for the exact meanings see the SVG specification):

None of these parameters must be validated. It is assumed that this has been done before.

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.

AUTHOR ^

Lutz Gehlen, <perl at lutzgehlen.de>

LICENSE AND COPYRIGHT ^

Copyright 2011 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.

syntax highlighting: