Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Path , shape and image blending

$
0
0

@bg32014 wrote:

I am getting started with blending and i am not clear in some aspects of it. I have 3 layers. The first layer is a image at the bottom. A solid rectangle is laid on top of it on the 2nd level. A path is overlaid on the 3rd layer. I want to blend these three layers so that the path completely exposes the image at the first layer. I am not sure how to achieve this.

void ofApp::draw()
{
    ofImage img_1;
    ofRectangle rect_1;
    ofPath path_1;

    img_1.loadImage("bg.png");
    rect_1.set(200, 200, 400, 300);
    path_1.arc(0, 0, 50, 50, 30, 120);

    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    
    ofSetColor(255, 255, 255, 255);
    img_1.draw(0, 0);
    
    ofSetColor(0, 128, 0, 255);
    ofRect(rect_1);
    
    ofEnableBlendMode(OF_BLENDMODE_SUBTRACT);
    path_1.setFillColor(ofColor(255, 255, 255, 255));
    path_1.draw(mouseX, mouseY);
    
    ofDisableBlendMode();
}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles