Take a look at the Ketai Library - KetaiGesture:
Provides gesture recognition services to a processing sketch. To
receive gesture events a sketch can define the following methods:
...
onPinch(float x, float y, float r) - x,y of center, r is the distance
Example of code use to change the size of a circle using the Pinch motion:
import ketai.ui.*;
import android.view.MotionEvent;
float ellipseWidth = 50;
float ellipseHeight = 50;
KetaiGesture gesture;
void setup() {
size(displayWidth, displayHeight);
gesture = new KetaiGesture(this);
}
void draw() {
orientation(PORTRAIT);
background(0);
fill(0);
stroke(255);
ellipse(width/2, height/2, ellipseWidth, ellipseHeight);
}
void onPinch (float x, float y, float d) {
ellipseWidth += d;
ellipseHeight += d;
}
public boolean surfaceTouchEvent(MotionEvent event) {
//Call this to keep mouseX and mouseY updated
super.surfaceTouchEvent(event);
//Forward the event to the class for processing
return gesture.surfaceTouchEvent(event);
}
Hope this helps!
