aboutsummaryrefslogtreecommitdiff
path: root/Perl/t/Maps.t
blob: a49f2da8fe4092b3785bdf82b2deca84f5226c93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/perl -w

#
# $Id: Maps.t,v 1.1 2005-12-02 21:51:12 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 => 2;
        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 => 800, -height => 600, -backcolor => "white",
                     -render => 0)->pack;

like  ($zinc, qr/^Tk::Zinc=HASH/ , "zinc has been created");


$zinc->add('text', 1, -position => [10,5], -text => 
"this is a simple sample of a mapitem in TkZinc");

$zinc->after(10, \&proceedTest);

Tk::MainLoop;

sub proceedTest {
 
$zinc->mapinfo('first', 'create');

my $k = 10;
foreach (0..70) {
foreach my $j (0..80) {
  $zinc->mapinfo('first', 'add', 'line', 'simple', 1, 10, 10+$j*$k, 790, 10+$j*$k);
  $zinc->mapinfo('first', 'add', 'line', 'simple', 1, 10+$j*$k, 10, 10+$j*$k, 790);
}
}

$zinc->add('map', 1, -mapinfo => 'first');


$zinc->mapinfo('second', 'create');

$k = 30;
foreach (0..70) {
foreach my $j (0..80) {
  $zinc->mapinfo('first', 'add', 'line', 'dashed', 1, 10, 5+$j*$k, 790, 5+$j*$k);
  $zinc->mapinfo('first', 'add', 'line', 'mixed', 1, 5+$j*$k, 10, 5+$j*$k, 790);
  $zinc->mapinfo('first', 'add', 'line', 'simple', 1, 10, 5+$j*$k, 790, 5+$j*$k);
  $zinc->mapinfo('first', 'add', 'line', 'simple', 1, 5+$j*$k, 10, 5+$j*$k, 790);
}
}

$zinc->add('map', 1, -color => 'red', -mapinfo => 'second');

&pass("map is displayed");
$zinc->after(1000, sub {exit});

}