Portrety Uliczne Nieznajomych - zobacz wyjątkową galerię portretów z warszawskich ulic
ZALOGUJ SIĘ
login:
hasło:
przypomnij hasło
załóż konto użytkownika
(i zobacz kilka porad gratis)
   
WYSZUKIWARKA I DZIAŁY
całe porady  tytuły
zaznacz działy do przeszukania
(brak wyboru = wszystkie działy)
PHP
MySQL >
PostgreSQL
SQLite
Perl
Java
XML
XSLT
XPath
WML
SVG
RegExp
Wyszukiwarki
Ochrona
VBScript
Google Plus
XHTML/CSS
JavaScript
Grafika
Flash
Photoshop
Windows
Linux
Bash
Apache
Procmail
E-biznes
Explorer
Opera
Firefox
Inne porady
   
KURSY, DOKUMENTACJE
Własne:
XHTML/CSS
JavaScript
ActionScript
WML, RSS, SSI
Pozostałe:
PHP
MySQL
Java API
więcej...
   
użytkowników online: 40
W CZYM MOGĘ POMÓC?


   
OPINIE UŻYTKOWNIKÓW
Po wysłaniu do Dariusza problemu jeszcze nie opisanego w poradach, odpowiedź pojawia się na stronach już po 24 godzinach. To jedna z najważniejszych zalet serwisu! Za około 100 złotych rocznie mam profesjonalnego i doświadczonego konsultanta od technologii internetowych! Polecam serwis z poradami każdemu webmasterowi, niezależnie od stażu pracy i umiejętności.

Paweł Kowalski
grupa hiperMEDIA.pl

   
GALERIA FOTOGRAFII
   
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net

[Spis] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [X] [W] [Z]

imagefilledrectangle

(PHP 3, PHP 4, PHP 5)

imagefilledrectangle -- Draw a filled rectangle

Description

int imagefilledrectangle ( resource image, int x1, int y1, int x2, int y2, int color )

imagefilledrectangle() creates a filled rectangle of color color in image image starting at upper left coordinates x1, y1 and ending at bottom right coordinates x2, y2. 0, 0 is the top left corner of the image.




User Contributed Notes

TMG
01-Feb-2006 03:18

you can also add the rating til to the image


me [a.t.] forestfactory [d.o.t.] de
13-Oct-2005 01:44

As of PHP 5, it seems to be no longer necessary to draw the rectangle from the upper left to the lower right corner. This led me into big trouble porting a script developed under PHP 5 to PHP 4.


michal dot kocarek at seznam dot cz
30-May-2004 10:18

If you want to draw a rectangle with rounded corners, you can use this simple function...
Rectangle starts at x1y1 and ends at x2y2. $radius defines radius of circled corner.

<?

function ImageRectangleWithRoundedCorners(&$im, $x1, $y1, $x2, $y2, $radius, $color) {
// draw rectangle without corners
imagefilledrectangle($im, $x1+$radius, $y1, $x2-$radius, $y2, $color);
imagefilledrectangle($im, $x1, $y1+$radius, $x2, $y2-$radius, $color);
// draw circled corners
imagefilledellipse($im, $x1+$radius, $y1+$radius, $radius*2, $radius*2, $color);
imagefilledellipse($im, $x2-$radius, $y1+$radius, $radius*2, $radius*2, $color);
imagefilledellipse($im, $x1+$radius, $y2-$radius, $radius*2, $radius*2, $color);
imagefilledellipse($im, $x2-$radius, $y2-$radius, $radius*2, $radius*2, $color);
}

?>


sdonie at lgc dot com
27-May-2004 07:19

I made some simple additions to the 'ratings bar' example above to allow for different sizes. It also doesn't assume that global GET variables is turned on, and explicitly looks for parameters it needs.

----
<?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);

?>


booga
18-Jan-2004 02:48

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);

?>


ivank at 2xtreme dot net
31-Mar-2002 01:34

As stated above, it needs to go from the top left corner to the bottom right corner. Just use this to flip it if neccessary:

// flip them if neccessary (x3, y3 are temp vars)
if($x1 > $x2) { $x3 = $x2; $x2 = $x1; $x1 = $x3; }
if($y1 > $y2) { $y3 = $y2; $y2 = $y1; $y1 = $y3; }
ImageFilledRectangle($im, $x1, $y1, $x2, $y2, $color);


saramg at uclink dot berkeley dot edu
30-Nov-2001 04:42

Important quirk to note:

While imagerectangle will allow you to use a different order of your coordinates (such as bottom-left to upper-right), imagefilledrectangle will only work correctly if you use top-left to bottom-right as indicated in the docs.


 

 
  © 1996-2012 & Reporter.plmiejscao serwisieabonamentwarunki korzystaniaRSSkontakt