From c7b4bd19a006d61c3b4979e884370d123cec7524 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Mon, 9 May 2016 00:30:22 -0500 Subject: Ports the basic script to split modules --- lib/renderers/ansi.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 lib/renderers/ansi.js (limited to 'lib/renderers/ansi.js') diff --git a/lib/renderers/ansi.js b/lib/renderers/ansi.js new file mode 100644 index 0000000..c3975da --- /dev/null +++ b/lib/renderers/ansi.js @@ -0,0 +1,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; -- cgit