summaryrefslogtreecommitdiff
path: root/nextus/src
diff options
context:
space:
mode:
Diffstat (limited to 'nextus/src')
-rw-r--r--nextus/src/ofApp.cpp4
-rw-r--r--nextus/src/vectorPlugin.cpp148
-rw-r--r--nextus/src/vectorPlugin.h34
3 files changed, 102 insertions, 84 deletions
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 << ":"<<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";
+ select_random_shapes();
+
+ ofLog()<<"loaded SVG "<<filename<<", "<<segmenters.size()<<" paths";
}
else {
@@ -83,48 +75,60 @@ void svgPanel::load(string filename){
}
}
-void svgPanel::select_random_shapes(float duration,bool generate){
- float timedelta=ofGetElapsedTimef()-last_frame_time;
- last_frame_time=ofGetElapsedTimef();
- //track how long each shape has been selected
- for (int i=0;i<shape_selection_durations.size();i++){
- if (shape_selection_durations[i]>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 << ":"<<spawn<<" ";
}
+}
+
+void svgPanel::update_random_shapes(bool generate=true){
+
shape_selection.clear();
+ //track how long each shape has been selected and recreate the selection
for (int i=0;i<shape_selection_durations.size();i++){
- if (shape_selection_durations[i]>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 <<":"<<shape_selection_durations[s]<<" ";
}
- //cout << timedelta <<": decay selection: "<<shape_selection.size()<<" shapes (" << strom.str() <<") \n";
- if (generate){
-
- //the toggle was pressed
- //simulate a button
- generate_shapes=false;
+ cout << timedelta <<": decay selection: "<<shape_selection.size()<<" shapes (" << strom.str() <<") \n";
+ */
+ if (generate){
while (shape_selection.size()<(segmenters.size()*shapes_amount)){
int selection=rand()%segmenters.size();
if (shape_selection.find(selection)==shape_selection.end()){
- shape_selection_durations[selection]=duration+ofRandom(1.0f);
+ shape_selection_durations[selection]=shapes_duration+ofRandom(1.0f);
shape_selection.insert(selection);
}
}
+ /*
std::stringstream strm;
for (auto& s:shape_selection){
strm << s <<":"<<shape_selection_durations[s]<<" ";
}
+ cout << "random selection: "<<shape_selection.size()<<" shapes (" << strm.str() <<") \n";
+ */
}
- //cout << "random selection: "<<shape_selection.size()<<" shapes (" << strm.str() <<") \n";
}
@@ -138,55 +142,55 @@ vector<colourPolyline> svgPanel::getAllLines(){
vector<colourPolyline> svgPanel::getLines(){
vector<colourPolyline> output;
- return output;
+
//if (!use_onset||onset_frame<onset_duration||shapes_randomise){
- if (shapes_randomise){
- //if (framecounter==0){
- // select_random_shapes();
- // framecounter=shapes_duration;
- //}
- select_random_shapes(shapes_duration,generate_shapes); //from audio !use_onset||onset_frame<onset_duration);
- for (auto s:shape_selection){
- if (use_segmenter){
- auto segments=segmenters[s].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);
- }
- }
- else {
- //output.push_back(colourPolyline(segmenters[s].getPoly(),ofColor(laser_R,laser_G,laser_B)));
- output.push_back(segmenters[s].getPoly());
+ if (shapes_randomise){
+ //if (framecounter==0){
+ // select_random_shapes();
+ // framecounter=shapes_duration;
+ //}
+ update_random_shapes(true); //from audio !use_onset||onset_frame<onset_duration);
+ for (auto s:shape_selection){
+ if (use_segmenter){
+ auto segments=segmenters[s].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);
}
}
- framecounter--;
+ else {
+ //output.push_back(colourPolyline(segmenters[s].getPoly(),ofColor(laser_R,laser_G,laser_B)));
+ output.push_back(segmenters[s].getPoly());
+ }
}
- 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);
- }
- }
- 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<colourPolyline> 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<colourPolyline> 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<colourPolyline> getLines() {};
+ virtual void update() {};
protected:
ofVec2f size;
@@ -58,6 +59,7 @@ class defaultPanel: public vectorPanel{
vector<colourPolyline> 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<colourPolyline> getAllLines();
vector<colourPolyline> 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<bool> shapes_randomise;
- ofParameter<bool> generate_shapes; //manual version of audio driven version
+ ofxButton shapes_generate;
ofParameter<float> shapes_amount;
ofParameter<float> shapes_duration;
//ofxToggle use_mask;
//ofxToggle invert_mask;
//segmenter
+ ofxLabel segmenterlabel;
+
ofParameter<bool> use_segmenter;
//ofxToggle colour_segmenter;
ofParameter<float> 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