Cairo: how do I use $cr->append_path to draw a path?


I'm playing with Cairo to generate hexmaps for role-playing games, and
using the $cr->move_to and $cr->line_to methods, this works fine.

However, according to the documentation, I should also be able to build
a Cairo::Path object and use $cr->append_path to do the same thing. Yet,
when I try, it doesn't work. See the below code for an example:


use strict;
use warnings;
use Cairo;
use Data::Dump qw/dump/;

my $surface = Cairo::PdfSurface->create('out.pdf',200,200);
my $cr = Cairo::Context->create($surface);

# The following does not work:
my $path = [
            { type => "move-to", points => [[10,10]] },
            { type => "line-to", points => [[10,190]] },
            { type => "line-to", points => [[190,190]] },
            { type => "line-to", points => [[190,10]] },
            { type => "close-path", points => [] } ,

# This however does:
#my $path = $cr->copy_path;
#dump $path;

Am I doing something wrong, or am I reading the documentations



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