void Swatch::assemble( Timeline &timeline ) { float dur = 0.2f; // mPos = mAnchorPos + vec2( 15.0f, 0.0f ); timeline.apply( &mPos, mAnchorPos, dur, EaseOutAtan( 10 ) ).finishFn( bind( &Swatch::setDeselected, this ) ); timeline.apply( &mScale, 1.0f, dur, EaseOutAtan( 10 ) ); }
void Item::mouseOver( Timeline &timeline ) { if( !mIsBeingSelected ){ float dur = 0.2f; // title timeline.apply( &mTitlePos, mMouseOverDest, dur, EaseOutAtan( 10 ) ); timeline.apply( &mTitleColor, Color( 1, 1, 1 ), 0.05f, EaseOutAtan( 10 ) ); // bar timeline.apply( &mBarColor, Color( 0, 0, 0 ), dur, EaseOutAtan( 10 ) ); timeline.apply( &mBarAlpha, 0.4f, dur, EaseOutAtan( 10 ) ); timeline.apply( &mBarWidth, mMaxBarWidth, dur, EaseOutAtan( 10 ) ); for( std::vector<Swatch>::iterator swatchIt = mSwatches.begin(); swatchIt != mSwatches.end(); ++swatchIt ) { swatchIt->mouseOver( timeline ); } } }
void Item::mouseOff( Timeline &timeline ) { if( !mIsBeingSelected ){ float dur = 0.4f; // title timeline.apply( &mTitlePos, mTitleStart, dur, EaseOutBounce( 1.0f ) ); timeline.apply( &mTitleColor, Color( 0.7f, 0.7f, 0.7f ), 0.05f, EaseOutAtan( 10 ) ); // bar timeline.apply( &mBarColor, Color( 0, 0, 0 ), 0.2f, EaseOutAtan( 10 ) ); timeline.apply( &mBarAlpha, 0.0f, 0.2f, EaseOutAtan( 10 ) ); timeline.apply( &mBarWidth, 0.0f, 0.2f, EaseInAtan( 10 ) ); for( std::vector<Swatch>::iterator swatchIt = mSwatches.begin(); swatchIt != mSwatches.end(); ++swatchIt ) { swatchIt->mouseOff( timeline ); } } }
void Swatch::scatter( Timeline &timeline, float width, float height ) { vec2 pos1( 0.0f, mPos().y ); vec2 pos2( 0.0f, height ); vec2 pos3 = vec2( Rand::randFloat( width ), Rand::randFloat( height - 50.0f, height + 50.0f ) );//pos2 + rVec; float dur = Rand::randFloat( 0.25f, 0.5f ); // pos timeline.apply( &mPos, mPos(), 0.2f, EaseInAtan( 10 ) ).finishFn( bind( &Swatch::setSelected, this ) ); timeline.appendTo( &mPos, pos2, 0.0001f, EaseNone() ); timeline.appendTo( &mPos, pos3, dur, EaseOutAtan( 20 ) ); // alpha timeline.apply( &mAlpha, 0.0f, 0.2f, EaseInAtan( 10 ) ); timeline.appendTo( &mAlpha, 1.0f, dur, EaseOutAtan( 10 ) ); // scale float s = (float)Rand::randInt( 3, 7 ); timeline.apply( &mScale, 1.0f, 0.2f, EaseInAtan( 10 ) ); timeline.appendTo( &mScale, s*s, dur, EaseOutAtan( 20 ) ); }
void Item::select( Timeline &timeline, float leftBorder ) { if( !mIsSelected ){ mIsBeingSelected = true; mFadeFloat = 0.0f; float dur1 = 0.2f; float dur2 = 0.2f; // title position // set selected after initial animation timeline.apply( &mTitlePos, mTitleDest1, dur1, EaseInAtan( 10 ) ).finishFn( bind( &Item::setSelected, this ) ); timeline.appendTo( &mTitlePos, mTitleDest2 - vec2( 25.0f, 0.0f ), 0.0001f, EaseNone() ); timeline.appendTo( &mTitlePos, mTitleFinish, dur2, EaseOutAtan( 10 ) ); // title color timeline.apply( &mTitleColor, Color( 1, 1, 1 ), dur1, EaseInQuad() ); // title alpha timeline.apply( &mTitleAlpha, 0.0f, dur1, EaseInAtan( 10 ) ); timeline.appendTo( &mTitleAlpha, 1.0f, dur2, EaseOutAtan( 10 ) ); // desc position timeline.apply( &mDescPos, mDescDest, dur2, EaseOutAtan( 10 ) ).timelineEnd( -dur1 ); // desc alpha timeline.apply( &mDescAlpha, 1.0f, dur2, EaseOutQuad() ).timelineEnd( -dur1*0.5f ); // fadeFloat (used to adjust dropshadow offset) timeline.apply( &mFadeFloat, 0.0f, dur1, EaseInAtan( 10 ) ); timeline.appendTo( &mFadeFloat, 0.0f, 0.25f, EaseNone() ); timeline.appendTo( &mFadeFloat, 1.0f, dur2, EaseOutQuad() ); // bar width timeline.apply( &mBarWidth, 0.0f, dur1, EaseInOutAtan( 10 ) ); for( std::vector<Swatch>::iterator swatchIt = mSwatches.begin(); swatchIt != mSwatches.end(); ++swatchIt ) { swatchIt->scatter( timeline, math<float>::max( mTitleBigTex->getWidth(), 500.0f ), mTitleFinish.y + 50.0f ); } } }
void Item::deselect( Timeline &timeline ) { mIsBeingSelected = false; float dur1 = 0.2f; float dur2 = 0.2f; // set title position // set deselected after initial animation timeline.apply( &mTitlePos, mTitleDest2, dur1, EaseInAtan( 10 ) ).finishFn( bind( &Item::setDeselected, this ) ); timeline.appendTo( &mTitlePos, mTitleDest1, 0.0001f, EaseNone() ); timeline.appendTo( &mTitlePos, mTitleStart, dur2, EaseOutElastic( 2.0f, 0.5f ) ); // set title color timeline.apply( &mTitleColor, Color( 1, 1, 1 ), dur1, EaseInAtan( 10 ) ); timeline.appendTo( &mTitleColor, Color( 0.7f, 0.7f, 0.7f ), 0.05f, EaseOutAtan( 10 ) ); // set title alpha timeline.apply( &mTitleAlpha, 0.0f, dur1, EaseInAtan( 10 ) ); timeline.appendTo( &mTitleAlpha, 1.0f, dur2, EaseOutAtan( 10 ) ); // set desc position timeline.apply( &mDescPos, mDescStart, dur1, EaseInAtan( 10 ) ).timelineEnd(); // set desc alpha timeline.apply( &mDescAlpha, 0.0f, dur1, EaseInQuad() ).timelineEnd( -dur1 ); // set bar timeline.apply( &mBarWidth, 0.0f, dur1, EaseInAtan( 10 ) ); mBarAlpha = 0.3f; mIsSelected = false; for( std::vector<Swatch>::iterator swatchIt = mSwatches.begin(); swatchIt != mSwatches.end(); ++swatchIt ){ swatchIt->assemble( timeline ); } }
void Swatch::mouseOff( Timeline &timeline ) { timeline.apply( &mScale, 1.0f, 0.2f, EaseOutAtan( 10 ) ); }
void Character::animOut( Timeline &timeline, mat4 matrix ) { mDestMatrix = matrix; timeline.apply( &mColorCur, mColorStart, 1.0f, EaseOutQuad() ).finishFn( bind( &Character::onAnimOut, this ) ); timeline.apply( &mMatrix, matrix, 1.0f, EaseOutQuad() ); }
void Character::animIn( Timeline &timeline, mat4 matrix ) { mDestMatrix = matrix; timeline.apply( &mColorCur, mColorDest, 1.0f, EaseOutAtan( 20 ) ); timeline.apply( &mMatrix, matrix, 0.5f, EaseOutAtan( 10 ) ); }