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  

draw()

   
Examples  
float yPos = 0.0; 
 
void setup() { 
  size(200, 200); 
  framerate(30); 
} 
 
void draw() { 
  background(204); 
  yPos = yPos - 1.0; 
  if(yPos < 0) { 
    yPos = height; 
  } 
  line(0, yPos, width, yPos); 
} 
 


void setup() { 
  size(200, 200); 
} 
 
void draw() { } 
 
void mousePressed() { 
  line(mouseX, 10, mouseX, 90); 
} 
 

Description   Called directly after setup() and continuously executes the lines of code contained inside its block until the program is stopped or noLoop() is called. draw() is called automatically and should never be called explicitly. It should always be controlled with noLoop(), redraw() and loop(). After noLoop() stops the code in draw() from executing, redraw() causes the code inside draw() to execute once and loop() will causes the code inside draw() to execute continuously again. The number of times draw() executes in each second may be controlled with the delay() and framerate() functions. There can only be one draw() function for each sketch and draw() must exist if you want the code to run continuously or to process events such as mousePressed(). Sometimes, you might have an empty call to draw() in your program as shown in the above example.
   
Syntax  
draw() {
  statements
}
   
Parameters  
statements   A sequence of statements

   
Returns   None
   
Usage   Web & Application
   
Related   setup()
loop()
noLoop()
 
 






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








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