resources/images: Create padding image filter

Closes #11599
This commit is contained in:
Joe Mooring
2023-10-27 20:19:39 -07:00
committed by Bjørn Erik Pedersen
parent db14238ba3
commit 3ed28e4bfe
4 changed files with 146 additions and 4 deletions

View File

@@ -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 {