//-------------------------------------------------------------- void testApp::keyPressed(int key) { if(key == 'f') // toggle fullscreen { bFullscreen = !bFullscreen; if(!bFullscreen) { ofSetWindowShape(1024,640); ofSetFullscreen(false); // figure out how to put the window in the center: int screenW = ofGetScreenWidth(); int screenH = ofGetScreenHeight(); ofSetWindowPosition(screenW/2-1024/2, screenH/2-640/2); } else if(bFullscreen == 1) { ofSetFullscreen(true); } } if(key == 's') // save image ofSaveFrame(); if(key == 'c') // clear screen { ofBackground(0, 0, 0); ofBackground(0, 0, 0); // no mistake, one call might not _always_ clear the screen. (maybe due to double-buffering?) } }
//-------------------------------------------------------------- void santiSoundize::keyPressed(int key){ switch(key){ case 'f': ofToggleFullscreen(); break; case 's': ofSaveFrame(); break; case 'p': m_audio.setPaused(m_isPlaying); m_isPlaying = !m_isPlaying; break; case 'd': cout << "m_balls.size() " << m_balls.size() << endl; cout << "ofGetFrameRate() " << ofGetFrameRate() << endl; cout << "ofGetTargetFrameRate() " << ofGetTargetFrameRate() << endl; break; case 'o': ofFileDialogResult result = ofSystemLoadDialog("open audio file"); if (result.bSuccess){ m_audio.loadSound(result.getPath(),true); m_audio.play(); m_isPlaying = true; } break; } }
//-------------------------------------------------------------- void ofApp::update(){ // whenever we work with video, we need to call update() // (that way, we can receive the new frame from the webcam) cam.update(); if(xpos == 0) { ofSaveFrame(); } }
//-------------------------------------------------------------- void ofApp::keyPressed(int key){ if(key == ' '){ ofBackground(0); } if(key == 's'){ ofSaveFrame(); } gif.keyPressed(key); }
//-------------------------------------------------------------- void QuasicrystalApp::draw() { img_.draw(0, 0); float now = ofGetElapsedTimef(); float frameTime = now - frameStart_; std::cout << "Frame " << ofGetFrameNum() << ": " << frameTime << " seconds" << std::endl; frameStart_ = now; ofSaveFrame(); }
void ofApp::update() { if (isRecording) { ofSaveFrame(); recordFrameCounter++; if (recordFrameCounter >= recordMaxFrames) { isRecording = false; recordFrameCounter = 0; } } }
//-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ screenGrab.setAnchorPoint(screenGrab.getWidth()/2, screenGrab.getHeight()/2); screenGrab.grabScreen(0, 0, ofGetScreenWidth(), ofGetScreenHeight()); screenGrab.resize(0.9 * screenGrab.width, 0.9 *screenGrab.height); //screenGrab.saveImage("images/testImage.bmp"); screenGrab.setCompression(OF_COMPRESS_SRGB); ofSaveFrame(); // ofEnableBlendMode(OF_BLENDMODE_MULTIPLY); for (int i = 0; i < screenGrab.width; i++){ for (int j = 0; j <screenGrab.height; j++) { if (screenGrab.getColor(i,j) != ofColor(25, 128, 128)){ screenGrab.setColor(i, j, ofColor(64,ofRandom(0,255),ofRandom(0,255))); } } } //ofSaveFrame(); // ofSaveScreen("screen.bmp"); //switch gamestate on mouse down if(game_state == "title") {game_state = "start";} if(game_state == "start") {game_state = "step1";} else if(game_state == "step1") {game_state = "step2";} else if(game_state == "step2") {game_state = "title";} }
//-------------------------------------------------------------- void ofApp::draw(){ ofBeginShape(); bool first = true; int currentDraw; for(float i=-M_PI;i<=M_PI;i+=step) { if(first) {currentDraw = 0; first = false;} else {currentDraw = 1;} setFold(i,pos,currentDraw); } pos += step; ofEndShape(); if(pos > M_PI) { ofSleepMillis(1000); ofSaveFrame(); ofExit(); } }
//-------------------------------------------------------------- void ofApp::update() { if (bConstantSlide) { yRotTarget += rotationalSpeed; } // ease the zoom and rotation of the camera zoom += (zoomTarget - zoom) * 0.03; cameraRotation.y += (yRotTarget - cameraRotation.y) * 0.02; // save image to file if (bSaveImages) { ofSaveFrame(); } }
//-------------------------------------------------------------- void ofApp::keyPressed(int key){ //hitting any key swaps the camera view if(key == 'c') { usecamera = !usecamera; } if(key == 'm') { drawMode = !drawMode; } if(key == ' ') { ofSaveFrame(); } }
//-------------------------------------------------------------- void ofApp::keyPressed(int key){ switch ( key ) { case 'a': cam.enableMouseInput(); break; case 'f': ofSetFullscreen( isFullscreen ); isFullscreen = !isFullscreen; break; case 'g': drawGrid = !drawGrid; break; case 's': ofSaveFrame(); break; default: break; } }
void testApp::keyPressed(int key) { if(key == 'f') { ofSaveScreen("out.png"); } else if(key == 's') { recording = !recording; if(recording) { saver.setCodecQualityLevel(OF_QT_SAVER_CODEC_QUALITY_NORMAL); saver.setup(ofGetWidth(), ofGetHeight(), "../output.mov"); screen.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_COLOR); } else { saver.finishMovie(); } } else if (key == ' ') { modifyDecoder = !modifyDecoder; cout << "zskew: " << decoder.zskew << endl; cout << "zscale: " << decoder.zscale << endl; } else if(key == OF_KEY_RIGHT) { startOffset++; } else if(key == OF_KEY_LEFT) { startOffset--; } else if(key == 'p') { ofSaveFrame(); } }
void testApp::keyPressed(int key){ if(key == 'p') ofSaveFrame(); }
//-------------------------------------------------------------- void testApp::keyPressed(int key){ if( key=='d' ){ copias[select].setShader("shaders/"+shaderFiles[nShader]); cout << select; }; if( key=='s' ){ copias[select].setShader("shaders/transpativo"); cout << select; }; if( key=='l' ){ loadSet(set); }; if( key=='c' ){ int temp=animationRefs[set].x+ofRandom(animationRefs[set].y-animationRefs[set].x); setupCopia(select, temp , "shaders/transparento"); //copias[select].setPos(ofGetMouseX() ,ofGetMouseX(),3,1); cout << copias.size(); }; if( key=='v' ){ copias[select].scaleX=ofRandom(5.0); }; if( key=='f' ){ set=max(set-1, 0); cout << set; nImage=0; }; if( key=='h' ){ cout << animationRefs.size() ; set=min(set+1, int(animationRefs.size()-1)); if (!animationsLoaded[set]) { loadSet(set); } //cout << min(set, ); nImage=0; //nImage++; }; if( key=='1' ){ select++; cout << select; }; if( key=='0' ){ select--; cout << select; // cout << max(copias.size(), select); // }; if( key=='b' ){ copias[select].glitch=true; // cout << max(copias.size(), select); // }; if( key=='n' ){ copias[select].glitch=false; // cout << max(copias.size(), select); // }; if( key=='z' ){ nShader=int(nShader+1)%int(shaderFiles.size()-1); // nShader++; // cout << max(copias.size(), select); // }; if( key=='x' ){ nShader=max(int(nShader-1), 0); // cout << max(copias.size(), select); // }; if( key=='p' ){ ofSaveFrame(); // cout << max(copias.size(), select); // }; if( key=='g' ){ //int temp=animationRefs[set].x+ofRandom(animationRefs[set].y-animationRefs[set].x); advanceOne(select); }; }
void testApp::keyPressed(int key) { ofSaveFrame(); }
void urgTimelapse::run(float speed, float periodSize, bool bClockwise, float alignmentAngle, float startPeriod) { // exit function if frame number is -1 if (frameNum == -1) return; // reset frame (MUST DO THIS) renderedFrame.clear(); // ------------------------------------ // ------------ FILL FRAME ------------ // ------------------------------------ // reset counter int scanNum = 0; // add scans to the mesh as dictated by the frames ofBuffer::Line it = buffer.getLines().begin(); advance(it, frames[frameNum].start); ofBuffer::Line end = buffer.getLines().end(); for (it, end; it != end; ++it) { // get line string line = *it; vector<string> values = ofSplitString(line, ","); // put all the points in a scan in the mesh for (int i = minIndex; i < maxIndex; i++) { // find the x and y coordinates float px = ofToFloat(values[2 * i + 1]); float py = ofToFloat(values[2 * i + 2]); // find the vector to this point ofVec3f thisPoint(px, py, 0.); // remove points too close double sqDist = thisPoint.distanceSquared(ofVec3f(0.,0.,0.)); if (sqDist < minSqDist2Cam) continue; // rotate this point 90 degrees about the z axis to orient it upwards thisPoint.rotate(90., ofVec3f(0., 0., 1.)); // apply the alignment angle stretch or compression to realign the two chuncks float alignmentFactor = (float)i / 682. * alignmentAngle; thisPoint.rotate(alignmentFactor, ofVec3f(0., 0., 1.)); // rotate this point about the y axis an amount proportional to this scanNumber and the number of scans in this frame (since this changes) float rotationAmt = (float)scanNum / (float)frames[frameNum].length * periodSize; // if clockwise is true, rotate in negative direction if (bClockwise) rotationAmt *= -1.; // if period is 180 and frame is odd, rotate 180 degrees if ((int)periodSize == 180 && (frameNum % 2)) rotationAmt += 180.; thisPoint.rotate(rotationAmt, ofVec3f(0., 1., 0.)); // add the point to the mesh with a color renderedFrame.addVertex(thisPoint); renderedFrame.addColor(ofFloatColor(1.)); } scanNum++; if (scanNum >= frames[frameNum].length) break; } cout << "rendered frame # " << frameNum << endl; // increment the frame number frameNum++; if (frameNum >= frames.size()) { // stop running this operation frameNum = -1; } // NOW RENDER ofPushMatrix(); // rotate the original frame ofRotate(startRotateX, 1, 0, 0); ofRotate(startRotateY, 0, 1, 0); ofRotate(startRotateZ, 0, 0, 1); renderedFrame.drawVertices(); ofPopMatrix(); // SAVE IMAGE ofSaveFrame(); }
//-------------------------------------------------------------- void testApp::draw(){ ofBackgroundGradient(128, 0); ofBackground(ofColor::black); //if(fftData.size()>0){ // line.resize(fftData.size()); // int rectWidth = ofGetWidth()/fftData.size(); ofSetColor(ofColor::white); ofSetLineWidth(2); ofNoFill(); ofSetColor(ofColor::white); glPushMatrix(); if(currentMode == supershape){ ofSetLineWidth(stkWeight.value); superShape(); } else if(currentMode == circle){ if(mesh.getNumVertices()> 0){ ofPushMatrix(); cam.begin(); ofTranslate(ofGetWidth()/2, ofGetHeight()/2); for (int i=0; i<mesh.getNumVertices(); i++) { ofSphere(mesh.getVertices()[i].x, mesh.getVertices()[i].y, mesh.getVertices()[i].z, 3); } cam.end(); ofPopMatrix(); } // circleFFT(); } else if(currentMode == supershapeFFT3D){ if(mesh.getVertices().size()> 0){ ofPushMatrix(); cam.begin(); /* ofTranslate(ofGetWidth()/2, ofGetHeight()/2); // ofRotate(ofGetMouseY(), 1, 0, 0); // mainMesh.drawFaces(); cout<<"drawing"<<endl; // GLuint vbo; glGenBuffers( 1, &vbo ); glBindBuffer( GL_ARRAY_BUFFER, vbo ); glBufferData( GL_ARRAY_BUFFER, mesh.getVertices().size() * sizeof(ofVec3f), mesh.getVertices().data(), GL_STATIC_DRAW ); glDrawArrays( GL_POINTS, 0, mesh.getVertices().size() ); glDeleteBuffers(1, &vbo); glFlush(); */ // for (int i=0; i<mesh.getNumVertices(); i++) { // // ofSphere(mesh.getVertices()[i].x, mesh.getVertices()[i].y, mesh.getVertices()[i].z, 10); // } mesh.drawWireframe(); cam.end(); ofPopMatrix(); } } glPopMatrix(); if(saveFrame){ ofSaveFrame(); cout<<"savingFrame!"<<endl; saveFrame = false; } }
//-------------------------------------------------------------- void testApp::draw(){ // gray rectangle ofSetColor(240); ofRect(0, 430, ofGetWindowWidth(), 40); // black dot ofSetColor(0); ofCircle(50, 450, 15); // red dot ofSetColor(255, 0, 0); ofCircle(100, 450, 15); // green dot ofSetColor(0, 255, 0); ofCircle(150, 450, 15); // blue dot ofSetColor(0, 0, 255); ofCircle(200, 450, 15); // heart indicator ofSetColor(255); gHeart.draw(400, 450); // if the drawer has requested to save, draw a half-heart // (will just draw on top of other one if ( bSaveRequestSent ) { rHeart.draw(400, 450); } if ( bSaveRequestReceived ) { lHeart.draw(400, 450); } if (bSaveRequestSent && bSaveRequestReceived ) { fullHeart.draw(400, 450); } // drawing indicator for what color is selected ofNoFill(); ofSetColor(100); if (penColor == ofColor(0, 0, 0) ) { ofCircle(50, 450, 18); } else if (penColor == ofColor(255, 0, 0) ) { ofCircle(100, 450, 18); } else if (penColor == ofColor(0, 255, 0) ) { ofCircle(150, 450, 18); } else if (penColor == ofColor(0, 0, 255) ) { ofCircle(200, 450, 18); } ofFill(); ofSetColor( penColor ); // local drawing if ( bIsDrawing ) { ofLine(lastX, lastY, mouseX, mouseY); // every time we draw a line, send a message to the remote app spacebrew.sendRange("lastPosX", lastX); spacebrew.sendRange("lastPosY", lastY); spacebrew.sendRange("posX", mouseX); spacebrew.sendRange("posY", mouseY); lastX = mouseX; lastY = mouseY; } // draw remote information // note, the remote variables will update only when // the app receives all four within one frame ofSetColor(remoteColor); ofLine(remoteLastX, remoteLastY, remoteX, remoteY); if ( bSaveRequestReceived && bSaveRequestSent ) { // fullHeart.draw(400, 450); // note: if draw heart here, is black in saved .png file ofSaveFrame(); bSaveRequestReceived = false; bSaveRequestSent = false; ofSetColor( 255, 255, 255 ); ofRect(0, 0, ofGetWindowWidth(), ofGetWindowHeight()); } }