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

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:

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

         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]