aboutsummaryrefslogtreecommitdiff
path: root/Perl
diff options
context:
space:
mode:
authormertz2004-09-20 20:07:06 +0000
committermertz2004-09-20 20:07:06 +0000
commit9373cebaaceb73b1f0682dfa764dc3f86f4a3721 (patch)
tree0e15603a48e46ee34b9fbfd2e22ef9adad3fb547 /Perl
parentb6d3d6562b2735a1f766c4ceb55a254551dd4df2 (diff)
downloadtkzinc-9373cebaaceb73b1f0682dfa764dc3f86f4a3721.zip
tkzinc-9373cebaaceb73b1f0682dfa764dc3f86f4a3721.tar.gz
tkzinc-9373cebaaceb73b1f0682dfa764dc3f86f4a3721.tar.bz2
tkzinc-9373cebaaceb73b1f0682dfa764dc3f86f4a3721.tar.xz
This test is for some gradients, clipping, etc... based on lot
of repeatitive, animated, graphics updates
Diffstat (limited to 'Perl')
-rw-r--r--Perl/t/AnimatedGradient.t175
1 files changed, 175 insertions, 0 deletions
diff --git a/Perl/t/AnimatedGradient.t b/Perl/t/AnimatedGradient.t
new file mode 100644
index 0000000..e65f9a3
--- /dev/null
+++ b/Perl/t/AnimatedGradient.t
@@ -0,0 +1,175 @@
+#!/usr/bin/perl -w
+
+#
+# $Id: AnimatedGradient.t,v 1.1 2004-09-20 20:07:06 mertz Exp $
+# Author: Christophe Mertz mertz@intuilab.com
+#
+
+# this test mainly does funny effects when openGL is on
+
+
+# testing all the import
+
+BEGIN {
+ if (!eval q{
+# use Test::More qw(no_plan);
+ use Test::More tests => 18;
+ 1;
+ }) {
+ print "# tests only work properly with installed Test::More module\n";
+ print "1..1\n";
+ print "ok 1\n";
+ exit;
+ }
+ if (!eval q{
+ use Tk::Zinc;
+ 1;
+ }) {
+ print "unable to load Tk::Zinc";
+ print "1..1\n";
+ print "ok 1\n";
+ exit;
+ }
+}
+
+use strict;
+my $mw = MainWindow->new();
+my $zinc = $mw->Zinc(-width => 200, -height => 200, -backcolor => "white",
+ -render => 1)->pack;
+
+like ($zinc, qr/^Tk::Zinc=HASH/ , "zinc has been created");
+
+$zinc->add('text', 1, -position => [10,5], -text =>
+"the gradient fills a rectangle
+which is clipped by the curve
+made of two circles...\n"x5);
+
+
+my $circle1 = $zinc->add('arc', 1, [20,20,180,180]);
+my $circle2 = $zinc->add('arc', 1, [70,70,130,130]);
+
+my $curve = $zinc->add('curve', 1, [],
+ -fillcolor => 'red', -filled => 1, -linewidth => 1);
+$zinc->contour($curve, 'add', 1, $circle1);
+$zinc->contour($curve, 'add', -1, $circle2);
+
+$zinc->remove($circle1);
+$zinc->remove($circle2);
+
+my $gradient;
+for (1..4) {
+ for (my $i = 0; $i <=360; $i++) {
+ $gradient = "=axial $i | red | white 50 | blue";
+ $zinc->itemconfigure($curve, -fillcolor => $gradient);
+ $zinc->update;
+ }
+}
+pass("turning gradient one side");
+
+for (1..4) {
+ for (1..100) {
+ $zinc->translate($curve,0.5,0.5);
+ $zinc->update;
+ }
+ for (1..800) {
+ $zinc->rotate($curve, 3.14159/400, 100,100);
+ $zinc->update;
+ }
+ for (1..100) {
+ $zinc->translate($curve,0.5,0.5);
+ $zinc->update;
+ }
+
+ for (1..400) {
+ $zinc->translate($curve,-0.5,-0.5);
+ $zinc->update;
+ }
+ for (1..200) {
+ $zinc->translate($curve,0.5,0.5);
+ $zinc->update;
+ }
+ pass ("shaking the circle around");
+}
+
+for (1..4) {
+ for (my $i = 359; $i > 0; $i--) {
+ $gradient = "=axial $i | red | white 50 | blue";
+ $zinc->itemconfigure($curve, -fillcolor => $gradient);
+ $zinc->update;
+ }
+}
+pass("turning gradient the other side");
+
+
+my $gr = $zinc->add('group', 1);
+my $rect = $zinc->add('rectangle', $gr, [0,-480,200,180], -filled => 1,
+ -fillcolor => "=axial 90 |blue|white 10|red 20|white 30|blue 40|white 50|red 60|white 70|blue 80|white 90|red");
+
+$zinc->chggroup($curve, $gr);
+$zinc->itemconfigure($curve, -visible => 0);
+
+$zinc->itemconfigure($gr, -clip => $curve);
+
+
+pass("displaying a translated rectangle filled with froggy colors and clipped by two circles");
+for (1..2) {
+ for (my $i = 0; $i<500 ; $i++) {
+ $zinc->translate($rect, 0,1);
+ $zinc->update;
+ }
+ for (my $i = 0; $i<500 ; $i++) {
+ $zinc->translate($rect, 0,-1);
+ $zinc->update;
+ }
+ pass ("a thousand translation");
+}
+
+$zinc->translate($rect, 0,250);
+
+
+for (1..1000) {
+ $zinc->scale($rect, 1, 0.998, 100,100);
+ $zinc->update;
+}
+pass("a thousand scaling down");
+
+
+for (1..360) {
+ $zinc->rotate($rect, 3.14159/180, 100,100);
+ $zinc->update;
+}
+pass("360 rotation of 1°");
+
+
+for (1..360) {
+ $zinc->rotate($rect, -3.14159/180, 100,100);
+ $zinc->update;
+}
+pass("360 rotation of 1°");
+
+
+for (1..360) {
+ $zinc->rotate($rect, -3.14159/180, 100,100);
+ $zinc->update;
+}
+
+
+for (1..1000) {
+ $zinc->scale($rect, 1, 1/0.998, 100,100);
+ $zinc->update;
+}
+pass("a thousand scaling up");
+
+
+
+for (1..4) {
+ for my $i (0..200) {
+ $zinc->itemconfigure($gr, -alpha => (200-$i)/2);
+ $zinc->update;
+ }
+ for my $i (0..200) {
+ $zinc->itemconfigure($gr, -alpha => $i/2);
+ $zinc->update;
+ }
+ pass("fade out/in in 400 steps");
+}