diff options
Diffstat (limited to 'vendor/github.com/gdamore/tcell/v2/color.go')
-rw-r--r-- | vendor/github.com/gdamore/tcell/v2/color.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/vendor/github.com/gdamore/tcell/v2/color.go b/vendor/github.com/gdamore/tcell/v2/color.go index 8a13a073a..8e50fa302 100644 --- a/vendor/github.com/gdamore/tcell/v2/color.go +++ b/vendor/github.com/gdamore/tcell/v2/color.go @@ -14,7 +14,10 @@ package tcell -import "strconv" +import ( + ic "image/color" + "strconv" +) // Color represents a color. The low numeric values are the same as used // by ECMA-48, and beyond that XTerm. A 24-bit RGB value may be used by @@ -35,7 +38,7 @@ const ( // system or terminal default may exist. It's also the zero value. ColorDefault Color = 0 - // ColorIsValid is used to indicate the color value is actually + // ColorValid is used to indicate the color value is actually // valid (initialized). This is useful to permit the zero value // to be treated as the default. ColorValid Color = 1 << 32 @@ -1066,4 +1069,13 @@ func GetColor(name string) Color { // PaletteColor creates a color based on the palette index. func PaletteColor(index int) Color { return Color(index) | ColorValid -}
\ No newline at end of file +} + +// FromImageColor converts an image/color.Color into tcell.Color. +// The alpha value is dropped, so it should be tracked separately if it is +// needed. +func FromImageColor(imageColor ic.Color) Color { + r, g, b, _ := imageColor.RGBA() + // NOTE image/color.Color RGB values range is [0, 0xFFFF] as uint32 + return NewRGBColor(int32(r>>8), int32(g>>8), int32(b>>8)) +} |