Getting ControlP5 Label Color to work
in
Contributed Library Questions
•
1 year ago
I've searched high and low and can't find an example of changing the color of a cp5 label text. The ref docs point to a .setColor(int) method, but calling that method gives an error saying the function setColor() does not exist. I can use .setColorBackground() but it doesn't change anything. I'm using this in a HUD for an OpenGL application, but I can't find/create an example of even a regular use of a cp5 label where I can set the background color and/or text color. Seems like this should work.
Any ideas?
Here's the example cp5/OpenGL code using a label...
- /**
- * ControlP5 with PeasyCam support. tested with peasy 0.93
- *
- * by jeffg 2011
- * https://forum.processing.org/topic/opengl2-and-controlp5
- */
- import peasy.*;
- import controlP5.*;
- import processing.opengl.*;
- PeasyCam cam;
- ControlP5 controlP5;
- Textlabel statusLabel;
- int buttonValue = 1;
- int myColor = color(255,0,0);
- void setup() {
- size(400,400,OPENGL);
- cam = new PeasyCam(this, 100);
- controlP5 = new ControlP5(this);
- controlP5.addButton("button",10,100,60,80,20).setId(1);
- controlP5.addButton("buttonValue",4,100,90,80,20).setId(2);
- // Need a label for this application
- statusLabel = controlP5.addTextlabel("status","STATUS: ",100,150);
- statusLabel.setColor(color(255)); //This line gives an error -- comment out
- statusLabel.setColorBackground(color(128)); //This line is accepted but has no effect with any color value on label backcolor
- controlP5.setAutoDraw(false);
- }
- void draw() {
- background(0);
- fill(myColor);
- box(30);
- pushMatrix();
- translate(0,0,20);
- fill(0,0,255);
- box(5);
- popMatrix();
- gui();
- }
- void gui() {
- cam.beginHUD();
- controlP5.draw();
- cam.endHUD();
- }
- void controlEvent(ControlEvent theEvent) {
- println(theEvent.controller().id());
- }
- void button(float theValue) {
- myColor = color(random(255),random(255),random(255));
- println("a button event. "+theValue);
- }
1