Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include "cinder/app/AppBasic.h"
#include "cinder/ImageIo.h"
#include "cinder/Utilities.h"
#include <vector>
using namespace ci;
using namespace ci::app;
using std::vector;
class CopySurfaceApp : public AppBasic {
public:
void prepareSettings(Settings *settings);
void setup();
void update();
void draw();
void shutdown();
void keyDown( KeyEvent event );
void mouseDrag( MouseEvent event );
void fileDrop( FileDropEvent event );
private:
vector<Vec2i> mCircles;
bool mDoSave;
float mCircleRadius;
};
void CopySurfaceApp::prepareSettings(Settings *settings)
{
settings->setWindowSize(1920,1080);
settings->setTitle("CopySurface");
}
void CopySurfaceApp::setup()
{
mDoSave = false;
int rows = 10;
int columns = 20;
mCircleRadius = 0.5 * getWindowHeight()/rows;
for( int x = 0; x != columns; ++x ) {
for (int y=0; y != rows; ++y) {
mCircles.push_back( Vec2i( (x+0.5) * mCircleRadius * 2, (y+0.5) * mCircleRadius * 2 ) );
}
}
}
void CopySurfaceApp::update()
{
}
void CopySurfaceApp::draw()
{
gl::clear( Color::white() );
gl::color( Color( CM_HSV, fmod(getElapsedSeconds(),8.0)/8.0, 1.0, 1.0 ) );
for (vector<Vec2i>::iterator pos = mCircles.begin(); pos != mCircles.end(); ++pos) {
gl::drawSolidCircle( *pos, mCircleRadius );
}
if( mDoSave )
{
//gl::drawString( "Saving Images" );
writeImage( "../test/"+toString<int>(getElapsedFrames()) + ".png", copyWindowSurface() );
} else {
//gl::drawString( "Only Copying Screen" );
copyWindowSurface();
}
}
void CopySurfaceApp::mouseDrag( MouseEvent event )
{
}
void CopySurfaceApp::keyDown( KeyEvent event )
{
switch( event.getChar() ){
case 's':
mDoSave = !mDoSave;
break;
default:
break;
}
}
void CopySurfaceApp::fileDrop( FileDropEvent event )
{
}
void CopySurfaceApp::shutdown()
{
}
// This line tells Cinder to actually create the application
CINDER_APP_BASIC( CopySurfaceApp, RendererGl )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.