class GUIControl{ String label; float angle; float cos, sin; int start, stop; int radius = 10; float value,minVal,maxVal; //----------- GUIControl(String label,int i, float minVal, float maxVal, float value){ this.label = label; this.minVal = minVal; this.maxVal = maxVal; this.value = value; start = 17; stop = 35; angle = -0.7 + 0.4*i; cos = cos(angle); sin = sin(angle); } //----------- void mouseHover(float dx,float dy){ float v = atan2( dy, dx ); float d = mag(dx, dy); if( abs(v-angle) < 0.2 && d<=stop && d>=start ) text(label,6+(int)(stop*cos),2+(int)(stop*sin)); } //----------- void mouseInput(float dx,float dy){ float v = atan2( dy, dx ); float d = mag(dx, dy); if( abs(v-angle) < 0.2 && d<=stop && d>=start ) value = (maxVal-minVal)*(d-start)/(stop-start) + minVal; } //----------- void setValue(float x){ value = x; } //----------- float getValue(){ return value; } //----------- void draw(){ strokeWeight(5); stroke(128,128); line( start*cos, start*sin, stop*cos, stop*sin ); float r = start + (stop-start)*value/(maxVal-minVal); stroke(128); line( start*cos, start*sin, r*cos, r*sin ); } }