]>
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 | |
a0666be3 RBR |
12 | const colorOffset = Math.round((red + blue + green) * 7 / (255 * 3)); |
13 | const colorNumber = 40 + colorOffset; | |
c7b4bd19 | 14 | |
a0666be3 | 15 | return `\x1B[${colorNumber}m`; |
c7b4bd19 | 16 | }; |