<?php

// a simple modification to the gradient code, to get stripes

header("Content-type: image/png");
if (
$percent = @$_GET['percent']) { bar_graph($percent,350,14); } else { bar_graph(50,350,14); }

/*
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..
    
        
if ($i % 10 <= 4 ) {
            
$fill = imagecolorallocate($img,255-($i/255),255-(255*($i/255)),(255*($i/255))-255);
        } else {
            
$fill = imagecolorallocate($img,0,0,0); // black
        
}
          
imagefilledrectangle($img,$i,1,$i,$height-2,$fill);
    }
    
    
imagefilledrectangle($img,$bar+1,1,$bar+1,$height-2,$frame);
    
imagestring ($img, 2, $bar-imagefontwidth(2)*strlen($percent)-2,($height-imagefontheight(2))/2, $percent, $bg);
    
    
imagepng($img);
    
imagedestroy($img);
}
back to the source menu
test