Created
February 7, 2017 09:07
-
-
Save hideyukisaito/a85aafb40f5ffc93989e390175b35fd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofApp.h" | |
ofImage img; | |
ofImage capture; | |
ofVideoPlayer video; | |
std::vector<ofPoint> positions; | |
std::vector<ofColor> colors; | |
bool captured = false; | |
//-------------------------------------------------------------- | |
void ofApp::setup(){ | |
img.load("test.png"); | |
video.setPlayer(ofPtr<ofBaseVideoPlayer>(new ofGstVideoPlayer)); | |
video.load("Transition 08.mov"); | |
ofSetWindowShape(img.getWidth(), img.getHeight()); | |
for (auto i = 0; i < 50; ++i) | |
{ | |
positions.push_back(ofPoint(ofRandom(ofGetWidth()), ofRandom(ofGetHeight()))); | |
colors.push_back(ofColor(ofRandom(255), ofRandom(255), ofRandom(255))); | |
} | |
video.play(); | |
ofLog() << "start"; | |
} | |
//-------------------------------------------------------------- | |
void ofApp::update(){ | |
ofLog() << "update"; | |
video.setSpeed(1.0); | |
video.getPosition(); | |
video.getDuration(); | |
video.setPosition(10); | |
video.update(); | |
if (!captured && 30 < ofGetFrameNum()) | |
{ | |
capture.grabScreen(0, 0, ofGetWidth(), ofGetHeight()); | |
capture.save(ofGetTimestampString() + ".png"); | |
ofExit(0); | |
} | |
} | |
//-------------------------------------------------------------- | |
void ofApp::draw(){ | |
ofSetColor(255); | |
img.draw(0, 0); | |
glEnable(GL_BLEND); | |
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); | |
video.draw(0, 0, ofGetWidth(), ofGetHeight()); | |
for (auto i = 0; i < positions.size(); ++i) | |
{ | |
ofSetColor(colors.at(i)); | |
ofDrawCircle(positions.at(i), 20); | |
} | |
glDisable(GL_BLEND); | |
} | |
//-------------------------------------------------------------- | |
void ofApp::keyPressed(int key){ | |
if ('c' == key) | |
{ | |
capture.grabScreen(0, 0, ofGetWidth(), ofGetHeight()); | |
capture.save(ofGetTimestampString() + ".png"); | |
ofExit(0); | |
} | |
} | |
//-------------------------------------------------------------- | |
void ofApp::keyReleased(int key){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseMoved(int x, int y ){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseDragged(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mousePressed(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseReleased(int x, int y, int button){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseEntered(int x, int y){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::mouseExited(int x, int y){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::windowResized(int w, int h){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::gotMessage(ofMessage msg){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::dragEvent(ofDragInfo dragInfo){ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment