diff options
author | Dylan Enloe <enloed@gmail.com> | 2017-09-12 13:58:47 -0700 |
---|---|---|
committer | Dylan Enloe <enloed@gmail.com> | 2017-09-12 14:05:33 -0700 |
commit | 8bff891f3c22551664e7f82702b5f778b780654b (patch) | |
tree | 95970318b104087f2cbc334dad8744aee0439fc0 /core | |
parent | 0f006994d8be89e3c06bbec50eeab6746b17865c (diff) |
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
Diffstat (limited to 'core')
-rw-r--r-- | core/color.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/color.cpp b/core/color.cpp index ab264d31d4..1f8934ed05 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; |