void Mover::display() { float alphaVal = lmap<float>( 200, 0, 255, 0, 1 ); gl::color( 0.5f, 0.5f, 0.5f, alphaVal ); Rectf rectangle = Rectf( Vec2f( 0, 0 ), Vec2f( mMass * 16, mMass * 16 ) ); rectangle.offsetCenterTo( Vec2f( 0, 0 ) ); gl::pushMatrices(); gl::translate( mLocation.x, mLocation.y ); gl::rotate( toDegrees( mAngle ) ); gl::drawSolidRect( rectangle ); gl::color( 0, 0, 0, alphaVal ); glLineWidth(2.0); gl::drawStrokedRect( rectangle ); gl::popMatrices(); }
void Gallery::Picture::render( const Rectf &rect ) { Rectf txtRect; Rectf outRect = rect; gl::pushModelView(); Vec2f flipScale( 1, 1 ); double currentTime = app::getElapsedSeconds(); if ( zooming ) { Rectf zoomRect; if ( mTexture ) zoomRect = mTexture.getBounds(); else zoomRect = Rectf( 0, 0, 1024, 768 ); Rectf screenRect( app::getWindowBounds() ); zoomRect = zoomRect.getCenteredFit( screenRect, true ); if ( screenRect.getAspectRatio() > zoomRect.getAspectRatio() ) zoomRect.scaleCentered( screenRect.getWidth() / zoomRect.getWidth() ); else zoomRect.scaleCentered( screenRect.getHeight() / zoomRect.getHeight() ); Vec2f center = lerp< Vec2f >( zoomRect.getCenter(), outRect.getCenter(), mZoom ); float scale = lerp< float >( zoomRect.getWidth(), outRect.getWidth(), mZoom ) / outRect.getWidth(); outRect.offsetCenterTo( center ); outRect.scaleCentered( scale ); if ( mZoom == 1. ) zooming = false; } else if ( currentTime < appearanceTime ) { flipScale = Vec2f( 0, 1 ); } else if ( currentTime < appearanceTime + sFlipDuration * .5 ) { float flipU = easeOutQuart( ( currentTime - appearanceTime ) / ( sFlipDuration * .5 ) ); flipScale = Vec2f( flipU, 1 ); } else if ( flipping ) { float flipU = easeInOutQuart( math<float>::clamp( ( currentTime - flipStart ) / sFlipDuration ) ); if ( ( flipU >= .5 ) && !flipTextureChanged ) { setRandomTexture(); flipTextureChanged = true; } flipScale = Vec2f( math<float>::abs( flipU * 2 - 1 ), 1 ); if ( flipU >= 1 ) flipping = false; } if ( mTexture ) { txtRect = mTexture.getBounds(); mTexture.bind(); gl::color( Color::white() ); } else { txtRect = Rectf( 0, 0, 1024, 768 ); gl::color( Color::black() ); } txtRect = txtRect.getCenteredFit( outRect, true ); gl::translate( txtRect.getCenter() ); gl::scale( flipScale ); gl::translate( -txtRect.getCenter() ); gl::drawSolidRect( txtRect ); if ( mTexture ) mTexture.unbind(); else gl::color( Color::white() ); gl::popModelView(); }