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 | |
| parent | 77ce73a9b57cf3deac08720b449886b71412ea2f (diff) | |
store laser and stars settings
Diffstat (limited to 'lasertext/src')
| -rw-r--r-- | lasertext/src/lineTransformer.h | 1 | ||||
| -rw-r--r-- | lasertext/src/ofApp.cpp | 43 | ||||
| -rw-r--r-- | lasertext/src/ofApp.h | 34 |
3 files changed, 66 insertions, 12 deletions
diff --git a/lasertext/src/lineTransformer.h b/lasertext/src/lineTransformer.h index f5ec22f..9e44d1a 100644 --- a/lasertext/src/lineTransformer.h +++ b/lasertext/src/lineTransformer.h @@ -17,5 +17,4 @@ class lineTransformer { colourPolyline static polyLineTransform(ofPoint (*transferFunction)(const ofPoint),colourPolyline& poly,float colourFade=1.0f); ofPolyline static makePolygon(int num,float diam); void static drawPoly(ofPolyline poly,float x,float y); - };
\ No newline at end of file diff --git a/lasertext/src/ofApp.cpp b/lasertext/src/ofApp.cpp index a4e076d..89fa856 100644 --- a/lasertext/src/ofApp.cpp +++ b/lasertext/src/ofApp.cpp @@ -20,12 +20,14 @@ void ofApp::setup(){ banner.loadFont("fonts/EMSDecorousScript.svg"); // EMSPepita.svg"); //fonts.getPath(currentFont)); banner.init("Everything Is Going To Be Alright"); - starsgui.setup("stars","",5,350); + starsgui.setup("stars","",5,450); starsgui.add(stars_x.set("x", 0.0f, -2000.0f, 2000.0f)); starsgui.add(stars_y.set("y", 0.0f, -2000.0f, 2000.0f)); + starsgui.add(stars_rate.set("y", 1.0f, 0.01f, 3.0f)); starsgui.add(stars_radius.set("radius", 100.0f, 10.0f, 500.0f)); starsgui.add(stars_speed.set("speed", 5.0f, 0.0f, 10.0f)); starsgui.add(stars_life.set("life", 4.0f, 3.0f, 10.0f)); + starsgui.add(bScanStars.set("scan", true)); textgui.setup("text","",5,650); @@ -74,6 +76,19 @@ void ofApp::setup(){ laser_pos_y=XML.getValue("POSITION:Y", 0); laser_scale=XML.getValue("SCALE", 1.0f); + laser_intensity=XML.getValue("laser:intensity",30); + laser_points=XML.getValue("laser:points",30000); + laser_subdivide=XML.getValue("laser:subdivide",15); + laser_blank_num=XML.getValue("laser:blankpoints",8); + laser_max_angle=XML.getValue("laser:maxangle",15.0f); + + stars_x=XML.getValue("stars:X",0.0f); + stars_y=XML.getValue("stars:Y",0.0f); + stars_rate=XML.getValue("stars:rate",1.0f); + stars_radius=XML.getValue("stars:radius",100.0f); + stars_speed=XML.getValue("stars:speed",5.0f); + stars_life=XML.getValue("stars:life",4.0f); + stars.init(ofVec2f(2000.0f,2000.0f),100.0f,1.0,5.0,4.0,1.0); } @@ -104,6 +119,19 @@ void ofApp::save_settings(){ XML.setValue("SCALE", laser_scale); + XML.setValue("laser:intensity",laser_intensity); + XML.setValue("laser:points",laser_points); + XML.setValue("laser:subdivide",laser_subdivide); + XML.setValue("laser:blankpoints",laser_blank_num); + XML.setValue("laser:maxangle",laser_max_angle); + + XML.setValue("stars:X",stars_x); + XML.setValue("stars:Y",stars_y); + XML.setValue("stars:rate",stars_rate); + XML.setValue("stars:radius",stars_radius); + XML.setValue("stars:speed",stars_speed); + XML.setValue("stars:life",stars_life); + XML.saveFile("settings.xml"); cout << "settings.xml saved!" <<std::endl; } @@ -121,6 +149,7 @@ void ofApp::update(){ stars.centre=ofVec2f(stars_x,stars_y); + stars.rate=stars_rate; stars.radius=stars_radius; stars.speed=stars_speed; stars.lifespan=stars_life;; @@ -189,14 +218,22 @@ void ofApp::draw(){ ofSetColor(255,255,255); - vector<colourPolyline> starshapes=stars.getPoints(); + vector<scannableColourPolyline> starshapes=stars.getPoints(); + + if (bScanStars){ + std::sort(starshapes.begin(),starshapes.end()); + } + + vector<colourPolyline> laserstars; + int numstars=0; for (auto& s: starshapes) { numstars+=s.size(); s.draw(); + laserstars.push_back((colourPolyline)s); } - num+=laser.draw(starshapes); + num+=laser.draw(laserstars); if (num>0){ ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser points: "+ofToString(num)+", stars: "+ofToString(numstars)); 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; |
