import processing.core.*;
import processing.data.*;
import processing.event.*;
import processing.opengl.*;
import android.view.MotionEvent;
import java.util.HashMap;
import java.util.ArrayList;
import java.io.*;
public class TestTouchMotion extends PApplet {
public void setup() {
orientation(PORTRAIT);
stroke(255);
smooth();
}
public void draw() {
background(0);
}
public void showCircle(float x, float y, float siz) {
int circleSize = 500;
float diameter = circleSize * siz;
noFill();
strokeWeight(20);
colorMode(RGB, 255);
stroke(PApplet.parseInt(random(0,255)),PApplet.parseInt(random(0,255)),PApplet.parseInt(random(0,255)));
ellipse(x, y, diameter, diameter);
fill(0,255,0);
ellipse(x, y, 8, 8);
}
public boolean dispatchTouchEvent(MotionEvent me) {
int numPointers = me.getPointerCount();
for(int i=0; i < numPointers; i++) {
int pointerId = me.getPointerId(i);
float x = me.getX(i);
float y = me.getY(i);
float siz = me.getSize(i);
showCircle(x, y, siz);
}
return super.dispatchTouchEvent(me);
}
public int sketchWidth() { return displayWidth; }
public int sketchHeight() { return displayHeight; }
}
2013年7月2日 星期二
[ Processing for Android ] A Simple TouchMotion example
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言