corz.org uses cookies to remember that you've seen this notice explaining that corz.org uses cookies, okay!
<?php
/*
corz fiery gradient bar graph..
designed with ampsig in mind..
https://corz.org/dev/php/workshop/bael+corz.dynamic.php.sig.page.php
feed it percent (0-100%), width, and height..
TADA!
;o)
(c) corz.org 2005
*/
header("Content-type: image/png");
if (isset($_GET['percent'])) {
bar_graph($_GET['percent'], 350, 12);
} else {
bar_graph(33,350,12);
}
/*
function bar graph($score (%), $width (px), $height(px) */
function bar_graph($score,$width,$height) {
$percent = $score.'%';
$bar = (($score/100) * $width)-2;
$img = imagecreate($width,$height);
$bg = imagecolorallocate($img,255,255,255); // white
$frame = imagecolorallocate($img,0,0,0); // black
imagerectangle($img,0,0,$width-1,$height-1,$frame);
for ($i=1; $i<=$bar; $i++) { // you could mess with the colors here..
$fill = imagecolorallocate($img,255-($i/255),255-(255*($i/255)),(255*($i/255))-255);
imagefilledrectangle($img,$i,1,$i,$height-2,$fill);
}
imagefilledrectangle($img,$bar+1,1,$bar+1,$height-2,$frame);
imagestring ($img, 1, $bar-imagefontwidth(1)*strlen($percent)-2,($height-imagefontheight(1))/2, $percent, $frame);
imagepng($img);
imagedestroy($img);
}
?>