-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWord.pde
More file actions
57 lines (50 loc) · 1.29 KB
/
Word.pde
File metadata and controls
57 lines (50 loc) · 1.29 KB
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
/*
word transcribed from google cloud speech-to-text
with time stamps
*/
class Word {
String txt;
int length;
float in, out;
float width;
float opacity;
Boolean paragraph;
Boolean spoken;
Word(float in_, float out_, String txt_, Boolean paragraph_) {
in = in_;
out = out_;
txt = txt_;
paragraph = paragraph_;
if (paragraph)
txt += " ...";
width = textWidth(this.txt);
length = txt.length();
opacity = 0.0;
spoken = false;
}
Boolean speaking() {
float now = (float)current_time/1000;
if ((in <= now) && (out >= now))
return true;
else
return false;
}
Boolean spoken() {
float now = (float)current_time/1000;
if ((in <= now))
return true;
else
return false;
}
void opacity(float value) {
if (opacity == 0.0)
// opacity = map(value, 0.0, 0.05, 100.0, 255.0);
opacity = map(value, 0.0, 0.08, 100.0, 255.0);
}
void display(int fill, float _x, float _y) {
fill(fill, int(opacity));
text(txt, _x, _y);
// int weight = int(map(fill, 0.0, 255.0, 0.0, 12.0));
// stroke_text(txt, weight, _x, _y);
}
}