-
Notifications
You must be signed in to change notification settings - Fork 18
/
Help.pde
50 lines (44 loc) · 1.1 KB
/
Help.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
boolean drawHelp = false;
long helpStartMS = millis();
String[] helpLines = {
"Keyboard Shortcuts:",
"",
"0-9 set drawing speed",
"a-g change setups",
"arrows change gears and mount points",
"x erase the paper",
"[ ] change pen color",
"< > change pen width",
"/ invert connecting rod",
"~ draw entire cycle",
};
void helpDraw()
{
if (drawHelp) {
long elapsed = millis() - helpStartMS;
float alpha = constrain(map(elapsed, 10*1000, 13*1000, 1, 0),0,1);
if (alpha <= 0.0001) {
drawHelp = false;
}
noStroke();
float hx = width-500*seventyTwoScale;
float hy = 30*seventyTwoScale-100*constrain(map(elapsed,0,300,1,0),0,1);
fill(255,alpha*alpha*192);
rect(hx-8, 0, width-(hx-8), hy + 22*helpLines.length);
fill(100, alpha*alpha*255);
textFont(hFont);
textAlign(LEFT);
for (int i = 0; i < helpLines.length; ++i) {
text(helpLines[i], hx, hy+22*i);
}
}
}
void toggleHelp()
{
if (drawHelp) {
drawHelp = false;
} else {
drawHelp = true;
helpStartMS = millis();
}
}