Documentation ¶
Overview ¶
Package xtermcolor provides a palette for xterm colors, and conversion to that palette from anything implementing color.Color
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrorEmptyHexStr is returned by FromHexStr when an empty hex string is provided ErrorEmptyHexStr = errors.New("Empty hex string provided") // ErrorHexParse is returned by FromHexStr when an invalid hex string is provided ErrorHexParse = errors.New("Failed to parse string as hex; try something like #CC66FF") )
View Source
var Colors = color.Palette{}/* 256 elements not displayed */
Colors lists Xterm color codes vs. RGBA; values taken from https://gist.github.com/jasonm23/2868981 color.Palette is really []color.Color and provides .Convert() and .Index()
Functions ¶
func FromColor ¶
FromColor finds the closest xterm colour to a given color.Color
Example ¶
package main import ( "fmt" "image/color" "github.com/tomnomnom/xtermcolor" ) func main() { fmt.Println(xtermcolor.FromColor(color.RGBA{120, 210, 120, 255})) }
Output: 114
func FromHexStr ¶
FromHexStr finds the closest xterm color to a given 24 bit hex string, e.g. "#CC66FF" or "FEFEFE" It's mostly useful if you're used to specifying colours as hex in CSS etc
Example ¶
package main import ( "fmt" "github.com/tomnomnom/xtermcolor" ) func main() { code, err := xtermcolor.FromHexStr("#CC66FF") if err != nil { fmt.Println(err) } fmt.Println(code) }
Output: 171
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.