Color-in certain shapes

Let’s say I am drawing a bunch of different lines with ofBeginShape(), ofVertex() and ofEndShape() inside of a for loop (only one line gets drawn after every iteration). How would I go about coloring in the different shapes I would be creating with different colors?

Not sure if I get the question, but I would call ofSetColor() every time before ofBeginShape()?

    int h = 200;
    int w = 5;
    ofColor colors[3] = {ofColor::aquamarine, ofColor::navy, ofColor::white};
    for(char i=0; i<10; i++){
        int x = i * 50 + 25;
        ofVertex(x, ofGetWindowHeight() * 0.5);
        ofVertex(x, ofGetWindowHeight() * 0.5 - h);
        ofVertex(x + w, ofGetWindowHeight() * 0.5 - h);
        ofVertex(x + w, ofGetWindowHeight() * 0.5);
        ofVertex(x, ofGetWindowHeight() * 0.5);

Resulting in:

1 Like

So if I want to use random colors everytime, do I still have to somehow use an array? Or is it possible to do what you did without using an array of specified colors?

ofSetColor(ofColor(ofRandom(255), ofRandom(255), ofRandom(255))); is very random.
The array was just something I randomly did :slight_smile: