void ProjectorTimer::checkProjectorPower(){ int currentHour; int currentDay; if(useFakeTime){ currentHour = fakeHours; currentDay = fakeDay; } else { currentHour = ofGetHours(); currentDay = ofGetWeekday(); } bool dayEnabled = false; switch (currentDay) { //is today enabled? case 0: dayEnabled = autoPwrSun; break; case 1: dayEnabled = autoPwrMon; break; case 2: dayEnabled = autoPwrTues; break; case 3: dayEnabled = autoPwrWeds; break; case 4: dayEnabled = autoPwrThurs; break; case 5: dayEnabled = autoPwrFri; break; case 6: dayEnabled = autoPwrSat; break; default: break; } //if it's between the on hour and the off hour, and the projector's off, and today is enabled, turn it on. if it's later than the off hour and the projector is on, and today is enabled, turn it off. if (currentHour >= projOnHour && currentHour < projOffHour && !pjControl.getProjectorStatus() && dayEnabled) { startupProjectors(); projectorPower = true; ofLogWarning()<<"started projector automatically at "<< currentHour<<":"<<ofGetMinutes()<<endl; } else if (currentHour >= projOffHour && pjControl.getProjectorStatus() && dayEnabled){ shutdownProjectors(); projectorPower = false; ofLogWarning()<<"shut down projector automatically at "<< currentHour<<":"<<ofGetMinutes()<<endl; } }
// --------------------------------- void Clockbug::update() { // Our goal here is to calculate 2 things: target angle and target distance // Which angle should the bug be at? // Hint: this depends on which "type" it is float targetAngle; if(type==BUG_TYPE_HOUR_HAND) { float hours = ofGetHours() + (ofGetMinutes()/60.0) + (ofGetSeconds()/3600.0); targetAngle = ofMap(hours, 0, 12, CLOCK_TOP, CLOCK_TOP+M_TWO_PI); } if(type==BUG_TYPE_MINUTE_HAND) { float minutes = ofGetMinutes() + (ofGetSeconds()/60.0); targetAngle = ofMap(minutes, 0, 60, CLOCK_TOP, CLOCK_TOP+M_TWO_PI); } if(type==BUG_TYPE_SECOND_HAND) { float seconds = ofGetSeconds(); targetAngle = ofMap(seconds, 0, 60, CLOCK_TOP, CLOCK_TOP+M_TWO_PI); } // Calculate some "noise" -- smoothly changing random values // This will give us a value between 0 and 1. float angleNoise = ofNoise(noise[0], ofGetElapsedTimef()/slow); // change the noise value from [0 -> 1] to [-5 -> 5] angleNoise = ofMap(angleNoise, 0, 1, ofDegToRad(-5), ofDegToRad(5)); // Add that noise to the target angle. This will make the bug move // a little bit (+/- 5 degrees) around it's target angle targetAngle += angleNoise; // Now that we have determined the angle the bug will be at, // we will calculate how far away from the center it should be. // once again, we get smoothly changing noise [0 -> 1] // and then calculate the dist on the scale of [0 -> maximumDistance] float dist = ofNoise(noise[1], ofGetElapsedTimef()/slow); float targetDist = ofMap(dist, 0, 1, 0, maximumDistance); // Calculate where the bug should be moving towards // Here we are converting from radial to cartesian. ofPoint target; target.x = cos(targetAngle) * targetDist; target.y = sin(targetAngle) * targetDist; // Move towards target point ofPoint diff = target - pos; pos += diff / 10.0; }
bool ofxCameraSequenceRecorder::createNewTimeStampDirectory(){ ofSetDataPathRoot("./data/"); // relative to data folder_name = "capture-"+ofToString(ofGetYear()) +ofToString(ofGetMonth()) +ofToString(ofGetDay())+"-" +ofToString(ofGetHours()) +ofToString(ofGetMinutes()) +ofToString(ofGetSeconds()); string dir = ofToDataPath(folder_name); cout << "\n\nCreating new directory for capture: " << dir << endl; File file_handle(dir); bool success = false; try{ success = file_handle.createDirectory(); }catch( Poco::Exception &except ){ ofLog(OF_LOG_ERROR, "Could not make directory"); return false; } if(success==false)ofLog(OF_LOG_WARNING, "Could not make directory because it already exists"); return success; }
void ParticleTrace :: saveFBO ( ofxFBOTexture& fbo ) { int y = ofGetYear(); int m = ofGetMonth(); int d = ofGetDay(); int r = ofGetHours(); int n = ofGetMinutes(); int s = ofGetSeconds(); char str[255]; sprintf( str, "screengrab_lrg/image_%02d%02d%02d_%02d%02d%02d.png", y % 1000, m, d, r, n, s ); int w = fbo.getWidth(); int h = fbo.getHeight(); ofxCvColorImage imgTemp; imgTemp.allocate( w, h ); imgTemp.setFromPixels( (unsigned char*)fbo.getPixels(), w, h ); imgTemp.mirror( true, false ); ofImage imgSave; imgSave.allocate( w, h, OF_IMAGE_COLOR ); imgSave.setFromPixels( imgTemp.getPixels(), w, h, OF_IMAGE_COLOR ); imgSave.saveImage( str ); imgTemp.clear(); imgSave.clear(); }
void RiodeoJaneiro::draw(){ ofSetColor(255, 0, 127); int s = ofGetSeconds(); int m = ofGetMinutes(); int h = ofGetHours(); int n; if(h>=12){ n = h-12; }else{ n = h+24-12; } string weather = response["weather"][0]["main"].asString(); float temp = response["main"]["temp"].asFloat(); float rate = response2["rates"]["JPY"].asFloat(); string city = " Rio de Janeiro\n\n"; city += " Brazil\n\n"; city += " " + ofToString(n, 0) + ":" + ofToString(m, 0) + ":" + ofToString(s, 0) + "\n\n"; city += " -12h\n\n"; city += " 25h20min\n\n"; city += " " + weather + "\n\n"; city += " " + ofToString(temp, 1) + "\n\n"; city += " " + ofToString(rate,2) + "yen"; waster.drawString(city, ofGetWidth()-250, 250); }
/* EmergenceLog::dateTimeString * Returns the current date/time in following format: * 2011-05-26,14-36-587,28.469 */ string EmergenceLog::fileDateTimeString(float beatTime) { string output = ""; int year = ofGetYear(); int month = ofGetMonth(); int day = ofGetDay(); int hours = ofGetHours(); int minutes = ofGetMinutes(); int seconds = ofGetSeconds(); output = output + ofToString(year) + "."; if (month < 10) output = output + "0"; output = output + ofToString(month) + "."; if (day < 10) output = output + "0"; output = output + ofToString(day) + ", "; if (hours < 10) output = output + "0"; output = output + ofToString(hours) + "."; if (minutes < 10) output = output + "0"; output = output + ofToString(minutes) + "."; if (seconds < 10) output = output + "0"; output = output + ofToString(seconds) + ", "; output = output + ofToString(beatTime, 3); return output; }
//-------------------------------------------------------------- void testApp::draw(){ // copy enable part of gl state // glPushAttrib(GL_ENABLE_BIT); // setup gl state // glEnable(GL_DEPTH_TEST); // glEnable(GL_CULL_FACE); // light.enable(); // begin scene to post process // post.begin(cam); // post.begin(); // cam.begin(); ofPushMatrix(); // ofScale(1, -1, 1); // ofEnableAlphaBlending(); // ofSetColor(255, 255, 255); vbo.bind(); vbo.updateVertexData(pos, total); // vbo.updateColorData(color, total); // vbo.updateTexCoordData(tex_coord, total); for (int i=0; i<GRID_WIDTH; i++) { for (int j=0; j<GRID_HEIGHT; j++) { int index = (j*GRID_WIDTH+i) * LENGTH; vbo.draw(GL_TRIANGLE_FAN, index,LENGTH); } } vbo.unbind(); ofPopMatrix(); // end scene and draw // post.end(); // cam.end(); // post.end(); // set gl state back to original // glPopAttrib(); // image.grabScreen(0, 0, ofGetWidth(), ofGetHeight()); // if(saver.isRecording()) saver.writeRGB(image.getPixels()); // server.publishScreen(); if(ofGetLogLevel()==OF_LOG_VERBOSE) { for (int j=0; j<GRID_HEIGHT; j++) { for (int i=0; i<GRID_WIDTH; i++) { int index2 = (j*GRID_WIDTH+i); ofCircle(center_pos[index2],10); } } ofDrawBitmapString(ofToString(ofGetFrameRate()), 20,20); } ofDrawBitmapString(ofToString(ofGetHours())+":"+ofToString(ofGetMinutes()),ofGetWidth()*0.5,ofGetHeight()*0.5); }
void ofApp::updateWebcam() { camera.update(); if (camera.isFrameNew()) { colorImg.setFromPixels(camera.getPixels(), camera.width, camera.height); colorImg.mirror(false, true); grayImage = colorImg; // Set Timer For New BG if(ofGetMinutes() % 1 == 0) { bLearnBakground = true; } // Learn A New Background Image if (bLearnBakground == true){ grayBg = grayImage; bLearnBakground = false; } // take the abs value of the difference between background and incoming and then threshold: grayDiff.absDiff(grayBg, grayImage); grayDiff.threshold(threshold); // update the cv images grayImage.flagImageChanged(); // Find The Blobs contourFinder.findContours(grayDiff, minBlob, maxBlob, 20, false); } cout << "FOUND " << contourFinder.nBlobs << " BLOBS" << endl; }
void testApp::fireCamera(){ ofDirectory dir; char pathc[1024]; sprintf(pathc, "%02d_%02d_%02d_%02d", ofGetDay(), ofGetHours(), ofGetMinutes(), ofGetSeconds()); string path(pathc); dir.createDirectory(path); cameraFiredTime = ofGetElapsedTimef(); cout << "Firing camera at time "<< cameraFiredTime << endl; shouldFireCamera = false; camera1.takePhoto(); pullBackRender = true; pullFrontRender = true; ofFile f(path); currentSaveDirectory = f.getAbsolutePath(); cout << " absolute path is " << f.getAbsolutePath() << endl; //front.getColorImage().saveImage(f.getAbsolutePath() + "/backTexture.png"); }
TimeHandler::TimeHandler(bool _realTime){ realTime = _realTime; if (realTime) { minutesPerDay = 24 * 60; currentHour = ofGetHours(); timePerDay = minutesPerDay*60*ofGetFrameRate(); oneHour = timePerDay/24; currentDay = 1; currentTime = ofGetHours() * oneHour; currentTime += ofGetMinutes() * (oneHour/60); } else { minutesPerDay = 1; currentDay = 1; startTime = 0; currentTime = startTime; currentHour = 0; timePerDay = minutesPerDay*60*ofGetFrameRate(); oneHour = timePerDay/24; } }
void ScreenRecorder::setupNewDirectory() { counter = 0; string year = ofToString(ofGetYear()); string month = ofToString(ofGetMonth()); if (month.size() == 1) month.insert(0, "0"); string day = ofToString(ofGetDay()); if (day.size() == 1) day.insert(0, "0"); string hour = ofToString(ofGetHours()); if (hour.size() == 1) hour.insert(0, "0"); string minute = ofToString(ofGetMinutes()); if (minute.size() == 1) minute.insert(0, "0"); string second = ofToString(ofGetSeconds()); if (second.size() == 1) second.insert(0, "0"); currentPath = rootFolderName + "/recording_" + year + "-" + month + "-" + day + "_" + hour + "." + minute + "." + second; printf("rootFolderName = %s, currentPath = %s \n", rootFolderName.c_str(), currentPath.c_str()); ofDirectory dir(currentPath); if(!dir.exists()) dir.create(true); millisAtLastFrame = ofGetElapsedTimeMillis(); }
//-------------------------------------------------- void simpleLogger::log(int logLevel, const char* format, ...){ //thanks stefan! //http://www.ozzu.com/cpp-tutorials/tutorial-writing-custom-printf-wrapper-function-t89166.html logRecord record; record.year = ofGetYear(); record.month = ofGetMonth(); record.day = ofGetDay(); record.hour = ofGetHours(); record.minute = ofGetMinutes(); record.seconds = ofGetSeconds(); record.level = logLevel; char str[2048] = {0}; va_list args; va_start( args, format ); vsprintf(str, format, args ); va_end( args ); record.msg = str; record.logStr = convertToString(record); logs.push_back(record); logToXml(record); }
void ofApp::update() { ofBackground(0); #ifdef INTERACTIVE if(playState <= 1) { #ifdef KINECT updateKinect(); #else updateWebcam(); #endif updateBlobs(); updateFBOs(); if(ofGetFrameNum() % 60 == 0) { updateBrightness(); } } else if(playState >= 2) { updateMovies(); } #else if (playState == 1) playState = 2; updateMovies(); #endif // Write if(ofGetMinutes() % 10 == 0) { writeDiagnostics(); } }
void Sydney::draw(){ ofSetColor(127, 255, 0); int s = ofGetSeconds(); int m = ofGetMinutes(); int h = ofGetHours(); int n; if(h<=22){ n = h+1; }else{ n = h-23; } string weather = response["weather"][0]["main"].asString(); float temp = response["main"]["temp"].asFloat(); float rate = response2["rates"]["JPY"].asFloat(); string city = " Sydney\n\n"; city += " Australia\n\n"; city += " " + ofToString(n, 0) + ":" + ofToString(m, 0) + ":" + ofToString(s, 0) + "\n\n"; city += " +1h\n\n"; city += " 9h30min\n\n"; city += " " + weather + "\n\n"; city += " " + ofToString(temp, 1) + "\n\n"; city += " " + ofToString(rate,2) + "yen"; waster.drawString(city, ofGetWidth()-250, 250); }
void nebulaEye::csvRecordCb(bool & flag){ if ( flag ){ csvRecorder.clear(); ofResetElapsedTimeCounter(); stringstream ss; ss << ofGetYear(); ss << setfill('0') << setw(2) << ofGetMonth(); ss << setfill('0') << setw(2) << ofGetDay() << "-"; ss << setfill('0') << setw(2) << ofGetHours(); ss << setfill('0') << setw(2) << ofGetMinutes(); ss << setfill('0') << setw(2) << ofGetSeconds() << ".csv"; ofLog() << "try to create file : " << ss.str(); csvRecorder.filePath = ofToDataPath(ss.str()); ofLog() << "record CSV to : " << csvRecorder.filePath; int idx(0); csvRecorder.setString(0,idx++,"date"); csvRecorder.setString(0,idx++,"time"); csvRecorder.setString(0,idx++,"blob x"); csvRecorder.setString(0,idx++,"blob y"); csvRecorder.setString(0,idx++,"flow zone 0"); csvRecorder.setString(0,idx++,"flow zone 1"); csvRecorder.setString(0,idx++,"flow zone 2"); csvRecorder.setString(0,idx++,"flow zone 3"); } else { csvRecorder.saveFile(); // Save the recorded values in the csvRecorder ofxCsv object // csvRecorder.saveFile( ofToDataPath( csvFileName )); ofLog() << "Saved " << csvRecorder.numRows << " rows to " << csvRecorder.filePath; } }
//-------------------------------------------------------------- string ofApp::getTakeName() { return ofToString(ofGetYear(), 4, '0') + "-" + ofToString(ofGetMonth(), 2, '0') + "-" + ofToString(ofGetDay(), 2, '0') + "-" + ofToString(ofGetHours(), 2, '0') + "-" + ofToString(ofGetMinutes(), 2, '0') + "-" + ofToString(ofGetSeconds(), 2, '0'); }
void inputManager::startRecord(){ folderName = "recordedImages/" + ofToString(ofGetMonth(),0) + ofToString(ofGetDay(), 0) + ofToString(ofGetHours(), 0) + ofToString(ofGetMinutes(), 0) + ofToString(ofGetSeconds(), 0); fileHelper.makeDirectory(folderName); bRecord = true; }
void ofApp::touchDoubleTap(int x, int y, int id){ //string fileName = "screenshot/" + ofGetTimestampString() + ".png"; string fileName= "/sdcard/DCIM/myFolder/ob" + ofToString(ofGetYear()) + ofToString(ofGetMonth()) + ofToString(ofGetDay()) + ofToString(ofGetHours()) + ofToString(ofGetMinutes()) + ofToString(ofGetSeconds()) + ".png"; ofSaveScreen(fileName); }
//-----------------------------------------------keyPressed p or x to save--------------- void ofApp::keyPressed(int key) { // key 'p' or key 'x' is used to save the images and create a movie. //TODO: move this to be done by the mouse. Maybe the mouse wheel or the move from the optical sensor. if (key == 'p' || key == 'x') { //makes a folder and video name using time date tags when saving and exporting. int day = ofGetDay(); int hour = ofGetHours(); int minute = ofGetMinutes(); char timeStamp[24]; sprintf(timeStamp,"%02d%02d%02d",day,hour,minute); char exportFile[100]; ofImage img2Export; ofPixels pix2Export; for(int i = 0; i < videoArray.size(); i ++) { videoArray[i].readToPixels(pix2Export); img2Export.setFromPixels(pix2Export); sprintf(exportFile,"image-%03d.png",i);//saves the images.//dms img2Export.saveImage(exportFile); } char videoExportCmd[256]; sprintf(videoExportCmd, "/usr/local/bin/ffmpeg -r %d -y -i ./data/image-%%03d.png -c:v mpeg4 -r %d -pix_fmt yuv420p ~/Desktop/data/v%s.mp4",frameRate,frameRate,timeStamp); system(videoExportCmd);//saves the images as a video. dms char deleteOldImages[24]; sprintf(deleteOldImages, "rm data/*.png");//dms delete old images system(deleteOldImages); char exportAWS[100]; char nameAWS[100]; sprintf(nameAWS,"v%s.mp4",timeStamp); sprintf(exportAWS,"aws s3 cp ~/Desktop/data/%s s3://stopmotion/%s",nameAWS,nameAWS); system(exportAWS); } }
void testApp::keyPressed(int key){ if(key == 'p') ofSaveScreen(ofToString(ofGetMinutes()) + "_" + ofToString(ofGetFrameNum()) + ".png"); if(key == 's') { slowMotion = !slowMotion; if(slowMotion) timeStep = .05; else timeStep = 1; } }
//-------------------------------------------------------------- void testApp::keyPressed(int key){ if(timeline.isModal()){ return; } if(key == ' '){ timeline.togglePlay(); } if(key == 'T'){ camTrack.addKeyframe(); } if(key == 'L'){ camTrack.lockCameraToTrack = !camTrack.lockCameraToTrack; if(!camTrack.lockCameraToTrack){ cam.setAnglesFromOrientation(); } } if(key == 'R'){ rendering = !rendering; if(rendering){ currentFrameNumber = 0; char fileName[1024]; sprintf(fileName, "frame_%02d_%02d_%02d/", ofGetDay(), ofGetHours(), ofGetMinutes() ); renderFolder = string(fileName); ofDirectory(renderFolder).create(true); } timeline.stop(); player.getVideoPlayer()->stop(); timeline.setPercentComplete(timeline.getInOutRange().min); timeline.play(); } if(key == 'f'){ ofToggleFullscreen(); } if(key == 'S'){ loadShader(); } if(key == '1'){ particleRenderer.sampleTextureColors(player.getVideoPlayer()->getPixelsRef()); } if(key == 'P'){ generateAmbientParticles(); } }
void testApp::createFileName(void) { ostringstream oss; oss << ofGetYear() << "-"; oss << setw(2) << setfill('0') << ofGetMonth() << "-"; oss << setw(2) << setfill('0') << ofGetDay() << "-"; oss << setw(2) << setfill('0') << ofGetHours() << "-"; oss << setw(2) << setfill('0') << ofGetMinutes() << "-"; oss << setw(2) << setfill('0') << ofGetSeconds() << ".mov"; mFileName = oss.str(); }
void ofApp::saveData() { string userTime = "User" + std::to_string(userIndex) + ":time"; string userColor = "User" + std::to_string(userIndex) + ":color"; string userDay = "User" + std::to_string(userIndex) + ":day"; string userHour = "User" + std::to_string(userIndex) + ":hour"; dataLog.setValue(userTime, finalCounter); dataLog.setValue(userColor, Light::getInstance().getCurrentColor()); //<<<<<<<-----------------------------!!!!!INTRODUIR COLOR!!!!! dataLog.setValue(userDay, std::to_string(ofGetDay())); dataLog.setValue(userHour, std::to_string(ofGetHours()) + "." + std::to_string(ofGetMinutes())); dataLog.saveFile("Log_BlueProject_" + std::to_string(ofGetDay()) + "_" + std::to_string(ofGetHours()) + "h" + std::to_string(ofGetMinutes()) + ".xml"); dataLog.saveFile("Log_BlueProject_" + std::to_string(ofGetDay()) + "_" + std::to_string(ofGetHours()) + "h" + std::to_string(ofGetMinutes()) + "_copy.xml"); }
//-------------------------------------------------------------- string motionDetector::generateFileName() { string _root = "kinectRecord"; string _timestamp = ofToString(ofGetDay()) + ofToString(ofGetMonth()) + ofToString(ofGetYear()) + ofToString(ofGetHours()) + ofToString(ofGetMinutes()) + ofToString(ofGetSeconds()); string _filename = (_root + _timestamp + ".oni"); return _filename; }
//-------------------------------------------------------------- bool ofApp::isTimeToOpenScreen() { float currentHour = ofGetHours() + (ofGetMinutes()/60.0); float timeOpen; int switchMode = gui.getValueI("TIME_SWITCHON_TYPE"); if(switchMode==1){ timeOpen = gui.getValueF("TIME_SWITCHON_HOUR") + (gui.getValueF("TIME_SWITCHON_MINUTE")/60.0); }else if(switchMode==0){ timeOpen = mySunrise.getSunset()-0.5; // open half an hour before sunset }else if(switchMode==2){ timeOpen = true; } float timeClose = gui.getValueF("TIME_SWITCHOFF_HOUR")+(gui.getValueF("TIME_SWITCHOFF_MINUTE")/60.0); return currentHour>timeOpen && currentHour<timeClose; }
//-------------------------------------------------------------- void ofApp::draw(){ string s; s = ofToString(ofGetHours()) + ofToString(ofGetMinutes()) + ".ai"; if (loop) { vg.beginEPS(s); /*===========================code===========================*/ for (int i = 0; i < 5000; i++) { vg.setColor(ofRandom(255), ofRandom(255), ofRandom(255)); vg.rect(ofRandom(ofGetWidth()), ofRandom(ofGetHeight()), ofRandom(5), ofRandom(5)); } /*===========================code===========================*/ vg.endEPS(); loop = false; } }
//-------------------------------------------------------------- void testApp::keyPressed(int key){ if(key == ' '){ timeline.togglePlay(); } if(key == 'g'){ generate(); } if(key == 't'){ traverse(); } if(key == 'T'){ camTrack.addKeyframe(); } if(key == 'L'){ camTrack.lockCameraToTrack = !camTrack.lockCameraToTrack; if(!camTrack.lockCameraToTrack){ cam.setAnglesFromOrientation(); } } if(key == 'f'){ ofToggleFullscreen(); } if(key == 'R'){ rendering = !rendering; if(rendering){ char folder[1024]; sprintf(folder, "frames_%02d_%02d_%02d/",ofGetDay(), ofGetHours(), ofGetMinutes()); renderFolder = folder; frameNum = 0; ofDirectory(renderFolder).create(true); timeline.setCurrentFrame(timeline.getInFrame()); timeline.play(); } } if(key == 'S'){ loadShader(); } }
//-------------------------------------------------------------- void testApp::draw(){ sprintf (timeString, "time: %i:%i:%i \nelapsed time %lli", ofGetHours(), ofGetMinutes(), ofGetSeconds(), ofGetElapsedTimeMillis()); ofSetHexColor(0xffffff); vagRounded.drawString(eventString, 98,198); ofSetColor(255,122,220); vagRounded.drawString(eventString, 100,200); ofSetHexColor(0xffffff); vagRounded.drawString(timeString, 98,98); ofSetColor(255,122,220); vagRounded.drawString(timeString, 100,100); }
//------------------------------------------------------------------ uiPresent::uiPresent() { sprintf (timeString, "time: %0.2i:%0.2i:%0.2i \nelapsed time %i", ofGetHours(), ofGetMinutes(), ofGetSeconds(), ofGetElapsedTimeMillis()); sprintf(eventString, "touch = (%2.0f, %2.0f - id %i)", 0.0, 0.0, 0.0); thisImage.setup(); thisText = new text(); //load uiPresent images pencil = new ofImage; font = new ofImage; table = new ofImage; okSave = new ofImage; pencil->loadImage("images/ui/glyphicons_030_pencil.png"); font->loadImage("images/ui/glyphicons_100_font.png"); table->loadImage("images/ui/glyphicons_119_table.png"); okSave->loadImage("images/ui/glyphicons_206_ok_2.png"); //set initial values for state pencilSelected = new bool; fontSelected = new bool; tableSelected = new bool; okSaveSelected = new bool; *pencilSelected = true; *fontSelected = false; *tableSelected = false; *okSaveSelected = false; pencilBox = new ofRectangle; fontBox = new ofRectangle; tableBox = new ofRectangle; okSaveBox = new ofRectangle; pencilBox->set(0, 300, pencil->getWidth()+20, pencil->getHeight()+20); fontBox->set(0, 345, pencil->getWidth()+20, pencil->getHeight()+20); tableBox->set(0, 390, pencil->getWidth()+20, pencil->getHeight()+20); okSaveBox->set(0, 435, pencil->getWidth()+20, pencil->getHeight()+20); theText = "Nick's daughter Penny has 25 dimes. She likes to arrange them\ninto three piles, putting an odd number of dimes into each pile. In\nhow many ways could she do this?\nSolve this problem before continuiPresentng. "; }
void ofxGLEditor::saveToFile() { string curPath = ofToDataPath("", false); #ifdef TARGET_OSX ofSetDataPathRoot("../../../data/scripts/"); #endif string zero = "0"; string y = ofToString(ofGetYear()); string m = ofToString(ofGetMonth()); if (m.size() == 1) m = zero+m; string d = ofToString(ofGetDay()); if (d.size() == 1) d = zero+d; string hour = ofToString(ofGetHours()); if (hour.size() == 1) hour = zero+hour; string min = ofToString(ofGetMinutes()); if (min.size() == 1) min = zero+min; string sec = ofToString(ofGetSeconds()); if (sec.size() == 1) sec = zero+sec; string ymdhms = "gamuzaScript_"+y+m+d+hour+min+sec; string en = ".lua"; #ifndef __APPLE__ string fin = "scripts/"+ymdhms+en; #else string fin = ymdhms+en; #endif string scriptPath = fin; string file = ofToDataPath(scriptPath); ofstream myfile; myfile.open(file.c_str(), _S_out); string script; for (unsigned int i = 0; i < glEditor.size(); i++) { script += wstring_to_string(glEditor[i]->GetAllText()); script += "\n"; } myfile << script; myfile.close(); #ifdef TARGET_OSX ofSetDataPathRoot(curPath); #endif cout << "script saved" << endl; }