Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Black = &Named{"black", blackRGB} DarkBlue = &Named{"dark_blue", darkBlueRGB} DarkGreen = &Named{"dark_green", darkGreenRGB} DarkAqua = &Named{"dark_aqua", darkAquaRGB} DarkRed = &Named{"dark_red", darkRedRGB} DarkPurple = &Named{"dark_purple", darkPurpleRGB} Gold = &Named{"gold", goldRGB} Gray = &Named{"gray", grayRGB} DarkGray = &Named{"dark_gray", darkGrayRGB} Blue = &Named{"blue", blueRGB} Green = &Named{"green", greenRGB} Aqua = &Named{"aqua", aquaRGB} Red = &Named{"red", redRGB} LightPurple = &Named{"light_purple", lightPurpleRGB} Yellow = &Named{"yellow", yellowRGB} White = &Named{"white", whiteRGB} // NamesOrder is the order of the named colors. NamesOrder = []*Named{ Black, DarkBlue, DarkGreen, DarkAqua, DarkRed, DarkPurple, Gold, Gray, DarkGray, Blue, Green, Aqua, Red, LightPurple, Yellow, White, } // Names is a map of the named colors. Names = func() map[string]*Named { m := map[string]*Named{} for _, a := range NamesOrder { m[a.Name] = a } return m }() )
Minecraft named color.
View Source
var InvalidFormatErr = errors.New("color.Hex: invalid format")
Functions ¶
This section is empty.
Types ¶
type Color ¶
type Color interface { fmt.Stringer color.Color Hex() string // Returns the hex "html" representation of the color, as in #ff0080. Named() *Named // Returns the exact or nearest Named color. }
Color is the interface for a Minecraft text color, either Named or RGB (for Hex).
type RGB ¶
type RGB colorful.Color
RGB is a Minecraft text color.
func Hex ¶
Hex parses a web color given by its hex RGB format. See https://en.wikipedia.org/wiki/Web_colors for input format.
Modified version of https://stackoverflow.com/a/54200713/1705598.
func MustHex ¶
MustHex parses a "html" hex color-string, either in the 3 "#f0c" or 6 "#ff1034" digits form. It panics on error.
func (*RGB) NearestNamed ¶
NearestNamed finds the nearest Named color for to this RGB.
Click to show internal directories.
Click to hide internal directories.