Last active
December 23, 2015 03:59
-
-
Save j-v/6576817 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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