Prima::Cairo - Prima extension for Cairo drawing
The module allows for programming Cairo library together with Prima widgets.
use strict; use warnings; use Cairo; use Prima qw(Application); use Prima::Cairo; my $w = Prima::MainWindow->new( onPaint => sub { my ( $self, $canvas ) = @_; $canvas->clear; my $cr = $canvas->cairo_context; $cr->rectangle (10, 10, 40, 40); $cr->set_source_rgb (0, 0, 0); $cr->fill; $cr->rectangle (50, 50, 40, 40); $cr->set_source_rgb (1, 1, 1); $cr->fill; $cr->show_page; }); run Prima;
Returns the Cairo context bound to the Prima drawable - widget, bitmap etc or an undef.
Options:
Prima coordinate system is such that lower left pixel is (0,0), while cairo system is that (0,0) is upper left pixel. By default cairo_context returns a context adapted for Prima, but if you want native cairo coordinate system call it like this:
cairo_context
$canvas->cairo_context( transform => 0 );
This also affect font rendering, so when Prima transform is used, Cairo font must not be changed via
$cairo->set_font_size(18)
but rather via
my $matrix = $cairo->get_font_matrix; $matrix->scale(1.8, 1.8); # default cairo matrix is 10 $cairo->set_font_matrix($matrix);
Returns a im::bpp24 (for color surfaces) or im::Byte/im::BW (for a8/a1 mask surfaces) Prima::Image object with pixels copies from the image surface. If $class is 'Prima::Icon' and image surface has 'argb32' format then fills the 1-bit alpha channel in the Prima icon object.
$class
Returns a rgb24 Cairo::ImageSurface object with pixels copied from the image
Returns a argb32 Cairo::ImageSurface object with pixels copied from the image and its mask
Before installing the module, you need to install Cairo perl wrapper. That requires libcairo binaries, includes, and pkg-config.
In case you don't have cairo binaries and include files, grab them here:
http://prima.eu.org/Cairo/cairo-win.zip
unzip and run <code>make install</code>.
Strawberry 5.20 is shipped with a broken pkg-config ( https://rt.cpan.org/Ticket/Display.html?id=96315, https://rt.cpan.org/Ticket/Display.html?id=96317 ), you'll need to install the latest ExtUtils::PkgConfig from CPAN.
This setup is needed both for Cairo and Prima-Cairo.
Dmitry Karasik, <dmitry@karasik.eu.org>.
Prima, Cairo
git clone git@github.com:dk/Prima-Cairo.git
This software is distributed under the BSD License.
To install Prima::Cairo, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Prima::Cairo
CPAN shell
perl -MCPAN -e shell install Prima::Cairo
For more information on module installation, please visit the detailed CPAN module installation guide.