diff options
| author | Tim Redfern <redfernt@gmail.com> | 2023-08-17 22:41:00 +0100 |
|---|---|---|
| committer | Tim Redfern <redfernt@gmail.com> | 2023-08-17 22:41:00 +0100 |
| commit | 6c6bb89f8b3bd00fa7fc693e8dedc65efd502c0b (patch) | |
| tree | 3fd2eedf5e0b586bc9e5f38d66e6457ee6f2cf40 /lasertext/src/ofApp.h | |
| parent | f50dd71c019a901c032ce87fc007a76198a02632 (diff) | |
object oriented stars+gui
Diffstat (limited to 'lasertext/src/ofApp.h')
| -rw-r--r-- | lasertext/src/ofApp.h | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/lasertext/src/ofApp.h b/lasertext/src/ofApp.h index 621b729..052d565 100644 --- a/lasertext/src/ofApp.h +++ b/lasertext/src/ofApp.h @@ -37,23 +37,30 @@ public: class starSystem{ public: vector<star> stars; - ofVec2f centre; - float radius; - float rate; - float speed; - float lifespan; float agevar; float last; - starSystem(ofVec2f c=ofVec2f(0,0), float _rad=100,float r=0.5,float s=5.0,float l=5.0,float v=1.0){ - init(c,_rad,r,s,l,v); + ofxPanel gui; + ofParameter<float> x; + ofParameter<float> y; + ofParameter<float> rate; + ofParameter<float> radius; + ofParameter<float> speed; + ofParameter<float> lifespan; + ofParameter<bool> bScan; + starSystem(){ } - void init(ofVec2f c, float _rad,float r,float s,float l,float v){ - centre=c; - radius=_rad; - rate=r; - speed=s; - lifespan=l; + void init(string name="",int _gx=5, int _gy=5, float _x=0, float _y=0, float _rad=100,float r=0.5,float s=5.0,float l=5.0,float v=1.0){ + agevar=v; + + gui.setup(name,"",_gx,_gy); + gui.add(x.set("x", _x, -2000.0f, 2000.0f)); + gui.add(y.set("y", _y, -2000.0f, 2000.0f)); + gui.add(rate.set("rate", r, 0.01f, 3.0f)); + gui.add(radius.set("radius", _rad, 10.0f, 500.0f)); + gui.add(speed.set("speed", s, 0.0f, 10.0f)); + gui.add(lifespan.set("life", l, 3.0f, 10.0f)); + gui.add(bScan.set("scan", true)); } void update(){ float now=ofGetElapsedTimef(); @@ -96,17 +103,30 @@ public: } } - vector<scannableColourPolyline> getPoints(){ + vector<colourPolyline> getPoints(){ float now=ofGetElapsedTimef(); - vector<scannableColourPolyline> o; - for(auto& s:stars){ + vector<scannableColourPolyline> s; + for(auto& star:stars){ 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)); - o.push_back(l); + l.addVertex(x+star.pos.x,y+star.pos.y,ofColor(1.0f-((now-star.birthday)/star.lifespan)*128.0f)); + l.addVertex(x+star.pos.x+1,y+star.pos.y+1,ofColor(1.0f-((now-star.birthday)/star.lifespan)*128.0f)); + s.push_back(l); + } + + if (bScan){ + std::sort(s.begin(),s.end()); } - return o; + + vector<colourPolyline> o; + + int numstars=0; + for (auto& shape: s) { + shape.draw(); + o.push_back((colourPolyline)shape); + } + + return o; } }; @@ -141,15 +161,6 @@ class ofApp : public ofBaseApp{ string displaytext; glyphbanner banner; - 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; ofParameter<float> laser_pos_x; |
