From d503992380630c1ee6d2edce8861d5f6e31cf8a1 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sat, 18 Aug 2018 12:09:34 +0100 Subject: start vector plugin arch --- gui/src/chaoslib.h | 203 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 gui/src/chaoslib.h (limited to 'gui/src/chaoslib.h') diff --git a/gui/src/chaoslib.h b/gui/src/chaoslib.h new file mode 100644 index 0000000..9196e88 --- /dev/null +++ b/gui/src/chaoslib.h @@ -0,0 +1,203 @@ +#pragma once + +#include "ofMain.h" +#include "ofxGui.h" +#include "ofxAChaoslib.h" + + +class AChaosplugin{ + public: + AChaosBase* plugin; + vector > params; + string name; + AChaosplugin(AChaosBase* _plugin,string _name,vector _params={0,0,0,0,0,0}){ + plugin=_plugin; + name=_name; + ofLog()<<"AChaosplugin creating "<<_name<<" with "<<_plugin->get_param_labels().size()<<" parameters"; + //ofLog()<<"AChaosplugin copied "<get_param_labels().size()<<" parameters"; + plugin->setup(); + + load_defaults(); + //ofLog()<<"AChaosplugin created "<iv.size();i++){ + if (plugin->get_param_labels()[i].size()){ + params.push_back(ofParameter ().set(plugin->get_param_labels()[i],plugin->iv[i],0,plugin->iv[i]*5)); + } + } + } + +}; + +class Chaosplugin{ + public: + Chaosplugin(){ + + } + vector plugins; + int whichplugin; + ofParameter name; +}; + + +class Chaoslib{ + public: + vector plugins; + vector > params; + int whichplugin; + ofParameter name; + Chaoslib(){ + //can only use those that have 2 output params? + //or just make it 1 dimensional? only affect the x axis? + //plugins.push_back(new AChaosplugin(new AChaosBaker(),"Baker")); + plugins.push_back(new AChaosplugin(new AChaosClifford(),"Clifford")); + plugins.push_back(new AChaosplugin(new AChaosCollatz(),"Collatz")); + plugins.push_back(new AChaosplugin(new AChaosDuffing(),"Duffing")); + plugins.push_back(new AChaosplugin(new AChaosGinger(),"Ginger")); + plugins.push_back(new AChaosplugin(new AChaosHenon(),"Henon")); + whichplugin=0; + update_name(); + } + + + + AChaosbase* get_plugin(){ + return plugins[whichplugin]->plugin; + } + AChaosbase* get_params(){ + return plugins[whichplugin]->params; + } + void next(){ + whichplugin=(whichplugin+1)%plugins.size(); + update_name(); + } + void previous(){ + whichplugin=whichplugin-1; + if (whichplugin<0){ + whichplugin=plugins.size()-1; + } + update_name(); + } + void update_name(){ + name=plugins[whichplugin]->name; + //save old params & load new + } + std::string &get_name(){ + return plugins[whichplugin]->name; + } +}; + +class chaosPanel : public ofxPanel { + public: + chaosPanel(){ + ofRegisterKeyEvents(this, defaultEventsPriority); + } + bool isSelected; + ofParameter active; + ofParameter amount; + ofParameter scale; //?per plugin?? + bool mouseMoved(ofMouseEventArgs & args){ + if (args.x>getPosition().x&& + args.x-getPosition().xgetPosition().y&& + args.y-getPosition().y "< "< "< + transformer + <> + chaos + <> + drawing + + */ + + int shown=0; + + void update_sliders(){ + clear(); + add(plugin_label.setup(chaosloader.name)); + add(active.set("use",false)); + add(amount.set("amount", 0.0f, -0.1f, 0.1f)); + + for (int i=0;iget_param_labels()[i].size()){ + + add(chaosloader.get_params()[i]); + + } + } + } + colourPolyline compute_chaos(colourPolyline& poly){ + float chaosscale=1.0f; + colourPolyline tempPoly; + for (int i=0;iiv.size()]; + iv[0]=poly[i].x-(ofGetWidth()/2)/chaosscale; + iv[1]=poly[i].y-(ofGetHeight()/2)/chaosscale; + //chaos_a,chaos_b,chaos_k,chaos_p}; + //ofLog() << i<<": calculating chaos with: "<"<<((poly[i].x-(ofGetWidth()/2))/chaosscale)<<" "<"<<((poly[i].y-(ofGetHeight()/2))/chaosscale)<<" "<set(iv); + chaosloader.get_plugin()->calc(); + //ofLog() << i<<": got points: "<ov[0]*chaosscale)+(ofGetWidth()/2), + (chaosloader.get_plugin()->ov[1]*chaosscale)+(ofGetHeight()/2)), + poly.getColourAt(i)); + } + return tempPoly; +} +private: + Chaoslib chaosloader; + ofxLabel plugin_label; + ofParameter plugin_name; + + +}; + -- cgit v1.2.3