OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 namespace WebCore { | 31 namespace WebCore { |
32 | 32 |
33 inline int blend(int from, int to, double progress) | 33 inline int blend(int from, int to, double progress) |
34 { | 34 { |
35 return static_cast<int>(lround(static_cast<double>(from) + static_cast<doubl
e>(to - from) * progress)); | 35 return static_cast<int>(lround(static_cast<double>(from) + static_cast<doubl
e>(to - from) * progress)); |
36 } | 36 } |
37 | 37 |
38 inline unsigned blend(unsigned from, unsigned to, double progress) | 38 inline unsigned blend(unsigned from, unsigned to, double progress) |
39 { | 39 { |
40 return static_cast<unsigned>(lround(static_cast<double>(from) + static_cast<
double>(to - from) * progress)); | 40 return static_cast<unsigned>(lround(to > from ? static_cast<double>(from) +
static_cast<double>(to - from) * progress : static_cast<double>(from) - static_c
ast<double>(from - to) * progress)); |
41 } | 41 } |
42 | 42 |
43 inline double blend(double from, double to, double progress) | 43 inline double blend(double from, double to, double progress) |
44 { | 44 { |
45 return from + (to - from) * progress; | 45 return from + (to - from) * progress; |
46 } | 46 } |
47 | 47 |
48 inline float blend(float from, float to, double progress) | 48 inline float blend(float from, float to, double progress) |
49 { | 49 { |
50 return static_cast<float>(from + (to - from) * progress); | 50 return static_cast<float>(from + (to - from) * progress); |
51 } | 51 } |
52 | 52 |
53 } // namespace WebCore | 53 } // namespace WebCore |
54 | 54 |
55 #endif // AnimationUtilities_h | 55 #endif // AnimationUtilities_h |
OLD | NEW |