diff options
| author | Kyle Van Berendonck | 2017-10-13 15:49:31 +1100 |
|---|---|---|
| committer | Kyle Van Berendonck | 2017-11-21 21:48:11 +1100 |
| commit | 8e4336a7294f0cc31aa5ccfb2854c702aa86dcca (patch) | |
| tree | 30310e228a417f968d98fd999136578943d76468 /core/color.h | |
| parent | c846e49a7d3439d9aef5d499ad403304d89a3b3c (diff) | |
| download | godot-8e4336a7294f0cc31aa5ccfb2854c702aa86dcca.tar.gz godot-8e4336a7294f0cc31aa5ccfb2854c702aa86dcca.tar.zst godot-8e4336a7294f0cc31aa5ccfb2854c702aa86dcca.zip | |
Diffstat (limited to 'core/color.h')
| -rw-r--r-- | core/color.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/color.h b/core/color.h index 972b6a1b3..da2bfdcd9 100644 --- a/core/color.h +++ b/core/color.h @@ -101,6 +101,24 @@ struct Color { return res; } + _FORCE_INLINE_ Color darkened(float p_amount) const { + + Color res = *this; + res.r = CLAMP(res.r * (1.0f - p_amount), 0.0, 1.0); + res.g = CLAMP(res.g * (1.0f - p_amount), 0.0, 1.0); + res.b = CLAMP(res.b * (1.0f - p_amount), 0.0, 1.0); + return res; + } + + _FORCE_INLINE_ Color lightened(float p_amount) const { + + Color res = *this; + res.r = CLAMP(res.r + (1.0f - res.r) * p_amount, 0.0, 1.0); + res.g = CLAMP(res.g + (1.0f - res.g) * p_amount, 0.0, 1.0); + res.b = CLAMP(res.b + (1.0f - res.b) * p_amount, 0.0, 1.0); + return res; + } + _FORCE_INLINE_ uint32_t to_rgbe9995() const { const float pow2to9 = 512.0f; |
