File: findfill.t

package info (click to toggle)
libimage-imlib2-perl 1.12-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 192 kB
  • ctags: 39
  • sloc: perl: 289; ansic: 112; makefile: 70
file content (51 lines) | stat: -rw-r--r-- 1,063 bytes parent folder | download
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
#!/usr/bin/perl -w
use strict;
use Test::More tests => 10;

use_ok('Image::Imlib2');

my $i = Image::Imlib2->load("t/findfill.png");
my($w, $h) = ($i->width, $i->height);
isa_ok($i, 'Image::Imlib2');

# find red
$i->set_colour(255, 0, 0, 255);
my($rx, $ry) = $i->find_colour;
is($rx, 186);
is($ry, 51);
$i->set_colour(127, 0, 0, 255);
$i->fill($rx, $ry);
$i->fill($rx + 10, $ry);

# find green
$i->set_colour(0, 255, 0, 255);
($rx, $ry) = $i->find_colour;
is($rx, 163);
is($ry, 145);
$i->set_colour(0, 127, 0, 255);
$i->fill($rx, $ry);
$i->fill($rx + 10, $ry);

# find blue
$i->set_colour(0, 0, 255, 255);
($rx, $ry) = $i->find_colour;
is($rx, 158);
is($ry, 97);
$i->set_colour(0, 0, 127, 255);
$i->fill($rx, $ry);
$i->fill($rx + 5, $ry);

my $new = Image::Imlib2->new($w, $h);
$new->set_colour(255, 255, 255, 255);
$new->fill_rectangle(0, 0, $w, $h);

# find black
$i->set_colour(0, 0, 0, 255);
($rx, $ry) = $i->find_colour;
is($rx, 143);
is($ry, 12);
$i->set_colour(127, 127, 127, 255);
$i->fill($rx, $ry, $new);
#$new->save("new.png");

#$i->save("done.png");