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

PHP Home Page

Manual Table of Contents
Up to Gráficos
Quick Reference
Gráficos
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 page
* GetImageSize
* ImageArc
* ImageChar
* ImageCharUp
* ImageColorAllocate
* ImageColorAt
* ImageColorClosest
* ImageColorExact
* ImageColorResolve
* ImageColorSet
* ImageColorsForIndex
* ImageColorsTotal
* ImageColorTransparent
* ImageCopyResized
* ImageCreate
* ImageCreateFromGif
* ImageDashedLine
* ImageDestroy
* ImageFill
* ImageFilledPolygon
* ImageFilledRectangle
* ImageFillToBorder
* ImageFontHeight
* ImageFontWidth
* ImageGif
* ImageInterlace
* ImageLine
* ImageLoadFont
* ImagePolygon
* ImagePSBBox
* ImagePSEncodeFont
* ImagePSFreeFont
* ImagePSLoadFont
* ImagePSText
* ImageRectangle
* ImageSetPixel
* ImageString
* ImageStringUp
* ImageSX
* ImageSY
* ImageTTFBBox
* ImageTTFText

  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, 14 Sep 2000
ImageFillToBorder 
Next page


ImageFilledRectangle

(PHP3 <= 3.0.16, PHP4 )

ImageFilledRectangle -- dibuja un rectángulo relleno

Descripción

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

ImageFilledRectangle crea un rectángulo relleno con color col en la imagen im comenzando con las coordenadas superiores izquierdas x1, y1 y finalizando en las coordenadas inferiores derechas x2, y2. 0,0 es la esquina superior izquierda de la imagen.


User Contributed Notes: ImageFilledRectangle


domih@firstworld.net
06-Jul-2000 02:50
<br />The following example creates a clickable color and gray palettes.
<br />
<br />Note: you must have a pngs directory at the document root level.
<br />
<tt>
<br />&lt;script language="JavaScript"&gt;
<br />
<br />&nbsp;var&nbsp;coRed=127;coGreen=127;coBlue=255; // Original color
<br />&nbsp;
<br />&nbsp;var&nbsp;Hex=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
<br />&nbsp;
<br />&nbsp;function rgb2hex(cRed,cGreen,cBlue){
<br />&nbsp;&nbsp;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];
<br />&nbsp;&nbsp;return cColor;
<br />&nbsp;}
<br />&nbsp;
<br />&nbsp;function ShowColor(cColor){
<br />&nbsp;&nbsp;with (document){
<br />&nbsp;&nbsp;&nbsp;// Do whatever you have to do here
<br />&nbsp;&nbsp;}
<br />&nbsp;};
<br />&nbsp;
<br />&nbsp;function plttClick(cRed,cGreen,cBlue){
<br />&nbsp;&nbsp;&nbsp;// Change the color
<br />&nbsp;&nbsp;coRed=cRed;
<br />&nbsp;&nbsp;coGreen=cGreen;
<br />&nbsp;&nbsp;coBlue=cBlue;
<br />&nbsp;&nbsp;&nbsp;// Replace the following line with your own code
<br />&nbsp;&nbsp;alert(cRed+','+cGreen+','+cBlue)
<br />&nbsp;}
<br />&nbsp;
<br />&nbsp;function plttOver(cRed,cGreen,cBlue){
<br />&nbsp;&nbsp;ShowColor(rgb2hex(cRed,cGreen,cBlue));
<br />&nbsp;&nbsp;&nbsp;// Add you own code here
<br />&nbsp;&nbsp;self.status='Red: '+cRed+' / Green: '+cGreen+' / Blue: '+cBlue;
<br />&nbsp;}
<br />&nbsp;
<br />&nbsp;function plttOut(){
<br />&nbsp;&nbsp;&nbsp;// Restore original color
<br />&nbsp;&nbsp;ShowColor(rgb2hex(coRed,coGreen,coBlue));
<br />&nbsp;&nbsp;&nbsp;// Add you own code here
<br />&nbsp;&nbsp;self.status='Click on the color of your choice';
<br />&nbsp;}
<br />
<br />&lt;/script&gt;
<br />&nbsp;
<br />&nbsp;
<br />&lt;?php
<br />
<br />&nbsp;&nbsp;// -- Color Palette -
<br />&nbsp;&nbsp;
<br />&nbsp;&nbsp;$arColors[]=0;&nbsp;&nbsp;// 0x00
<br />&nbsp;&nbsp;$arColors[]=51;&nbsp;&nbsp;// 0x33
<br />&nbsp;&nbsp;$arColors[]=102;&nbsp;// 0x66
<br />&nbsp;&nbsp;$arColors[]=153;&nbsp;// 0x99
<br />&nbsp;&nbsp;$arColors[]=204;&nbsp;// 0xCC
<br />&nbsp;&nbsp;$arColors[]=255;&nbsp;// 0xFF
<br />&nbsp;&nbsp;$plttSize=Count($arColors);
<br />&nbsp;&nbsp;$cellWidth=12;
<br />&nbsp;&nbsp;$pic=ImageCreate($plttSize*$plttSize*($cellWidth+1),$plttSize*($cellWidth+1));
<br />&nbsp;&nbsp;ImageFilledRectangle($pic,0,0,$plttSize*$plttSize*($cellWidth+1),$plttSize*($cellWidth+1),ImageColorAllocate($pic,255,255,255));
<br />&nbsp;&nbsp;$cTop=0;
<br />&nbsp;&nbsp;print("&lt;map name=\"color-pltt\"&gt;\n");
<br />&nbsp;&nbsp;for($cRed=0;$cRed&lt;$plttSize;$cRed++){
<br />&nbsp;&nbsp;&nbsp;$cLeft=0;
<br />&nbsp;&nbsp;&nbsp;for($cGreen=0;$cGreen&lt;$plttSize;$cGreen++){
<br />&nbsp;&nbsp;&nbsp;&nbsp;for($cBlue=0;$cBlue&lt;$plttSize;$cBlue++){
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ImageFilledRectangle($pic,$cLeft,$cTop,$cLeft+$cellWidth-1,$cTop+$cellWidth-1,ImageColorAllocate($pic,$arColors[$cRed],$arColors[$cGreen],$arColors[$cBlue]));
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print("&lt;area shape=\"rect\" coords=\"".$cLeft.",".$cTop.",".($cLeft+$cellWidth-1).",".($cTop+$cellWidth-1)."\" href=/old?u=http%3A%2F%2Fphp.net%2Fmanual%2Fes%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;\" /&gt;\n");
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$cLeft=$cLeft+$cellWidth+1;
<br />&nbsp;&nbsp;&nbsp;&nbsp;}
<br />&nbsp;&nbsp;&nbsp;}
<br />&nbsp;&nbsp;&nbsp;$cTop=$cTop+$cellWidth+1;
<br />&nbsp;&nbsp;}
<br />&nbsp;&nbsp;print("&lt;/map&gt;\n");
<br />&nbsp;&nbsp;ImagePNG($pic,"./pngs/color-pltt.png");
<br />&nbsp;&nbsp;ImageDestroy($pic);
<br />&nbsp;&nbsp;
<br />&nbsp;&nbsp;// -- Gray Palette -
<br />&nbsp;&nbsp;
<br />&nbsp;&nbsp;$plttSize=32; // Must be a divider of 256
<br />&nbsp;&nbsp;$cellWidth=12; // Must be &gt;0
<br />&nbsp;&nbsp;$pic=ImageCreate(($plttSize+1)*($cellWidth+1),$cellWidth+1);
<br />&nbsp;&nbsp;ImageFilledRectangle($pic,0,0,$plttSize*($cellWidth+1),$cellWidth+1,ImageColorAllocate($pic,255,255,255));
<br />&nbsp;&nbsp;$incRGB=floor(256/$plttSize);
<br />&nbsp;&nbsp;$cLeft=0;
<br />&nbsp;&nbsp;$cTop=0;
<br />&nbsp;&nbsp;print("&lt;map name=\"gray-pltt\"&gt;\n");
<br />&nbsp;&nbsp;for($cGray=0;$cGray&lt;($plttSize+1);$cGray++){
<br />&nbsp;&nbsp;&nbsp;if($cGray==0){
<br />&nbsp;&nbsp;&nbsp;&nbsp;$grayRGB=0;
<br />&nbsp;&nbsp;&nbsp;} else {
<br />&nbsp;&nbsp;&nbsp;&nbsp;$grayRGB=($cGray*$incRGB)-1;
<br />&nbsp;&nbsp;&nbsp;}
<br />&nbsp;&nbsp;&nbsp;ImageFilledRectangle($pic,$cLeft,$cTop,$cLeft+$cellWidth-1,$cTop+$cellWidth-1,ImageColorAllocate($pic,$grayRGB,$grayRGB,$grayRGB));
<br />&nbsp;&nbsp;&nbsp;print("&lt;area shape=\"rect\" coords=\"".$cLeft.",".$cTop.",".($cLeft+$cellWidth-1).",".($cTop+$cellWidth-1)."\" href=/old?u=http%3A%2F%2Fphp.net%2Fmanual%2Fes%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;\" /&gt;\n");
<br />&nbsp;&nbsp;&nbsp;$cLeft=$cLeft+$cellWidth+1;
<br />&nbsp;&nbsp;}
<br />&nbsp;&nbsp;print("&lt;/map&gt;\n");
<br />&nbsp;&nbsp;ImagePNG($pic,"./pngs/gray-pltt.png");
<br />&nbsp;&nbsp;ImageDestroy($pic);
<br />?&gt;
<br />&nbsp;&nbsp;
<br />&lt;p&gt;Color Palette&lt;/p&gt;
<br />&lt;img src=/old?u=http%3A%2F%2Fphp.net%2Fmanual%2Fes%2F%26quot%3B.%2Fpngs%2Fcolor-pltt.png%26quot&y=1999 usemap="#color-pltt" border="0" /&gt;
<br />&lt;p&gt;Gray Palette&lt;/p&gt;
<br />&lt;img src=/old?u=http%3A%2F%2Fphp.net%2Fmanual%2Fes%2F%26quot%3B.%2Fpngs%2Fgray-pltt.png%26quot&y=1999 usemap="#gray-pltt" border="0" /&gt;
<br /></tt>
<br />



 About Notes


Previous page
 ImageFilledPolygon
 Updated
Thu, 14 Sep 2000
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.