2
* Animation plugin for compiz/beryl
6
* Copyright : (C) 2006 Erkin Bahceci
7
* E-mail : erkinbah@gmail.com
9
* Based on Wobbly and Minimize plugins by
11
* E-mail : davidr@novell.com>
13
* Particle system added by : (C) 2006 Dennis Kasprzyk
14
* E-mail : onestone@beryl-project.org
16
* Beam-Up added by : Florencio Guimaraes
17
* E-mail : florencio@nexcorp.com.br
19
* Hexagon tessellator added by : Mike Slegeir
20
* E-mail : mikeslegeir@mail.utexas.edu>
22
* This program is free software; you can redistribute it and/or
23
* modify it under the terms of the GNU General Public License
24
* as published by the Free Software Foundation; either version 2
25
* of the License, or (at your option) any later version.
27
* This program is distributed in the hope that it will be useful,
28
* but WITHOUT ANY WARRANTY; without even the implied warranty of
29
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
* GNU General Public License for more details.
32
* You should have received a copy of the GNU General Public License
33
* along with this program; if not, write to the Free Software
34
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
39
const float WaveAnim::kMinDuration = 400;
41
// ===================== Effect: Wave =========================
43
WaveAnim::WaveAnim (CompWindow *w,
44
WindowEvent curWindowEvent,
46
const AnimEffect info,
47
const CompRect &icon) :
48
Animation::Animation (w, curWindowEvent, duration, info, icon),
49
TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon),
50
GridTransformAnim::GridTransformAnim (w, curWindowEvent, duration, info,
56
WaveAnim::adjustDuration ()
58
if (mTotalTime < kMinDuration)
60
mTotalTime = kMinDuration;
61
mRemainingTime = mTotalTime;
69
mGridHeight = optValI (AnimationOptions::MagicLampWavyGridRes); // TODO new option
75
float forwardProgress = 1 - progressLinear ();
76
if (mCurWindowEvent == WindowEventClose)
77
forwardProgress = 1 - forwardProgress;
79
CompRect winRect (mAWindow->savedRectsValid () ?
80
mAWindow->saveWinRect () :
81
mWindow->geometry ());
82
CompRect outRect (mAWindow->savedRectsValid () ?
83
mAWindow->savedOutRect () :
84
mWindow->outputRect ());
85
CompWindowExtents outExtents (mAWindow->savedRectsValid () ?
86
mAWindow->savedOutExtents () :
89
int wx = winRect.x ();
90
int wy = winRect.y ();
92
int oy = outRect.y ();
93
int owidth = outRect.width ();
94
int oheight = outRect.height ();
96
float waveHalfWidth = (oheight * mModel->scale ().y () *
97
optValF (AnimationOptions::WaveWidth) / 2);
99
float waveAmp = (pow ((float)oheight / ::screen->height (), 0.4) *
100
0.04 * optValF (AnimationOptions::WaveAmpMult));
104
forwardProgress * (oheight * mModel->scale ().y () + 2 * waveHalfWidth);
106
GridModel::GridObject *object = mModel->objects ();
107
unsigned int n = mModel->numObjects ();
108
for (unsigned int i = 0; i < n; i++, object++)
110
Point3d &objPos = object->position ();
112
if (i % 2 == 0) // object is at the left side
114
float origy = wy + mModel->scale ().y () *
115
(oheight * object->gridPosition ().y () -
119
float distFromWaveCenter =
120
fabs (objPos.y () - wavePosition);
122
if (distFromWaveCenter < waveHalfWidth)
124
setZ (waveAmp * (cos (distFromWaveCenter *
125
M_PI / waveHalfWidth) + 1) / 2);
129
else // object is at the right side
131
// Set y/z position to the y/z position of the object at the left
132
// on the same row (previous object)
133
Point3d &leftObjPos = (object - 1)->position ();
134
objPos.setY (leftObjPos.y ());
135
objPos.setZ (leftObjPos.z ());
138
float origx = wx + mModel->scale ().x () *
139
(owidth * object->gridPosition ().x () -