Created
September 12, 2011 18:33
-
-
Save vvasabi/1212009 to your computer and use it in GitHub Desktop.
Touch Events in Processing.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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