From 28718e114696f1d5d735992c29f8e0b1dd83a90d Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 19 Apr 2023 12:01:10 +0100 Subject: WIP some svg stuff working --- nextus/src/ofApp.cpp | 4 +- nextus/src/vectorPlugin.cpp | 148 +++++++++++++++++++++++--------------------- nextus/src/vectorPlugin.h | 34 +++++++--- 3 files changed, 102 insertions(+), 84 deletions(-) (limited to 'nextus/src') diff --git a/nextus/src/ofApp.cpp b/nextus/src/ofApp.cpp index 45c3aaf..48bcb9a 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); } @@ -53,7 +53,7 @@ void ofApp::load_settings(){ void ofApp::update(){ - + svginput.update(); } diff --git a/nextus/src/vectorPlugin.cpp b/nextus/src/vectorPlugin.cpp index 03b7eaa..c87de08 100644 --- a/nextus/src/vectorPlugin.cpp +++ b/nextus/src/vectorPlugin.cpp @@ -53,7 +53,7 @@ void svgPanel::load(string filename){ path.getStrokeColor() ) ); - //shape_selection_durations.push_back(0.0f); + shape_selection_durations.push_back(0.0f); } //strm << " , "; @@ -61,21 +61,13 @@ void svgPanel::load(string filename){ //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 << ":"<0.0f){ - shape_selection_durations[i]=shape_selection_durations[i]-timedelta; - } +void svgPanel::select_random_shapes(){ + + 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 << ":"<0.0f){ + if (shape_selection_durations[i]>timedelta){ + shape_selection_durations[i]-=timedelta; shape_selection.insert(i); } } + + // + + /* std::stringstream strom; for (auto& s:shape_selection){ strom << s <<":"< svgPanel::getAllLines(){ vector svgPanel::getLines(){ vector output; - return output; + //if (!use_onset||onset_framegetSegments(segmenter_number,segmenter_length,phase); - for (auto segment=segments.begin();segment!=segments.end();segment++){ - //output.push_back(colourPolyline(*segment,ofColor(laser_R,laser_G,laser_B))); - output.push_back(*segment); - } - } - else { - //output.push_back(colourPolyline(shape->getPoly(),ofColor(laser_R,laser_G,laser_B))); - output.push_back(shape->getPoly()); + framecounter--; + } + else { + for (auto shape=segmenters.begin();shape!=segmenters.end();shape++){ + if (use_segmenter){ + auto segments=shape->getSegments(segmenter_number,segmenter_length,phase); + for (auto segment=segments.begin();segment!=segments.end();segment++){ + //output.push_back(colourPolyline(*segment,ofColor(laser_R,laser_G,laser_B))); + output.push_back(*segment); } } - } - /* - this should happen at output stage? - - if (contour_useColour){ - vector newPolys; - for (auto p: output){ - newPolys.push_back(colourPolyline((ofPolyline)p,ofColor(laser_R,laser_G,laser_B))) ; + else { + //output.push_back(colourPolyline(shape->getPoly(),ofColor(laser_R,laser_G,laser_B))); + output.push_back(shape->getPoly()); } - output=newPolys; } - */ - //} + } + /* + this should happen at output stage? + if (contour_useColour){ + vector newPolys; + for (auto p: output){ + newPolys.push_back(colourPolyline((ofPolyline)p,ofColor(laser_R,laser_G,laser_B))) ; + } + output=newPolys; + } + */ +//} + return output; } \ No newline at end of file diff --git a/nextus/src/vectorPlugin.h b/nextus/src/vectorPlugin.h index 8a3f557..94ea947 100644 --- a/nextus/src/vectorPlugin.h +++ b/nextus/src/vectorPlugin.h @@ -19,15 +19,15 @@ class vectorPanel { { size=_size; position=_pos; - panel.setup(_title,"",0,size.y+5); + panel.setup(_title,"",_pos.x,_pos.y+size.y+5); } - void draw(){ + void draw(){ + panel.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); @@ -39,6 +39,7 @@ class vectorPanel { ofPopMatrix(); } virtual vector getLines() {}; + virtual void update() {}; protected: ofVec2f size; @@ -58,6 +59,7 @@ class defaultPanel: public vectorPanel{ vector output; return output; } + void update(){}; }; class svgPanel: public vectorPanel{ @@ -67,34 +69,46 @@ class svgPanel: public vectorPanel{ ofVec2f _size=DISPLAYSIZE, ofVec2f _pos=ofPoint(5,5) ) : vectorPanel(_title,_size,_pos){ - //panel.add(ofxLabel().setup("SHAPES","")); + panel.add(shapeslabel.setup("SHAPES","")); panel.add(shapes_randomise.set("randomise",false)); - panel.add(generate_shapes.set("generate",false)); + //panel.add(shapes_generate.setup("generate")); panel.add(shapes_amount.set("amount",0.2,0.0,1.0)); panel.add(shapes_duration.set("duration",5.0,0,10.0)); - panel.add(use_segmenter.set("SEGMENTER",false)); - panel.add(shapes_randomise.set("randomise",false)); + panel.add(segmenterlabel.setup("SEGMENTER","")); + panel.add(use_segmenter.set("enable",false)); panel.add(segmenter_speed.set("speed",0.2,-1.0,1.0)); panel.add(segmenter_length.set("length",0.2,0.0,1.0)); panel.add(segmenter_number.set("number",1,1,8)); + + //shapes_generate.addListener(this,&svgPanel::generate_shapes); } void load(string filename); - void select_random_shapes(float duration,bool generate); + void select_random_shapes(); + void update_random_shapes(bool generate); vector getAllLines(); vector getLines(); + void update(){ + timedelta=ofGetElapsedTimef()-last_frame_time; + last_frame_time=ofGetElapsedTimef(); + phase=fmod(phase+(timedelta*segmenter_speed),1); + //while(phase<1) phase+=1.0f; + } private: //ofxFloatSlider contour_simplify; + ofxLabel shapeslabel; //svg gui ofParameter shapes_randomise; - ofParameter generate_shapes; //manual version of audio driven version + ofxButton shapes_generate; ofParameter shapes_amount; ofParameter shapes_duration; //ofxToggle use_mask; //ofxToggle invert_mask; //segmenter + ofxLabel segmenterlabel; + ofParameter use_segmenter; //ofxToggle colour_segmenter; ofParameter segmenter_speed; @@ -110,5 +124,5 @@ class svgPanel: public vectorPanel{ //float rotate_amt; //float scale_phase,scale_amt; - float last_frame_time; + float last_frame_time, timedelta; }; \ No newline at end of file -- cgit v1.2.3