#pragma once #include "ofMain.h" #include "ofxSvg.h" #include "ofxGui.h" #include "ofxXmlSettings.h" #include "ofxHelios.h" #include "lineTransformer.h" #include "colourPolyline.h" #include "vectortext.h" class scannableColourPolyline: public colourPolyline{ public: bool operator < (const scannableColourPolyline& line) const { return (operator[](0).x < line[0].x); } }; class star{ public: star(ofVec2f p,ofVec2f v,float l){ pos=p; vel=v; birthday=ofGetElapsedTimef(); lifespan=l; } void update(vector& stars){ pos+=vel; } ofVec2f pos; ofVec2f vel; float birthday; float lifespan; }; class starSystem{ public: vector 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); } void init(ofVec2f c, float _rad,float r,float s,float l,float v){ centre=c; radius=_rad; rate=r; speed=s; lifespan=l; agevar=v; } void update(){ float now=ofGetElapsedTimef(); float segment=now-last; last=now; for(auto it = stars.begin(); it != stars.end();) { if(now-it->birthday>it->lifespan){ //ofLog()<<"erase star"; it = stars.erase(it); } else { //ofLog()<<"update star"; it->update(stars); ++it; } } if (ofRandom(rate) getPoints(){ float now=ofGetElapsedTimef(); vector o; for(auto& s: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); } return o; } }; class ofApp : public ofBaseApp{ public: void setup(); void update(); void draw(); void exit(); void keyPressed(ofKeyEventArgs &keyargs); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void mouseEntered(int x, int y); void mouseExited(int x, int y); void windowResized(int w, int h); void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); void default_settings(); void save_settings(); ofxHelios laser; ofDirectory fonts; int currentFont; string displaytext; glyphbanner banner; ofxPanel starsgui; ofParameter stars_x; ofParameter stars_y; ofParameter stars_rate; ofParameter stars_radius; ofParameter stars_speed; ofParameter stars_life; ofParameter bScanStars; ofxPanel textgui; ofParameter laser_scale; ofParameter laser_pos_x; ofParameter laser_pos_y; ofParameter text_speed; //======= laser gui ofxPanel lasergui; ofParameter laser_power; ofParameter laser_intensity; ofParameter laser_points; ofParameter laser_subdivide; ofParameter laser_blank_num; ofParameter laser_max_angle; ofxXmlSettings XML; starSystem stars; glm::vec2 warpframe[4]; int select_warpframe; bool bDrawFrame; ofPoint outputWindowSize; ofPoint outputPosition; float outputScale; };