how do you store/record the value of mouse position in an array?

edited January 2018 in How To...

im trying to store/ record the mouse position every time it is clicked into an array. (i'm new to processing)

Tagged:

Answers

  • Answer ✓
    int[] x = new int[0];
    int[] y = new int[0];
    
    void setup() 
    {
      size(200, 200);
    }
    
    void draw() 
    {
    }
    
    void mousePressed() { // Click to add a line segment
      x = append(x, mouseX);
      y = append(y, mouseY);
      for (int i = 0; i<x.length; i++) {
        println(x[i], y[i]);
      }
      println();
    }
    
  • thank you! kind sir :)

Sign In or Register to comment.