Sample color pallete output
Created
May 26, 2022 09:34
-
-
Save ShivamJoker/ef0d21e9905edf17452122c0648e588a to your computer and use it in GitHub Desktop.
Simple function which rendereds RGB color in your terminal console
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
type RgbColor = { | |
r: number; | |
g: number; | |
b: number; | |
}; | |
// Borrowed from https://stackoverflow.com/a/50984135/5748481 | |
const toRgb = (_text: string, rgb: RgbColor)=> { | |
const { r, g, b } = rgb; | |
return "\x1b[38;2;" + r + ";" + g + ";" + b + "m" + _text + "\x1b[0m"; | |
}; | |
// usage | |
toRgb("hello", {r: 123, g: 223, b: 100}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment