ControlP5: canvas and group

edited December 2013 in Library Questions

Hi there,

I'm working with ControlP5 and I want to create a ControlP5 group with an image and some controls inside. How to add a canvas to a group is well documented. Of course, no problem adding controls to a group, but I can't figure out how to include a canvas and some controls into the same group. Any help would be more than welcome!!

r.-

Answers

  • Answer ✓

    Hi, moving a canvas to group is not implemented. but try the following:

    import controlP5.*;
    // uses processing 2.0 and controlP5 2.0.4
    ControlP5 cp5;
    void setup() {
      size(400, 400);
      cp5 = new ControlP5(this);
      Group t = cp5.addGroup("group-test").setPosition(100, 100).setWidth(200);
      cp5.addSlider("slider").setPosition(0, 10).moveTo(t);
      t.addDrawable(new CDrawable() {
        public void draw(PApplet p) {
          p.pushMatrix();
          p.translate(0, 30);
          p.fill(255);
          p.rect(0, 0, 200, 50);
          p.popMatrix();
        }
      }
      );
    }
    
    void draw() {
      background(0);
    }
    
  • Hi sojamo,

    Nice solution! I didn't know the addDrawable function.

    Thanks a lot, r.-

Sign In or Register to comment.