Skip to content

Instantly share code, notes, and snippets.

@j-v
Last active December 23, 2015 03:59
Show Gist options
  • Save j-v/6576817 to your computer and use it in GitHub Desktop.
Save j-v/6576817 to your computer and use it in GitHub Desktop.
import controlP5.*;
ControlP5 controlP5;
void setup() {
// ....
new EndlessKnob(controlP5, "knob1").setRange(0,360)
.setPosition(70, 120)
.setRadius(25);
}
class EndlessKnob extends Knob {
EndlessKnob(ControlP5 theControlP5, java.lang.String theName)
{
super(theControlP5, theName);
setConstrained(false);
setAngleRange(PI*2);
setStartAngle(PI/2);
}
void onDrag() {
super.onDrag();
float theValue = getValue();
if (theValue > getMax()){
theValue -= (getMax() - getMin());
}
else if (theValue < getMin()) {
theValue += (getMax() - getMin());
}
setValue(theValue);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment