★ wanayoo — archive 1999 http://www.php.net/manual/it/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 pageFrench version of this pageHungarian 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
* ImageDashedLine
* ImageDestroy
* ImageFill
* ImageFilledPolygon
* ImageFilledRectangle
* ImageFillToBorder
* ImageFontHeight
* ImageFontWidth
* ImageGIF
* ImagePng
* ImageJPEG
* ImageInterlace
* ImageLine
* ImageLoadFont
* ImagePolygon
* ImagePSBBox
* ImagePSEncodeFont
* ImagePSFreeFont
* ImagePSLoadFont
* ImagePsExtendFont
* ImagePsSlantFont
* ImagePSText
* ImageRectangle
* ImageSetPixel
* ImageString
* ImageStringUp
* ImageSX
* ImageSY
* ImageTTFBBox
* ImageTTFText
Manual: ImageFilledRectangle
View the source code for this pageSearch the site



Previous page
 ImageFilledPolygon
 Updated
Sun, 06 Aug 2000
ImageFillToBorder 
Next page


ImageFilledRectangle

(unknown)

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: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%2Fwww.php.net%2Fmanual%2Fit%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%2Fwww.php.net%2Fmanual%2Fit%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%2Fwww.php.net%2Fmanual%2Fit%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%2Fwww.php.net%2Fmanual%2Fit%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
Sun, 06 Aug 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.