• Show Sketch
/** @peep sketchcode */
import controlP5.*;
 
ControlP5 cp5;
 
Accordion accordion;
 
color c = color(0, 160, 100);
 
 
color lightBlue = color(66, 168, 237);
color darkBlue = color(0, 102, 153);
color orange = color(204, 102, 0);
 
color fillColor = lightBlue;
 
void setup(){
  size(600, 600);
   translate(width/2, height/2);
  gui();
}
void gui() {
 
  cp5 = new ControlP5(this);
 
  // group number 1, contains 2 bangs
  //Group g1 = cp5.addGroup("myGroup1")
  //              .setBackgroundColor(color(0, 64))
  //              .setBackgroundHeight(150)
  //              ;
 
  //cp5.addBang("bang")
  //   //.setPosition(10,20)
  //   .setSize(100,100)
  //   .moveTo(g1)
  //   .plugTo(this,"shuffle");
  //   ;
 
  // group number 2, contains a radiobutton
  Group g2 = cp5.addGroup("myGroup2")
                .setBackgroundColor(color(0, 64))
                .setBackgroundHeight(150)
                ;
 
  cp5.addRadioButton("radio")
     .setPosition(10,20)
     .setItemWidth(20)
     .setItemHeight(20)
     .addItem("black", 0)
     .addItem("red", 1)
     .addItem("green", 2)
     .addItem("blue", 3)
     .addItem("grey", 4)
     .setColorLabel(color(255))
     .activate(2)
     .moveTo(g2)
     ;
 
  // group number 3, contains a bang and a slider
  Group g3 = cp5.addGroup("myGroup3")
                .setBackgroundColor(color(0, 64))
                .setBackgroundHeight(150)
                ;
 
  //cp5.addBang("shuffle")
  //  .setPosition(10,20)
  //  .setSize(40,50)
  //  .moveTo(g3)
  //  ;
 
  cp5.addSlider("hello")
     .setPosition(60,20)
     .setSize(100,20)
     .setRange(100,500)
     .setValue(100)
     .moveTo(g3)
     ;
 
  //cp5.addSlider("world")
  //  .setPosition(60,50)
  //  .setSize(100,20)
  //  .setRange(100,500)
  //  .setValue(200)
  //  .moveTo(g3)
  //  ;
 
  // create a new accordion
  // add g1, g2, and g3 to the accordion.
  accordion = cp5.addAccordion("acc")
                 .setPosition(40,40)
                 .setWidth(200)
                 //.addItem(g1)
                 .addItem(g2)
                 .addItem(g3)
                 ;
 
  cp5.mapKeyFor(new ControlKey() {public void keyEvent() {accordion.open(0,1,2);}}, 'o');
  cp5.mapKeyFor(new ControlKey() {public void keyEvent() {accordion.close(0,1,2);}}, 'c');
  cp5.mapKeyFor(new ControlKey() {public void keyEvent() {accordion.setWidth(300);}}, '1');
  cp5.mapKeyFor(new ControlKey() {public void keyEvent() {accordion.setPosition(0,0);accordion.setItemHeight(190);}}, '2'); 
  cp5.mapKeyFor(new ControlKey() {public void keyEvent() {accordion.setCollapseMode(ControlP5.ALL);}}, '3');
  cp5.mapKeyFor(new ControlKey() {public void keyEvent() {accordion.setCollapseMode(ControlP5.SINGLE);}}, '4');
  cp5.mapKeyFor(new ControlKey() {public void keyEvent() {cp5.remove("myGroup1");}}, '0');
 
  accordion.open(0,1,2);
 
  // use Accordion.MULTI to allow multiple group 
  // to be open at a time.
  accordion.setCollapseMode(Accordion.MULTI);
 
  // when in SINGLE mode, only 1 accordion  
  // group can be open at a time.  
  // accordion.setCollapseMode(Accordion.SINGLE);
}
void radio(int theC) {
  switch(theC) {
    case(0):c=color(0,200);break;
    case(1):c=color(255,0,0,200);break;
    case(2):c=color(0, 200, 140,200);break;
    case(3):c=color(0, 128, 255,200);break;
    case(4):c=color(50,128);break;
  }
} 
void draw() {
  background(255);
  strokeWeight(4);
  fill(c);
   //float s1 = cp5.getController("hello").getValue();
 
 
 
  //float distance = dist(mouseX, mouseY, width/2, height/2);
  //if (mousePressed && distance < 400) {
  //  fill(orange);
  //} else {
  //  fill(lightBlue);
  //}
  triangle(200, 200, 140, 350, 260, 350);//not
  triangle(200, 200, 140, 50, 260, 50);//top
  triangle(200, 200, 350, 140, 350, 260);//right
  triangle(200, 200, 50, 140, 50, 260);//left
 
  //if (mousePressed && distance < 400) {
  //  fill(orange);
  //} else {
  //  fill(darkBlue);
  //}
  triangle(200, 200, 140, 50, 50,140);//left top
  triangle(200, 200, 50, 260, 140, 350);//left bot
  triangle(200, 200, 260, 350, 350, 260);//right bot 
  triangle(200, 200, 350, 140, 260, 50);//right top
}

Comments

Nobody has said anything yet.