Connect points clicked with a line?

I'm very new to programming + processing and I'm trying to make a program where every time the mouse is clicked a point is drawn where the mouse was clicked, and each point is connected to the previous point through a line. So far I've figured out how to draw a point when/where the mouse is clicked, and I've figured out how to draw line continuously as long as the mouse is held down, but I haven't figured out how to simply connect the points drawn. I know there's a way to connect line through the previous mouse position, but is there a way to connect only to the last position where the mouse was clicked? Thanks! Here is what I have so far:

void setup(){
  size(500,500);
  background(200);
}


  void draw(){
    if (mousePressed == true){
      point(mouseX,mouseY);
    }

  }
Tagged:

Answers

Sign In or Register to comment.