return undef;
}
}
- i_poly_aa_cfill_m($self->{IMG}, $opts{'x'}, $opts{'y'},
- $mode, $opts{'fill'}{'fill'});
+ unless (i_poly_aa_cfill_m($self->{IMG}, $opts{'x'}, $opts{'y'},
+ $mode, $opts{'fill'}{'fill'})) {
+ return $self->_set_error($self->_error_as_msg);
+ }
}
else {
my $color = _color($opts{'color'});
unless ($color) {
$self->{ERRSTR} = $Imager::ERRSTR;
- return;
+ return;
+ }
+ unless (i_poly_aa_m($self->{IMG}, $opts{'x'}, $opts{'y'}, $mode, $color)) {
+ return $self->_set_error($self->_error_as_msg);
}
- i_poly_aa_m($self->{IMG}, $opts{'x'}, $opts{'y'}, $mode, $color);
}
return $self;
#!perl -w
use strict;
-use Test::More tests => 24;
+use Test::More tests => 28;
use Imager qw/NC/;
use Imager::Test qw(is_image is_color3);
"save to file");
}
+{
+ # fail 2 point polygon
+ my $im = Imager->new(xsize => 10, ysize => 10);
+ ok(!$im->polygon(x => [ 0, 5 ], y => [ 0, 5 ]),
+ "fail to draw poly with only two points");
+ like($im->errstr, qr/polygons must have at least 3 points/,
+ "check error message");
+ my $im2 = Imager->new(xsize => 10, ysize => 10);
+ ok(!$im2->polygon(x => [ 0, 5 ], y => [ 0, 5 ], fill => { solid => "#FFFFFF" }),
+ "fail to draw poly with only two points (fill)");
+ like($im2->errstr, qr/polygons must have at least 3 points/,
+ "check error message");
+}
+
Imager->close_log;
Imager::malloc_state();