]> git.r.bdr.sh - rbdr/tomato-sauce/blame - lib/renderers/ansi.js
Ports the basic script to split modules
[rbdr/tomato-sauce] / lib / renderers / ansi.js
CommitLineData
c7b4bd19
BB
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
5const 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
13module.exports = ANSI;