summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2018-09-18 17:11:15 +0200
committerRémi Verschelde <rverschelde@gmail.com>2018-09-18 17:11:15 +0200
commitc4f14e091c0f63f7951b0cf0aa97a733ac448044 (patch)
tree570cf6f938881067bbb3a55d265aa09f30431e0e
parentf148e8eedeb1ff2dcf74d6843d1314d7c6db12a7 (diff)
Color: Fix rounding error converting from float to 8-bit
Fixes #16736.
-rw-r--r--core/variant_op.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 2edf33ec1c..9afc31a772 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -1656,13 +1656,13 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
} else if (p_index == CoreStringNames::singleton->a) {
return v->a;
} else if (p_index == CoreStringNames::singleton->r8) {
- return int(v->r * 255.0);
+ return int(Math::round(v->r * 255.0));
} else if (p_index == CoreStringNames::singleton->g8) {
- return int(v->g * 255.0);
+ return int(Math::round(v->g * 255.0));
} else if (p_index == CoreStringNames::singleton->b8) {
- return int(v->b * 255.0);
+ return int(Math::round(v->b * 255.0));
} else if (p_index == CoreStringNames::singleton->a8) {
- return int(v->a * 255.0);
+ return int(Math::round(v->a * 255.0));
} else if (p_index == CoreStringNames::singleton->h) {
return v->get_h();
} else if (p_index == CoreStringNames::singleton->s) {