diff options
| author | Tim Redfern <tim@getdrop.com> | 2022-08-16 16:44:55 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@getdrop.com> | 2022-08-16 16:44:55 +0100 |
| commit | 1fe5dceef2df8cb7a67e0760507be418bee754b8 (patch) | |
| tree | 740a65366eeeba7057270225fef0afe236129319 /lasertext | |
| parent | 3f24a2f8f7f05b9200fb0f5341a3fc1139ee7748 (diff) | |
animate with timing
Diffstat (limited to 'lasertext')
| -rw-r--r-- | lasertext/src/ofApp.cpp | 16 | ||||
| -rw-r--r-- | lasertext/src/ofApp.h | 24 |
2 files changed, 24 insertions, 16 deletions
diff --git a/lasertext/src/ofApp.cpp b/lasertext/src/ofApp.cpp index 2974056..96b56ab 100644 --- a/lasertext/src/ofApp.cpp +++ b/lasertext/src/ofApp.cpp @@ -5,10 +5,6 @@ what do we want to store/control per letter? */ - -int MAX_POINTS=40000; -int LASER_INTENSITY=128; - //-------------------------------------------------------------- void ofApp::setup(){ fonts.open("fonts/"); @@ -20,10 +16,11 @@ void ofApp::setup(){ banner.loadFont("fonts/EMSPepita.svg"); //fonts.getPath(currentFont)); banner.init("Everything Is Going To Be Alright"); - laser.set_pts(MAX_POINTS); - laser.set_intensity(LASER_INTENSITY); + textgui.setup("text","",5,680); + textgui.add(text_scale.set("scale", 1.0f, 0.5f, 3.0f)); + textgui.add(text_speed.set("speed", 1.0f, 0.0f, 2.0f)); - lasergui.setup("laser","",5,700); + lasergui.setup("laser","",5,750); lasergui.add(laser_power.set("power", true)); lasergui.add(laser_intensity.set("intensity", 30, 0, 255)); lasergui.add(laser_points.set("points", 30000, 0, 40000)); @@ -41,7 +38,7 @@ void ofApp::setup(){ } //-------------------------------------------------------------- void ofApp::update(){ - banner.update(1.0f); + banner.update(text_speed); laser.set_pts(laser_points); laser.set_subdivide(laser_subdivide); @@ -56,9 +53,10 @@ void ofApp::draw(){ ofBackground(0,0,0); ofSetColor(255,255,255); + textgui.draw(); lasergui.draw(); - vector<colourPolyline> shapes = banner.getOutlines(0.08f); //+(0.02f*sin(ofGetElapsedTimef()*.1f))); + vector<colourPolyline> shapes = banner.getOutlines(0.08f*text_scale); //+(0.02f*sin(ofGetElapsedTimef()*.1f))); int num = 0; 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; |
