Code:
function thermGraph( $current, $goal, $width, $height, $font, $bgcolor01, $bgcolor02, $bgcolor03, $fgcolor01, $fgcolor02, $fgcolor03, $txcolor01, $txcolor02, $txcolor03 ) {
$bar = 0.50;
// create the image
$image = ImageCreate($width, $height);
$bg = ImageColorAllocate($image,$bgcolor01,$bgcolor02,$bgcolor03);
$fg = ImageColorAllocate($image,$fgcolor01,$fgcolor02,$fgcolor03);
$tx = ImageColorAllocate($image,$txcolor01,$txcolor02,$txcolor03);
// Build background
ImageFilledRectangle($image,0,0,$width,$height,$bg);
// Build bottom bulb
imagearc($image, $width/2, $height-($width/2), $width, $width, 0, 360, $fg);
ImageFillToBorder($image, $width/2, $height-($width/2), $fg, $fg);
// Build "Bottom level
ImageFilledRectangle($image,
($width/2)-(($width/2)*$bar),
$height-$width,
($width/2)+(($width/2)*$bar),
$height-($width/2),
$fg );
// Draw Top Border
ImageRectangle( $image,
($width/2)-(($width/2)*$bar),
0,
($width/2)+(($width/2)*$bar),
$height-$width,
$fg);
// Fill to %
ImageFilledRectangle( $image,
($width/2)-(($width/2)*$bar),
($height-$width) * (1-($current/$goal)),
($width/2)+(($width/2)*$bar),
$height-$width,
$fg );
// Add tic's
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);
}
// Add % over BULB
$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, $tx);
// 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"],
$HTTP_GET_VARS["Bgcolor01"],
$HTTP_GET_VARS["Bgcolor02"],
$HTTP_GET_VARS["Bgcolor03"],
$HTTP_GET_VARS["Fgcolor01"],
$HTTP_GET_VARS["Fgcolor02"],
$HTTP_GET_VARS["Fgcolor03"],
$HTTP_GET_VARS["Txcolor01"],
$HTTP_GET_VARS["Txcolor02"],
$HTTP_GET_VARS["Txcolor03"] );
?>
Vielen Dank!!
Lesezeichen