GD::Cairo - GD API wrapper around Cairo


GD-Cairo documentation  | view source Contained in the GD-Cairo distribution.

Index


NAME

Top

GD::Cairo - GD API wrapper around Cairo

SYNOPSIS

Top

  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

Top

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

Top

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

Top

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

Top

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

Top

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

http://cairographics.org/manual/

AUTHOR

Top

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

COPYRIGHT AND LICENSE

Top


GD-Cairo documentation  | view source Contained in the GD-Cairo distribution.