aboutsummaryrefslogtreecommitdiff
path: root/lib/renderers/ansi.js
blob: c3975da9e7ef4ae0eba0470e7be6cd3c63b0203e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
'use strict';

// Returns a basic ANSI color. See the color table in:
// https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
const ANSI = function (red, blue, green) {
  let colorOffset = Math.round((red + blue + green) * 7 / (255 * 3));

  let colorNumber = 40 + colorOffset;

  return `\x1B[${colorNumber}m`;
};

module.exports = ANSI;