Esempio n. 1
0
void
GhostAnim::updateAttrib (GLWindowPaintAttrib &attrib)
{
    AnimJCScreen *ajs = AnimJCScreen::get (screen);
    attrib.opacity *= 1. - progressLinear ();
    attrib.saturation *= ajs->optionGetGhostSaturation ();
}
Esempio n. 2
0
Point
ZoomAnim::getCenter ()
{
    Point center;

    if (zoomToIcon ())
    {
	getCenterScale (&center, 0);
    }
    else
    {
	float forwardProgress = progressLinear ();

	CompRect inRect (mAWindow->savedRectsValid () ?
			 mAWindow->savedInRect () :
			 mWindow->borderRect ());

	center.setX (inRect.x () + inRect.width () / 2.0);

	if (mCurWindowEvent == WindowEventShade ||
	    mCurWindowEvent == WindowEventUnshade)
	{
	    float origCenterY = (inRect.y () +
				 inRect.height () / 2.0);
	    center.setY ((1 - forwardProgress) * origCenterY +
			 forwardProgress * (inRect.y () +
					    mDecorTopHeight));
	}
	else // i.e. (un)minimizing without zooming
	{
	    center.setY (inRect.y () + inRect.height () / 2.0);
	}
    }
    return center;
}
Esempio n. 3
0
float
ZoomAnim::getActualProgress ()
{
    float forwardProgress = 0;

    if (zoomToIcon ())
	getZoomProgress (&forwardProgress, 0, true);
    else
	forwardProgress = progressLinear ();

    return forwardProgress;
}
Esempio n. 4
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);
}
Esempio n. 5
0
void
GhostAnim::step ()
{
    float t = 1. - progressLinear ();
    if (mCurWindowEvent == WindowEventClose)
	t = 1. - t;

    CompRect winRect (mAWindow->savedRectsValid () ?
                      mAWindow->saveWinRect () :
                      mWindow->geometry ());
    CompRect outRect (mAWindow->savedRectsValid () ?
                      mAWindow->savedOutRect () :
                      mWindow->outputRect ());
    CompWindowExtents outExtents (mAWindow->savedRectsValid () ?
			          mAWindow->savedOutExtents () :
			          mWindow->output ());

    int wx = winRect.x ();
    int wy = winRect.y ();

    int owidth = outRect.width ();
    int oheight = outRect.height ();

    AnimJCScreen *ajs = AnimJCScreen::get (screen);

    float waveAmp = 3 * ajs->optionGetGhostAmplitude ();
    float waveLengthX1 = 0.4;
    float waveLengthX2 = 0.3;
    float waveLengthY1 = 0.45;
    float waveLengthY2 = 0.35;
    float wavePositionX1 =  0.25 * t * ajs->optionGetGhostWaveSpeed ();
    float wavePositionX2 = -0.25 * t * ajs->optionGetGhostWaveSpeed ();
    float wavePositionY1 =  0.25 * t * ajs->optionGetGhostWaveSpeed ();
    float wavePositionY2 = -0.25 * t * ajs->optionGetGhostWaveSpeed ();

    GridModel::GridObject *object = mModel->objects ();
    unsigned int n = mModel->numObjects ();
    for (unsigned int i = 0; i < n; i++, object++)
    {
	Point3d &objPos = object->position ();

	float origx = wx + mModel->scale ().x () *
		(owidth * object->gridPosition ().x () -
		outExtents.left);

	float origy = wy + mModel->scale ().y () *
		(oheight * object->gridPosition ().y () -
		outExtents.top);

	float x = object->gridPosition ().x ();
	float y = object->gridPosition ().y ();

	float distFromWaveX1 = x - wavePositionX1;
	float distFromWaveX2 = x - wavePositionX2;
	float distFromWaveY1 = y - wavePositionY1;
	float distFromWaveY2 = y - wavePositionY2;

	objPos.setX (origx +
		     waveAmp * sin (distFromWaveX1 / waveLengthX1 * 2 * M_PI) +
		     waveAmp * sin (distFromWaveX2 / waveLengthX2 * 2 * M_PI));

	objPos.setY (origy +
		     waveAmp * sin (distFromWaveY1 / waveLengthY1 * 2 * M_PI) +
		     waveAmp * sin (distFromWaveY2 / waveLengthY2 * 2 * M_PI));

	objPos.setZ (0);
    }
}
Esempio n. 6
0
void
RaindropAnim::step ()
{
    float t = 1. - progressLinear ();
    if (mCurWindowEvent == WindowEventClose)
	t = 1. - t;

    CompRect winRect (mAWindow->savedRectsValid () ?
                      mAWindow->saveWinRect () :
                      mWindow->geometry ());
    CompRect outRect (mAWindow->savedRectsValid () ?
                      mAWindow->savedOutRect () :
                      mWindow->outputRect ());
    CompWindowExtents outExtents (mAWindow->savedRectsValid () ?
			          mAWindow->savedOutExtents () :
			          mWindow->output ());

    int wx = winRect.x ();
    int wy = winRect.y ();

    int owidth = outRect.width ();
    int oheight = outRect.height ();

    AnimJCScreen *ajs = AnimJCScreen::get (screen);

    float waveLength = ajs->optionGetRaindropWavelength ();
    int numWaves = ajs->optionGetRaindropNumWaves ();
    float waveAmp = (pow ((float)oheight / ::screen->height (), 0.4) * 0.08) *
	    ajs->optionGetRaindropAmplitude ();
    float wavePosition = -waveLength * numWaves +
	    (1. + waveLength * numWaves) * t;

    GridModel::GridObject *object = mModel->objects ();
    unsigned int n = mModel->numObjects ();
    for (unsigned int i = 0; i < n; i++, object++)
    {
	Point3d &objPos = object->position ();

        float origx = wx + mModel->scale ().x () *
		(owidth * object->gridPosition ().x () -
		outExtents.left);
        objPos.setX (origx);

	float origy = wy + mModel->scale ().y () *
		(oheight * object->gridPosition ().y () -
		outExtents.top);
        objPos.setY (origy);

	// find distance to center in grid terms
	float gridDistance = sqrt (pow (object->gridPosition ().x ()-0.5, 2) +
			           pow (object->gridPosition ().y ()-0.5, 2)) *
			     sqrt (2);

	float distFromWave = gridDistance - wavePosition;
	if (distFromWave < waveLength*numWaves && distFromWave > 0)
	    objPos.setZ (waveAmp *
		    sin (3.14159265 * distFromWave / waveLength / numWaves) *
		    pow (sin (3.14159265 * distFromWave / waveLength), 2));
	else
	    objPos.setZ (0);
    }
}
Esempio n. 7
0
void
FlickerSingleAnim::step ()
{
    int layer = MultiAnim <FlickerSingleAnim,5>::getCurrAnimNumber (mAWindow);

    CompRect winRect (mAWindow->savedRectsValid () ?
                      mAWindow->saveWinRect () :
                      mWindow->geometry ());
    CompRect outRect (mAWindow->savedRectsValid () ?
                      mAWindow->savedOutRect () :
                      mWindow->outputRect ());
    CompWindowExtents outExtents (mAWindow->savedRectsValid () ?
                                  mAWindow->savedOutExtents () :
                                  mWindow->output ());

    int wx = winRect.x ();
    int wy = winRect.y ();
    int owidth = outRect.width ();
    int oheight = outRect.height ();

    float t = 1 - progressLinear ();
    if (mCurWindowEvent == WindowEventClose)
	t = 1 - t;

    float amplitude = AnimJCScreen::get (screen)->optionGetFlickerAmplitude ();
    float waveLength = 0.4;
    float wavePosition = -waveLength + (1. + waveLength) * t;

    float displacement = 0;

    GridModel::GridObject *object = mModel->objects ();
    unsigned int n = mModel->numObjects ();
    for (unsigned int i = 0; i < n; i++, object++)
    {
	Point3d &objPos = object->position ();

	if (i % 2 == 0) // left side; reuse old displacement on right side
	{
	    float distFromWave = object->gridPosition ().y () - wavePosition;

	    if (distFromWave > 0 && distFromWave <= waveLength)
	    {
		displacement = amplitude * sin (distFromWave/waveLength * M_PI);
	    }
	    else
	    {
		displacement = 0;
	    }
	}

        float x = wx + mModel->scale ().x () *
            (owidth * object->gridPosition ().x () - outExtents.left);

	float y = wy + mModel->scale ().y () *
	    (oheight * object->gridPosition ().y () - outExtents.top);

	switch (layer)
	{
	    case 1:
		x -= displacement;
		break;
	    case 2:
		x += displacement;
		break;
	    case 3:
		y -= displacement;
		break;
	    case 4:
		y += displacement;
		break;
	    default:
		break;
	}

        objPos.setX (x);
	objPos.setY (y);
	objPos.setZ (0);
    }
}