<?php
if (isset ($_GET['max']))	$max = $_GET['max'];
if (isset ($_GET['val']))	$val = $_GET['val'];
if (isset ($_GET['col']))	$col = $_GET['col']; 

$width = 400;
$height = 10;
$lun = $val / $max * $width;
$im = imagecreatetruecolor($width, $height);

$white = imagecolorallocate($im, 255, 255, 255);
imagecolortransparent($im, $white);

$color['red']  = imagecolorallocate($im, 255, 0, 0);
$color['blue'] = imagecolorallocate($im, 0, 0, 255);

imagefilledrectangle($im, 0, 0, $width, $height, $white);
imagefilledrectangle($im, 0, 0, $lun, $height, $color[$col]);

header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
?>
