summaryrefslogtreecommitdiff
path: root/futuregael/src/show.h
diff options
context:
space:
mode:
authorTim Redfern <redfernt@gmail.com>2023-09-20 23:35:53 +0100
committerTim Redfern <redfernt@gmail.com>2023-09-20 23:35:53 +0100
commitcde8fab86a40be5d3c99bfd2d97605638647179f (patch)
tree5f3d25c4eb6757ba399f746dfb96ea175ad8467f /futuregael/src/show.h
parentd47d1294179af82651602c5b548658bcd3b7bdac (diff)
mostly works
Diffstat (limited to 'futuregael/src/show.h')
-rw-r--r--futuregael/src/show.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/futuregael/src/show.h b/futuregael/src/show.h
index c5a7605..45d0023 100644
--- a/futuregael/src/show.h
+++ b/futuregael/src/show.h
@@ -13,6 +13,7 @@ public:
clear();
vector<string> m=ofSplitString(message," ");
+ width=0;
for (auto& word: m){
glyphWord w;
int pos=0;
@@ -28,8 +29,10 @@ public:
ofColor::fromHsb(ofRandom(119)+112,ofRandom(255),255)
));
pos++;
+ w.width+=w.glyphs[w.glyphs.size()-1].width;
}
words.push_back(w);
+ width+=(w.width+enspace);
}
if (audio.load(audiofile)){
@@ -49,8 +52,9 @@ public:
words.clear();
}
vector<colourPolyline>& getOutlines(float time){
+ float wordphase=time/duration;
float phase=time/avgWordDuration;
- float phaseseg=fmod(phase,(int)phase);
+ float phaseseg=fmod(phase,1.0f);
//ofLog()<<"phase "<<phase<<" phaseseg "<<phaseseg;
@@ -93,16 +97,20 @@ public:
outlines.clear();
- float s=0.1f;
+ float s=0.05f;
- float p=(-(ofGetWidth()/3))/s;
+ float p=(-ofGetWidth()/3*s)-(width*wordphase);
if (word1>-1&&word1<words.size()){
+ for (int i=0;i<word1;i++){
+ p+=words[i].width;
+ p+=enspace;
+ }
for (auto& g:words[word1].glyphs){
for (auto& o:g.outline){
auto q=o;
q.scale(s,-s);
- q.translate(glm::vec3(p*s,-ofGetHeight()/3,0));
+ q.translate(glm::vec3(p*s,0,0));
outlines.push_back(colourPolyline(q,g.colour*word1amt));
}
p+=g.width;
@@ -115,7 +123,7 @@ public:
for (auto& o:g.outline){
auto q=o;
q.scale(s,-s);
- q.translate(glm::vec3(p*s,-ofGetHeight()/3,0));
+ q.translate(glm::vec3(p*s,0,0));
outlines.push_back(colourPolyline(q,g.colour*word2amt));
}
p+=g.width;
@@ -133,6 +141,7 @@ public:
float avgWordDuration;
vector<colourPolyline> outlines;
float enspace;
+ float width;
};