| 73 | } |
| 74 | |
| 75 | float CalcSaturation(float time_delta_ms, const ColorHSV& color, bool key_on) { |
| 76 | if (color.v_ <= 0.0) { |
| 77 | return color.s_; |
| 78 | } |
| 79 | if (!key_on) { |
| 80 | return 1.0f; |
| 81 | } |
| 82 | static const float kDefaultSaturationTime = 0.05f * 1000.f; |
| 83 | |
| 84 | // At time = 0.0 the saturation_factor will be at 0.0 and then transition to 1.0 |
| 85 | float saturation_factor = mapf(time_delta_ms, |
| 86 | 0.0f, kDefaultSaturationTime, |
| 87 | 0.0f, 1.0f); |
| 88 | // As time increases the saturation factor will continue |
| 89 | // to grow past 1.0. We use min to clamp it back to 1.0. |
| 90 | saturation_factor = fl::min(1.0f, saturation_factor); |
| 91 | // TODO - make the saturation interpolate between the original |
| 92 | // color and the unsaturated state. |
| 93 | return saturation_factor; |
| 94 | } |
| 95 | |
| 96 | } // namespace. |
| 97 | |