]> git.r.bdr.sh - rbdr/tomato-sauce/blame_incremental - lib/renderers/ansi.js
Update code and dpendencies
[rbdr/tomato-sauce] / lib / renderers / ansi.js
... / ...
CommitLineData
1'use strict';
2
3/**
4 * Returns a basic ansi color, see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
5 * for more info.
6 *
7 * @function ANSIRenderer
8 * @implements IRenderer
9 */
10module.exports = function (red, blue, green) {
11
12 const colorOffset = Math.round((red + blue + green) * 7 / (255 * 3));
13 const colorNumber = 40 + colorOffset;
14
15 return `\x1B[${colorNumber}m`;
16};