示例#1
0
 public void customize(DropdownList ddl) {
   ddl.setBackgroundColor(color(190));
   ddl.setItemHeight(20);
   ddl.setBarHeight(15);
   ddl.captionLabel().set("pulldown");
   ddl.captionLabel().style().marginTop = 3;
   ddl.captionLabel().style().marginLeft = 3;
   ddl.valueLabel().style().marginTop = 3;
   //  for(int i=0;i<2;i++) {
   ddl.addItem("180 deg", 0);
   ddl.addItem("30 deg", 1);
   //  }
   ddl.setColorBackground(color(60));
   ddl.setColorActive(color(255, 128));
 }
示例#2
0
 public void InitComDropdown() {
   // Initialize portCommList
   int posX = 20;
   int posY = 70;
   PortsList = controlP5.addDropdownList("portComList", posX, posY, 100, 84);
   // Set the background color of the list (you wont see this though).
   PortsList.setBackgroundColor(color(200));
   // Set the height of each item when the list is opened.
   PortsList.setItemHeight(20);
   // Set the height of the bar itself.
   PortsList.setBarHeight(15);
   // Set the lable of the bar when nothing is selected.
   PortsList.captionLabel().set("Select COM port");
   // Set the top margin of the lable.
   PortsList.captionLabel().style().marginTop = 3;
   // Set the left margin of the lable.
   PortsList.captionLabel().style().marginLeft = 3;
   // Set the top margin of the value selected.
   PortsList.valueLabel().style().marginTop = 3;
   // Store the Serial ports in the string comList (char array).
   comList = serial.list();
   // We need to know how many ports there are, to know how many items to add to the list, so we
   // will convert it to a String object (part of a class).
   String comlist = join(comList, ",");
   // We also need how many characters there is in a single port name, we\u00b4ll store the chars
   // here for counting later.
   String COMlist = comList[0];
   // Here we count the length of each port name.
   int size2 = COMlist.length();
   // Now we can count how many ports there are, well that is count how many chars there are, so we
   // will divide by the amount of chars per port name.
   int size1 = comlist.length() / size2;
   // Now well add the ports to the list, we use a for loop for that. How many items is determined
   // by the value of size1.
   for (int i = 0; i < size1; i++) {
     // This is the line doing the actual adding of items, we use the current loop we are in to
     // determin what place in the char array to access and what item number to add it as.
     PortsList.addItem(comList[i], i);
   }
   // Set the color of the background of the items and the bar.
   PortsList.setColorBackground(color(60));
   // Set the color of the item your mouse is hovering over.
   PortsList.setColorActive(color(255, 128));
 }
示例#3
0
  public void setup() {
    size(800, 500);
    ball = new Ball(width / 2, height / 2, new PVector(5, 5));
    rectMode(CENTER);
    paddles = new Paddle[2];
    paddles[0] = new Paddle(width - 40, 20);
    paddles[1] = new Paddle(40, 20);

    setupContext();
    skeleton = new TSSkeleton();
    cp5 = new ControlP5(this);
    //  cp5.addBang("restart").setPosition(350, 10).setSize(10, 10);

    d1 = cp5.addDropdownList("paddle1").setPosition(width - 150, 20);
    d2 = cp5.addDropdownList("paddle2").setPosition(50, 20);
    d3 = cp5.addDropdownList("1_or_2_player").setPosition(150, 20);
    d4 = cp5.addDropdownList("speed").setPosition(250, 20);

    jointNames = loadStrings("joints.txt");

    d4.addItem("slow", 0);
    d4.addItem("fast", 1);
    d4.addItem("Jeez-us", 2);

    for (int i = 0; i < jointNames.length; i++) {
      d1.addItem(jointNames[i], i);
      d2.addItem(jointNames[i], i);
    }

    d3.addItem("one player", 0);
    d3.addItem("two players", 1);

    smooth();
    println("SimpleOpenNI.SKEL_HEAD " + SimpleOpenNI.SKEL_HEAD);
    println("SimpleOpenNI.SKEL_LEFT_ANKLE " + SimpleOpenNI.SKEL_LEFT_ANKLE);
    println("SimpleOpenNI.SKEL_LEFT_COLLAR " + SimpleOpenNI.SKEL_LEFT_COLLAR);
    println("SimpleOpenNI.SKEL_LEFT_ELBOW " + SimpleOpenNI.SKEL_LEFT_ELBOW);
    println("SimpleOpenNI.SKEL_LEFT_FINGERTIP " + SimpleOpenNI.SKEL_LEFT_FINGERTIP);
    println("SimpleOpenNI.SKEL_LEFT_FOOT " + SimpleOpenNI.SKEL_LEFT_FOOT);
    println("SimpleOpenNI.SKEL_LEFT_HAND " + SimpleOpenNI.SKEL_LEFT_HAND);
    println("SimpleOpenNI.SKEL_LEFT_HIP " + SimpleOpenNI.SKEL_LEFT_HIP);
    println("SimpleOpenNI.SKEL_LEFT_KNEE " + SimpleOpenNI.SKEL_LEFT_KNEE);
    println("SimpleOpenNI.SKEL_LEFT_SHOULDER " + SimpleOpenNI.SKEL_LEFT_SHOULDER);
    println("SimpleOpenNI.SKEL_LEFT_WRIST " + SimpleOpenNI.SKEL_LEFT_WRIST);
    println("SimpleOpenNI.SKEL_NECK " + SimpleOpenNI.SKEL_NECK);
    println("SimpleOpenNI.SKEL_RIGHT_ANKLE " + SimpleOpenNI.SKEL_RIGHT_ANKLE);
    println("SimpleOpenNI.SKEL_RIGHT_COLLAR " + SimpleOpenNI.SKEL_RIGHT_COLLAR);
    println("SimpleOpenNI.SKEL_RIGHT_ELBOW " + SimpleOpenNI.SKEL_RIGHT_ELBOW);
    println("SimpleOpenNI.SKEL_RIGHT_FINGERTIP " + SimpleOpenNI.SKEL_RIGHT_FINGERTIP);
    println("SimpleOpenNI.SKEL_RIGHT_FOOT " + SimpleOpenNI.SKEL_RIGHT_FOOT);
    println("SimpleOpenNI.SKEL_RIGHT_HAND  " + SimpleOpenNI.SKEL_RIGHT_HAND);
    println("SimpleOpenNI.SKEL_RIGHT_HIP " + SimpleOpenNI.SKEL_RIGHT_HIP);
    println("SimpleOpenNI.SKEL_RIGHT_KNEE " + SimpleOpenNI.SKEL_RIGHT_KNEE);
    println("SimpleOpenNI.SKEL_RIGHT_SHOULDER " + SimpleOpenNI.SKEL_RIGHT_SHOULDER);
    println("SimpleOpenNI.SKEL_RIGHT_WRIST " + SimpleOpenNI.SKEL_RIGHT_WRIST);
    println("SimpleOpenNI.SKEL_TORSO " + SimpleOpenNI.SKEL_TORSO);
    println("SimpleOpenNI.SKEL_WAIST " + SimpleOpenNI.SKEL_WAIST);

    translations = new int[jointNames.length];
    translations[0] = 1;
    translations[1] = 19;
    translations[2] = 5;
    translations[3] = 7;
    translations[4] = 10;
    translations[5] = 20;
    translations[6] = 9;
    translations[7] = 17;
    translations[8] = 18;
    translations[9] = 6;
    translations[10] = 8;
    translations[11] = 2;
    translations[12] = 23;
    translations[13] = 11;
    translations[14] = 13;
    translations[15] = 16;
    translations[16] = 24;
    translations[17] = 15;
    translations[18] = 21;
    translations[19] = 22;
    translations[20] = 12;
    translations[21] = 14;
    translations[22] = 3;
    translations[23] = 4;

    font = loadFont("AlBayan-48.vlw");
    textFont(font, 48);
  }