summaryrefslogtreecommitdiff
path: root/lasertext/src/ofApp.h
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2022-08-16 16:44:55 +0100
committerTim Redfern <tim@getdrop.com>2022-08-16 16:44:55 +0100
commit1fe5dceef2df8cb7a67e0760507be418bee754b8 (patch)
tree740a65366eeeba7057270225fef0afe236129319 /lasertext/src/ofApp.h
parent3f24a2f8f7f05b9200fb0f5341a3fc1139ee7748 (diff)
animate with timing
Diffstat (limited to 'lasertext/src/ofApp.h')
-rw-r--r--lasertext/src/ofApp.h24
1 files changed, 17 insertions, 7 deletions
diff --git a/lasertext/src/ofApp.h b/lasertext/src/ofApp.h
index 3fcde84..5ca1895 100644
--- a/lasertext/src/ofApp.h
+++ b/lasertext/src/ofApp.h
@@ -50,6 +50,7 @@ class glyphbanner{
vector<colourPolyline> outlines;
ofVec2f centre;
float lastUpdateTime;
+ float playhead;
float enspace;
vector<string> split(string s) {
size_t pos_start = 0, pos_end;
@@ -70,6 +71,7 @@ public:
void init(string message){
createWords(message);
lastUpdateTime=ofGetElapsedTimef();
+ playhead=0.0f;
}
int length(){
int l=0;
@@ -177,27 +179,31 @@ public:
}
}
void clear(){words.clear();}
- void update(float period=1.0f){
- float t=ofGetElapsedTimef()/period;
+ void update(float speed=1.0f){
+
+ float delta=ofGetElapsedTimef()-lastUpdateTime;
+ lastUpdateTime=ofGetElapsedTimef();
+ playhead+=delta*speed;
+
int theword=0;
float segment=0.0f;
if (false){ //1 word per second
- theword=int(t)%words.size();
- segment=t-int(t);
+ theword=int(playhead)%words.size();
+ segment=playhead-int(playhead);
}
else { //proportional to #of letters
- int theletter=int(t)%glyphCount();
+ int theletter=int(playhead)%glyphCount();
theword=0;
while((theletter-=words[theword].glyphs.size())>0){
theword++;
}
- segment=(((float)theletter+words[theword].glyphs.size()+t-int(t))/words[theword].glyphs.size());
+ segment=(((float)theletter+words[theword].glyphs.size()+playhead-int(playhead))/words[theword].glyphs.size());
}
//calculate params for word/letter anim
for (int i=0;i<words.size();i++){
words[i].amount=(i==theword?sin(segment*3.1415):0);
for (auto& g:words[i].glyphs){
- if (ofRandom(period)<0.01) {
+ if (ofRandom(100)<speed) {
g.randomiseColour();
}
}
@@ -252,6 +258,10 @@ class ofApp : public ofBaseApp{
string displaytext;
glyphbanner banner;
+ ofxPanel textgui;
+ ofParameter<float> text_scale;
+ ofParameter<float> text_speed;
+
//======= laser gui
ofxPanel lasergui;