コード例 #1
0
  // hide and show controls
  public void hideControls() {

    if (keyPressed && (key == ' ')) {

      cp5.show();
      // stats and controls
      fill(0, 100);
      noStroke();
      rect(0, 0, 300, 300);

      fill(255);
      textSize(25);
      text("windSpeed: " + String.format("%.2f", wind), 10, 150);
      text("people: " + peopleLength, 10, 180);
      text("behaviors: " + physics.behaviors.size(), 10, 210);
      text("circles: " + circles.size(), 10, 240);
      text("framerate: " + frameRate, 10, 270);
    } else {
      cp5.hide();
    }
  }
コード例 #2
0
  // use this function to calibrate force coefficients in real time
  public void controllers() {

    cp5 = new ControlP5(this);

    // slider control for gravity
    cp5.addSlider("gravY")
        .setPosition(10, height - 60)
        .setRange(0.0f, 0.2f)
        .setSize(200, 10)
        .setColorCaptionLabel(0)
        .setCaptionLabel("gravity");

    // slider control for drag
    cp5.addSlider("drag")
        .setPosition(10, height - 50)
        .setRange(0.0f, 0.2f)
        .setSize(200, 10)
        .setColorCaptionLabel(0);

    // slider control for attractor strength
    cp5.addSlider("attStrength")
        .setPosition(10, height - 35)
        .setRange(0.0f, 0.2f)
        .setSize(200, 10)
        .setColorCaptionLabel(0);

    // slider control for max wind speed
    cp5.addSlider("maxWind")
        .setPosition(10, height - 10)
        .setRange(0.0f, 0.25f)
        .setSize(200, 10)
        .setColorCaptionLabel(0);

    // background color
    cp =
        cp5.addColorPicker("picker")
            .setPosition(10, 65)
            .setColorValue(color(0xff40B785, 255))
            .hideBar();
  }