summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/math/color.h4
-rw-r--r--core/variant/variant_call.cpp1
2 files changed, 5 insertions, 0 deletions
diff --git a/core/math/color.h b/core/math/color.h
index ffd0fd8f6e..815dd98d96 100644
--- a/core/math/color.h
+++ b/core/math/color.h
@@ -94,6 +94,10 @@ struct Color {
void invert();
Color inverted() const;
+ _FORCE_INLINE_ float get_luminance() const {
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;
+ }
+
_FORCE_INLINE_ Color lerp(const Color &p_to, float p_weight) const {
Color res = *this;
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index 51b9119933..d2bda34818 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -1644,6 +1644,7 @@ static void _register_variant_builtin_methods() {
bind_method(Color, lightened, sarray("amount"), varray());
bind_method(Color, darkened, sarray("amount"), varray());
bind_method(Color, blend, sarray("over"), varray());
+ bind_method(Color, get_luminance, sarray(), varray());
bind_method(Color, is_equal_approx, sarray("to"), varray());