Re: Cairo: how do I use $cr->append_path to draw a path?
- From: Torsten Schoenfeld <kaffeetisch gmx de>
- To: gtk-perl-list gnome org
- Subject: Re: Cairo: how do I use $cr->append_path to draw a path?
- Date: Sun, 07 Aug 2011 20:05:07 +0200
On 15.07.2011 16:02, Torsten Schoenfeld wrote:
On 15.07.2011 06:47, Mart van de Wege wrote:
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.
Judging from the code, this conversion direction is not implemented yet,
and the documentation neglects to mention it. (Irregardless of the path
you input, a NULL is passed to libcairo.) I think I have code for this
in a local branch at home. I'll try to polish it and post here soon.
Turned out to be a little more complicated than I anticipated. But here
it is now:
http://git.gnome.org/browse/perl-Cairo/commit/?id=861203aec1479564b6812278f2721ebf544a9399
You can now pass plain old array references to append_path(), and you
can alter paths returned from Cairo, with some caveats. The relevant
bits from the docs:
Note that the paths returned by Cairo are implemented as tied array
references which do not support adding, removing or shuffling of path
segments. For these operations, you need to make a shallow copy
first:
my @path_clone = @{$path};
# now you can alter @path_clone which ever way you want
The points of a single path element can be changed directly, however,
without the need for a shallow copy:
$path->[$i]{points} = [[3, 4], [5, 6], [7, 8]];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]