#pragma once #include "ofMain.h" #include "ofxGui.h" #include "ofxXmlSettings.h" #include "ofxSVG.h" #include "ofxClipper.h" #include "ofxMidi.h" #include "ofxPONK.h" #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); drawcontent(); ofPopMatrix(); ofPopMatrix(); } virtual void drawcontent() {};; 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){ ofLog()<<"loading SVG "< 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 outlines= path.getOutline(); for (auto& outline:outlines){ //strm << outline.size() << "->"; //outline.simplify(contour_simplify); //strm << outline.size() << " "; segmenters.push_back(colourLineSegmenter(outline,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 << ":"<getPoly().draw(); } } 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 segmenters; //vector shape_selection_durations; //set shape_selection; //int framecounter; //float phase,prev_time; //to calculate phase //float rotate_amt; //float scale_phase,scale_amt; }; class ofApp: public ofBaseApp, public ofxMidiListener { public: ofApp() : networkinput("network",DISPLAYSIZE,ofPoint(5,5)), svginput("svg",DISPLAYSIZE,ofPoint(210,5)), textinput("text",DISPLAYSIZE,ofPoint(415,5)) {} void setup(); void update(); void draw(); void exit(); void keyPressed(ofKeyEventArgs &keyargs); void keyReleased(ofKeyEventArgs & args); 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 newMidiMessage(ofxMidiMessage& eventArgs); //======================================= //MIDI ofxMidiIn midiIn; ofxMidiMessage midiMessage; //======================================= //saving settings ofxXmlSettings XML; void default_settings(); void save_settings(); void load_settings(); //======================================= //inputs svgPanel networkinput; svgPanel svginput; svgPanel textinput; };