FAQ-OMatic

 view release on metacpan or  search on metacpan

lib/FAQ/OMatic/Part.pm  view on Meta::CPAN

	my ($lines) = 0;
	my ($text) = "";

	# THANKS to "John R. Jackson" <jrj@gandalf.cc.purdue.edu> for
	# grepping for unprotected while constructs.
	while (defined($_ = &{$closure})) {
		chomp;
		my ($key,$value) = FAQ::OMatic::keyValue($_);
		if ($key eq 'Author') {
			# convert old-style 'Author' keys to 'Author-Set' keys
			# transparently. Eventually all such items will get written
			# out with updated header keys.
			$key = 'Author-Set';
		}
		if ($key eq 'DateOfPart') {
			# convert old-style 'DateOfPart' keys to 'LastModifiedSecs' keys
			# transparently.
			$value = FAQ::OMatic::Item::compactDateToSecs($value);
				# turn back into seconds
			$key = 'LastModifiedSecs';
		}
		if ($key eq 'Lines') {
			# Lines header is always last before the text content of a Part
			$lines = $value;
			last;
		} elsif ($key =~ m/-Set$/) {
			# header key ends in '-Set' -- that means it may appear multiple

lib/FAQ/OMatic/statgraph.pm  view on Meta::CPAN

	# get x interval automatically
	$rangex = $maxx - $minx;
	my ($intervalx,$unitsx) = autoIntervalDays($rangex);

	$width = $FAQ::OMatic::Appearance::graphWidth;
	$height = $FAQ::OMatic::Appearance::graphHeight;	# from FAQ::OMatic::FaqConfig
	my $borderx = 30;
	my $bordery = 10;

	my $image = new GD::Image ($width, $height);
	my $transparent = $image->colorAllocate(255, 255, 255);
	my $framefill = $image->colorAllocate(255, 255, 255);
	my $grid = $image->colorAllocate(192, 192, 192);
	my $datafill = $image->colorAllocate(0, 0, 132);
	my $datacolor = $image->colorAllocate(240, 0, 0);
	my $frame = $image->colorAllocate(128, 0, 0);
	my $labels = $image->colorAllocate(10, 88, 0);

	# draw the graph in this order, back-to-front:
	# transparent (whole image background)
	# framefill
	# grid
	# datafill
	# datacolor
	# ticks (grid color)
	# frame
	# labels

	# transparent
	$image->filledRectangle(0, 0, $width, $height, $transparent);

	# framefill
	# note these are globals so calc[xy] can see them
	($basex, $basey) = ($borderx, $bordery);
	($sizex, $sizey) = ($width-2*$borderx, $height-3*$bordery);
	$image->filledRectangle($basex, $basey, $basex+$sizex, $basey+$sizey,
			$framefill);

	# grid
	for ($i=$miny; $i<=$maxy; $i+=$intervaly) {

lib/FAQ/OMatic/statgraph.pm  view on Meta::CPAN

				  [ 1, 1,$framefill],
				  [ 0, 1,$framefill],
				  [-1, 1,$framefill],
				  [ 0, 0,$datafill] );
	foreach my $spot (@spots) {
		$image->string(gdTinyFont, calcx($maxx)-5*length($value)+18+$spot->[0],
			max(calcy($mydata[$#mydata])-9+$spot->[1],$basey+2),
			$value, $spot->[2]);
	}

	# make image background transparent so it'll look nicer sitting
	# in the browser
	$image->transparent($transparent);

	# send image
	print $image->$image_type();
}

1;



( run in 0.896 second using v1.01-cache-2.11-cpan-0a6323c29d9 )