From 921d068da6a13de0be46d037dfc0c32c63497b51 Mon Sep 17 00:00:00 2001 From: mertz Date: Sat, 15 Jan 2005 14:28:56 +0000 Subject: correcting e typo removing a forgotten print adding rotate interaction (so that we could for ex. test memoryleaks!) --- Perl/demos/Tk/demos/zinc_lib/tiger.pl | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'Perl/demos/Tk') diff --git a/Perl/demos/Tk/demos/zinc_lib/tiger.pl b/Perl/demos/Tk/demos/zinc_lib/tiger.pl index 1ec4e0d..4972d39 100644 --- a/Perl/demos/Tk/demos/zinc_lib/tiger.pl +++ b/Perl/demos/Tk/demos/zinc_lib/tiger.pl @@ -15,7 +15,7 @@ use Tk::Zinc; use Tk::Zinc::Debug; my $mw = MainWindow->new(); -$mw->title('tiger generated form svg'); +$mw->title('tiger generated from svg file'); my ($WIDTH,$HEIGHT) = (600,600); my $zinc = $mw->Zinc(-width => $WIDTH, -height => $HEIGHT, @@ -32,11 +32,12 @@ my $zinc = $mw->Zinc(-width => $WIDTH, -height => $HEIGHT, -optionsFormat => 'row', ); -my $top_group = $zinc->add('group', 1, -tags => ['__svg__1']); +my $top_group = $zinc->add('group', 1); $text = " Drag-Button 1 for moving the tiger, Drag-Button 2 for zooming the tiger, +Drag-Button 3 for rotating the tiger, esc for getting help on Tk::Zinc::Debug functions. "; @@ -477,6 +478,8 @@ $zinc->Tk::bind('', [\&press, \&motion]); $zinc->Tk::bind('', [\&release]); $zinc->Tk::bind('', [\&press, \&zoom]); $zinc->Tk::bind('', [\&release]); +$zinc->Tk::bind('', [\&press, \&rotate]); +$zinc->Tk::bind('', [\&release]); &Tk::MainLoop; @@ -503,7 +506,6 @@ sub motion { $cur_x = $lx; $cur_y = $ly; $i++; - print "$i " if ! ($i%100); } sub zoom { @@ -534,6 +536,17 @@ sub zoom { $zinc->scale($top_group, $sx, $sx); #$sy); } +sub rotate { + my ($zinc) = @_; + my $ev = $zinc->XEvent(); + my $lx = $ev->x; + my $ly = $ev->y; + my $langle; + + $langle = atan2($ly, $lx); + $zinc->rotate($top_group, -($langle - $cur_angle)); + $cur_angle = $langle; +} sub release { my ($zinc) = @_; -- cgit v1.1