Merge pull request #22219 from akien-mga/color-float-to-8bit

Color: Fix rounding error converting from float to 8-bit
This commit is contained in:
Rémi Verschelde 2018-09-19 09:09:54 +02:00 committed by GitHub
commit ca2ecf70a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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) {