예제 #1
0
/// Compute the cross-fade opacity to make the effect look good with every
/// window opacity value.
GLushort
FocusFadeAnim::computeOpacity (GLushort opacityInt)
{
    float progress = 1 - progressLinear ();
    float opacity = opacityInt / (float)OPAQUE;
    float multiplier;

    bool newCopy = overNewCopy ();

    // flip opacity behavior for the other side of the cross-fade
    if (newCopy)
        progress = 1 - progress;

    if (mWindow->alpha () || (newCopy && opacity >= 0.91f))
	multiplier = progressDecelerate (progress);
    else if (opacity > 0.94f)
	multiplier = progressDecelerateCustom (progress, 0.55, 1.32);
    else if (opacity >= 0.91f && opacity < 0.94f)
	multiplier = progressDecelerateCustom (progress, 0.62, 0.92);
    else if (opacity >= 0.89f && opacity < 0.91f)
	multiplier = progressDecelerate (progress);
    else if (opacity >= 0.84f && opacity < 0.89f)
	multiplier = progressDecelerateCustom (progress, 0.64, 0.80);
    else if (opacity >= 0.79f && opacity < 0.84f)
	multiplier = progressDecelerateCustom (progress, 0.67, 0.77);
    else if (opacity >= 0.54f && opacity < 0.79f)
	multiplier = progressDecelerateCustom (progress, 0.61, 0.69);
    else
	multiplier = progress;

    multiplier = 1 - multiplier;
    float finalOpacity = opacity * multiplier;
    finalOpacity = MIN (finalOpacity, 1);
    finalOpacity = MAX (finalOpacity, 0);

    return (GLushort)(finalOpacity * OPAQUE);
}
예제 #2
0
void
ZoomAnim::getZoomProgress (float *pMoveProgress,
			   float *pScaleProgress,
			   bool neverSpringy)
{
    float forwardProgress =
	1 - mRemainingTime /
	(mTotalTime - mTimestep);
    forwardProgress = MIN (forwardProgress, 1);
    forwardProgress = MAX (forwardProgress, 0);

    float x = forwardProgress;
    bool backwards = false;
    int animProgressDir = 1;

    if (mCurWindowEvent == WindowEventUnminimize ||
	mCurWindowEvent == WindowEventOpen)
	animProgressDir = 2;
    if (mOverrideProgressDir != 0)
	animProgressDir = mOverrideProgressDir;
    if ((animProgressDir == 1 &&
	 (mCurWindowEvent == WindowEventUnminimize ||
	  mCurWindowEvent == WindowEventOpen)) ||
	(animProgressDir == 2 &&
	 (mCurWindowEvent == WindowEventMinimize ||
	  mCurWindowEvent == WindowEventClose)))
	backwards = true;
    if (backwards)
	x = 1 - x;

    float dampBase = (pow (1-pow (x,1.2)*0.5,10)-pow (0.5,10))/(1-pow (0.5,10));
    float nonSpringyProgress =
	1 - pow (progressDecelerateCustom (1 - x, .5f, .8f), 1.7f);

    float damping =
	pow (dampBase, 0.5);

    float damping2 =
	((pow (1-(pow (x,0.7)*0.5),10)-pow (0.5,10))/(1-pow (0.5,10))) *
	0.7 + 0.3;
    float springiness = 0;

    // springy only when appearing
    if ((mCurWindowEvent == WindowEventUnminimize ||
	 mCurWindowEvent == WindowEventOpen) &&
	!neverSpringy)
    {
	springiness = getSpringiness ();
    }

    float springyMoveProgress =
	cos (2*M_PI*pow (x,1)*1.25) * damping * damping2;

    float scaleProgress;
    float moveProgress;

    if (springiness > 1e-4f)
    {
	if (x > 0.2)
	{
	    springyMoveProgress *= springiness;
	}
	else
	{
	    // interpolate between (springyMoveProgress * springiness)
	    // and springyMoveProgress for smooth transition at 0.2
	    // (where it crosses y=0)
	    float progressUpto02 = x / 0.2f;
	    springyMoveProgress =
		(1 - progressUpto02) * springyMoveProgress +
		progressUpto02 * springyMoveProgress * springiness;
	}
	moveProgress = 1 - springyMoveProgress;
    }
    else
    {
	moveProgress = nonSpringyProgress;
    }
    if (mCurWindowEvent == WindowEventUnminimize ||
	mCurWindowEvent == WindowEventOpen)
	moveProgress = 1 - moveProgress;
    if (backwards)
	moveProgress = 1 - moveProgress;

    float scProgress = nonSpringyProgress;
    if (mCurWindowEvent == WindowEventUnminimize ||
	mCurWindowEvent == WindowEventOpen)
	scProgress = 1 - scProgress;
    if (backwards)
	scProgress = 1 - scProgress;

    scaleProgress =
	pow (scProgress, 1.25);

    if (pMoveProgress)
	*pMoveProgress = moveProgress;
    if (pScaleProgress)
	*pScaleProgress = scaleProgress;
}