File: 70-paint-gradient.t

package info (click to toggle)
libgraphics-primitive-perl 0.67-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 372 kB
  • sloc: perl: 2,586; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 1,176 bytes parent folder | download | duplicates (5)
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
use Test::More tests => 7;

use Geometry::Primitive::Circle;
use Geometry::Primitive::Line;
use Graphics::Color::RGB;

BEGIN {
    use_ok('Graphics::Primitive::Paint::Gradient::Linear');
    use_ok('Graphics::Primitive::Paint::Gradient::Radial');
}

my $line = Graphics::Primitive::Paint::Gradient::Linear->new(
    line => Geometry::Primitive::Line->new(
        start => [0, 0],
        end => [10, 10]
    )
);
isa_ok($line, 'Graphics::Primitive::Paint::Gradient::Linear');

my $red = Graphics::Color::RGB->new(red => 1, green => 0, blue => 0);
my $blue = Graphics::Color::RGB->new(red => 0, green => 0, blue => 1);

cmp_ok($line->stop_count, '==', 0, 'stop count');

$line->add_stop(0.0, $red);
cmp_ok($line->stop_count, '==', 1, 'stop count');
$line->add_stop(0.75, $blue);

my @stops = $line->stops;
cmp_ok(scalar(@stops), '==', 2, '2 stops');

my $rad = Graphics::Primitive::Paint::Gradient::Radial->new(
    start => Geometry::Primitive::Circle->new(
        origin => [0, 0],
        radius => 5
    ),
    end => Geometry::Primitive::Circle->new(
        origin => [10, 10],
        radius => 3
    )
);
isa_ok($rad, 'Graphics::Primitive::Paint::Gradient::Radial');