// GESTURE DECOMPOSITION DRAWING // BY PATRICK HEBRON int recDuration = 15; // Drawing Duration (in seconds) int fps = 24; // Frame rate int incr = 20; // Initial playback position interval (must be < maxCount) int maxCount = recDuration*fps; // Number of positions to record boolean playbackMode = false; int prevX; int prevY; int curr = 0; int loopCount = 0; int[][] arr = new int[maxCount][2]; void setup() { size(1000, 600); smooth(); background(0); frameRate(fps); strokeWeight(4); stroke(255, 255, 255); } void draw() { if(playbackMode == true) { // Playback Mode // Handle curr position if(curr == 0) { // Initialize prevX = arr[1][0]; prevY = arr[1][1]; } else if(curr > 0) { // Draw line(prevX, prevY, arr[curr][0], arr[curr][1]); } // Update prev with curr prevX = arr[curr][0]; prevY = arr[curr][1]; // Check if next position is < max position if(curr + incr < maxCount) { curr += incr; // Move to next position } else { // If not at final incr, prepare for next if(incr != 1) { background(0); // Turn this off to draw on top of previous iterations curr = 0; // Reset to first position incr--; // Move to next position interval } } } else { // Recording Mode // Loop through each recording position if(loopCount < maxCount) { if (mousePressed == true) { // Draw line if(loopCount == 0) line(mouseX, mouseY, mouseX, mouseY); else line(pmouseX, pmouseY, mouseX, mouseY); // Record position and incr for next arr[loopCount][0] = mouseX; arr[loopCount][1] = mouseY; loopCount++; } } else { // Move to playback mode playbackMode = true; background(0); } } }