]>
Commit | Line | Data |
---|---|---|
c7b4bd19 BB |
1 | 'use strict'; |
2 | ||
fd38d409 RBR |
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 | */ | |
10 | module.exports = function (red, blue, green) { | |
c7b4bd19 | 11 | |
fd38d409 RBR |
12 | const colorOffset = Math.round((red + blue + green) * 7 / (255 * 3)); |
13 | const colorNumber = 40 + colorOffset; | |
c7b4bd19 BB |
14 | |
15 | return `\x1B[${colorNumber}m`; | |
16 | }; |