aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormertz2005-01-15 14:28:56 +0000
committermertz2005-01-15 14:28:56 +0000
commit921d068da6a13de0be46d037dfc0c32c63497b51 (patch)
treedb5eefbf03c30096237e30c2203c5fa9d8b6f29b
parent7dce903738307480baef174d0b6de8e61e546daa (diff)
downloadtkzinc-921d068da6a13de0be46d037dfc0c32c63497b51.zip
tkzinc-921d068da6a13de0be46d037dfc0c32c63497b51.tar.gz
tkzinc-921d068da6a13de0be46d037dfc0c32c63497b51.tar.bz2
tkzinc-921d068da6a13de0be46d037dfc0c32c63497b51.tar.xz
correcting e typo
removing a forgotten print adding rotate interaction (so that we could for ex. test memoryleaks!)
-rw-r--r--Perl/demos/Tk/demos/zinc_lib/tiger.pl19
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) = @_;