diff options
| author | Tim Redfern <tim@getdrop.com> | 2022-08-25 21:55:37 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@getdrop.com> | 2022-08-25 21:55:37 +0100 |
| commit | 835ce29a83b134b037c5d9d4b9fc7a7d0cb1ada4 (patch) | |
| tree | be7c3d0539ffd8e882793e4bbac766173fb290e1 /lasertext/src/ofApp.h | |
| parent | 77ce73a9b57cf3deac08720b449886b71412ea2f (diff) | |
store laser and stars settings
Diffstat (limited to 'lasertext/src/ofApp.h')
| -rw-r--r-- | lasertext/src/ofApp.h | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/lasertext/src/ofApp.h b/lasertext/src/ofApp.h index a78f0c2..a099cf6 100644 --- a/lasertext/src/ofApp.h +++ b/lasertext/src/ofApp.h @@ -9,6 +9,12 @@ #include "lineTransformer.h" #include "colourPolyline.h" +class scannableColourPolyline: public colourPolyline{ +public: + bool operator < (const scannableColourPolyline& line) const { + return (operator[](0).x < line[0].x); + } +}; class star{ public: @@ -68,10 +74,15 @@ public: float a=ofRandom(3.57f); float r=ofRandom(radius); ofVec2f offset=ofVec2f(cos(a)*r,sin(a)*r); + + //avoid having stars that don't move, for safety + a=ofRandom(3.57f); + r=(ofRandom(0.8)+0.2)*speed; + ofVec2f speed=ofVec2f(cos(a)*r,sin(a)*r); stars.push_back(star( offset, - ofVec2f(ofRandom(speed)-(speed/2),ofRandom(speed)-(speed/2)), + speed, lifespan+ofRandom(agevar)-(agevar/2) )); /* @@ -84,11 +95,11 @@ public: } } - vector<colourPolyline> getPoints(){ + vector<scannableColourPolyline> getPoints(){ float now=ofGetElapsedTimef(); - vector<colourPolyline> o; + vector<scannableColourPolyline> o; for(auto& s:stars){ - colourPolyline l; + scannableColourPolyline l; //ofLog()<<"get star"; l.addVertex(centre.x+s.pos.x,centre.y+s.pos.y,ofColor(1.0f-((now-s.birthday)/s.lifespan)*128.0f)); l.addVertex(centre.x+s.pos.x+1,centre.y+s.pos.y+1,ofColor(1.0f-((now-s.birthday)/s.lifespan)*128.0f)); @@ -240,6 +251,7 @@ public: } words.push_back(w); } + //ofLog()<<"created "<<words.size()<<" words"; } void createWords(vector<glyphWord> _words){ clear(); @@ -315,14 +327,18 @@ public: else { //proportional to #of letters int theletter=int(playhead)%glyphCount(); theword=0; - while((theletter-=words[theword].glyphs.size())>0){ + while(theletter>words[theword].glyphs.size()){ + theletter-=words[theword].glyphs.size(); theword++; } - segment=(((float)theletter+words[theword].glyphs.size()+playhead-int(playhead))/words[theword].glyphs.size()); - } + float playfraction=playhead-int(playhead); + + //segment=(((float)theletter+words[theword].glyphs.size()+playhead-int(playhead))/words[theword].glyphs.size()); + segment=(((float)theletter+playfraction-1)/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); + words[i].amount=(i==theword?sin(segment*3.14):0); for (auto& g:words[i].glyphs){ if (ofRandom(100)<speed) { g.colour= @@ -388,9 +404,11 @@ class ofApp : public ofBaseApp{ ofxPanel starsgui; ofParameter<float> stars_x; ofParameter<float> stars_y; + ofParameter<float> stars_rate; ofParameter<float> stars_radius; ofParameter<float> stars_speed; ofParameter<float> stars_life; + ofParameter<bool> bScanStars; ofxPanel textgui; ofParameter<float> laser_scale; |
