public class StripeGUIManager{
private ControlP5 control;
private ControlWindow window;
private Controller<Toggle> bgColor;
private Controller<Toggle> rSpeeds;
private Controller<Knob> blurKnob;
private Controller<Knob> speedKnob;
public static float scalerAmt;
public static float blurAmt;
public static boolean blackOrWhite;
public static boolean randomSpeeds;
public StripeGUIManager(PApplet p) {
control = new ControlP5(p);
// Init window
window = control
.addControlWindow("Stripe_Control_Window", 100, 100, 200, 200)
.hideCoordinates().setBackground(p.color(90));
// Speed Scaler Knob
speedKnob = control.addKnob("scalerAmt").setRange(0.2f, 3.5f)
.setValue(1).setPosition(10, 100).setRadius(30)
.setColorForeground(p.color(255))
.setColorBackground(p.color(200, 160, 100))
.setColorActive(p.color(255, 60, 60))
.setDragDirection(Knob.HORIZONTAL);
// Init blur knob
blurKnob = control.addKnob("blurAmt").setRange(1, 100).setValue(5)
.setPosition(100, 100).setRadius(30)
.setColorForeground(p.color(255))
.setColorBackground(p.color(200, 160, 100))
.setColorActive(p.color(255, 60, 60))
.setDragDirection(Knob.HORIZONTAL);
// Init toggle switch
bgColor = control.addToggle("blackOrWhite").setPosition(10, 40)
.setSize(50, 20).setValue(true).setMode(ControlP5.SWITCH);
rSpeeds = control.addToggle("randomSpeeds").setPosition(80, 40)
.setSize(50, 20).setMode(ControlP5.SWITCH);
// Set controls to window object
((Toggle) bgColor).moveTo(window);
((Knob) blurKnob).moveTo(window);
((Knob) speedKnob).moveTo(window);
((Toggle) rSpeeds).moveTo(window);
}
public void ControlEvent(ControlEvent theEvent) {
if (theEvent.isController()) {
System.out.println("Something is happening.");
if (theEvent.getName().matches("blurAmt")) {
blurAmt = theEvent.getValue();
}
}}} //Sorry about the formatting... It's a forum thing..