src

package
v0.0.0-...-acf5d39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ASCIIClear = "\x1b[0m"

ASCIIClear is the ASCII needed to reset the color settings

Variables

View Source
var ANSIColor = [...]RGB{
	{0x00, 0x00, 0x00}, {0xcd, 0x00, 0x00},
	{0x00, 0xcd, 0x00}, {0xcd, 0xcd, 0x00},
	{0x00, 0x00, 0xee}, {0xcd, 0x00, 0xcd},
	{0x00, 0xcd, 0xcd}, {0xe5, 0xe5, 0xe5},
	{0x7f, 0x7f, 0x7f}, {0xff, 0x00, 0x00},
	{0x00, 0xff, 0x00}, {0xff, 0xff, 0x00},
	{0x5c, 0x5c, 0xff}, {0xff, 0x00, 0xff},
	{0x00, 0xff, 0xff}, {0xff, 0xff, 0xff},
}

ANSIColor are the color sets for both 8 and 16 color terms

Functions

func AnsiClear

func AnsiClear(out io.Writer) error

AnsiClear writes the needed reset for the color settings

func DetectTermColor

func DetectTermColor() int

DetectTermColor is the "Poor-mans color mode detection."

func Distance

func Distance(rgb1, rgb2 RGB) float64

Distance calculates the Euclidean distance squared between two RGB values.

Types

type RGB

type RGB struct {
	R, G, B float64
}

RGB is a simple holder for Red, Green, and Blue

func NewRGB

func NewRGB(r, g, b float64) RGB

NewRGB creates a new RGB instance with the provided color values.

func (RGB) Sum

func (rgb RGB) Sum() float64

Sum up the three values

type Writer

type Writer struct {
	io.Writer
	Colors    int
	OurSpread float64
	Spread    float64
	Frequency float64
}

Writer does the ANSI wrapping of rainbow gradients

func (*Writer) Write

func (lw *Writer) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL