boolean in; color theColor; //noise values float xoff = 0.0; float xincrement = 0.005; boolean changeOfPather=false; ArrayList pathList, pathArray; Point currentPoint;//, prevPoint; void setup(){ size(500,400); background(0); in=false; smooth(); pathList = new ArrayList(); //initialize currentPoint to avoid checking if it's null every time currentPoint = new Point(-1,-1);//prevPoint = //pathArray = new ArrayList(); } void draw(){ //fill(0,1); //rect(0,0,width,height); in=checkIn(); checkChangeOfPather(in); if(in){ drawBigLine(); storePoints(); runIn(); } else { runOut(); } } void drawBigLine(){ color c = color(red(theColor),green(theColor),blue(theColor),15); stroke(c); line(mouseX,mouseY,pmouseX,pmouseY); line(mouseX-1,mouseY-1,pmouseX-1,pmouseY-1); line(mouseX+1,mouseY+1,pmouseX+1,pmouseY+1); line(mouseX+1,mouseY-1,pmouseX+1,pmouseY-1); line(mouseX-1,mouseY+1,pmouseX-1,pmouseY+1); } void storePoints(){ if(currentPoint.x() != mouseX || currentPoint.y() != mouseY){ currentPoint.setX(mouseX); currentPoint.setY(mouseY); pathArray.add(new LivePoint(mouseX,mouseY,theColor)); } } boolean checkIn(){ if(mouseX<=0 || mouseX>=width || mouseY<=0 || mouseY>=height){ return false; }else{ return true; } } void checkChangeOfPather(boolean _in){ if(changeOfPather!=_in){ //person in or out changeOfPather=_in; if(_in){ //new person in: change Color theColor = getColor(); pathArray = new ArrayList(); } else { //person out, store the path arrayList in the array of arrays (pathArray) pathList.add(pathArray); //erase path adn redraw it // repath(); } } } color getColor(){ int noiseVarR=int(random(20,255)); int noiseVarG=int(random(20,255)); int noiseVarB=int(random(20,255)); color c=color(noiseVarR,noiseVarG+15,noiseVarB+100); return c; } void runIn(){ //background(0); if(!pathList.isEmpty()){ //this would be useless in this context... but anyways... for(int i=0;i