Re: Rendering SVG on Cairo



On Wed, 2008-04-16 at 08:30 +0300, Ari Jolma wrote:

Is anyone aware of SVG to Cairo rendering code? There are SVG and 
SVG::Parser modules and of course Cairo, but a missing piece is a code, 
which interprets SVG into Cairo calls. SVG and Cairo seem to have a lot 
in common so it wouldn't be so hard to write one.

librsvg and thus Gnome2::Rsvg can do this.  Here's an example (which
lacks error checking):

use Cairo;
use Gnome2::Rsvg;

my $handle = Gnome2::Rsvg::Handle -> new();
$handle -> write($svg_data);
$handle -> close();

my $surface = Cairo::ImageSurface -> create("argb32", 10, 10);
my $cr = Cairo::Context -> create($surface);
$handle -> render_cairo($cr);

-- 
Bye,
-Torsten




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]