diff options
Diffstat (limited to 'lib/renderers/ansi.js')
| -rw-r--r-- | lib/renderers/ansi.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/renderers/ansi.js b/lib/renderers/ansi.js new file mode 100644 index 0000000..c3975da --- /dev/null +++ b/lib/renderers/ansi.js @@ -0,0 +1,13 @@ +'use strict'; + +// Returns a basic ANSI color. See the color table in: +// https://en.wikipedia.org/wiki/ANSI_escape_code#Colors +const ANSI = function (red, blue, green) { + let colorOffset = Math.round((red + blue + green) * 7 / (255 * 3)); + + let colorNumber = 40 + colorOffset; + + return `\x1B[${colorNumber}m`; +}; + +module.exports = ANSI; |