Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Color ¶
type Color struct { // Red is the red component of the RGB color. Red uint8 // Green is the green component of the RGB color. Green uint8 // Blue is the blue component of the RGB color. Blue uint8 }
Color represents an RGB color.
func New ¶
New creates a new RGB color from the given red, green, and blue values.
Parameters:
- rule: The red component of the RGB color.
- green: The green component of the RGB color.
- blue: The blue component of the RGB color.
Returns:
- Color: The new RGB color. Never returns nil.
func (Color) Background ¶
Background writes an ANSI escape code to set the terminal's background color to the RGB values of the Color receiver.
Parameters:
- w: The writer to which the ANSI escape code is written.
Returns:
- error: An error if writing to the writer fails or if the writer is nil.
func (Color) Bytes ¶
Bytes returns the bytes of the color.
Returns:
- []byte: The bytes of the color. Never returns nil.
func (Color) Foreground ¶
Foreground writes an ANSI escape code to set the terminal's text color to the RGB values of the Color receiver.
Parameters:
- w: The writer to which the ANSI escape code is written.
Returns:
- error: An error if writing to the writer fails or if the writer is nil.
type Style ¶
type Style struct {
// contains filtered or unexported fields
}
Style represents a style.
var ( // DefaultStyle is the default style. It is white foreground and black background. DefaultStyle *Style )
func (*Style) Background ¶
Background sets the background color of the style.
Parameters:
- color: The color to set as the background.
Returns:
- *Style: A new Style with the updated background color. Never returns nil.
func (*Style) Foreground ¶
Foreground sets the foreground color of the style.
Parameters:
- color: The color to set as the foreground.
Returns:
- *Style: A new Style with the updated foreground color. Never returns nil.
func (Style) String ¶
String returns a string that sets the terminal's foreground and background colors to the RGB values of the Style's fg and bg fields. This string can be printed to apply the color styling in the terminal.
Returns:
- string: A string that, when printed, sets both the foreground and background colors of the terminal.