diff options
Diffstat (limited to 'Perl/demos')
-rw-r--r-- | Perl/demos/Tk/demos/zinc_lib/tiger.pl | 19 |
1 files changed, 16 insertions, 3 deletions
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('<ButtonPress-1>', [\&press, \&motion]); $zinc->Tk::bind('<ButtonRelease-1>', [\&release]); $zinc->Tk::bind('<ButtonPress-2>', [\&press, \&zoom]); $zinc->Tk::bind('<ButtonRelease-2>', [\&release]); +$zinc->Tk::bind('<ButtonPress-3>', [\&press, \&rotate]); +$zinc->Tk::bind('<ButtonRelease-3>', [\&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) = @_; |