FAQ
 
 
Cover  \ Exhibition  \ Learning  \ Reference  \ Download  \ Discourse   
      Language \ Environment \ Libraries \ Comparison
 
   
   
Abridged (A-Z) \ Complete (A-Z)  
   
  Reference for Processing (BETA) version 91+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.  
Name  

line()

   
Examples  
line(30, 20, 85, 75); 
line(30, 20, 85, 20); 
stroke(126); 
line(85, 20, 85, 75); 
stroke(255); 
line(85, 75, 30, 75); 
// Drawing lines in 3D requires P3D 
// or OPENGL as a parameter to size() 
size(100, 100, P3D); 
line(30, 20, 0, 85, 20, 15); 
stroke(126); 
line(85, 20, 15, 85, 75, 0); 
stroke(255); 
line(85, 75, 0, 30, 75, -50); 
Description   Draws a line (a direct path between two points) to the screen. The version of line() with four parameters draws the line in 2D. To color a line, use the stroke() function. A line cannot be filled, therefore the fill() method will not affect the color of a line. 2D lines are drawn with a width of one pixel by default, but this can be changed with the strokeWeight() function. The version with six parameters allows the line to be placed anywhere within XYZ space. Drawing this shape in 3D using the z parameter requires the P3D or OPENGL parameter in combination with size as shown in the above example.
   
Syntax  
line(x1, y1, x2, y2); 
line(x1, y1, z1, x2, y2, z2); 
   
Parameters  
x1   int or float: x-coordinate of the first point

y1   int or float: y-coordinate of the first point

z1   int or float: z-coordinate of the first point

x2   int or float: x-coordinate of the second point

y2   int or float: y-coordinate of the second point

z2   int or float: z-coordinate of the second point

   
Returns   None
   
Usage   Web & Application
   
Related   strokeWeight()
strokeJoin()
strokeCap()
beginShape()
 
 






   
 
Updated: Fri Jul 15 16:35:44 PDT 2005
 
 








Creative Commons License
 
  Processing is an open project initiated by Ben Fry and Casey Reas  
  © Info