GIFgraph uses the GD module’s drawing primitives internally for drawing its graphs. Unfortunately there are no explicitly exported methods for interfacing GIFgraph objects with other GD objects. However, it is easy to pass a GIFgraph drawing to a GD object for further manipulation. This section will expand on the biorhythm example from the beginning of the chapter by merging the graph with another GIF image that will act as a frame for the graph.
For our purposes, the
can still be used to generate the HTML
page that drives the example. The
that generates the graph image will have to be replaced with the
following script, whose output is shown in Figure 6.10:
#!/usr/local/bin/perl # # bio.cgi (modified) # This script demonstrates how to pass a graph drawn with GIFgraph to an # image created with the GD module. # use strict; use GD; use GIFgraph::bars; use Date::Calc; use CGI; my $query = new CGI; # Retrieve the parameters passed in from the form # my ($dob, $start, $end) =( $query->param('dob'), $query->param('start'), $query->param('end') ); # The following section is the same as the bio.cgi script from the # beginning of the chapter (without the comments) # my $pi = atan2(1,1) * 4; my $days = datediff(parsedate($start), parsedate($end)); my $dobdiff = datediff(parsedate($dob), parsedate($start)); my @xvalues = daterange(parsedate($start)); my @pvalues = calculate(23, $dobdiff % 23, $days); my @evalues = calculate(28, ...