PHP GDI ile progress bar yapmak - PHP Webmaster bilgi bankası, knowledge base Webmaster Araçları

AnaSayfa > PHP > PHP GDI ile progress bar yapmak
Kategori: PHP
Gönderen: Admin
Tarih: 2009-05-29
Puan: 0   Puan:0 | Katılımcı:0 | Katılımcı : 0
Okunma: 4738
  
 
1 puan 2 puan 3 puan 4 puan 5 puan 6 puan 7 puan 8 puan 9 puan 10 puan

<?php
header("Content-type: image/jpeg");$current = isset($_GET['c']) ? $_GET['c'] : 50;
$start = isset($_GET['s']) ? $_GET['s'] : 0;
$end = isset($_GET['e']) ? $_GET['e'] : 100;
$p = isset($_GET['p']) ? $_GET['p'] : 0;

$pos = floor(2 * $current/($end - $start) * 100);

$im = imagecreate(200, 16); // width , height px
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$green = imagecolorallocate($im, 0, 204, 51);

imagesetthickness($im, 2);

imagerectangle($im, 0, 0, 200, 15, $white);
imagefilledrectangle($im, 0, 0, $pos, 16, $green);

if ($p) {
$text = ($pos / 2) . '%';
$font = 'arial.ttf';
$black = imagecolorallocate($im, 0, 0, 0);
imagettftext($im, 8, 0, 95, 12, $black, $font, $text);
}

imagejpeg($im);
imagedestroy($im);
?>
koddaki renklerleri fontları,boyutları kendinize göre uyarlayabilirsiniz.

diğer Php sayfanızdan çağırma yöntemi

<img src="bar.php?s=0&e=100&c=500&p=1" />

burada s başlama default 0
burada e bitiş default 100
burada c barda renklendirilecek alanın uzunluğu
burada p barda % olarak gösterilip gösterilemeyeceği
default 0 yok 0 var 1



Yorumlar
Henüz Kimse Yorum Yapmamış, ilk yorumu siz ekleyin!
Yorum Ekleme Aparatı
Yorum Eklemek için lütfen sol menuden giris yapınız..
Toplam 0 yorum listelendi.