Skip to content

Instantly share code, notes, and snippets.

@vvasabi
Created September 12, 2011 18:33
Show Gist options
  • Save vvasabi/1212009 to your computer and use it in GitHub Desktop.
Save vvasabi/1212009 to your computer and use it in GitHub Desktop.
Touch Events in Processing.js
void setup() {
size(400, 300);
background(255);
}
void touchMove(TouchEvent touchEvent) {
// empty the canvas
noStroke();
fill(255);
rect(0, 0, 400, 300);
// draw circles at where fingers touch
fill(180, 180, 100);
for (int i = 0; i < touchEvent.touches.length; i++) {
int x = touchEvent.touches[i].offsetX;
int y = touchEvent.touches[i].offsetY;
ellipse(x, y, 50, 50);
}
}
void touchEnd(TouchEvent touchEvent) {
noStroke();
fill(255);
rect(1, 1, 400, 300);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment