ofxTriangle
ofxTriangle copied to clipboard
ofSetColor setting all triangles color
I'm experiencing an issue with setting a color within the library. I have it in a for loop with nTriangles, yet it seems that its setting all the triangles to the same color. I'm averaging colors from a video and I have checked to make sure they are changing.
Here's the code snippet:
void ofxTriangle::draw(float x, float y, bool fillSwitch) { if (fillSwitch) ofFill(); else ofNoFill();
if(averageColors.size() > 0){
for (int i=0; i<nTriangles; i++){
float r = averageColors[i].r;
float g = averageColors[i].g;
float b = averageColors[i].b;
ofSetColor(r,g,b);
//ofSetColor(255, 88, 130);
ofPushMatrix();
ofTranslate(x, y, 0);
ofTriangle(triangles[i].a.x, triangles[i].a.y,
triangles[i].b.x, triangles[i].b.y,
triangles[i].c.x, triangles[i].c.y);
ofPopMatrix();
}
}
}
Thanks!
Ian