]> git.r.bdr.sh - rbdr/tomato-sauce/blame_incremental - lib/renderers/256_colors.js
Adds the binary wrapper
[rbdr/tomato-sauce] / lib / renderers / 256_colors.js
... / ...
CommitLineData
1'use strict';
2
3// Returns a 256 color, see
4// https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
5// under 256 colors for more info.
6const TwoFiftySixColors = function (red, blue, green) {
7 let redValue = Math.round(red * 5 / 255);
8 let blueValue = Math.round(blue * 5 / 255);
9 let greenValue = Math.round(green * 5 / 255);
10
11 let colorNumber = 16 + 36 * redValue + 6 * greenValue + blueValue;
12
13 return `\x1B[48;5;${colorNumber}m`;
14};
15
16module.exports = TwoFiftySixColors;