]> git.r.bdr.sh - rbdr/tomato-sauce/blob - lib/renderers/ansi.js
Adds the binary wrapper
[rbdr/tomato-sauce] / lib / renderers / ansi.js
1 'use strict';
2
3 // Returns a basic ANSI color. See the color table in:
4 // https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
5 const ANSI = function (red, blue, green) {
6 let colorOffset = Math.round((red + blue + green) * 7 / (255 * 3));
7
8 let colorNumber = 40 + colorOffset;
9
10 return `\x1B[${colorNumber}m`;
11 };
12
13 module.exports = ANSI;