aboutsummaryrefslogtreecommitdiffhomepage
path: root/resources/images/color.go
diff options
context:
space:
mode:
Diffstat (limited to 'resources/images/color.go')
-rw-r--r--resources/images/color.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/resources/images/color.go b/resources/images/color.go
index 0eedecb89..fe891fe88 100644
--- a/resources/images/color.go
+++ b/resources/images/color.go
@@ -56,13 +56,13 @@ func ColorToHexString(c color.Color) string {
func hexStringToColor(s string) (color.Color, error) {
s = strings.TrimPrefix(s, "#")
- if len(s) != 3 && len(s) != 6 {
+ if len(s) != 3 && len(s) != 4 && len(s) != 6 && len(s) != 8 {
return nil, fmt.Errorf("invalid color code: %q", s)
}
s = strings.ToLower(s)
- if len(s) == 3 {
+ if len(s) == 3 || len(s) == 4 {
var v string
for _, r := range s {
v += string(r) + string(r)
@@ -80,7 +80,9 @@ func hexStringToColor(s string) (color.Color, error) {
}
// Set Alfa to white.
- s += "ff"
+ if len(s) == 6 {
+ s += "ff"
+ }
b, err := hex.DecodeString(s)
if err != nil {