Utility graph colours now configurable

Look in the graph design GUI for sliders
This commit is contained in:
James Alliban
2014-01-22 15:13:38 +00:00
parent fa5df9cad7
commit 8ad8d65b44
19 changed files with 113 additions and 40 deletions
+9 -7
View File
@@ -99,13 +99,15 @@ void GUI::addGraphDesignGUI()
gui->addSlider("Grid Blue", 0, 255, &app->scene.gridCol[2], length, dim);
gui->addSlider("Grid Alpha", 0, 255, &app->scene.gridCol[3], length, dim);
//gui->addSpacer(length, 1);
//gui->addSlider("Data0 red", 0, 255, &app->scene.graphManager.col0[0], length, dim);
//gui->addSlider("Data0 green", 0, 255, &app->scene.graph.col0[1], length, dim);
//gui->addSlider("Data0 blue", 0, 255, &app->scene.graph.col0[2], length, dim);
//gui->addSlider("Data0 alpha", 0, 255, &app->scene.graph.col0[3], length, dim);
gui->addLabel("COLOUR");
gui->addSlider("Front red", 0, 255, &Graph::colFront[0], length, dim);
gui->addSlider("Front green", 0, 255, &Graph::colFront[1], length, dim);
gui->addSlider("Front blue", 0, 255, &Graph::colFront[2], length, dim);
gui->addSlider("Front alpha", 0, 255, &Graph::colFront[3], length, dim);
gui->addSlider("Back red", 0, 255, &Graph::colBack[0], length, dim);
gui->addSlider("Back green", 0, 255, &Graph::colBack[1], length, dim);
gui->addSlider("Back blue", 0, 255, &Graph::colBack[2], length, dim);
gui->addSlider("Back alpha", 0, 255, &Graph::colBack[3], length, dim);
finaliseCanvas(gui, true);
+47 -1
View File
@@ -15,6 +15,8 @@ float Graph::graphHeightMax;
float Graph::graphEndPercent;
float Graph::zRange;
float Graph::graphTextZOffset;
float Graph::colFront[4];
float Graph::colBack[4];
float Graph::lineLength;
float Graph::lineSpacing;
@@ -44,6 +46,9 @@ void Graph::update(ofVec3f activeCamPos)
drawInfoToFbo();
}
if (hasColorChanged())
updateColours();
ofVec3f camPos = activeCamPos;
centre = ofVec3f(0.1, 0.1, ofMap(graphID, 0, 29, -zRange, zRange));
distToCam = sqrt(double(ABS(camPos.x - centre.x) * ABS(camPos.x - centre.x) * ABS(camPos.x - centre.x) +
@@ -170,7 +175,19 @@ void Graph::addNewData(DataObject newData)
graphMesh.addVertex(vertexTop);
graphMesh.addVertex(vertexBottom);
ofColor col = ofColor(ofMap(graphID, 0, 29, 0, 255), ofMap(graphID, 0, 29, 255, 0), ofMap(graphID, 0, 29, 150, 50), 255);
ofColor col;
col.r = (int)ofMap(graphID, 0, 29, colFront[0], colBack[0]);
col.g = (int)ofMap(graphID, 0, 29, colFront[1], colBack[1]);
col.b = (int)ofMap(graphID, 0, 29, colFront[2], colBack[2]);
col.a = (int)ofMap(graphID, 0, 29, colFront[3], colBack[3]);
//= ofColor(ofMap(
// graphID, 0, 29, 0, 255),
// ofMap(graphID, 0, 29, 255, 0),
// ofMap(graphID, 0, 29, 150, 50),
// 255);
//if (ofRandomuf() < 0.1) col = ofColor(ofRandom(255), ofRandom(255), ofRandom(255), 255);
@@ -229,4 +246,33 @@ vector<string> Graph::explode(const string &delimiter, const string &str)
}
arr.push_back( str.substr(k, i-k) );
return arr;
}
bool Graph::hasColorChanged()
{
if (colFront[0] != colBack[0] || colFront[1] != colBack[1] || colFront[2] != colBack[2] || colFront[3] != colBack[3])
return true;
else
return false;
}
void Graph::updateColours()
{
ofColor col;
col.r = (int)ofMap(graphID, 0, 29, colFront[0], colBack[0]);
col.g = (int)ofMap(graphID, 0, 29, colFront[1], colBack[1]);
col.b = (int)ofMap(graphID, 0, 29, colFront[2], colBack[2]);
col.a = (int)ofMap(graphID, 0, 29, colFront[3], colBack[3]);
for (int i = 0; i < graphMesh.getColors().size(); i+=2)
{
graphMesh.setColor(i, col);
graphMesh.setColor(i+1, ofColor(col.r, col.g, col.b, 0));
}
}
+6
View File
@@ -20,6 +20,8 @@ public:
void drawInfoToFbo();
void clear();
vector<string> explode(const string &delimiter, const string &str);
bool hasColorChanged();
void updateColours();
testApp *app;
int graphID;
@@ -41,6 +43,10 @@ public:
static float graphEndPercent;
static float zRange;
static float graphTextZOffset;
static float colFront[4];
static float colBack[4];
static float prevColFront[4];
static float prevColBack[4];
static float lineLength;
static float lineSpacing;