summaryrefslogtreecommitdiffstats
path: root/core/color.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/color.h')
-rw-r--r--core/color.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/color.h b/core/color.h
index 9b5850f56b..491c72d449 100644
--- a/core/color.h
+++ b/core/color.h
@@ -30,6 +30,7 @@
#define COLOR_H
#include "ustring.h"
+#include "math_funcs.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -97,6 +98,16 @@ struct Color {
return res;
}
+ _FORCE_INLINE_ Color to_linear() const {
+
+ return Color(
+ r<0.04045 ? r * (1.0 / 12.92) : Math::pow((r + 0.055) * (1.0 / (1 + 0.055)), 2.4),
+ g<0.04045 ? g * (1.0 / 12.92) : Math::pow((g + 0.055) * (1.0 / (1 + 0.055)), 2.4),
+ b<0.04045 ? b * (1.0 / 12.92) : Math::pow((b + 0.055) * (1.0 / (1 + 0.055)), 2.4),
+ a
+ );
+ }
+
static Color hex(uint32_t p_hex);
static Color html(const String& p_color);
static bool html_is_valid(const String& p_color);