float rotAngle = 0; void lineRotate(float armLength, float speed){ clearDisplay(); strokeWeight(10); // Controls thickness of line stroke(color(0, 0, 255)); fill(0,0,0); if ((screenWidth - menu.width)/calibrator.magx - t > 2*armLength){ ellipseMode(CENTER); ellipse(convertXCoord(centerX), convertYCoord(centerY), (screenWidth - menu.width)/calibrator.magx - t, (screenWidth - menu.width)/calibrator.magx - t); t = t + speed; } else { ellipseMode(CENTER); ellipse(convertXCoord(centerX), convertYCoord(centerY), 2*armLength, 2*armLength); line(convertXCoord(centerX), convertYCoord(centerY), convertXCoord(centerX) + armLength*cos(rotAngle*PI/180), convertYCoord(centerY) + armLength*sin(rotAngle*PI/180)); rotAngle = rotAngle + speed; } }