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

PHP Home Page

Manual Table of Contents
Up to Graphics
Quick Reference
German version of this pageJapanese version of this pageItalian 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
* ImageTypes
* read_exif_data
Manual: ImageLine
View the source code for this pageSearch the site



Previous page
 ImageInterlace
 Updated
Sat, 12 Aug 2000
ImageLoadFont 
Next page


ImageLine

(unknown)

ImageLine -- Draw a line

Description

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

ImageLine() draws a line from x1, y1 to x2, y2 (top left is 0, 0) in image im of color col.

See also ImageCreate() and ImageColorAllocate().


User Contributed Notes: ImageLine


moracchini@publicis-technology.com
03-Jan-2000 11:00
I try to draw graphics wtih php' functions.
I arrive to create an image gif. But i want to draw in : draw lines and rectangles and write in.
My code is :
<PRE>
<HTML>
<BODY>
&lt;?
header("Content-type: image/gif");
//phpinfo();
$im0= imagecreate(1000, 1000);
imagegif($im0, "test0.gif");

$col1 ="12,20,20";
$im1 = imagerectangle($im0, 5, 100, 200, 200, $col1);
imagegif($im1, "test1.gif");

$col2 ="122,200,250";
$im2 = imageline($im0, 5, 200, 200, 200, $col2);
imagegif($im2, "test2.gif");
?>

<IMG SRC=/old?u=http%3A%2F%2Fwww.php.net%2Fmanual%2F%26quot%3Btest1.gif%26quot%3B%26gt%3B&y=1999
<IMG SRC=/old?u=http%3A%2F%2Fwww.php.net%2Fmanual%2F%26quot%3Btest2.gif%26quot%3B%26gt%3B&y=1999
</BODY>
</HTML>
</PRE>

Thank you for your help!



bolke@xs4all.nl
16-Mar-2000 04:23
forget about your html tags. ImageGif immediatly returns the image to the browser. So for each image you create you have to call a seperate function AS AN IMAGE.


maurice@klikit.nl
01-May-2000 07:23
Another thing,
the returning value of imageline is not an image itself, it is an returning integer, so you don't have to work with $im1, $im2, just use $im0 to make it work.
(Quote: ImageLine draws a line from x1,y1 to x2,y2 (top left is 0,0) in image im of color col.)



domih@firstworld.net
06-Jul-2000 02:20
<br />The following example draws the sin and cos curves.
<br />
<br />Note: you must have a pngs directory at the document root level.
<br />
<pre>
<br />&lt;?php
<br /> $picWidth=360*2;
<br /> $picHeight=200;
<br /> $pic=ImageCreate($picWidth+1,$picHeight+1);
<br /> $cWhite=ImageColorAllocate($pic,255,255,255);
<br /> ImageFilledRectangle($pic,0,0,$picWidth+1,$picHeight+1,$cWhite);
<br /> $cRed=ImageColorAllocate($pic,255,0,0);
<br /> $cBlue=ImageColorAllocate($pic,0,0,255);
<br /> $curX=0;
<br /> $curY=$picHeight;
<br /> for($pt=0;$pt<$picWidth;$pt++){
<br /> $newX=$curX+1;
<br /> $newY=($picHeight/2)+(cos(deg2rad($newX))*($picHeight/2));
<br /> ImageLine($pic,$curX,$curY,$newX,$newY,$cRed);
<br /> $curX=$newX;
<br /> $curY=$newY;
<br /> }
<br /> $curX=0;
<br /> $curY=$picHeight/2;
<br /> for($pt=0;$pt<$picWidth;$pt++){
<br /> $newX=$curX+1;
<br /> $newY=($picHeight/2)+(sin(deg2rad($newX))*($picHeight/2));
<br /> ImageLine($pic,$curX,$curY,$newX,$newY,$cBlue);
<br /> $curX=$newX;
<br /> $curY=$newY;
<br /> }
<br /> $cBlack=ImageColorAllocate($pic,0,0,0);
<br /> ImageLine($pic,0,0,0,$picHeight,$cBlack);
<br /> ImageLine($pic,0,$picHeight/2,$picWidth,$picHeight/2,$cBlack);
<br /> ImagePNG($pic,"./pngs/graph.png");
<br /> ImageDestroy($pic);
<br />?&gt;
<br />&lt;img src=/old?u=http%3A%2F%2Fwww.php.net%2Fmanual%2F%26quot%3B.%2Fpngs%2Fgraph.png%26quot&y=1999 border="0" /&gt;
</pre>



rolf.winterscheidt@it-mannesmann.de
24-Jul-2000 02:08
Last example doesn't work. What's about $pt? The FOR isn't right...



 About Notes


Previous page
 ImageInterlace
 Updated
Sat, 12 Aug 2000
ImageLoadFont 
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.