Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Slit-Scan from Form+Code in Art, Design, and Architecture; Cinder version fork
/**
* Forked by Forrest Oliphant, http://sembiki.com/
* Simplified from:
*
* Transform: Slit-Scan from Form+Code in Art, Design, and Architecture
* implemented in C++ by Patrick Tierney <http://ptierney.com>
*
* Requires Cinder 0.8.2 available at http://libcinder.org
*
* Project files are located at https://github.com/hlp/form-and-code
*
* For more information about Form+Code visit http://formandcode.com
*/
#include "cinder/app/AppBasic.h"
#include "cinder/Surface.h"
#include "cinder/Capture.h"
#include "cinder/gl/gl.h"
#include "cinder/gl/Texture.h"
using namespace ci;
class Transform_SlitScan : public ci::app::AppBasic {
public:
void prepareSettings(Settings* settings);
void setup();
void update();
void draw();
private:
Capture capture;
Surface inSurface;
Surface outSurface;
int video_width;
int video_height;
int video_slice_x;
int window_width;
int window_height;
int draw_position_x;
bool newFrame;
};
void Transform_SlitScan::prepareSettings(Settings* settings) {
video_width = 320;
video_height = 240;
video_slice_x = video_width / 2;
window_width = 1000;
window_height = video_height;
draw_position_x = 0;
newFrame = false;
outSurface = Surface(window_width, window_height, ci::SurfaceChannelOrder::RGB);
settings->setWindowSize(window_width, window_height);
}
void Transform_SlitScan::setup() {
try {
capture = ci::Capture(video_width, video_height);
capture.start();
} catch (...) {
// if we threw in the start close the program
ci::app::console() << "Unable to open webcam." << std::endl;
exit(1);
}
if (capture.getWidth() != video_width || capture.getHeight() != video_height) {
ci::app::console() << "Unable to open webcam at desired size." << std::endl;
exit(1);
}
}
void Transform_SlitScan::update() {
newFrame = false;
if (!capture || !capture.checkNewFrame())
return;
newFrame = true;
inSurface = capture.getSurface();
outSurface.copyFrom(inSurface, Area( video_slice_x, 0, video_slice_x+1, video_height ), Vec2i( draw_position_x - video_slice_x, 0 ) );
}
void Transform_SlitScan::draw() {
if (!newFrame)
return;
draw_position_x++;
if (draw_position_x >= window_width)
draw_position_x = 0;
if( outSurface )
gl::draw( gl::Texture( outSurface ) );
}
CINDER_APP_BASIC(Transform_SlitScan, ci::app::RendererGl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.