Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_Easing.c
Go to the documentation of this file.
1
3{
4 //------------------------------------------------------------------------------------------------
8 static float EaseInSine(float t)
9 {
10 return -1 * Math.Cos(t * Math.PI_HALF) + 1;
11 }
12
13 //------------------------------------------------------------------------------------------------
17 static float EaseOutSine(float t)
18 {
19 return Math.Sin(t * Math.PI_HALF);
20 }
21
22 //------------------------------------------------------------------------------------------------
26 static float EaseInOutSine(float t)
27 {
28 return -0.5 * (Math.Cos(Math.PI * t) - 1);
29 }
30
31 //------------------------------------------------------------------------------------------------
35 static float EaseInQuad(float t)
36 {
37 return t * t;
38 }
39
40 //------------------------------------------------------------------------------------------------
44 static float EaseOutQuad(float t)
45 {
46 return t * (2 - t);
47 }
48
49 //------------------------------------------------------------------------------------------------
53 static float EaseInOutQuad(float t)
54 {
55 if (t < 0.5)
56 return 2 * t * t;
57 else
58 return -1 + (4 - 2 * t) * t;
59 }
60
61 //------------------------------------------------------------------------------------------------
65 static float EaseInCubic(float t)
66 {
67 return t * t * t;
68 }
69
70 //------------------------------------------------------------------------------------------------
74 static float EaseOutCubic(float t)
75 {
76 float t1 = t - 1;
77 return t1 * t1 * t1 + 1;
78 }
79
80 //------------------------------------------------------------------------------------------------
84 static float EaseInOutCubic(float t)
85 {
86 if (t < 0.5)
87 return 4 * t * t * t;
88 else
89 return (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
90 }
91
92 //------------------------------------------------------------------------------------------------
96 static float EaseInQuart(float t)
97 {
98 return t * t * t * t;
99 }
100
101 //------------------------------------------------------------------------------------------------
105 static float EaseOutQuart(float t)
106 {
107 float t1 = t - 1;
108 return 1 - t1 * t1 * t1 * t1;
109 }
110
111 //------------------------------------------------------------------------------------------------
115 static float EaseInOutQuart(float t)
116 {
117 float t1 = t - 1;
118
119 if (t < 0.5)
120 return 8 * t * t * t * t;
121 else
122 return 1 - 8 * t1 * t1 * t1 * t1;
123 }
124
125 //------------------------------------------------------------------------------------------------
129 static float EaseInQuint(float t)
130 {
131 return t * t * t * t * t;
132 }
133
134 //------------------------------------------------------------------------------------------------
138 static float EaseOutQuint(float t)
139 {
140 float t1 = t - 1;
141 return 1 + t1 * t1 * t1 * t1 * t1;
142 }
143
144 //------------------------------------------------------------------------------------------------
148 static float EaseInOutQuint(float t)
149 {
150 float t1 = t - 1;
151
152 if (t < 0.5)
153 return 16 * t * t * t * t * t;
154 else
155 return 1 + 16 * t1 * t1 * t1 * t1 * t1;
156 }
157
158 //------------------------------------------------------------------------------------------------
162 static float EaseInExpo(float t)
163 {
164 if (t == 0)
165 return 0;
166
167 return (10 * (t - 1)) * (10 * (t - 1));
168 }
169
170 //------------------------------------------------------------------------------------------------
174 static float EaseOutExpo(float t)
175 {
176 if (t == 1)
177 return 1;
178
179 return -((-10 * t) * (-10 * t)) + 1;
180 }
181
182 //------------------------------------------------------------------------------------------------
186 static float EaseInOutExpo(float t)
187 {
188 if (t == 0 || t == 1)
189 return t;
190
191 float scaledTime = t * 2;
192 float scaledTime1 = scaledTime - 1;
193
194 if (scaledTime < 1)
195 return 0.5 * (10 * scaledTime1) * (10 * scaledTime1);
196
197 return 0.5 * (-(10 * scaledTime1 * 10 * scaledTime1) + 2);
198 }
199
200 //------------------------------------------------------------------------------------------------
204 static float EaseInCirc(float t)
205 {
206 return -1 * (Math.Sqrt(1 - t * t) - 1);
207 }
208
209 //------------------------------------------------------------------------------------------------
213 static float EaseOutCirc(float t)
214 {
215 float t1 = t - 1;
216 return Math.Sqrt(1 - t1 * t1);
217 }
218
219 //------------------------------------------------------------------------------------------------
223 static float EaseInOutCirc(float t)
224 {
225 float scaledTime = t * 2;
226 float scaledTime1 = scaledTime - 2;
227
228 if (scaledTime < 1)
229 return -0.5 * (Math.Sqrt(1 - scaledTime * scaledTime) - 1);
230
231 return 0.5 * (Math.Sqrt(1 - scaledTime1 * scaledTime1) + 1);
232 }
233
234 //------------------------------------------------------------------------------------------------
239 static float EaseInBack(float t, float magnitude = 1.70158)
240 {
241 return t * t * ((magnitude + 1) * t - magnitude);
242 }
243
244 //------------------------------------------------------------------------------------------------
249 static float EaseOutBack(float t, float magnitude = 1.70158)
250 {
251 float scaledTime = t - 1;
252 return (scaledTime * scaledTime * ((magnitude + 1) * scaledTime + magnitude)) + 1;
253 }
254
255 //------------------------------------------------------------------------------------------------
260 static float EaseInOutBack(float t, float magnitude = 1.70158)
261 {
262 float scaledTime = t * 2;
263 float scaledTime2 = scaledTime - 2;
264
265 float s = magnitude * 1.525;
266
267 if (scaledTime < 1)
268 return 0.5 * scaledTime * scaledTime * (((s + 1) * scaledTime) - s);
269
270 return 0.5 * (scaledTime2 * scaledTime2 * ((s + 1) * scaledTime2 + s) + 2);
271 }
272
273 //------------------------------------------------------------------------------------------------
278 static float EaseInElastic(float t, float magnitude = 0.7)
279 {
280 if (t == 0 || t == 1)
281 return t;
282
283 float scaledTime = t;
284 float scaledTime1 = scaledTime - 1;
285
286 float p = 1 - magnitude;
287 float s = p / Math.PI2 * Math.PI_HALF;
288
289 return -(10 * scaledTime1 * 10 * scaledTime1 * Math.Sin((scaledTime1 - s) * Math.PI2 / p));
290 }
291
292 //------------------------------------------------------------------------------------------------
297 static float EaseOutElastic(float t, float magnitude = 0.7)
298 {
299 float p = 1 - magnitude;
300 float scaledTime = t * 2;
301
302 if (t == 0 || t == 1)
303 return t;
304
305 float s = p / Math.PI2 * Math.PI_HALF;
306 return (10 * scaledTime * 10 * scaledTime * Math.Sin((scaledTime - s) * Math.PI2 / p)) + 1;
307 }
308
309 //------------------------------------------------------------------------------------------------
314 static float EaseInOutElastic(float t, float magnitude = 0.65)
315 {
316 float p = 1 - magnitude;
317
318 if (t == 0 || t == 1)
319 return t;
320
321 float scaledTime = t * 2;
322 float scaledTime1 = scaledTime - 1;
323
324 float s = p / Math.PI2 * Math.PI_HALF;
325
326 if (scaledTime < 1)
327 return -0.5 * ((10 * scaledTime1) * (10 * scaledTime1) * Math.Sin((scaledTime1 - s) * Math.PI2 / p));
328
329 return (10 * scaledTime1 * 10 * scaledTime1 * Math.Sin((scaledTime1 - s) * Math.PI2 / p) * 0.5) + 1;
330 }
331
332 //------------------------------------------------------------------------------------------------
336 static float EaseOutBounce(float t)
337 {
338 float scaledTime = t;
339 float scaledTime2;
340 if (scaledTime < (1 / 2.75))
341 return 7.5625 * scaledTime * scaledTime;
342
343 if (scaledTime < (2 / 2.75))
344 {
345 scaledTime2 = scaledTime - (1.5 / 2.75);
346 return (7.5625 * scaledTime2 * scaledTime2) + 0.75;
347 }
348
349 if (scaledTime < (2.5 / 2.75))
350 {
351 scaledTime2 = scaledTime - (2.25 / 2.75);
352 return (7.5625 * scaledTime2 * scaledTime2) + 0.9375;
353 }
354
355 scaledTime2 = scaledTime - (2.625 / 2.75);
356 return (7.5625 * scaledTime2 * scaledTime2) + 0.984375;
357 }
358
359 //------------------------------------------------------------------------------------------------
363 static float EaseInBounce(float t)
364 {
365 return 1 - EaseOutBounce(1 - t);
366 }
367
368 //------------------------------------------------------------------------------------------------
372 static float EaseInOutBounce(float t)
373 {
374 if (t < 0.5)
375 return EaseInBounce(t * 2) * 0.5;
376
377 return (EaseOutBounce((t * 2) - 1) * 0.5) + 0.5;
378 }
379}
Definition Math.c:13
Input value between 0 and 1, no automatic clamping of input (do your own !!).
Definition SCR_Easing.c:3