diff options
| author | Tim Redfern <tim@getdrop.com> | 2023-04-23 23:22:38 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@getdrop.com> | 2023-04-23 23:22:38 +0100 |
| commit | 9e0236016f5d6afd3a73edad183dfb2b02387e98 (patch) | |
| tree | 5589b5010a1de6eed1650493e812179b84e6e3c6 /nextus/src/vectorPlugin.h | |
| parent | cdb92d8c8532a287b752a92f1cf0cbf88d52c117 (diff) | |
many fixes for Nextus show at the complex April 22 2023
Diffstat (limited to 'nextus/src/vectorPlugin.h')
| -rw-r--r-- | nextus/src/vectorPlugin.h | 97 |
1 files changed, 61 insertions, 36 deletions
diff --git a/nextus/src/vectorPlugin.h b/nextus/src/vectorPlugin.h index 78ce06d..a2cdb84 100644 --- a/nextus/src/vectorPlugin.h +++ b/nextus/src/vectorPlugin.h @@ -23,28 +23,16 @@ class vectorPanel { position=_pos; panel.setup(_title,"",_pos.x,_pos.y+size.y+5); - /* + float f1=-1.0; float f2=1.0; - vector<glm::vec3> v1 = {{f1,f1,0},{f2,f1,0}}; - vector<glm::vec3> v2 = {{f2,f1,0},{f2,f2,0}}; - vector<glm::vec3> v3 = {{f2,f2,0},{f1,f2,0}}; - vector<glm::vec3> v4 = {{f1,f2,0},{f1,f1,0}}; - ofPolyline p1,p2,p3,p4; - p1.addVertices(v1); - p2.addVertices(v2); - p3.addVertices(v3); - p4.addVertices(v4); - frame.push_back(p1); - frame.push_back(p2); - frame.push_back(p3); - frame.push_back(p4); - */ - ofPolyline p=ofPolyline().fromRectangle(ofRectangle(-1.0f,-1.0f,2.0f,2.0f)); - p.close(); - - frame.push_back(p); + frame.addVertex(f1,f1); + frame.addVertex(f2,f1); + frame.addVertex(f2,f2); + frame.addVertex(f1,f2); + frame.close(); + } void draw(){ panel.draw(); @@ -64,18 +52,19 @@ class vectorPanel { ofPopMatrix(); } vector<colourPolyline> clipOutput() { - ofLog()<<"frame has "<<frame.size()<<" paths"; - return lineClipper::mask(getOutput(),ofRectangle(-1.0f,-1.0f,2.0f,2.0f)); + //ofLog()<<"frame has "<<frame.size()<<" paths"; + return lineClipper::clip(getOutput(),frame); }; - vector<colourPolyline> getOutput() {return getLines();}; - virtual vector<colourPolyline> getLines() {}; - virtual void update() {}; + virtual vector<colourPolyline> getOutput()=0; + //vector<colourPolyline> getOutput(){return getLines();} + virtual vector<colourPolyline> getLines()=0; + virtual void update()=0; protected: ofVec2f size; ofPoint position; ofxPanel panel; - vector <ofPolyline> frame; + ofPolyline frame; }; class defaultPanel: public vectorPanel{ @@ -86,6 +75,9 @@ class defaultPanel: public vectorPanel{ ofVec2f _size=DISPLAYSIZE, ofVec2f _pos=ofPoint(5,5) ) : vectorPanel(_title,_size,_pos){} + vector<colourPolyline> getOutput(){ + return getLines(); + } vector<colourPolyline> getLines(){ vector<colourPolyline> output; return output; @@ -103,22 +95,39 @@ class transformPanel: public vectorPanel{ ) : vectorPanel(_title,_size,_pos){ origin=ofPoint(0,0); rotation=0; - panel.add(use_rotate.set("rotate",false)); + scale_time=0; + panel.add(transform.set("transform",false)); + panel.add(use_rotate.set("rotate enable",false)); panel.add(rotation_delta.set("rotation",0.1,-2.0,2.0)); + panel.add(use_scale.set("scale enable",false)); + panel.add(scale_factor.set("scale factor",0.1,0.0,10.0)); + panel.add(scale_osc_freq.set("scale osc freq",0.1,0.01,2.0)); + panel.add(scale_osc_scale.set("scale osc scale",0.0,0.0,10.0)); + panel.add(randomise.setup("randomise")); + randomise.addListener(this,&transformPanel::randomiseScale); + } + void randomiseScale(){ + scale_time=ofRandom(6.3f); } void update(){ timedelta=ofGetElapsedTimef()-last_frame_time; last_frame_time=ofGetElapsedTimef(); if (use_rotate) rotation+=rotation_delta*timedelta; + if (use_scale) { + scale_time+=timedelta*scale_osc_freq; + scale=scale_factor+((sin(scale_time)+1.0)*scale_osc_scale); + } }; vector<colourPolyline> getOutput(){ vector<colourPolyline> lines=getLines(); - if (use_rotate){ + if (transform){ ofMatrix4x4 rm = ofMatrix4x4::newIdentityMatrix(); rm.rotateRad(rotation,0,0,1); - //if (use_scale){ - // rm.scale(scale_amt,scale_amt,scale_amt); + if(use_scale){ + rm.scale(scale,scale,scale); + } + //} //rm.translate(outputWindowSize.x/2,outputWindowSize.y/2,0); vector<colourPolyline> transformedLines; @@ -132,8 +141,16 @@ class transformPanel: public vectorPanel{ protected: ofPoint origin; float rotation; + float scale; + float scale_time; + ofParameter<bool> transform; ofParameter<bool> use_rotate; ofParameter<float> rotation_delta; + ofParameter<bool> use_scale; + ofParameter<float> scale_factor; + ofParameter<float> scale_osc_freq; + ofParameter<float> scale_osc_scale; + ofxButton randomise; float last_frame_time, timedelta; }; @@ -152,6 +169,7 @@ class svgPanel: public transformPanel{ ofVec2f _pos=ofPoint(5,5) ) : transformPanel(_title,_size,_pos){ panel.add(shapeslabel.setup("SHAPES","")); + panel.add(colourise.set("colourise",false)); panel.add(shapes_randomise.set("randomise",false)); //panel.add(shapes_generate.setup("generate")); panel.add(shapes_amount.set("amount",0.2,0.0,1.0)); @@ -179,7 +197,7 @@ class svgPanel: public transformPanel{ //ofxFloatSlider contour_simplify; ofxLabel shapeslabel; - //svg gui + ofParameter<bool> colourise; ofParameter<bool> shapes_randomise; ofxButton shapes_generate; ofParameter<float> shapes_amount; @@ -207,31 +225,37 @@ class svgPanel: public transformPanel{ }; -class textPanel: public vectorPanel{ +class textPanel: public transformPanel{ public: textPanel( string _title="", ofVec2f _size=DISPLAYSIZE, ofVec2f _pos=ofPoint(5,5) - ) : vectorPanel(_title,_size,_pos){ + ) : transformPanel(_title,_size,_pos){ + styles={"Style: Words","Style: Overlapping","Style: Sentence"}; panel.add(use_beat.set("use beat", false)); panel.add(beat_duration.set("duration factor", 0.5f, 0.0f, 1.0f)); - panel.add(text_speed.set("speed", 5.0f, 0.0f, 25.0f)); + panel.add(text_speed.set("speed", 5.0f, 0.0f, 100.0f)); panel.add(text_scale.set("scale", 0.001f, 0.0f, 0.01f)); panel.add(enable_anim.set("animate", true)); - panel.add(spread_anim.set("spread", true)); + panel.add(anim_style.set(styles[0], 0,0,styles.size()-1)); panel.add(anim_rev.set("reverse", false)); panel.add(vert_pos.set("vert_pos", 0.0f, -0.3f, 0.3f)); panel.add(vert_spread.set("vert_spread", 0.0f, -0.3f, 0.3f)); text.loadFont("fonts/EMSOsmotron.svg"); + anim_style.addListener(this,&textPanel::styleChanged); } void update(){ + transformPanel::update(); text.update(); } + void styleChanged(int &style){ + anim_style.setName(styles[style]); + } vector<colourPolyline> getLines(){ vector<colourPolyline> shapes=text.getOutlines( text_scale, - spread_anim?STYLE_OVERLAPPING:STYLE_SENTENCE, + anim_style, 0,0, enable_anim, anim_rev, @@ -257,11 +281,12 @@ class textPanel: public vectorPanel{ ofParameter<float> text_speed; ofParameter<float> text_scale; ofParameter<bool> enable_anim; - ofParameter<bool> spread_anim; + ofParameter<int> anim_style; ofParameter<bool> anim_rev; ofParameter<float> vert_pos; ofParameter<float> vert_spread; glyphbanner text; + vector<string> styles; }; /* class textgui : public ofxPanel{ |
