/** a simple gauge simulator by guru */ void setup() { size(300,300); smooth(); } void draw() { background(255); pushMatrix(); translate( width/2,height/2-20); drawGauge( map( mouseX, 0,width,0,1 )); popMatrix(); pushMatrix(); translate( width/2,height-20); drawGauge( map( mouseY, 0,width,0,1 )); popMatrix(); } void drawGauge( float val ) { stroke(0); for( int i=0; i<31; i++) { float a = radians(210 + i * 120 / 30); float r1 = 100; float r2 = 90; r2 = i % 5 == 0 ? 85 : r2; r2 = i % 10 == 0 ? 80 : r2; line( r1*cos(a), r1*sin(a), r2*cos(a), r2*sin(a)); } stroke( 255,0,0 ); float b = radians( 210 + val * 120 ); fill(255,0,0); ellipse(0,0,10,10); line( -10*cos(b),-10*sin(b),100 * cos(b), 100 * sin(b)); }