Created
August 20, 2021 05:43
-
-
Save bfu4/e28611cd058b0c33726854cc9ca6a69b to your computer and use it in GitHub Desktop.
colors again
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package colors | |
import "strconv" | |
type Color int | |
const ( | |
Black Color = iota | |
Red | |
Green | |
Yellow | |
Blue | |
Magenta | |
Turquoise | |
LightGray | |
Gray | |
BrightRed | |
BrightGreen | |
BrightYellow | |
BrightBlue | |
BrightMagenta | |
Aqua | |
White | |
LightRed Color = 124 | |
LightOrange Color = 214 | |
LightYellow Color = 226 | |
LightGreen Color = 82 | |
LightBlue Color = 63 | |
LightPurple Color = 183 | |
LightPink Color = 212 | |
formatSequence = "\u001b[38;5;" | |
resetSequence = "\033[0m" | |
rowJump = 36 | |
) | |
func Custom(initial, shift int) Color { | |
return Color(initial + (rowJump * shift)) | |
} | |
func (c Color) String() string { | |
return formatSequence + strconv.Itoa(int(c)) + "m" | |
} | |
func (c Color) Text(text string) string { | |
return c.String() + text + resetSequence | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment