Er der en som kan omskive denne kode så der også kommer en tekst i midten af "ratingbar"en?
<?php
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);
?>
Her skulle den gerne gøre det...
Husk at rette den $minus_pxs, du kan måske lave et eller andet smart så den selv regner ud, hvor mange pixels den skal minuse...
<?php
function drawRating()
{
$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);
// indsat en grøn farve...
$gron = ImageColorAllocate($image, 0, 255, 0);
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);
// Ret denne til, i forhold til hvor meget teksten fylder...
$minus_pxs = 15;
// indskriv tekst..., bare vælg en anden farve hvis du vil...
ImageString($image, 1, ($width/2)-$minus_pxs, 1, "Hejsa!", $gron);
imagePNG($image);
imagedestroy($image);
}
header("Content-type: image/png");
drawRating();
?>
Indlæg senest redigeret d. 25.04.2006 20:25 af Bruger #6791