Skip to content

Instantly share code, notes, and snippets.

@nulltask
Created February 8, 2012 09:15
Show Gist options
  • Save nulltask/1767053 to your computer and use it in GitHub Desktop.
Save nulltask/1767053 to your computer and use it in GitHub Desktop.
ofLecture 2
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
ofBackground(0, 0, 0);
ofEnableAlphaBlending();
ofEnableSmoothing();
ofSetFrameRate(30);
ofSetVerticalSync(true);
camWidth = 480;
camHeight = 360;
video.setVerbose(true);
video.initGrabber(camWidth, camHeight);
}
//--------------------------------------------------------------
void testApp::update(){
video.grabFrame();
}
//--------------------------------------------------------------
void testApp::draw(){
ofSetColor(255, 255, 255);
video.draw(0, 0);
unsigned char* px = video.getPixels();
for (int i = 0; i < camWidth; i += 10) {
for (int j = 0; j < camHeight; j += 10) {
unsigned char r = px[j*3*camWidth+i*3];
unsigned char g = px[j*3*camWidth+i*3+1];
unsigned char b = px[j*3*camWidth+i*3+2];
// r = 255 - r;
// g = 255 - g;
// b = 255 - b;
float f = (255 - (r + g + b)) / 3 * 0.005;
ofSetColor(r, g, b, 128);
ofCircle(camWidth + i, j, 10.0 * f, 10.0 * f);
}
}
}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment