diff options
author | elasota <ejlasota@gmail.com> | 2018-08-21 22:56:04 -0400 |
---|---|---|
committer | elasota <ejlasota@gmail.com> | 2018-08-21 22:56:04 -0400 |
commit | 35f6ba5c5d950171ec3e4f15934ac5494b19acb1 (patch) | |
tree | c154bca58614f4970dcf144b886e906d4a8972d3 /core/color.cpp | |
parent | 0e6551d8e2c080149bedcefd6c9dd0061261ea3f (diff) | |
download | redot-engine-35f6ba5c5d950171ec3e4f15934ac5494b19acb1.tar.gz |
BPTC support
Diffstat (limited to 'core/color.cpp')
-rw-r--r-- | core/color.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/core/color.cpp b/core/color.cpp index 0d8cad1a5e..17c9e2daeb 100644 --- a/core/color.cpp +++ b/core/color.cpp @@ -253,6 +253,21 @@ Color Color::hex64(uint64_t p_hex) { return Color(r, g, b, a); } +Color Color::from_rgbe9995(uint32_t p_rgbe) { + + float r = p_rgbe & 0x1ff; + float g = (p_rgbe >> 9) & 0x1ff; + float b = (p_rgbe >> 18) & 0x1ff; + float e = (p_rgbe >> 27); + float m = Math::pow(2, e - 15.0 - 9.0); + + float rd = r * m; + float gd = g * m; + float bd = b * m; + + return Color(rd, gd, bd, 1.0f); +} + static float _parse_col(const String &p_str, int p_ofs) { int ig = 0; |