Blend object colors


I want to blend colors but i don’t know how !

Basically i have a circle with a color. I want to change its color by blending another color to it.

How would i achieve that ?

Well i was able to blend colors but by drawing the circle twice ! There must be a cleaner and more optimized solution i guess…

void ball::draw() {
    ofCircle(position, radius);
    ofSetColor(ofMap(dist.x + dist.y, -10, 10, 40, 200, true));
    ofCircle(position, radius);

Try calling lerp on the color.

ofColor tcolor( 255, 0, 0 );
ofColor bcolor( 255, 0, 255 );
tcolor.lerp( bcolor, sin( ofGetElapsedTimef() ) * 0.5 + 0.5 );
ofSetColor( tcolor );

hello @NickHardeman

yes this is working thanks

but i was looking for something more like regular blending modes like Add, Multiply or Screen…
Strange that there is no easy blending method like

ofColor a(r, g, b);
ofColor b(r1, g1, b1);
ofColor c = a.blend(b, blend_mode);

The only solution i found is to encode the blend formula i needed

void ball::draw() {
    ofColor color = ofColor(ofRandom(16), ofRandom(16), ofRandom(16));
    ofColor c = ofColor(ofMap(dist.x + dist.y, -10, 10, 40, 200, true));
    // formula for color SCREEN blend mode
    ofSetColor(ofColor(255) - (((ofColor(255) - c)*(ofColor(255) - color))/ofColor(255)));
    ofCircle(position, radius);

If anyone has another solution…