★ wanayoo — archive 1999 http://www.php.net/manual/de/function.imagefilledrectangle.phpNouvelle recherche | Portail wanayoo
PHP
Friday, June 29, 2001  
downloads | documentation | faq | support | reporting bugs | links 

search for in the  


previousImageFilledPolygon
ImageFillToBordernext

Last updated: Fri, 22 Jun 2001
view this page in English | Brazilian Portuguese | Czech | Dutch | French | German | Hungarian | Italian | Japanese | Korean | Spanish | Plain HTML

ImageFilledRectangle

(PHP 3, PHP 4 )

ImageFilledRectangle -- Zeichnet ein gefülltes Rechteck

Beschreibung:

int imagefilledrectangle (int im, int x1, int y1, int x2, int y2, int col)

ImageFilledRectangle() erzeugt ein mit der Farbe col() gefülltes Rechteck innerhalb des Bildes im. Die obere linke Eck-Koordinate wird mittels x1 und y1, die untere rechte Eck-Koordinate mittels x2 und y2 definiert. 0, 0 ist dabei die linke obere Ecke des Bildes im.

User Contributed Notes
ImageFilledRectangle
add a note about notes
domih@firstworld.net
06-Jul-2000 02:50

The following example creates a clickable color and gray palettes.
Note: you must have a pngs directory at the document root level.
<script language="JavaScript">

 var coRed=127;coGreen=127;coBlue=255; // Original color
 
var Hex=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");

function rgb2hex(cRed,cGreen,cBlue){
cColor=Hex[Math.floor(cRed/16)]+Hex[cRed%16]+Hex[Math.floor(cGreen/16)]+Hex[cGreen%16]+Hex[Math.floor(cBlue/16)]+Hex[cBlue%16];
return cColor;
}
 
function ShowColor(cColor){
with (document){
 // Do whatever you have to do here
  }
 };
 
 function plttClick(cRed,cGreen,cBlue){
   // Change the color
  coRed=cRed;
  coGreen=cGreen;
  coBlue=cBlue;
   // Replace the following line with your own code
  alert(cRed+','+cGreen+','+cBlue)
 }
 
 function plttOver(cRed,cGreen,cBlue){
  ShowColor(rgb2hex(cRed,cGreen,cBlue));
   // Add you own code here
  self.status='Red: '+cRed+' / Green: '+cGreen+' / Blue: '+cBlue;
 }
 
 function plttOut(){
   // Restore original color
  ShowColor(rgb2hex(coRed,coGreen,coBlue));
   // Add you own code here
  self.status='Click on the color of your choice';
 }

</script>

<?php
  // -- Color Palette -
  
  $arColors[]=0;  // 0x00
  $arColors[]=51;  // 0x33
  $arColors[]=102; // 0x66
  $arColors[]=153; // 0x99
  $arColors[]=204; // 0xCC
  $arColors[]=255; // 0xFF
  $plttSize=Count($arColors);
  $cellWidth=12;
  $pic=ImageCreate($plttSize*$plttSize*($cellWidth+1),$plttSize*($cellWidth+1));
  ImageFilledRectangle($pic,0,0,$plttSize*$plttSize*($cellWidth+1),$plttSize*($cellWidth+1),ImageColorAllocate($pic,255,255,255));
  $cTop=0;
  print("<map name=\"color-pltt\">\n");
  for($cRed=0;$cRed<$plttSize;$cRed++){
   $cLeft=0;
   for($cGreen=0;$cGreen<$plttSize;$cGreen++){
    for($cBlue=0;$cBlue<$plttSize;$cBlue++){
     ImageFilledRectangle($pic,$cLeft,$cTop,$cLeft+$cellWidth-1,$cTop+$cellWidth-1,ImageColorAllocate($pic,$arColors[$cRed],$arColors[$cGreen],$arColors[$cBlue]));
     print("<area shape=\"rect\" coords=\"".$cLeft.",".$cTop.",".($cLeft+$cellWidth-1).",".($cTop+$cellWidth-1)."\" href=/old?u=http%3A%2F%2Fwww.php.net%2Fmanual%2Fde%2F%5C%26quot%3Bjavascript%3AplttClick%28%26quot%3B.%24arColors%5B%24cRed%5D.%26quot%3B%2C%26quot%3B.%24arColors%5B%24cGreen%5D.%26quot%3B%2C%26quot%3B.%24arColors%5B%24cBlue%5D.%26quot%3B%29%5C%26quot%3B&y=1999 onMouseOver=\"plttOver(".$arColors[$cRed].",".$arColors[$cGreen].",".$arColors[$cBlue].");return true;\" onMouseOut=\"plttOut();return true;\" />\n");
     $cLeft=$cLeft+$cellWidth+1;
    }
   }
   $cTop=$cTop+$cellWidth+1;
  }
  print("</map>\n");
  ImagePNG($pic,"./pngs/color-pltt.png");
  ImageDestroy($pic);
  
  // -- Gray Palette -
  
  $plttSize=32; // Must be a divider of 256
  $cellWidth=12; // Must be >0
  $pic=ImageCreate(($plttSize+1)*($cellWidth+1),$cellWidth+1);
  ImageFilledRectangle($pic,0,0,$plttSize*($cellWidth+1),$cellWidth+1,ImageColorAllocate($pic,255,255,255));
  $incRGB=floor(256/$plttSize);
  $cLeft=0;
  $cTop=0;
  print("<map name=\"gray-pltt\">\n");
  for($cGray=0;$cGray<($plttSize+1);$cGray++){
   if($cGray==0){
    $grayRGB=0;
   } else {
    $grayRGB=($cGray*$incRGB)-1;
   }
   ImageFilledRectangle($pic,$cLeft,$cTop,$cLeft+$cellWidth-1,$cTop+$cellWidth-1,ImageColorAllocate($pic,$grayRGB,$grayRGB,$grayRGB));
   print("<area shape=\"rect\" coords=\"".$cLeft.",".$cTop.",".($cLeft+$cellWidth-1).",".($cTop+$cellWidth-1)."\" href=/old?u=http%3A%2F%2Fwww.php.net%2Fmanual%2Fde%2F%5C%26quot%3Bjavascript%3AplttClick%28%26quot%3B.%24grayRGB.%26quot%3B%2C%26quot%3B.%24grayRGB.%26quot%3B%2C%26quot%3B.%24grayRGB.%26quot%3B%29%5C%26quot%3B&y=1999 onMouseOver=\"plttOver(".$grayRGB.",".$grayRGB.",".$grayRGB.");return true;\" onMouseOut=\"plttOut();return true;\" />\n");
   $cLeft=$cLeft+$cellWidth+1;
  }
  print("</map>\n");
  ImagePNG($pic,"./pngs/gray-pltt.png");
  ImageDestroy($pic);
?>
 

Color Palette


<img src=/old?u=http%3A%2F%2Fwww.php.net%2Fmanual%2Fde%2F%26quot%3B.%2Fpngs%2Fcolor-pltt.png%26quot&y=1999 usemap="#color-pltt" border="0" />

Gray Palette


<img src=/old?u=http%3A%2F%2Fwww.php.net%2Fmanual%2Fde%2F%26quot%3B.%2Fpngs%2Fgray-pltt.png%26quot&y=1999 usemap="#gray-pltt" border="0" />

add a note about notes


previousImageFilledPolygon
ImageFillToBordernext

Last updated: Fri, 22 Jun 2001

show source | credits | stats | mirror sites:  

Copyright © 2001 The PHP Group
All rights reserved.
This mirror generously provided by: chek.com
Last updated: Fri Jun 29 21:45:50 2001 EDT