From 8bff891f3c22551664e7f82702b5f778b780654b Mon Sep 17 00:00:00 2001 From: Dylan Enloe Date: Tue, 12 Sep 2017 13:58:47 -0700 Subject: [PATCH] Adds 3 and 4 digit html shortcuts to Color Color::html now expands 3 and 4 digit hex values into 6 and 8 digit values by repeating each digit. This is to bring it in line with how html handles these values fixes #10997 --- core/color.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/color.cpp b/core/color.cpp index ab264d31d4e..1f8934ed05b 100644 --- a/core/color.cpp +++ b/core/color.cpp @@ -250,6 +250,14 @@ Color Color::html(const String &p_color) { return Color(); if (color[0] == '#') color = color.substr(1, color.length() - 1); + if (color.length() == 3 || color.length() == 4) { + String exp_color; + for (int i = 0; i < color.length(); i++) { + exp_color += color[i]; + exp_color += color[i]; + } + color = exp_color; + } bool alpha = false;