diff options
| -rw-r--r-- | nextus/src/ofApp.cpp | 3 | ||||
| -rw-r--r-- | nextus/src/ofApp.h | 169 |
2 files changed, 4 insertions, 168 deletions
diff --git a/nextus/src/ofApp.cpp b/nextus/src/ofApp.cpp index 349c1a4..45c3aaf 100644 --- a/nextus/src/ofApp.cpp +++ b/nextus/src/ofApp.cpp @@ -15,7 +15,7 @@ void ofApp::setup(){ load_settings(); - madlaser.setup("madlaser",995,510); + //madlaser.setup("madlaser",995,510); ofSetFrameRate(60); } @@ -83,7 +83,6 @@ void ofApp::draw(){ madlaser.panel.draw(); madlaser.draw(output); - } diff --git a/nextus/src/ofApp.h b/nextus/src/ofApp.h index 47f5a7f..a549ff2 100644 --- a/nextus/src/ofApp.h +++ b/nextus/src/ofApp.h @@ -12,170 +12,7 @@ #include "lineTransformer.h" #include "lineSegmenter.h" - -static ofVec2f DISPLAYSIZE(200,200); -static int panelnum=1; - -class vectorPanel { - public: - vectorPanel( - string _title="", - ofVec2f _size=DISPLAYSIZE, - ofVec2f _pos=ofPoint(5,5)) - { - size=_size; - position=_pos; - panel.setup(_title,"",0,size.y+5); - } - void draw(){ - ofPushMatrix(); - ofTranslate(position); - ofSetColor(255); - ofNoFill(); - ofDrawRectangle(0,0,size.x,size.y); - panel.draw(); - ofPushMatrix(); - ofTranslate(size/2); - ofScale(DISPLAYSIZE.x/2.0f); - vector<colourPolyline> lines=getLines(); - for (auto& line:lines){ - line.draw(); - } - ofPopMatrix(); - ofPopMatrix(); - } - virtual vector<colourPolyline> getLines() {}; - - private: - ofVec2f size; - ofPoint position; - ofxPanel panel; -}; - -class svgPanel: public vectorPanel{ - public: - svgPanel( - string _title="", - ofVec2f _size=DISPLAYSIZE, - ofVec2f _pos=ofPoint(5,5) - ) : vectorPanel(_title,_size,_pos){} - void load(string filename){ - - ofxSVG svg; - svg.load(filename); - - //normalise the SVG paths to a square format - - float dimension=max(svg.getWidth(),svg.getHeight()); - - glm::vec2 src[]={ - glm::vec2(0,0), - glm::vec2(dimension,0), - glm::vec2(dimension,dimension), - glm::vec2(0,dimension) - }; - - glm::vec2 dst[]={ //PONK coords - glm::vec2(-1,-1), - glm::vec2(1,-1), - glm::vec2(1,1), - glm::vec2(-1,1) - }; - - ofMatrix4x4 xform=lineTransformer::getPerspectiveTransformMatrix(src,dst); - - vector <ofPath> imagepaths= svg.getPaths(); - - std::stringstream strm; - - if (imagepaths.size()){ - segmenters.clear(); - //shape_selection_durations.clear(); - for (auto& path:imagepaths){ - path.setPolyWindingMode(OF_POLY_WINDING_ODD); - - vector <ofPolyline> outlines= path.getOutline(); - for (auto& outline:outlines){ - //strm << outline.size() << "->"; - //outline.simplify(contour_simplify); - //strm << outline.size() << " "; - ofPolyline xformed=lineTransformer::polyLineTransform(xform,outline); - ofColor c1=path.getStrokeColor(); - ofColor colour=path.getFillColor(); - if (colour.r==colour.g&&colour.g==colour.b){ - colour=c1; - } - - segmenters.push_back( - colourLineSegmenter( - xformed, - path.getStrokeColor() - ) - ); - //shape_selection_durations.push_back(0.0f); - } - - //strm << " , "; - } - - //std::stringstream strom; - - //shape_selection.clear(); - //while (shape_selection.size()<(segmenters.size()*shapes_amount)){ - // int selection=(int)ofRandom(0,segmenters.size()); - // shape_selection.insert(selection); - //} - //for (auto s:shape_selection){ - // float spawn=(ofRandom(0,(float)shapes_duration)); - // shape_selection_durations[s]=spawn; - // strom << s << ":"<<spawn<<" "; - //} - //last_frame_time=ofGetElapsedTimef(); - //cout << "SVG: selected paths [ "<<strom.str() << " ]" <<std::endl; - //cout << "SVG: found " << imagepaths.size() << " paths with " << segmenters.size() << " shapes [ " << strm.str() << " ]" <<std::endl; - //select_random_shapes(shapes_duration); - ofLog()<<"loaded SVG "<<filename<<", "<<segmenters.size()<<" paths"; - - } - else { - ofLog()<<"could not load SVG "<<filename; - } - } - vector<colourPolyline> getLines(){ - vector<colourPolyline> output; - for (auto& shape:segmenters){ - output.push_back(shape.getPoly()); - } - //ofLog()<<"svg found "<<output.size()<<" lines"; - return output; - } - - private: - //ofxFloatSlider contour_simplify; - - //svg gui - //ofxToggle shapes_randomise; - //ofxFloatSlider shapes_amount; - //ofxFloatSlider shapes_duration; - //ofxToggle use_mask; - //ofxToggle invert_mask; - - //segmenter - //ofxToggle use_segmenter; - //ofxToggle colour_segmenter; - //ofxFloatSlider segmenter_speed; - //ofxFloatSlider segmenter_length; - //ofxIntSlider segmenter_number; - - - vector <colourLineSegmenter> segmenters; - //vector <float> shape_selection_durations; - //set <int> shape_selection; - //int framecounter; - //float phase,prev_time; //to calculate phase - //float rotate_amt; - //float scale_phase,scale_amt; -}; +#include "vectorPlugin.h" class ofApp: public ofBaseApp, public ofxMidiListener { @@ -219,9 +56,9 @@ class ofApp: public ofBaseApp, public ofxMidiListener { //======================================= //inputs - svgPanel networkinput; + defaultPanel networkinput; svgPanel svginput; - svgPanel textinput; + defaultPanel textinput; //======================================= //output |
