]> git.imager.perl.org - imager-graph.git/blame - t/t31tic_color.t
hoist all the copies of cmpimg into a common module
[imager-graph.git] / t / t31tic_color.t
CommitLineData
1509eee7 1#!perl -w
2use strict;
3use Imager::Graph::Line;
4use lib 't/lib';
5use Imager::Font::Test;
6use Test::More;
119bb3de 7use Imager::Graph::Test 'cmpimg';
1509eee7 8
9-d 'testout'
10 or mkdir "testout", 0700
11 or die "Could not create output directory: $!";
12
13++$|;
14
15my @warned;
16local $SIG{__WARN__} =
17 sub {
18 print STDERR $_[0];
19 push @warned, $_[0]
20 };
21
22
23use Imager qw(:handy);
24
25plan tests => 4;
26
27#my $fontfile = 'ImUgly.ttf';
28#my $font = Imager::Font->new(file=>$fontfile, type => 'ft2', aa=>1)
29# or plan skip_all => "Cannot create font object: ",Imager->errstr,"\n";
30my $font = Imager::Font::Test->new();
31
267997be 32my @data = (1 .. 7);
1509eee7 33my @labels = qw(alpha beta gamma delta epsilon phi gi);
34
35my $line = Imager::Graph::Line->new();
36ok($line, "creating line chart object");
37
38$line->set_font($font);
39$line->add_data_series(\@data);
40$line->set_labels(\@labels);
41$line->use_automatic_axis();
42$line->set_y_tics(5);
43
44
45my $img1 = $line->draw(outline => {line => '#FF0000'});
46ok($img1, "drawing line chart");
47
48$img1->write(file=>'testout/t31tic_color.ppm') or die "Can't save img1: ".$img1->errstr."\n";
267997be 49
50eval { require Chart::Math::Axis; };
51if ($@) {
5a50139d 52 cmpimg($img1, 'testimg/t31tic_color.ppm', 100_000);
267997be 53}
54else {
5a50139d 55 cmpimg($img1, 'testimg/t31tic_color_CMA.ppm', 100_000);
267997be 56}
1509eee7 57
58unless (is(@warned, 0, "should be no warnings")) {
59 diag($_) for @warned;
60}
61