2016年3月3日 星期四

week02

下載Leap-Sketch-Import Library-add Library

畫線

void setup()
{
  size(480,100);//WINDOW SIZE  -視窗大小 
}
void draw()
{

  line(mouseX,mouseY,pmouseX,pmouseY);

}



換顏色

void setup()
{
  size(480,100);//WINDOW SIZE 
  background(0); //background color 
}
void draw()
{
  stroke(#16B1DE);// line color
  line(mouseX,mouseY,pmouseX,pmouseY);
}



PVector [] pt = new PVector[10];
//pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8,pt9,pt10
void setup()
{
  size(480,100,P3D);//WINDOW SIZE,3D
  for(int i=0;i<10;i++) pt[i]=new PVector(0,0,0);
}
void draw()
{
  background(0);
  stroke(#16B1DE);// line color
  for(int i=9;i>0;i--){pt[i].x=pt[i-1].x;pt[i].y=pt[i-1].y;}
  //line(mouseX,mouseY,pmouseX,pmouseY);
  pt[0].x=mouseX;
  pt[0].y=mouseY;
  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);
  
}
一隻手指頭

PVector [] pt = new PVector[10];
//pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8,pt9,pt10
void setup()
{
  size(480,100,P3D);//WINDOW SIZE,3D
  for(int i=0;i<10;i++) pt[i]=new PVector(0,0,0);
  leap = new LeapMotion(this);
}
void draw()
{
  background(0);
  stroke(#16B1DE);// line color
  for(int i=9;i>0;i--){pt[i].x=pt[i-1].x;pt[i].y=pt[i-1].y;}
  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].y=now.y;
          break;
       }
     }
   }
  //line(mouseX,mouseY,pmouseX,pmouseY);
  
  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);
  
}

五隻手指頭
import de.voidplus.leapmotion.*;
LeapMotion leap;
PVector [][] pt = new PVector[5][100];
//pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8,pt9,pt10
void setup()
{
  size(640,480,P3D);//WINDOW SIZE,3D
  for(int f=0;f<5;f++)
  {
  for(int i=0;i<100;i++) pt[f][i]=new PVector(0,0,0);
  }
  leap = new LeapMotion(this);
  colorMode(HSB,100);
}
void draw()
{
  background(0);
  stroke(#16B1DE);// line color
  for(int f=0;f<5;f++)
  { for(int i=99;i>0;i--)
     {pt[f][i].x=pt[f][i-1].x;pt[f][i].y=pt[f][i-1].y;}
  }
  for(Hand hand : leap.getHands()){
    for(Finger finger : hand.getFingers()){
      int f=finger.getType();
      PVector now = finger.getPosition();
      pt[f][0].x=now.x;
      pt[f][0].y=now.y;
    }
  }
  for(int f=0;f<5;f++){
  stroke (f*20,100,100);
  for(int i=1;i<100;i++)
  line ( pt[f][i].x,pt[f][i].y,pt[f][i].z,pt[f][i-1].x,pt[f][i-1].y,pt[f][i-1].z);
  }
}
  
  
  








沒有留言:

張貼留言