示例#1
0
  // \u30c7\u30fc\u30bf\u53d6\u5f97
  public void getAllData() {

    // xively\u304b\u3089\u306e\u30c7\u30fc\u30bf\u53d6\u5f97
    String lines[] = getDataFromXively(URL, MY_KEY);

    // \u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u3092\u30ea\u30b9\u30c8\u306b\u683c\u7d0d
    dotLists = new ArrayList<ArrayList<dotObj>>();

    // \u30c1\u30e3\u30f3\u30cd\u30eb\u306e\u53d6\u5f97
    int max_channel = 0;
    int min_channel = 9999;
    for (int i = 0; i < lines.length; i++) {
      String data[] = split(lines[i], ',');
      int theChannel = PApplet.parseInt(data[0]);
      if (min_channel > theChannel) {
        min_channel = theChannel;
      }
      if (max_channel < theChannel) {
        max_channel = theChannel;
      }
    }

    // \u5168\u30c1\u30e3\u30f3\u30cd\u30eb\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3001\u30ea\u30b9\u30c8\u306b\u683c\u7d0d
    for (int channel = min_channel; channel <= max_channel; channel++) {
      ArrayList<dotObj> dotList = getDataList(lines, channel);
      dotLists.add(dotList);
    }
  }
示例#2
0
  public void controlEvent(ControlEvent theEvent) {
    // PulldownMenu is if type ControlGroup.
    // A controlEvent will be triggered from within the ControlGroup.
    // therefore you need to check the originator of the Event with
    // if (theEvent.isGroup())
    // to avoid an error message from controlP5.
    if (theEvent.isGroup()) {
      if (theEvent.group().name() == "ruleChoiceList") {
        //    println(theEvent.group().value()+" from "+theEvent.group());
        selectedRule = PApplet.parseInt(theEvent.group().value());
        // has to be here for the controlp5 library
      }
    } else if (theEvent.isController()) {
      //    println(theEvent.controller().value()+" from "+theEvent.controller());
    }

    //  switch(theEvent.controller().id()) {
    //    case(1):
    //    myColorRect = (int)(theEvent.controller().value());
    //    break;
    //    case(2):
    //    myColorBackground = (int)(theEvent.controller().value());
    //    break;
    //    case(3):
    //    println(theEvent.controller().stringValue());
    //    break;
    //  }

  }
示例#3
0
  // \u30c7\u30fc\u30bf\u3092\u30ea\u30b9\u30c8\u306b\u683c\u7d0d\u3057\u3066\u53d6\u5f97
  public ArrayList<dotObj> getDataList(String[] lines, int targetChannel) {

    ArrayList<dotObj> retList = new ArrayList<dotObj>();

    // \u5168\u30c7\u30fc\u30bf\u3092\u53c2\u7167\u3057\u3066\u5fc5\u8981\u306a\u60c5\u5831\u3092\u53d6\u308a\u51fa\u3059
    int index = 0;
    for (int i = 0; i < lines.length; i++) {
      // ','\u3067\u533a\u5207\u308a\u914d\u5217\u306b\u683c\u7d0d
      String data[] = split(lines[i], ',');
      // channel, date, valuse
      // \u306e\u9806\u3067\u30c7\u30fc\u30bf\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b
      int channel = PApplet.parseInt(data[0]); // \u30c1\u30e3\u30f3\u30cd\u30eb
      String timeStamp = data[1]; // \u65e5\u4ed8
      float val = PApplet.parseFloat(data[2]); // \u5024

      if (channel == targetChannel) {
        // println("channel: " + channel);
        // println("date   : " + timeStamp);
        // println("val    : " + val);

        // \u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u3092\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u30bb\u30c3\u30c8\u3057\u3001\u914d\u5217\u306b\u683c\u7d0d
        float m = map(val, -0.5f, 0.5f, height / 4, height);
        dotObj theObj = new dotObj(index * width / 70, m, 0);
        theObj.channel = channel;
        theObj.timeStamp = timeStamp;
        theObj.val = val;
        retList.add(theObj);

        index++;
      }
    }

    return retList;
  }
 public static void main(String[] passedArgs) {
   String[] appletArgs = new String[] {"crop_graphics_tri_large"};
   if (passedArgs != null) {
     PApplet.main(concat(appletArgs, passedArgs));
   } else {
     PApplet.main(appletArgs);
   }
 }
示例#5
0
 public static void main(String[] passedArgs) {
   String[] appletArgs = new String[] {"getDataFromXively"};
   if (passedArgs != null) {
     PApplet.main(concat(appletArgs, passedArgs));
   } else {
     PApplet.main(appletArgs);
   }
 }
示例#6
0
 public static void main(String[] passedArgs) {
   String[] appletArgs = new String[] {"EvvGC_GUI_v0_4"};
   if (passedArgs != null) {
     PApplet.main(concat(appletArgs, passedArgs));
   } else {
     PApplet.main(appletArgs);
   }
 }
 public static void main(String[] passedArgs) {
   String[] appletArgs = new String[] {"GoogleBillboard"};
   if (passedArgs != null) {
     PApplet.main(concat(appletArgs, passedArgs));
   } else {
     PApplet.main(appletArgs);
   }
 }
 public static void main(String[] passedArgs) {
   String[] appletArgs = new String[] {"shapes_shapes"};
   if (passedArgs != null) {
     PApplet.main(concat(appletArgs, passedArgs));
   } else {
     PApplet.main(appletArgs);
   }
 }
示例#9
0
 public static void main(String[] passedArgs) {
   String[] appletArgs =
       new String[] {"--full-screen", "--bgcolor=#666666", "--hide-stop", "build"};
   if (passedArgs != null) {
     PApplet.main(concat(appletArgs, passedArgs));
   } else {
     PApplet.main(appletArgs);
   }
 }
示例#10
0
文件: War.java 项目: RadianSmile/War
    public void addPlant(int type, int mouseX, int mouseY) {
      if (mouseX <= left || mouseX >= right || mouseY <= top || mouseY >= bottom) return;
      println(mouseX, mouseY);
      int colIndex = floor((mouseX - left) / wSpacing);
      int rowIndex = floor((mouseY - top) / hSpacing);

      int x = PApplet.parseInt(left + colIndex * wSpacing);
      int y = PApplet.parseInt(top + rowIndex * hSpacing);
      if (plants[colIndex][rowIndex] == null) plants[colIndex][rowIndex] = new Plant(type, x, y);
    }
 public static void main(String[] passedArgs) {
   String[] appletArgs =
       new String[] {
         "--full-screen", "--bgcolor=#666666", "--stop-color=#cccccc", "fruitloop_processing"
       };
   if (passedArgs != null) {
     PApplet.main(concat(appletArgs, passedArgs));
   } else {
     PApplet.main(appletArgs);
   }
 }
示例#12
0
  public void READ() {
    if (readEnable == false) return;

    myPort.write("g"); // sends get values command

    while (i < 200000000) {
      i++;
    } // delay
    i = 0;

    // myPort.write("OK");
    readStatus = "Can't Read";

    if (myPort.read() == 'x') {
      PitchP.setValue(myPort.read() / 100.00f);
      RollP.setValue(myPort.read() / 100.00f);
      YawP.setValue(myPort.read() / 100.00f);

      PitchD.setValue(myPort.read() / 100.00f);
      RollD.setValue(myPort.read() / 100.00f);
      YawD.setValue(myPort.read() / 100.00f);

      PitchPWR.setValue(myPort.read());
      RollPWR.setValue(myPort.read());
      YawPWR.setValue(myPort.read());

      RCcontrol = PApplet.parseChar(myPort.read());
      YawRCon = PApplet.parseChar(myPort.read());

      RollCal.setValue((myPort.read() - 100.00f) / 10.00f);

      if (RCcontrol == '0') {
        buttonRCOff.setColorBackground(green_);
        buttonRCOn.setColorBackground(gray_);
      }
      if (RCcontrol == '1') {
        buttonRCOff.setColorBackground(gray_);
        buttonRCOn.setColorBackground(green_);
      }

      if (YawRCon == '0') {
        buttonYawRC.setColorBackground(gray_);
        buttonYawAut.setColorBackground(green_);
      }
      if (YawRCon == '1') {
        buttonYawRC.setColorBackground(green_);
        buttonYawAut.setColorBackground(gray_);
      }

      readStatus = "Read OK";
    }
  }
 public void gameOver() { // trigger game over
   this.screen = 2; // sets screen to game over
   noStroke();
   noLoop();
   fill(255, 0, 0);
   rect(0, height / 8, width, height / 8 * 6);
   stroke(255);
   this.shooterlist[0] = null; // removes active ball
   String[] scores = loadStrings("scores.txt"); // loads high score from text file
   if (PApplet.parseInt(scores[0])
       < this.score) { // checks if current score is greater than high score
     scores[0] = "" + this.score + ""; // makes string
     saveStrings("data/scores.txt", scores); // saves to the scores.txt in data folder
   }
   fill(255);
   textSize(30);
   textAlign(CENTER, TOP);
   text("Game Over", width / 2, height / 8);
   textSize(20);
   text("Your Score\n" + this.score, 60, height / 8 * 2);
   text("High Score\n" + scores[0], width - (60 * width / 320), height / 8 * 2);
   fill(255, 0, 0);
   button = new Button(width / 2, 50, width / 4, height / 8 * 6, "Play Again", 18);
   button.display();
 }
  public void setup() {
    size(1000, 1000);
    background(255);

    // presets
    int rows = 12;
    int cols = 12;
    float outerRadius = width / cols;

    // randomly generated
    int pointCount;
    int steps;
    float innerRadius;
    float innerRadiusRatio;
    float outerRadiusRatio;
    float shadeRatio;
    float rotationRatio;

    translate(outerRadius / 2, outerRadius / 2);
    for (int i = 0; i < rows; i++) {
      for (int j = 0; j < cols; j++) {
        pointCount = PApplet.parseInt(random(5, 15));
        steps = PApplet.parseInt(random(3, 20));
        innerRadius = outerRadius * random(0.3f, 0.9f);
        innerRadiusRatio = innerRadius / steps;
        outerRadiusRatio = outerRadius / steps;

        float randColor = random(225, 255);
        shadeRatio = randColor / steps;
        rotationRatio = random(90, 200) / steps;

        pushMatrix();
        translate(outerRadius * j, outerRadius * i);
        for (int k = 0; k < steps; k++) {
          float shade = shadeRatio * k;
          fill(shade);
          stroke(randColor - shade, 100);
          pushMatrix();
          scale(0.4f);
          rotate(rotationRatio * k * PI / 180);
          star(pointCount, outerRadius - outerRadiusRatio * k, innerRadius - innerRadiusRatio * k);
          popMatrix();
        }
        popMatrix();
      }
    }
  }
  public void mousePressed() {
    if (mouseButton == LEFT) {

      int xX = PApplet.parseInt(mouseX) / cellSize;
      int yY = PApplet.parseInt(mouseY) / cellSize;
      //    fill(255);
      //    textSize(12);
      //    text( xX + " " + yY, mouseX, mouseY);
      grid[xX][yY].pressed();
    }
    if (mouseButton == RIGHT) {
      starttime = millis();
      if (play == true) {
        play = false;
      } else {
        play = true;
      }
    }
  }
 public void draw() {
   lights();
   background(255);
   noStroke();
   fill(200);
   translate(-width / 2, 0);
   t += 0.001f;
   int offset = 10;
   float shapeSize = 5.0f;
   for (int i = 1; i < 10; i++) {
     // ellipse(noise(t+i*offset*0.01)*width, sin(float(frameCount + i*offset)/100)*height/2,
     // shapeSize*i, shapeSize*i);
     float x = noise(t + i * offset * 0.01f) * width;
     float y = sin(PApplet.parseFloat(frameCount + i * offset) / 100) * height / 2;
     pushMatrix();
     translate(x, y);
     sphere(shapeSize * i);
     popMatrix();
   }
 }
 public static void main(String[] args) {
   PApplet.main(new String[] {"--present", triangleWorm.WormApplication.class.getName()});
 }
  public void draw() {
    background(0);

    for (int i = 0; i < cols; i++) {
      for (int j = 0; j < rows; j++) {

        if ((i & 1) == 0) {
          // even rows white
          grid[i][j].display(255);
        } else {
          // odd rows gray
          grid[i][j].display(220);
        }
      }
    }

    if (play == true) {
      int j;
      if (millis() - starttime < delaytime) {
        count_up = (millis() - starttime);
        count_down = delaytime - count_up;
        steptimer = floor(4 / (delaytime / count_up));
        fill(0);
        //        textSize(12);
        //        text(steptimer, mouseX, mouseY);
        for (j = 0; j < rows; j++) {
          grid[steptimer][j].display(120);
          if (grid[steptimer][j].active) {
            grid[steptimer][j].trigger(steptimer, j);
          }
        }

        switch (steptimer) {
          case 0:
            uno = PApplet.parseByte(unbinary("00010001"));
            due = PApplet.parseByte(unbinary("00010001"));
            break;
          case 1:
            uno = PApplet.parseByte(unbinary("00100010"));
            due = PApplet.parseByte(unbinary("00100010"));
            break;
          case 2:
            uno = PApplet.parseByte(unbinary("01000100"));
            due = PApplet.parseByte(unbinary("01000100"));
            break;
          case 3:
            uno = PApplet.parseByte(unbinary("10001000"));
            due = PApplet.parseByte(unbinary("10001000"));
            break;
        }
        print(binary(uno));
        println(binary(due));

        myPort.write(due);
        myPort.write(uno);
        myPort.write(',');
      } else {
        starttime = millis();
        j = 0;
      }

      for (int i = 0; i < cols; i++) {
        for (int k = 0; k < rows; k++) {

          if (grid[i][k].active) {
            // even rows white

            if ((i + 4 * k) < 8) {
              uno |= (1 << i + 4 * k);
            } else {
              due |= (1 << (i + 4 * k) - 8);
            }
          } else {
            // odd rows gray

            if ((i + 4 * k) < 8) {
              uno &= ~(1 << i + 4 * k); // chiedete a vanzati [email protected]
            } else {
              due &= ~(1 << (i + 4 * k) - 8);
            }
          }
        }
      }
    }

    // print(binary(uno));
    // print(binary(due));

    myPort.write(due);
    myPort.write(uno);
    myPort.write(',');

    println();
  }
  public void draw() {
    // background(33,22,223);
    background(0);
    scale(.45f, .45f);
    smooth(4);

    /////////////
    // rightline
    /////////////
    int test;
    pushMatrix();
    translate(
        offsety + width,
        offsetx - height + 250 - 30); // divide the with by the height of the original photo
    rotate(PI / 3);

    for (int i = 1; i < 6; i++) {
      //  if (int(random(1,filecount))%i == 0) {
      test = PApplet.parseInt(random(1, filecount));
      println(test);
      // println(filecount);
      smooth(4);

      image(img[PApplet.parseInt(random(1, filecount))], 250, 250);
      image(img[PApplet.parseInt(random(1, filecount))], offsetx * i + 250, 250);
      //    }
    }
    popMatrix();

    /////////////
    // leftline
    /////////////
    // int test;
    pushMatrix();
    translate(-90, offsetx + height + 550); // divide the with by the height of the original photo
    rotate(-PI / 3);

    for (int i = 1; i < 6; i++) {
      //  if (int(random(1,filecount))%i == 0) {
      // println(filecount);
      smooth(4);
      image(img[PApplet.parseInt(random(1, filecount))], 250, 250);
      image(img[PApplet.parseInt(random(1, filecount))], offsetx * i + 250, 250);
      //    }
    }
    popMatrix();

    /////////////
    // bottomline
    /////////////

    pushMatrix();
    for (int i = 1; i < 6; i++) {
      smooth(4);
      image(img[PApplet.parseInt(random(1, filecount))], 250, 2 * height - 310 + 250);
      image(img[PApplet.parseInt(random(1, filecount))], offsetx * i + 250, 2 * height - 310 + 250);
    }
    popMatrix();

    pushMatrix();
    smooth(4);
    xint = mouseX;
    yint = mouseY;

    println(xint);
    println(yint);

    // tri.beginDraw();
    // tri.scale(2.2, 2.2);
    // tri.translate(3,6);
    // tri.noStroke();

    scale(2.2f, 2.2f);
    translate(3, 6);
    noStroke();

    stroke(0);
    // stroke(33,22,223);
    strokeWeight(30);
    line(88, 655, 450, 18);
    line(450, 18, 815, 655);
    line(815, 655, 88, 655);
    // tri.endDraw();

    popMatrix();
  }
示例#20
0
  public void setup() {
    minim = new Minim(this);
    size(winWidth, winHeight, OPENGL);
    background(bGround);
    sm = new SceneManager(minim);
    rulesChecker = new RulesChecker();

    controlP5 = new ControlP5(this);
    // ruleChoiceList = controlP5.addDropdownList("ruleChoiceList",850,100,100,100);
    // customize(ruleChoiceList);
    selectedRule = 0;
    selectedCamera = 0;
    gl = ((PGraphicsOpenGL) g).gl;

    picker = new Picker(this);
    oscP5 = new OscP5(this, port);
    // TODO(sanjeet): Change the address
    interfaceAddr = new NetAddress("127.0.0.1", port);

    noStroke();
    lines = loadStrings("fileFriedrich.txt"); // Hardcoded input file name
    String[] tokens = split(lines[0], " ");
    if (tokens.length != 1) {
      println("Incorrect file format for number of cameras");
      return;
    }
    int numOfCams = PApplet.parseInt(tokens[0]);
    for (int i = 1; i < numOfCams + 1; i++) {

      tokens = split(lines[i], " ");
      float[] matrix = new float[16];
      for (int j = 0; j < tokens.length; j++) {
        matrix[j] = PApplet.parseFloat(tokens[j]);
      }

      cameras.add(new Cam(FloatBuffer.wrap(matrix))); // add all the cameras
    }

    tokens = split(lines[1 + numOfCams], " ");
    if (tokens.length != 1) {
      println("Incorrect file format for number of characters");
      return;
    }
    int numOfChars = PApplet.parseInt(tokens[0]);
    for (int i = 2 + numOfCams; i < lines.length; i++) {
      tokens = split(lines[i], " ");
      float[] matrix = new float[16];
      for (int j = 0; j < tokens.length; j++) {
        matrix[j] = PApplet.parseFloat(tokens[j]);
      }

      characters.add(new Character(FloatBuffer.wrap(matrix))); // add all the characters
    }

    characters.get(0).col = color(255, 255, 0);
    characters.get(1).col = color(255, 0, 255);

    timeline = new Timeline(sm);
    // add initial tick to the begining of the timeline
    timeline.addTick(cameras.get(0));

    debug = new Debug(controlP5);

    // title, start, end, initVal, xpos, ypos, width, height
    // controlP5.addSlider("Timeline", 0,120,0,100,winHeight-50,winWidth-200,30);

  }
示例#21
0
  public void WRITE() {
    if (writeEnable == false) return;

    myPort.write("h");

    myPort.write(PApplet.parseInt(PitchP.value() * 100));
    myPort.write(PApplet.parseInt(RollP.value() * 100));
    myPort.write(PApplet.parseInt(YawP.value() * 100));

    myPort.write(PApplet.parseInt(PitchD.value() * 100));
    myPort.write(PApplet.parseInt(RollD.value() * 100));
    myPort.write(PApplet.parseInt(YawD.value() * 100));

    myPort.write(PApplet.parseInt(PitchPWR.value()));
    myPort.write(PApplet.parseInt(RollPWR.value()));
    myPort.write(PApplet.parseInt(YawPWR.value()));

    myPort.write(RCcontrol);
    myPort.write(YawRCon);

    myPort.write(PApplet.parseInt(RollCal.value() * 10 + 100));
    // println (RollCal.value());
    // println (int (RollCal.value()*10+100));

    readStatus = "Write OK";
  }
示例#22
0
 public static void main(String args[]) {
   PApplet.main(new String[] {"--bgcolor=#FFFFFF", "lightArray"});
 }
 public static void main(String args[]) {
   PApplet.main(
       new String[] {"--present", "--bgcolor=#666666", "--hide-stop", "basic_processing_sketch"});
 }