3 use Imager::Graph::Area;
5 use Imager::Font::Test;
7 use Imager::Test qw(is_image_similar);
10 or mkdir "testout", 0700
11 or die "Could not create output directory: $!";
15 use Imager qw(:handy);
17 #my $fontfile = 'ImUgly.ttf';
18 #my $font = Imager::Font->new(file=>$fontfile, type => 'ft2', aa=>1)
19 # or plan skip_all => "Cannot create font object: ",Imager->errstr,"\n";
20 my $font = Imager::Font::Test->new();
24 100, 180, 80, 20, 2, 1, 0.5 ,
28 10, 20, 40, 200, 150, 10, 50,
30 my @labels = qw(alpha beta gamma delta epsilon phi gi);
35 my $area = Imager::Graph::Area->new;
36 ok($area, "creating area chart object");
38 # this may change output quality too
39 print "# Imager version: $Imager::VERSION\n";
40 print "# Font type: ",ref $font,"\n";
42 $area->add_data_series(\@data1, "Test Area");
43 $area->add_data_series(\@data2, "Test Area 2");
45 my $img1 = $area->draw
51 features => { legend => 1 },
56 orientation => "horizontal",
62 #outline => { line => '404040' },
64 or print "# ", $area->error, "\n";
66 ok($img1, "made the image");
68 ok($img1->write(file => "testout/t40area1.ppm"),
71 cmpimg($img1, "testimg/t40area1.png", 100_000);
75 my $area = Imager::Graph::Area->new;
76 ok($area, "made area chart object");
77 $area->add_data_series(\@data1, "Test area");
78 $area->show_horizontal_gridlines();
79 $area->set_y_tics(10);
80 my $img2 = $area->draw
82 features => [ "horizontal_gridlines", "areamarkers" ],
85 hgrid => { style => "dashed", color => "#888" },
88 outline => { color => "#F00", style => "dotted" },
91 ok($img2, "made second area chart image");
92 ok($img2->write(file => "testout/t40area2.ppm"),
95 cmpimg($img2, "testimg/t40area2.png", 80_000);
99 unless ($ENV{IMAGER_GRAPH_KEEP_FILES}) {
100 unlink "testout/t40area1.ppm";
101 unlink "testout/t40area2.ppm";
106 my ($img, $file, $limit) = @_;
112 $Imager::formats{png}
113 or skip("No PNG support", 1);
115 my $cmpimg = Imager->new;
116 $cmpimg->read(file=>$file)
117 or return ok(0, "Cannot read $file: ".$cmpimg->errstr);
118 my $diff = Imager::i_img_diff($img->{IMG}, $cmpimg->{IMG});
119 is_image_similar($img, $cmpimg, $limit, "Comparison to $file ($diff)");