-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGauge.pde
53 lines (49 loc) · 1.13 KB
/
Gauge.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class Gauge
{
private float currentValue;
private float min, max;
private String units;
private int x;
private int y;
private String text;
private PFont font;
Gauge (float min, float max, String units, int x, int y, String text)
{
this.min=min;
this.max=max;
this.units=units;
this.x=x;
this.y=y;
this.text=text;
font=createFont("ConnectionSerif.otf", 12);
//textFont(font);
}
//Gets input and stores it as current Value if it is within range
void getInput(float input)
{
if(input>=min && input<=max)
{
currentValue=input;
display();
}
else
{
println("input out of range");
}
}
//Displays the Gauge on screen
void display()
{
stroke(0,0,255);
strokeWeight(10);
fill(0);
ellipse(x, y, 250, 250);
strokeWeight(2);
fill(255);
textAlign(CENTER);
textSize(30);
text(nf(currentValue,0, 2)+units, x, y+15);
textSize(20);
text(text, x,y+160);
}
}