ofImage画像をofPath描画でマスクする #openFrameworks
ofImageへのマスク処理
0.9.0~ できるようになったというofImageへのマスク処理 setAlphaMask (参考:画像を形を指定してマスクする)を試してみました。
サンプルコード
ofPath path;
ofImage img;
ofFbo fbo;
void ofApp::setup(){
ofHideCursor();
//set path
for(auto i = 0 ; i < 100 ; i++){
ofSetColor(255);
const auto pos = ofPoint(ofRandom(float(ofGetWidth())),float(ofRandom(ofGetHeight())));
path.lineTo(pos);
}
//set fbo
fbo.allocate(ofGetWidth(),ofGetHeight(),GL_RGBA /*GL_LUMINANCE*/);
fbo.begin();
path.draw();
fbo.end();
//set img
//dataフォルダに好きな画像を入れてください。
if(!img.load("mirrorboy.jpg")){
ofLog() << "image is not loaded." ;
};
img.setAnchorPercent(0.5,0.5);
img.getTexture().setAlphaMask(fbo.getTexture());
}
void ofApp::draw(){
ofBackgroundGradient(ofColor::yellow,ofColor::gray);
ofSetColor(255);
img.draw(ofGetWidth()/2,ofGetHeight()/2);
}
Recent entries
- jit.gl.gridshape の matrixoutput についてのメモ #max8
- jit.gl.pix で簡易モーションブラー #max8 #jitter
- jit.gl.pix で Gold Noise #max8 #jitter
- Gen で配列をつくる検討 #Max8
- Package Managerで配布されているease objectを使いやすくしてイージング #max8
- Node for Max を用いて、定形外のUDPデータを受信 #Max8 #n4m
- 平ハウス物語 – 山田尚子監督作品 非公式ファンイベント
- The Splendid Expression – GITADORA×NOSTALGIA
- ghost in my place【from DEEMO II】
- EP “Boys O’Clock”
- 7th Album “多次元宇宙論”
- LEON.jpのWEB特集「大人のいい時間」にAromが紹介されました。
- 音できらめくキャンドルライト Arom(第2世代)発売開始
- EP “Strange Story”
- 都市の呼吸【from Cytus II】




