aboutsummaryrefslogtreecommitdiff
path: root/core/variant_op.cpp
diff options
context:
space:
mode:
authorAndreas Haas2016-05-31 20:50:19 +0200
committerRémi Verschelde2016-06-04 22:20:02 +0200
commit2b06d7e6f741d808465c41eefd7874f67a22910d (patch)
tree8d1c975da8bd2d56eff81556feb5ada79908aa32 /core/variant_op.cpp
parent79e9917367f18d5a9a519a50dc8aede9689af2ea (diff)
downloadgodot-2b06d7e6f741d808465c41eefd7874f67a22910d.tar.gz
godot-2b06d7e6f741d808465c41eefd7874f67a22910d.tar.zst
godot-2b06d7e6f741d808465c41eefd7874f67a22910d.zip
Make Color.{rgba}8 return int instead float
According to the class doc, these should be int. Also fixed a little bug: the setter for 'r8' changed the green value (cherry picked from commit da3247a500662dcbd8e1946ecf0a9af19a146982)
Diffstat (limited to '')
-rw-r--r--core/variant_op.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index f03ab43fc..f4fa3fce3 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -1354,7 +1354,7 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
return;
} else if (*str=="r8" ) {
valid=true;
- v->g=float(p_value)/255.0;
+ v->r=float(p_value)/255.0;
return;
} else if (*str=="g8" ) {
valid=true;
@@ -2213,16 +2213,16 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const {
return v->get_v();
} else if (*str=="r8") {
valid=true;
- return v->r*255.0;
+ return (int)Math::round(v->r*255.0);
} else if (*str=="g8" ) {
valid=true;
- return v->g*255.0;
+ return (int)Math::round(v->g*255.0);
} else if (*str=="b8" ) {
valid=true;
- return v->b*255.0;
+ return (int)Math::round(v->b*255.0);
} else if (*str=="a8" ) {
valid=true;
- return v->a*255.0;
+ return (int)Math::round(v->a*255.0);
}
} else if (p_index.get_type()==Variant::INT) {