summaryrefslogtreecommitdiff
path: root/lib/renderers/ansi.js
diff options
context:
space:
mode:
authorBen Beltran <ben@nsovocal.com>2016-05-09 00:30:22 -0500
committerBen Beltran <ben@nsovocal.com>2016-05-09 00:30:22 -0500
commitc7b4bd19a006d61c3b4979e884370d123cec7524 (patch)
tree6be738bd4641e2fd2ab8a754dc529e773c220d64 /lib/renderers/ansi.js
parentae6dbe43bf54581dd7012f95581d4a1b6ee245f0 (diff)
Ports the basic script to split modules
Diffstat (limited to 'lib/renderers/ansi.js')
-rw-r--r--lib/renderers/ansi.js13
1 files changed, 13 insertions, 0 deletions
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;