#!perl -w
use strict;
-use Test::More tests => 235;
+use Test::More tests => 250;
use Imager ':all';
-use Imager::Test qw(is_color3);
+use Imager::Test qw(is_color3 is_image);
use constant PI => 3.14159265358979;
init_log("testout/t21draw.log",1);
"save arc outline");
}
+{
+ # we document that drawing from d1 to d2 where d2 > d1 will draw an
+ # arc going through 360 degrees, test that
+ my $im = Imager->new(xsize => 200, ysize => 200);
+ ok($im->arc(x => 100, y => 100, aa => 0, filled => 0, color => '#fff',
+ d1 => 270, d2 => 90, r => 90), "draw non-aa arc through 0");
+ ok($im->arc(x => 100, y => 100, aa => 1, filled => 0, color => '#fff',
+ d1 => 270, d2 => 90, r => 80), "draw aa arc through 0");
+ ok($im->write(file => "testout/t21arc0.ppm"),
+ "save arc through 0");
+}
+
+{
+ # test drawing color defaults
+ {
+ my $im = Imager->new(xsize => 10, ysize => 10);
+ ok($im->box(), "default outline the image"); # should outline the image
+ is_color3($im->getpixel(x => 0, y => 0), 255, 255, 255,
+ "check outline default color TL");
+ is_color3($im->getpixel(x => 9, y => 5), 255, 255, 255,
+ "check outline default color MR");
+ }
+
+ {
+ my $im = Imager->new(xsize => 10, ysize => 10);
+ ok($im->box(filled => 1), "default fill the image"); # should fill the image
+ is_color3($im->getpixel(x => 0, y => 0), 255, 255, 255,
+ "check fill default color TL");
+ is_color3($im->getpixel(x => 5, y => 5), 255, 255, 255,
+ "check fill default color MM");
+ }
+}
+
+{ # flood_fill wouldn't fill to the right if the area was just a
+ # single scan-line
+ my $im = Imager->new(xsize => 5, ysize => 3);
+ ok($im, "make flood_fill test image");
+ ok($im->line(x1 => 0, y1 => 1, x2 => 4, y2 => 1, color => "white"),
+ "create fill area");
+ ok($im->flood_fill(x => 3, y => 1, color => "blue"),
+ "fill it");
+ my $cmp = Imager->new(xsize => 5, ysize => 3);
+ ok($cmp, "make test image");
+ ok($cmp->line(x1 => 0, y1 => 1, x2 => 4, y2 => 1, color => "blue"),
+ "synthezied filled area");
+ is_image($im, $cmp, "flood_fill filled horizontal line");
+}
malloc_state();
unlink "testout/t21arcout.ppm";
unlink "testout/t21aaarcout.ppm";
unlink "testout/t21aaarcs.ppm";
+ unlink "testout/t21arc0.ppm";
}
sub color_cmp {