4 use Test::More tests => 12;
7 use Imager::Test qw(is_image is_color3);
9 sub PI () { 3.14159265358979323846 }
11 -d "testout" or mkdir "testout";
14 push @cleanup, "testout/060-polypoly.log";
15 Imager->open_log(log => "testout/060-polypoly.log");
17 my $red = NC(255,0,0);
18 my $green = NC(0,255,0);
19 my $blue = NC(0,0,255);
20 my $white = NC(255,255,255);
21 my $black = NC(0, 0, 0);
24 unlink @cleanup unless $ENV{IMAGER_KEEP_FILES};
29 my $out = "testout/060-ppsimple.ppm";
30 my $im = Imager->new(xsize => 100, ysize => 100);
46 ), "simple filled polypolygon");
47 ok($im->write(file => $out), "save to $out");
48 my $cmp = Imager->new(xsize => 100, ysize => 100);
49 $cmp->box(filled => 1, color => $red, box => [ 20, 20, 39, 79 ]);
50 $cmp->box(filled => 1, color => $red, box => [ 60, 20, 79, 79 ]);
51 is_image($im, $cmp, "check expected output");
56 my $im = Imager->new(xsize => 100, ysize => 100);
74 ), "cross polypolygon nz");
75 save($im, "060-ppcrossnz.ppm");
76 my $cmp = Imager->new(xsize => 100, ysize => 100);
77 $cmp->box(filled => 1, color => $red, box => [ 10, 40, 89, 59 ]);
78 $cmp->box(filled => 1, color => $red, box => [ 40, 10, 59, 89 ]);
79 is_image($im, $cmp, "check expected output");
81 my $im2 = Imager->new(xsize => 100, ysize => 100);
87 #mode => "nonzero", # default to evenodd
88 ), "cross polypolygon eo");
89 save($im2, "060-ppcrosseo.ppm");
91 $cmp->box(filled => 1, color => $black, box => [ 40, 40, 59, 59 ]);
92 is_image($im2, $cmp, "check expected output");
94 # same as cross_cw except that the second box is in reversed order
106 my $im3 = Imager->new(xsize => 100, ysize => 100);
111 points => $cross_diff,
113 ), "cross polypolygon diff");
114 is_image($im3, $cmp, "check expected output");
115 save($im3, "060-ppcrossdiff.ppm");
121 my ($im, $file) = @_;
123 $file = "testout/" . $file;
124 push @cleanup, $file;
125 ok($im->write(file => $file), "save to $file");