summaryrefslogtreecommitdiff
path: root/lib/renderers/true_color.js
diff options
context:
space:
mode:
authorBen Beltran <ben@nsovocal.com>2016-05-09 00:31:52 -0500
committerBen Beltran <ben@nsovocal.com>2016-05-09 00:31:52 -0500
commita41763dd463339765081c1f968a7b93b8ccf572f (patch)
tree131f33520cc40abc387474fa9c2ac4f536e6d7d1 /lib/renderers/true_color.js
parent95da493e0ec223e1c7706fc0bdc364bd3a21d999 (diff)
parenta140f3add912ef4bd659c1c1e82184643be7d845 (diff)
Merge branch 'release/1.0.0'
Diffstat (limited to 'lib/renderers/true_color.js')
-rw-r--r--lib/renderers/true_color.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/renderers/true_color.js b/lib/renderers/true_color.js
new file mode 100644
index 0000000..5f7725f
--- /dev/null
+++ b/lib/renderers/true_color.js
@@ -0,0 +1,11 @@
+'use strict';
+
+// Returns an ANSI Code for True Color, see:
+// https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
+// and look for 24-bit colors. Only looks good in supported terminals,
+// otherwise looks like FakeColor.
+const TrueColor = function (red, blue, green) {
+ return `\x1B[48;2;${Math.round(red)};${Math.round(green)};${Math.round(blue)}m`;
+};
+
+module.exports = TrueColor;