note 39123 added to function.imagefilledrectangle
| From: | booga at rn2 dot php dot net | Date: | Sat, 17 Jan 2004 22:48:05 +0000 |
| Subject: | note 39123 added to function.imagefilledrectangle | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-63756@lists.php.net to get a copy of this message | ||
a simple way of using imagerectangle to create a percentage bar
<?php
//this needs to reside in its own php page
//you can include that php page in your html as you would an image:
//<IMG SRC="ratingpng.php?rating=25.2" border="0">
function drawRating($rating) {
$image = imagecreate(102,10);
$back = ImageColorAllocate($image,255,255,255);
$border = ImageColorAllocate($image,0,0,0);
$red = ImageColorAllocate($image,255,60,75);
$fill = ImageColorAllocate($image,44,81,150);
ImageFilledRectangle($image,0,0,101,9,$back);
ImageFilledRectangle($image,1,1,$rating,9,$fill);
ImageRectangle($image,0,0,101,9,$border);
imagePNG($image);
imagedestroy($image);
}
Header("Content-type: image/png");
drawRating($rating);
?>
----
Manual Page -- http://www.php.net/manual/en/function.imagefilledrectangle.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39123
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39123&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39123&report=yes
Search -- http://master.php.net/manage/user-notes.php