Sketch 2015-06-15
void ofApp::setupAnim() {
masker.setup(width, height);
layer1 = masker.newLayer();
layer2 = masker.newLayer();
image1.setup("foil.png");
image2.setup("foil.png");
image1.setOffsetX(0);
image1.setOffsetY(0);
image2.setOffsetX(1);
image2.setOffsetY(1);
pos = 0;
size = width * 0.2;
}
void ofApp::updateAnim(){
pos+=10;
if(pos > height * 2) {
pos = 0;
}
masker.beginLayer(layer1);
{
image1.incrementOffsetX(0.01);
image1.incrementOffsetY(0.01);
image1.draw();
}
masker.endLayer(layer1);
masker.beginMask(layer1);
{
ofBackground(ofColor::black);
ofSetColor(ofColor::white);
for(int x = 0; x < size; x++) {
if(x % 2 == 0) {
ofRect(x * size, height - pos, size, height);
}
}
}
masker.endMask(layer1);
masker.beginLayer(layer2);
{
image2.incrementOffsetX(-0.01);
image2.incrementOffsetY(-0.01);
image2.draw();
}
masker.endLayer(layer2);
masker.beginMask(layer2);
{
ofBackground(ofColor::black);
ofSetColor(ofColor::white);
for(int x = 0; x < size; x++) {
if(x % 2 != 0) {
ofRect(x * size, pos - height, size, height);
}
}
}
masker.endMask(layer2);
}
void ofApp::drawAnim() {
ofBackground(ofColor::black);
masker.draw();
masker.drawOverlay();
if(ofGetFrameNum() == 100) {
renderGif();
}
}
Masking and texture planes are getting much easier