//--------------------------------------------------------------
void ofApp::setup(){
    
    ofSetWindowTitle("ofxSunCalc Example");
    
    ofSetFrameRate(30);
    
    Poco::LocalDateTime now;
    
    date_str = Poco::DateTimeFormatter::format(now, "%Y-%m-%d %H:%M:%S");
    ofLogNotice("NOW") << date_str;
    //ofLogNotice("local tzd") << now.tzd();
    
    // Sydney, Australia
    lat = -33.8647; // Note southern degrees need to be - (not like those from google maps)
    lon = 151.2117; //
    
    latlon_str = "lat:" + ofToString(lat) + ", lon:" + ofToString(lon);
    
    ofLogNotice("today") << sun_calc.dateToString(now);
    
    SunCalcPosition sunpos = sun_calc.getSunPosition(now, lat, lon);
    
    pos_str = "altitude=" + ofToString(sunpos.altitude) + ", azimuth=" + ofToString(sunpos.azimuth * RAD_TO_DEG);
    
    ofLogNotice("sunpos") << pos_str;
    
    todayInfo = sun_calc.getDayInfo(now, lat, lon, true);
    
    min_info_str = sun_calc.infoToString(todayInfo, true);
    max_info_str = sun_calc.infoToString(todayInfo, false);
    ofLogNotice() << min_info_str << endl << endl << max_info_str;
    
    small_font.loadFont(OF_TTF_MONO, 8, false);
    
    Poco::LocalDateTime sixMonthsAgo = now - Poco::Timespan(30*6, 0, 0, 0, 0);
    Poco::LocalDateTime threeMonthsAgo = now - Poco::Timespan(30*3, 0, 0, 0, 0);
    Poco::LocalDateTime threeMonthsInFuture = now + Poco::Timespan(30*3, 0, 0, 0, 0);
    
    labels.push_back("6 months ago\n" +  ofxSunCalc::dateToDateString(sixMonthsAgo));
    labels.push_back("3 months ago\n" +  ofxSunCalc::dateToDateString(threeMonthsAgo));
    labels.push_back("Today\n" +  ofxSunCalc::dateToDateString(now));
    labels.push_back("3 months time\n" +  ofxSunCalc::dateToDateString(threeMonthsInFuture));
    
    
    vector<SunCalcDayInfo> sun_infos;
    
    sun_infos.push_back(sun_calc.getDayInfo(sixMonthsAgo, lat, lon, false));
    sun_infos.push_back(sun_calc.getDayInfo(threeMonthsAgo, lat, lon, false));
    sun_infos.push_back(todayInfo);
    sun_infos.push_back(sun_calc.getDayInfo(threeMonthsInFuture, lat, lon, false));
    
    // create/draw a timeline for each date
    for(int i = 0; i<4; i++) {
        timelines.push_back(ofFbo());
        timelines[i].allocate(ofGetWidth() - 20 - 110, 32);
        ofxSunCalc::drawSimpleDayInfoTimeline(timelines[i], sun_infos[i]);
    }

}
//--------------------------------------------------------------
void testApp::setup(){

    ///////////////////
    //     STEP 1    //
    ///////////////////
    //initialize values
    maxFrames = 30 ; 
    currentFrame = 0 ; 
    bMousePressed = false ; 
    
    for ( int i = 0; i < maxFrames ; i++ ) 
    {
        //Push back and allocate the screen in each Frame Buffer Object
        frames.push_back(ofFbo() ) ; 
        frames[i].allocate( ofGetWidth() , ofGetHeight() ) ; 
    }
    
    resetAllFbos( ) ; 
    
    //Prevents screen tearing
    ofSetVerticalSync( true ) ; 
    ofSetFrameRate( maxFrames ) ; 
    ofBackground( 0 , 0, 0 ) ; 
    
#ifdef STEP2
    ///////////////////
    //     STEP 2    //
    ///////////////////
    lastMouse = ofPoint ( 0 , 0 ) ; 
#endif
    
#ifdef STEP3
    ///////////////////
    //     STEP 3    //
    ///////////////////
    float dim = 35 ;    //height of sliders
	float xInit = OFX_UI_GLOBAL_WIDGET_SPACING; 
    float length = 320-xInit; 

    red = ofRandom( 255 ) ; 
    green = ofRandom( 255 ) ; 
    blue= ofRandom( 255 ) ; 
    red2 = ofRandom( 255 ) ; 
    green2 = ofRandom( 255 ) ; 
    blue2 = ofRandom( 255 ) ; 
    
    //Here a new instance of ofxUICanvas is created, we store a refernce to it using a pointer
    gui = new ofxUICanvas(0, 0, length+xInit, ofGetHeight());
    
    //When accessing pointers you use the "->" notation
    gui->addWidgetDown(new ofxUILabel("AWESOME LABEL", OFX_UI_FONT_LARGE));    
    //Setup sliders for the first Colors
    gui->addWidgetDown(new ofxUISlider(length-xInit,dim, 0.0, 255.0, red, "RED" )); 
    gui->addWidgetDown(new ofxUISlider(length-xInit,dim, 0.0, 255.0, green, "GREEN" )); 
    gui->addWidgetDown(new ofxUISlider(length-xInit,dim, 0.0, 255.0, blue, "BLUE" )); 
    
    gui->addWidgetDown(new ofxUISlider(length-xInit,dim, 0.0, 255.0, red2, "RED2" )); 
    gui->addWidgetDown(new ofxUISlider(length-xInit,dim, 0.0, 255.0, green2, "GREEN2" )); 
    gui->addWidgetDown(new ofxUISlider(length-xInit,dim, 0.0, 255.0, blue2, "BLUE2" )); 
    
    //Add an event listener to react to changes in the ofxUI changes
    ofAddListener(gui->newGUIEvent,this,&testApp::guiEvent);	
    
    //Turn off the ofxUI rendering for now
    gui->disable() ; 
    gui->loadSettings("ofxUISettings.xml") ; 
#endif
}
示例#3
0
void ofx2DPro::setupNumViewports(int _num){    
    while(renderTargets.size() < _num){
        renderTargets.push_back(ofFbo());
    }
}