2015年5月18日 星期一

import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
  size(600,600,P3D);
  leap=new LeapMotion(this);
}
void draw(){
  background(255);
  for(Hand hand: leap.getHands()){
    hand.draw();
    myDraw(hand.getPosition());//手掌
    myDraw(hand.getThumb().getPosition());//拇指
    myDraw(hand.getIndexFinger().getPosition());//食指
    myDraw(hand.getMiddleFinger().getPosition());//中指
    myDraw(hand.getRingFinger().getPosition());//無名指
    myDraw(hand.getPinkyFinger().getPosition());//小指
    /*用函式代替下面的東西*/
    /*PVector pos=hand.getPosition();
    translate(pos.x,pos.y);
    fill(255,0,0); box(100);*/
    }
}
void myDraw(PVector pos){//設一個函式把動作包起來
  pushMatrix();
    translate(pos.x,pos.y);
    fill(255,0,0); sphere(20);//畫一顆球
  popMatrix();//跟圖學一樣用push、pop保護起來
}

沒有留言:

張貼留言