note 42735 added to function.imagefilledrectangle

From: Date: Thu, 27 May 2004 14:21:19 +0000
Subject: note 42735 added to function.imagefilledrectangle
Groups: php.notes 
Request: Send a blank email to php-notes+get-70189@lists.php.net to get a copy of this message
Added parameters to allow for different sizes, and doesn't assume that parameters are globally available. <?php // copied from the PHP manual: // http://us3.php.net/manual/en/function.imagefilledrectangle.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="makebar.php?rating=25.2&width=200&height=20" border="0"> // rating is a percentage from 0 to 100. function drawRating($rating) { $width = $_GET['width']; $height = $_GET['height']; if ($width == 0) { $width = 102; } if ($height == 0) { $height = 10; } $rating = $_GET['rating']; $ratingbar = (($rating/100)*$width)-2; $image = imagecreate($width,$height); //colors $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,$width-1,$height-1,$back); ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$fill); ImageRectangle($image,0,0,$width-1,$height-1,$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+42735 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42735&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42735&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#70189) next »