OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_ANDROID_ANIMATION_UTILS_H_ |
| 6 #define CONTENT_BROWSER_ANDROID_ANIMATION_UTILS_H_ |
| 7 |
| 8 namespace content { |
| 9 |
| 10 template <typename T> |
| 11 T Lerp(T a, T b, T t) { |
| 12 return a + (b - a) * t; |
| 13 } |
| 14 |
| 15 template <typename T> |
| 16 T Clamp(T value, T low, T high) { |
| 17 return value < low ? low : (value > high ? high : value); |
| 18 } |
| 19 |
| 20 template <typename T> |
| 21 T Damp(T input, T factor) { |
| 22 T result; |
| 23 if (factor == 1) { |
| 24 result = 1 - (1 - input) * (1 - input); |
| 25 } else { |
| 26 result = 1 - std::pow(1 - input, 2 * factor); |
| 27 } |
| 28 return result; |
| 29 } |
| 30 |
| 31 } // namespace content |
| 32 |
| 33 #endif // CONTENT_BROWSER_ANDROID_ANIMATION_UTILS_H_ |
OLD | NEW |