| 1 |
#!perl -w |
| 2 |
use strict; |
| 3 |
use blib; |
| 4 |
use Imager; |
| 5 |
use Test::More tests => 9; |
| 6 |
|
| 7 |
BEGIN { use_ok('Imager::CountColor' => 'count_color') } |
| 8 |
|
| 9 |
my $black = Imager::Color->new(0, 0, 0); |
| 10 |
my $blue = Imager::Color->new(0, 0, 255); |
| 11 |
my $red = Imager::Color->new(255, 0, 0); |
| 12 |
my $im = Imager->new(xsize=>50, ysize=>50); |
| 13 |
is(count_color($im, $black), 2500, "check black vs black image"); |
| 14 |
is(count_color($im, $red), 0, "check red vs black image"); |
| 15 |
$im->box(filled=>1, color=>$blue, xmin=>25); |
| 16 |
is(count_color($im, $black), 1250, "check black vs black/blue image"); |
| 17 |
is(count_color($im, $red), 0, "check red vs black/blue image"); |
| 18 |
is(count_color($im, $blue), 1250, "check blue vs black/blue image"); |
| 19 |
$im->box(filled=>1, color=>$red, ymin=>25); |
| 20 |
is(count_color($im, $black), 625, "check black vs black/blue/red image"); |
| 21 |
is(count_color($im, $blue), 625, "check black vs black/blue/red image"); |
| 22 |
is(count_color($im, $red), 1250, "check black vs black/blue/red image"); |