On Mon, 2008-12-08 at 11:32 +0000, Neil Roberts wrote:
> 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].
or:
perldoc Clutter::Cogl
for the COGL bindings.
> Here is an example:
>
> use strict;
> use warnings;
>
> use Glib;
> use Clutter;
>
> use Glib qw( :constants );
> use Clutter qw( :init );
this can also be written like:
sub paint_round_rect
{
my ($self) = @_;
# get the allocation geometry in pixels
my $geometry = $self->get_allocation_geom();
Clutter::Cogl->color(Clutter::Color->new(0xff, 0x00, 0x00, 0xff));
Clutter::Cogl->path_round_rectangle(
$geometry->x(),
$geometry->y(),
$geometry->width(),
$geometry->height(),
20, # radius of the arc
1 # arc step, in degrees
);
Clutter::Cogl->path_fill();
# prevent the default ::paint handler to run
$self->signal_stop_emission_by_name("paint");
}
so that you can effectively use the Actor API to size the rectangle.
ideally, though, creating a class using Glib::Object::Subclass and
overriding the PAINT method would be a better idea, since you can then
install properties for the arc radius and eventual step, and control
them programmatically or via Clutter::Script instead of hard-coding
them.
ciao,
Emmanuele.
--
Emmanuele Bassi, Intel Open Source Technology Center
--
To unsubscribe send a mail to [EMAIL PROTECTED]