On Mon, 2008-12-08 at 10:48 +0100, Stéphane Esté-Gracias wrote:

> I'm try to use Cogl to draw rounded rectangles, but I don't understand
> how to use this package.
> Could you explain with sample code how to use Cogl to draw rounded rectangle ?

The Cogl drawing API needs to be used during a paint run. The easiest
way to do this is to connect to the paint signal of an actor.

You can see what parameters the path_round_rectangle function takes in
the C API docs [1].

Here is an example:

use strict;
use warnings;

use Glib;
use Clutter;

use Glib qw( :constants );
use Clutter qw( :init );

sub paint_round_rect
{
    Clutter::Cogl->color(Clutter::Color->new(0xff, 0x00, 0x00, 0xff));
    Clutter::Cogl->path_round_rectangle(20, 20, 100, 100, 20, 1);
    Clutter::Cogl->path_fill();
}

my $stage = Clutter::Stage->get_default();

# Create a 0x0 sized rectangle so we can hang onto its paint
my $rect = Clutter::Rectangle->new();

# Do our drawing when the rectangle paints
$rect->signal_connect(paint => \&paint_round_rect);

$stage->add($rect);

$stage->show();

Clutter->main();

- Neil

[1] http://tinyurl.com/6ez5rh

-- 
To unsubscribe send a mail to [EMAIL PROTECTED]

Reply via email to