Chapter 3: Example 3-4: Drawing a Continuous Line
// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com
// Example 3-4: Drawing a continuous line
void setup() {
size(200, 200);
background(255);
smooth();
}
void draw() {
stroke(0);
// Draw a line from previous mouse location to current mouse location.
line(pmouseX, pmouseY, mouseX, mouseY);
}









What would be the easiest way to get the line to start from a default point that was different from (0,0)?
Comment by Rupert — January 3, 2010 @ 4:39 pm
Processing always initializes the mouse location at 0,0 for the first frame. You could check and make sure the values are not 0,0 before you draw:
if (!(pmouseX == 0 && pmouseY == 0)) { line(pmouseX, pmouseY, mouseX, mouseY); }And even use your own variable to set up another starting point for when the values are 0,0.
Comment by Daniel Shiffman — January 4, 2010 @ 12:19 pm