2016/3/3
1.開啟 Leap Motion 的 Visualizer

2.操作 Visualizer

3.開小畫家 用滴管 點想要的顏色 在點選 編輯色彩 找到色碼

4.用 Processing 的 Tools->Color Selector 也可以找到顏色

5.寫出 可以在 Leap Motion出現的 1根 手指頭線

6.程式碼:
import de.voidplus.leapmotion.*;
LeapMotion leap;
PVector [] pt =new PVector [10];
void setup(){
size(640,480,P3D);
for(int i=0;i<10;i++) pt[i] = new PVector(0,0,0);
leap =new LeapMotion(this);
}
void draw(){
background(0);//背景
stroke(#72FF3B);
for(int i=9;i>0;i--){ pt[i].x=pt[i-1].x;pt[i].y=pt[i-1].y;} //backup the old values
for(Hand hand : leap.getHands() ){
for(Finger finger : hand.getFingers() ){
switch(finger.getType()) {
case 1:// System.out.println("index");
PVector now = finger.getPosition();
pt[0].x=now.x;//pt[0].x=mouseX;
pt[0].y=now.y;//pt[0].y=mouseY;
break;
}
}
}
for(int i=1;i<10;i++)
line(pt[i].x, pt[i].y, pt[i].z, pt[i-1].x, pt[i-1].y,pt[i-1].z);
}
沒有留言:
張貼留言