<?php
function thermGraph( $current, $goal, $width, $height, $font ) {
$bar = 0.50;
$image = ImageCreate($width, $height);
$bg = ImageColorAllocate($image,255,255,255 );
$fg = ImageColorAllocate($image,255,0,0);
$tx = ImageColorAllocate($image,0,0,0);
ImageFilledRectangle($image,0,0,$width,$height,$bg);
imagearc($image, $width/2, $height-($width/2), $width, $width, 0, 360, $fg);
ImageFillToBorder($image, $width/2, $height-($width/2), $fg, $fg);
ImageFilledRectangle($image,
($width/2)-(($width/2)$bar),
$height-$width,
($width/2)+(($width/2)$bar),
$height-($width/2),
$fg );
ImageRectangle( $image,
($width/2)-(($width/2)$bar),
0,
($width/2)+(($width/2)$bar),
$height-$width,
$fg);
ImageFilledRectangle( $image,
($width/2)-(($width/2)$bar),
($height-$width) (1-($current/$goal)),
($width/2)+(($width/2)*$bar),
$height-$width,
$fg );
for( $k=25; $k<100; $k+=25 ) {
ImageFilledRectangle( $image,
($width/2)+(($width/2)*$bar) -5,
($height-$width) - ($height-$width)*($k/100) -1,
($width/2)+(($width/2)*$bar) -1,
($height-$width) - ($height-$width)*($k/100) +1, $tx );
ImageString($image, $font,
($width/2)+(($width/2)*$bar) +2,
(($height-$width) - ($height-$width)*($k/100)) - (ImageFontHeight($font)/2),
sprintf( "%2d", $k),$tx);
}
$pct = sprintf( "%d%%", ($current/$goal)*100 );
ImageString( $image, $font+2, ($width/2)-((strlen($pct)/2)*ImageFontWidth($font+2)),
($height-($width/2))-(ImageFontHeight($font+2) / 2),
$pct, $bg);
// send the image
header("content-type: image/png");
imagepng($image);
}
thermGraph(
$HTTP_GET_VARS["Current"],
$HTTP_GET_VARS["Goal"],
$HTTP_GET_VARS["Width"],
$HTTP_GET_VARS["Height"],
$HTTP_GET_VARS["Font"] );
?>