/* We've modified this class slightly so that may be used as a controller for a beats Glide class instance. If the gl attribute is not null, then the program expects that gl is a Glide instance. The update function know maps the angle of the control knob to a control range determined by a lower limit (ll) and upper limit (ul). Two auxiliary functions have been added that map angle to control value and control value to angle. Note that there is no error checking here (bad!) to ensure that gl is actually a valid Glide instance. */ class Control { PImage img; float x; float y; float a; Glide gl = null; float ll = 0; float ul = 0; float ctrl = 0; Control(PImage img0, float x0, float y0, float a0) { img = img0; x = x0; y = y0; a = a0; } void update() { a -= mouseY - pmouseY; a = constrain(a, -135, 135); if (gl != null) { setCtrl(); gl.setValue(ctrl); } } void setAngle() { a = map(ctrl, ll, ul, -135, 135); } void setCtrl() { ctrl = map(a, -135, 135, ll, ul); } void draw() { pushMatrix(); translate(x, y); rotate(radians(a)); image(img, 0, 0); popMatrix(); } }