diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-05-28 16:41:00 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-05-28 16:41:00 +0100 |
| commit | 4aa44a0b9159300c24db4786a3cf2e4198f168f1 (patch) | |
| tree | 7c37a2b0fcbdeb296d7e45b0f213c772bee2991c | |
| parent | 040eaa3babb648bea889f8c152b522a86e8c39d5 (diff) | |
adding palete manipulation
| -rw-r--r-- | bin/data/bw.xml | 5 | ||||
| -rwxr-xr-x | config.make | 2 | ||||
| -rwxr-xr-x | src/testApp.cpp | 18 | ||||
| -rwxr-xr-x | src/testApp.h | 13 | ||||
| -rwxr-xr-x | src/viewport.h | 19 |
5 files changed, 54 insertions, 3 deletions
diff --git a/bin/data/bw.xml b/bin/data/bw.xml new file mode 100644 index 0000000..f8fd527 --- /dev/null +++ b/bin/data/bw.xml @@ -0,0 +1,5 @@ +<?xml version='1.0' encoding='utf-8'?> +<palette name="b&w"> + <colour hex="FFFFFF"/> + <colour hex="000000"/> +</palette> diff --git a/config.make b/config.make index 5bfa48a..85e8c5d 100755 --- a/config.make +++ b/config.make @@ -17,7 +17,7 @@ USER_CFLAGS = -std=c++11 # for example libraries like: # USER_LDFLAGS = libs/libawesomelib.a -USER_LDFLAGS = +USER_LDFLAGS = -lX11 EXCLUDE_FROM_SOURCE="bin,.xcodeproj,obj" diff --git a/src/testApp.cpp b/src/testApp.cpp index bc2fe0e..c7bf35a 100755 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -11,6 +11,9 @@ void previewWindow::draw(){ for (auto i:parent->viewports) i.draw(parent->brightSlider); } +void previewWindow::dragEvent(ofDragInfo dragInfo, ofxFenster* win){ + parent->dragEvent(dragInfo); +} //-------------------------------------------------------------- guiWindow::~guiWindow(){ cout << "gui window destroyed" << endl; @@ -24,6 +27,9 @@ void guiWindow::draw(){ parent->gui.draw(); } +void guiWindow::dragEvent(ofDragInfo dragInfo, ofxFenster* win){ + parent->dragEvent(dragInfo); +} //-------------------------------------------------------------- void testApp::create1port(bool & pressed){ if (!pressed) return; @@ -220,6 +226,18 @@ void testApp::gotMessage(ofMessage msg){ } //-------------------------------------------------------------- +void testApp::dragEvent(ofDragInfo dragInfo, ofxFenster* win){ + dragEvent(dragInfo); +} +void testApp::dragEvent(ofDragInfo dragInfo){ + printf("got draginfo: %s\n",dragInfo.files[0].c_str()); + int sta=dragInfo.files[0].find_last_of("\\/")+1; + int len=(dragInfo.files[0].find_last_of(".")+4)-sta; + string filename=dragInfo.files[0].substr(sta,len); + printf("loading %s\n",filename.c_str()); + + if (filename.length()) control.loadpalette(filename); +} void testApp::mousePressedEvent(ofMouseEventArgs &args) { diff --git a/src/testApp.h b/src/testApp.h index cc46dfc..376cdee 100755 --- a/src/testApp.h +++ b/src/testApp.h @@ -12,7 +12,10 @@ class previewWindow; class guiWindow; -//#define GRAB_TEXTURE +//load palettes and interpolate them with phase +//some audio drawing +//some actual drawing +//transitions class testApp : public ofxFensterListener { @@ -35,6 +38,8 @@ class testApp : public ofxFensterListener { void mousePressedEvent(ofMouseEventArgs &args); void keyPressedEvent(ofKeyEventArgs &args); void windowEvent(ofResizeEventArgs &args); + void dragEvent(ofDragInfo dragInfo); + void dragEvent(ofDragInfo dragInfo,ofxFenster* win); void toggleFPS(); bool showFPS; @@ -72,6 +77,10 @@ class testApp : public ofxFensterListener { vector<viewport> viewports; vpcontrol control; int windowsize; + + vector<ofColor> palette; + + void loadfilepalette(string &palette); }; @@ -82,6 +91,7 @@ public: void setup(); void setParent(testApp *p); void draw(); + void dragEvent(ofDragInfo dragInfo,ofxFenster* win); }; class guiWindow: public ofxFensterListener{ @@ -91,6 +101,7 @@ public: void setup(); void setParent(testApp *p); void draw(); + void dragEvent(ofDragInfo dragInfo,ofxFenster* win); }; diff --git a/src/viewport.h b/src/viewport.h index 9d2b72c..7ab1477 100755 --- a/src/viewport.h +++ b/src/viewport.h @@ -2,6 +2,7 @@ #define VIEWPORT_H
#include "ofMain.h"
+#include "ofxXmlSettings.h"
class vpcontrol {
public:
@@ -12,11 +13,27 @@ class vpcontrol { yshift=0;
fscale=1.0f;
}
+ void loadpalette(string &filename){
+ ofxXmlSettings XML;
+ if( !XML.loadFile(filename) ){
+ printf("unable to load palette file\n");
+ }else{
+ palette.clear();
+ palettename=XML.getAttribute("palette","name","",0);
+ if(XML.pushTag("palette")) {
+ int numCols=XML.getNumTags("colour");
+ for (int i=0;i<numCols;i++) {
+ palette.push_back(ofColor.fromHex(ofFromHex(XML.getAttribute("colour","hex",0x00,0))));
+ }
+ }
+ }
+ }
bool fillgrey;
float fillgreyfreq;
int xshift,yshift;
float fscale,scale;
-
+ vector<ofColor> palette;
+ string palettename;
};
class viewport
|
