Tim Brody > GD-Cairo-0.01 > GD::Cairo

Download:
GD-Cairo-0.01.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  

NAME ^

GD::Cairo - GD API wrapper around Cairo

SYNOPSIS ^

  use GD; # Needed for constants and GD::Polygon
  use GD::Cairo;

  # use GD;
  use GD::Cairo qw( :gd ); # Import GD constants and fonts

  # my $img = GD::Image->new( 400, 300, 1 );
  my $img = GD::Cairo->new( 400, 300, 1 );

  print $fh $img->svg;

DESCRIPTION ^

This module provides a GD API emulation for the Cairo graphics library. Cairo is a vector-based drawing package that aims to provide consistent output to many graphics contexts/formats.

METHODS ^

See <GD>.

GD::Cairo-specific methods

GD::Cairo->new( WIDTH, HEIGHT [, TRUECOLOR ] )

Create a new image of WIDTH by HEIGHT. WIDTH and HEIGHT are in user-space units (e.g. pixels for PNG or points for PDF).

GD::Cairo::ignoreMissing( [ WARN ] )

Ignore any missing functionality in GD::Cairo that may be in GD.

$data = $img->png

Return the image in PNG format.

$data = $img->pdf

Return the image in PDF format.

$data = $img->svg

Return the image in SVG format.

TODO ^

new(*FILEHANDLE)
new($filename)
new($data)
newFrom*

(newFromPngData implemented.)

colorClosestHWB
setAntiAliasedDontBlend($color [,$flag])
dashedLine

This is deprecated anyway.

fillToBorder

Unlikely to ever work.

clone
trueColorToPalette
alphaBlending
saveAlpha
interlaced

Ignored.

compare($image2)
clip($x1,$y1,$x2,$y2)
boundsSafe($x,$y)
GD::Polygon, GD::Polyline
GD::Simple

BUGS ^

Patches/suggestions are welcome.

Images are always true colour

I don't think Cairo supports paletted images, see http://cairographics.org/manual/cairo-Image-Surfaces.html#cairo-format-t.

Alignment in PNG Output

PngSurface doesn't appear to reliably translate coordinates onto the surface e.g. a point at 0,0 doesn't get rendered at all.

StringFT/String/StringUp

StringFT* will always render using 'Sans-Serif' and String* using 'Monospace' (which depend on fontconfig). I need an example for loading fonts with Cairo.

SetBrush

GD renders brushes by repeatedly rendering the brush (an image) along the path the given shape provides. This isn't practically achievable with Cairo (AFAIK), so instead I repeat the image along the path/fill.

SetStyle

Does not support gdStyledBrushed.

Memory Usage

In order to support GD::Image::fill GD::Cairo builds a stack of operations, which makes it memory inefficient compared to writing direct to a GD::Image surface.

GD::Cairo also stores a hash entry for every pixel set with setPixel to support getPixel.

SEE ALSO ^

Cairo, GD, GD::SVG (includes extensive discussion of why translating GD to a vector library is difficult).

http://cairographics.org/manual/

AUTHOR ^

Tim D Brody, <tdb01r@ecs.soton.ac.uk>

COPYRIGHT AND LICENSE ^

Copyright (C) 2007 by Tim D Brody

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: