void ofApp::drawAnim() {
    ofBackground(ofColor::black);
    ofSetColor(ofColor::wheat);
    
    
    offset.y = 0.02;
    drawLayer(&tex);
    rotateScreen(90, halfWidth);
    drawLayer(&tex);
    rotateScreen(90, halfHeight);
    drawLayer(&tex);
    rotateScreen(90, halfWidth);
    drawLayer(&tex);
    rotateScreen(90, halfHeight);
    drawLayer2(&tex); //cover up

    if(ofGetFrameNum() == 100) {
        renderGif();
    }
}
void ofApp::drawAnim() {
    ofBackground(0, 0, 0);

    ofEnableAlphaBlending();
    rotateScreen(ofGetFrameNum() * 2);
    for(int i = 0; i < cubes.size(); i++) {
        cubes.at(i).draw();
    }

    if(ofGetFrameNum() == 180) renderGif();
}
void ofApp::draw(){
    gif.begin();
    {
        if(ofGetFrameNum() == 0) ofBackground(0, 0, 0);
        image.draw();
        ofSetColor(ofColor::black, 16);
        ofRect(0, 0, gif.width, gif.height);
        
        ofEnableAlphaBlending();
        
        for(int i = 0; i < shapes.size(); i++) {
            shapes.at(i).setColor(ofColor::white);
        }
        shapeSystem.draw();
        
        rotateScreen(90);
        for(int i = 0; i < shapes.size(); i++) {
            shapes.at(i).setColor(ofColor(ofColor::black, 192));
        }
        shapeSystem.draw();
        
        rotateScreen(90);
        for(int i = 0; i < shapes.size(); i++) {
            shapes.at(i).setColor(ofColor(ofColor::black, 164));
        }
        shapeSystem.draw();
        
        rotateScreen(90);
        for(int i = 0; i < shapes.size(); i++) {
            shapes.at(i).setColor(ofColor(ofColor::black, 128));
        }
        shapeSystem.draw();
        
        ofDisableAlphaBlending();
    }
    gif.endAndCaptureFrame();
    gif.draw();
}
bool DjvuApplication::open( const QString &path_name )
{
    main_window_.attachModel(&model_);
    main_window_.show();
    DjVuView *view = down_cast<DjVuView*>(main_window_.activateView(DJVU_VIEW));

    // connect the signals with view
    connect( view, SIGNAL(rotateScreen()), this, SLOT(onRotateScreen()) );
    connect( view, SIGNAL(testSuspend()), this, SLOT(onSuspend()) );
    connect( view, SIGNAL(testWakeUp()), this, SLOT(onWakeUp()) );

    // connect the signals with sys_state_
    SysStatus & sys_status = SysStatus::instance();
    connect( &sys_status, SIGNAL( mountTreeSignal( bool, const QString & ) ),
             this, SLOT( onMountTreeSignal( bool, const QString &) ) );
    connect( &sys_status, SIGNAL( sdCardChangedSignal( bool ) ), this, SLOT( onSDChangedSignal( bool ) ) );
    connect( &sys_status, SIGNAL( aboutToShutdown() ), this, SLOT( onAboutToShutDown() ) );
    connect( &sys_status, SIGNAL( wakeup() ), this, SLOT( onWakeUp() ) );

#ifdef Q_WS_QWS
    connect(qApp->desktop(), SIGNAL(resized(int)), this, SLOT(onScreenSizeChanged(int)), Qt::QueuedConnection);
#endif

    view->attachModel(&model_);
    bool ret = model_.open(path_name);
    if ( !ret )
    {
        if ( sys::SysStatus::instance().isSystemBusy() )
        {
            // if loading fails, set busy to be false
            sys::SysStatus::instance().setSystemBusy( false );
        }
        view->deattachModel();
    }
    return ret;
}