forked from mbk-lab/rui_orig
Added NamedColors() function
This commit is contained in:
parent
8a625dcc78
commit
456744de82
|
@ -1,5 +1,7 @@
|
|||
package rui
|
||||
|
||||
import "sort"
|
||||
|
||||
const (
|
||||
// Black color constant
|
||||
Black Color = 0xff000000
|
||||
|
@ -446,3 +448,23 @@ var colorConstants = map[string]Color{
|
|||
"whitesmoke": 0xfff5f5f5,
|
||||
"yellowgreen": 0xff9acd32,
|
||||
}
|
||||
|
||||
type NamedColor struct {
|
||||
Name string
|
||||
Color Color
|
||||
}
|
||||
|
||||
// NamedColors returns the list of named colors
|
||||
func NamedColors() []NamedColor {
|
||||
count := len(colorConstants)
|
||||
result := make([]NamedColor, 0, count)
|
||||
for name, color := range colorConstants {
|
||||
result = append(result, NamedColor{Name: name, Color: color})
|
||||
}
|
||||
|
||||
sort.Slice(result, func(i, j int) bool {
|
||||
return result[i].Name < result[j].Name
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue