Login Register Wishes Forum About
Language Reference » Drawing functions » drawLine
Help topics
Latest updates
4600d  replaceImageMapTitle
4600d  replaceImageMapValues
4600d  createFunctionSerie
4600d  setAbsicssaPosition
4600d  negateValues
  Download as PDF
  Print this page
  Share this page
  Create an account
  Feed the updates!
Google AdSense
drawLine - Drawing lines

This function allows you to draw aliased lines on your pictures. It is possible to tune the rendering by playing with the $Format array. To learn more about this please read the Format array guide. Lines like all simple drawing functions are supporting anti-alias and shadows.

This function is also used internally by a lot of drawing functions.

Calling this function
Where :

X1,Y1 are the start coordinate of the line.
X2,Y2 are the end coordinate of the line.
Format is an array containing the drawing parameters of the arrow.

Customisation array - Tune up your line!

It is possible to customize the line rendering by playing with this array. Providing a detailled configuration is not mandatory, by default the line will be drawn black with no transparency.

The line color can be set with R, G, B.
The alpha transparency factor can be set with Alpha.
You can draw dashed lines using the Ticks parameter.
You can specify the weight of the line with the Weight parameter.

Sample script

 /* Enable shadow support */
 /* pChart library inclusions */

 /* Create the pChart object */
 $myPicture = new pImage(700,230);

 /* Draw the background */
 $Settings = array("R"=>170, "G"=>183, "B"=>87, "Dash"=>1, "DashR"=>190, "DashG"=>203, "DashB"=>107);

 /* Overlay with a gradient */
 $Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);

 /* Draw the picture border */ 
 /* Write the picture title */ 
 $myPicture->drawText(10,13,"drawLine() - Basis",array("R"=>255,"G"=>255,"B"=>255));

 /* Turn on shadow computing */ 

 /* Draw some lines */ 

 /* Draw an horizontal dashed line with extra weight */

 /* Another example of extra weight */

 /* Render the picture (choose the best way) */

This will draw 25 lines with random colors. As the shadow support is enabled on line 2, the line will be surrounded by a small (+2,+2) shadow.
Last updated on 12/25/2010 
by Jean-Damien 
Linked resources
Community comments
  No comments have been posted yet.
© Copyrights
Components used on this web site : Famfamfam icons has been made by Mark James, Rounded corners lite has been coded by Cameron Cooke and Tim Hutchison, SyntaxHighlighter has been written by Alex Gorbatchev. pChart and this web site have been created by Jean-Damien POGOLOTTI. This documentation contains 185 pages and 56 comments. 415 users have registered. This page has been rendered in 0,02 seconds. Wiki revision 1.37.