3 use Imager::Graph::Line;
5 use Imager::Font::Test;
9 or mkdir "testout", 0700
10 or die "Could not create output directory: $!";
15 local $SIG{__WARN__} =
22 use Imager qw(:handy);
26 #my $fontfile = 'ImUgly.ttf';
27 #my $font = Imager::Font->new(file=>$fontfile, type => 'ft2', aa=>1)
28 # or plan skip_all => "Cannot create font object: ",Imager->errstr,"\n";
29 my $font = Imager::Font::Test->new();
32 my @labels = qw(alpha beta gamma delta epsilon phi gi);
34 my $line = Imager::Graph::Line->new();
35 ok($line, "creating line chart object");
37 $line->set_font($font);
38 $line->add_data_series(\@data);
39 $line->set_labels(\@labels);
40 $line->use_automatic_axis();
44 my $img1 = $line->draw(outline => {line => '#FF0000'});
45 ok($img1, "drawing line chart");
47 $img1->write(file=>'testout/t31tic_color.ppm') or die "Can't save img1: ".$img1->errstr."\n";
48 cmpimg($img1, 'testimg/t31tic_color.ppm', 1);
50 unless (is(@warned, 0, "should be no warnings")) {
56 my ($img, $file, $limit) = @_;
63 or skip("No PNG support", 1);
65 my $cmpimg = Imager->new;
66 $cmpimg->read(file=>$file)
67 or return ok(0, "Cannot read $file: ".$cmpimg->errstr);
68 my $diff = Imager::i_img_diff($img->{IMG}, $cmpimg->{IMG});
69 cmp_ok($diff, '<', $limit, "Comparison to $file ($diff)");