summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax <maksloboda123@gmail.com>2018-06-19 20:42:59 +0300
committerMax <maksloboda123@gmail.com>2018-06-19 22:19:08 +0300
commit83b98785b3ab2a447e6158dde22fdd3438b32ee3 (patch)
tree503c55229df4f939a4647c73153f34e724e3b427
parentff01fd57bc19d9f4cb3929dbee87cdd9eda578e1 (diff)
Fixed float Color conversions to int types
-rw-r--r--core/color.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/core/color.cpp b/core/color.cpp
index b2f5889166..88e57ec6e2 100644
--- a/core/color.cpp
+++ b/core/color.cpp
@@ -37,38 +37,38 @@
uint32_t Color::to_argb32() const {
- uint32_t c = (uint8_t)(a * 255);
+ uint32_t c = (uint8_t)Math::round(a * 255);
c <<= 8;
- c |= (uint8_t)(r * 255);
+ c |= (uint8_t)Math::round(r * 255);
c <<= 8;
- c |= (uint8_t)(g * 255);
+ c |= (uint8_t)Math::round(g * 255);
c <<= 8;
- c |= (uint8_t)(b * 255);
+ c |= (uint8_t)Math::round(b * 255);
return c;
}
uint32_t Color::to_abgr32() const {
- uint32_t c = (uint8_t)(a * 255);
+ uint32_t c = (uint8_t)Math::round(a * 255);
c <<= 8;
- c |= (uint8_t)(b * 255);
+ c |= (uint8_t)Math::round(b * 255);
c <<= 8;
- c |= (uint8_t)(g * 255);
+ c |= (uint8_t)Math::round(g * 255);
c <<= 8;
- c |= (uint8_t)(r * 255);
+ c |= (uint8_t)Math::round(r * 255);
return c;
}
uint32_t Color::to_rgba32() const {
- uint32_t c = (uint8_t)(r * 255);
+ uint32_t c = (uint8_t)Math::round(r * 255);
c <<= 8;
- c |= (uint8_t)(g * 255);
+ c |= (uint8_t)Math::round(g * 255);
c <<= 8;
- c |= (uint8_t)(b * 255);
+ c |= (uint8_t)Math::round(b * 255);
c <<= 8;
- c |= (uint8_t)(a * 255);
+ c |= (uint8_t)Math::round(a * 255);
return c;
}
@@ -368,7 +368,7 @@ Color Color::named(const String &p_name) {
String _to_hex(float p_val) {
- int v = p_val * 255;
+ int v = Math::round(p_val * 255);
v = CLAMP(v, 0, 255);
String ret;