Hello. I am working on a school project. I am supposed to create a Snapchat filter. I am trying to create something close to the pen tool with Processing 3.
So far I have not been able to figure out how to use arrays along with vertex to form shapes.
Here’s the code I am stuck with
 for (int i = PenToolY.length-1; i > 0; i--) { 
    PenToolY[i] = PenToolY[i-1]; 
  } 
  for (int i = PenToolX.length-1; i > 0; i--) { 
    PenToolX[i] = PenToolX[i-1]; 
  } 
  // Add new values to the beginning 
  PenToolY[0] = mouseY; 
  // Display each pair of values as a line 
  for (int i = 1; i < PenToolY.length; i++) { 
    line(i, PenToolY[i], i-1, PenToolY[i-1]); 
    //beginShape(); 
    //vertex(i, PenToolY[i], i-1, PenToolY[i-1]); 
    //endShape(CLOSE); 
  } 
  PenToolX[0] = mouseX; 
  // Display each pair of values as a line 
  for (int i = 1; i < PenToolX.length; i++) { 
   line(i, PenToolX[i], i-1, PenToolX[i-1]); 
I have used the line function to see how arrays can affect the coordinates when combine with mouse interaction.
Here’s the full code: https://dmail-my.sharepoint.com/:w:/g/personal/2452239_dundee_ac_uk/EeDiLjfflZROqOfftoxH7UoBPWgS49sv5ff9CB-16qtVVw?e=RMAs73
This is what its results in:

I am a coding noob. Sorry if sharing a Word Doc comes across as naive.
Thanks in advance.