> This is an simple example. An screenshot is attached. I'm using 
> Fedora12, with GooCanvas installed using yum.
> 
> ##############################################
> 
> #!/usr/bin/perl
> use strict;
> 
> use Glib qw/TRUE FALSE/;
> use Gtk2 qw/-init -threads-init/;
> use Goo::Canvas;
> 
> my $win = Gtk2::Window->new;
> $win->signal_connect( destroy => sub { Gtk2->main_quit; } );
> 
> my $vbox = Gtk2 ::VBox->new( FALSE, 6 );
> $win->add($vbox);
> 
> my $canvas = Goo::Canvas->new();
> 
> $canvas->set_size_request( 600, 450 );
> $vbox->pack_start( $canvas, FALSE, FALSE, 0 );
> 
> my $root = $canvas->get_root_item;
> 
> # a crosshair targeted at (100,100)
> 
> Goo::Canvas::Rect->new( $root, 100, 100, 50, 50 );
> Goo::Canvas::Rect->new( $root, 50,  50,  50, 50 );
> Goo::Canvas::Rect->new( $root, 50,  100, 50, 50 );
> Goo::Canvas::Rect->new( $root, 100, 50,  50, 50 );
> 
> # here, I expect the diamond centered at (100,100)
> # but it left-top point is placed at (100,100)
> 
> Goo::Canvas::Polyline->new( $root, TRUE,
>     [
>         0, 10,
>         10, 0,
>         0, -10,
>         -10, 0
>     ],
>     'x'=>100,
>     'y' =>100
> );
> 
> $win->show_all;
> Gtk2->main;
> 

Ah. Your problem stems from explicitly setting the 'x' and 'y'
properties of the Polyline. These refer not to the origin of the item
(although this is a reasonable assumption), but to the left and top
edges of its bounding box. This is intentional
(http://mail.gnome.org/archives/goocanvas-list/2008-October/msg00033.html).

You could set 'x' and 'y' to what you intend them to be (i.e. [90,90]),
but it might be better either to use absolute coordinates in the shape
definition (if it is a static item) or to do a transform on the item
after the fact. Either:

$polyline->set_simple_transform( 100, 100, 1, 0); #absolute positioning

or

$polyline->translate(100,100); #relative positioning


Jeremy


_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Reply via email to