Re: Opposite of Tk::Canvas::canvasx()?

[email protected] Wed, 12 Apr 2006 10:16:12 +0200
Newsgroups gmane.comp.lang.perl.tk
Message-ID <[email protected]>
Ala Qumsieh <[email protected]> wrote:
> Does anybody know what is the exact calculation that:
> 
>   $x2 = $canvas->canvasx($x1);
> 
> does? I need the ability to reverse it, ie. get $x1,
> given $x2. I couldn't find a built-in function to do
> it, and I couldn't reverse engineer it either. So, I
> snooped around the source, but I couldn't even find
> where that function is defined!
> 

It's probably defined in the C core of Tk.

In my personal toolbox I have these methods:

=item widgetx, widgety

Opposite of canvasx and canvasy.

=cut

sub widgetx {
    my($c, $cx) = @_;
    my $c0 = $c->canvasx(0);
    $cx-$c0;
}

sub widgety {
    my($c, $cy) = @_;
    my $c0 = $c->canvasy(0);
    $cy-$c0;
}

__END__

Regards,
    Slaven

-- 
     __o		Slaven Rezic
   _`\<,_		slaven <at> rezic <dot> de
__(_)/ (_)____
______________________________________________________________________________
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to [email protected]