-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTalkoTimer.pde
129 lines (90 loc) · 2.81 KB
/
TalkoTimer.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
int talk_len = 40;
int num_slides = 50;
long talkElapsedTime = 0;
long talkStartTime = 0;
boolean talkRunning = false;
PFont text_font;
PFont number_font;
import java.util.concurrent.TimeUnit;
void setup() {
//size(1000,800,JAVA2D);
fullScreen();
frameRate(15);
number_font = createFont("AnonymousPro-Bold.ttf", height/4);
text_font = createFont("NixieOne.ttf", height/4);
}
void toggleTalkRun() {
talkRunning = ! talkRunning;
if(talkRunning) {
talkStartTime = millis();
}
}
void modTalkTime(int amt)
{
if(talkRunning) return;
talk_len = max(1, talk_len+ amt);
}
void modSlideCount(int amt)
{
if(talkRunning) return;
num_slides = max(1,num_slides+ amt);
}
void keyPressed()
{
if(keyCode == UP) modTalkTime(1);
if(keyCode == DOWN) modTalkTime(-1);
if(keyCode == LEFT) modSlideCount(-1);
if(keyCode == RIGHT) modSlideCount(1);
if(keyCode == ENTER) toggleTalkRun();
if(keyCode == RETURN) toggleTalkRun();
}
String clockTime="x";
String talkTime ="x";
void draw() {
background(10);
textAlign(CENTER,CENTER);
if(!talkRunning) {
fill(#AA1111);
textFont(number_font,height/6);
text(nf(num_slides), width*0.33,height*0.5);
text(nf(talk_len), width*0.66,height*0.5);
textFont(text_font,height/8);
text("slides", width*0.33, height*0.33);
text("mins", width*0.66, height*0.33);
}
else {
background(#6BA76D);
fill(#020502);
clockTime = (String.format("%02d:%02d",hour(),minute()));
textSize(height/5);
text(clockTime, width/2, height/3);
textFont(number_font);
int millisElapsed = (int)(millis() - talkStartTime);
String ElapsedTimeStr = String.format("%02d:%02d",
TimeUnit.MILLISECONDS.toMinutes(millisElapsed),
TimeUnit.MILLISECONDS.toSeconds(millisElapsed) -
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millisElapsed))
);
textSize(height/6);
text(ElapsedTimeStr, width/2, 2*(height/3));
// draw the bar telling how long you have for that slide.
// we can determine millis/slide
float millisPerSlide = (talk_len*60000)/num_slides;
// we can now determine what slide we should be on
float currentSlide = millisElapsed/millisPerSlide;
float currentSlidePercent=currentSlide%1;
float tBarWidth = width/3;
rect(
(width/2) - (tBarWidth/2),
0.5*height,
(currentSlidePercent*tBarWidth),
20
);
textSize(60);
if(millis() % 1000 == 0) { print(millisPerSlide); }
textAlign(CENTER,BOTTOM);
text(nf((int)currentSlide+1,0,0), width/2,height-30);
//text(nf(millisPerSlide/1000.0f),width/2,height);
//text(nf(currentSlide%1,0,3),40,height-50);
}
}