★ wanayoo — archive 1999 http://php.net/manual/cs/function.imagefilledrectangle.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Graphics
Quick Reference
English version of this pageGerman version of this pageJapanese version of this page
Italian version of this pageFrench version of this pageHungarian version of this page
Spanish version of this pageDutch version of this pageBrazilian Portuguese version of this page
Korean version of this pageCzech version of this page
Graphics
* GetImageSize
* ImageArc
* ImageChar
* ImageCharUp
* ImageColorAllocate
* ImageColorDeAllocate
* ImageColorAt
* ImageColorClosest
* ImageColorExact
* ImageColorResolve
* ImageGammaCorrect
* ImageColorSet
* ImageColorsForIndex
* ImageColorsTotal
* ImageColorTransparent
* ImageCopy
* ImageCopyResized
* ImageCreate
* ImageCreateFromGIF
* ImageCreateFromJPEG
* ImageCreateFromPNG
* ImageCreateFromWBMP
* ImageCreateFromString
* ImageDashedLine
* ImageDestroy
* ImageFill
* ImageFilledPolygon
* ImageFilledRectangle
* ImageFillToBorder
* ImageFontHeight
* ImageFontWidth
* ImageGIF
* ImagePNG
* ImageJPEG
* ImageWBMP
* ImageInterlace
* ImageLine
* ImageLoadFont
* ImagePolygon
* ImagePSBBox
* ImagePSEncodeFont
* ImagePSFreeFont
* ImagePSLoadFont
* ImagePsExtendFont
* ImagePsSlantFont
* ImagePSText
* ImageRectangle
* ImageSetPixel
* ImageString
* ImageStringUp
* ImageSX
* ImageSY
* ImageTTFBBox
* ImageTTFText
* ImageTypes
* read_exif_data

  Thanks to:
 Chek.com
 easyDNS
 VA Linux Systems

  Related sites:
Apache
MySQL
PostgreSQL
Zend Tech.

  Community:
LinuxFund.org
OSDN
Manual: ImageFilledRectangle
View the source code for this pageSearch the site



Previous page
 ImageFilledPolygon
 Updated
Thu, 01 Mar 2001
ImageFillToBorder 
Next page


ImageFilledRectangle

(PHP 3, PHP 4 )

ImageFilledRectangle -- Draw a filled rectangle

Description

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

ImageFilledRectangle() creates a filled rectangle of color col() in image im 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: ImageFilledRectangle


domih@firstworld.net
06-Jul-2000 02:50am
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%2Fphp.net%2Fmanual%2Fcs%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%2Fphp.net%2Fmanual%2Fcs%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%2Fphp.net%2Fmanual%2Fcs%2F%26quot%3B.%2Fpngs%2Fcolor-pltt.png%26quot&y=1999 usemap="#color-pltt" border="0" />

Gray Palette


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



 About Notes


Previous page
 ImageFilledPolygon
 Updated
Thu, 01 Mar 2001
ImageFillToBorder 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.