From 57a78ec06bccbb55a85c73891d88b983b4f01c94 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 27 May 2015 10:56:57 -0300 Subject: [PATCH] added conversion from int, string to color fixes #1971 --- core/variant.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/variant.cpp b/core/variant.cpp index d7817ac2689..034dc2b4fca 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -302,8 +302,8 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) { case COLOR: { static const Type valid[] = { - //STRING, - //INT, + STRING, + INT, NIL, }; @@ -1653,6 +1653,10 @@ Variant::operator Color() const { if (type==COLOR) return *reinterpret_cast(_data._mem); + else if (type==STRING) + return Color::html( operator String() ); + else if (type==INT) + return Color::hex( operator int() ); else return Color(); }