Line first coordinate is allways (0,0)

Hey All,

I would like to draw some lines:

void setup() {
  size(600, 600);
  noLoop();
}
void draw(){
  line(pmouseX, pmouseY, mouseX, mouseY);
}
void mouseClicked() {
  redraw();
}

My problem is, that the first line always starts from the 0,0. Is there any solution to give start it not from the origin?
cut

You can have a variable boolean firstTime and when it’s true

set it to false and make a line from the origin

3 Likes
void setup() {
  size(600, 600);
  noLoop();
}

void draw() {
  if (frameCount <= 2)  return;
  line(pmouseX, pmouseY, mouseX, mouseY);
}

void mousePressed() {
  redraw();
}
4 Likes