Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

extracted from cup

  • Loading branch information...
commit e8d9283a4dbc85f918ac2443a7db1c94dd3faa9d 1 parent 01229ff
@sjltaylor authored
View
0  README
No changes.
View
45 README.markdown
@@ -0,0 +1,45 @@
+# Technicolor
+
+Use node to remind you of Teletext.
+
+## Install
+
+ npm install technicolor
+
+## Use
+
+ var technicolor = require('technicolor');
+
+ var message = "Hello, Darling."
+ var prettyMessage = technicolor(message, {
+ color : 'red',
+ backgroundColor : 'white',
+ bold : true,
+ underline : true
+ });
+
+ console.info(prettyMessage);
+
+## Possibilities
+
+ var technicolor = require('technicolor');
+ technicolor.showAll();
+
+## Supported Colours
+
+* black
+* red
+* green
+* yellow
+* blue
+* purple
+* cyan
+* darkGrey
+* lightGrey
+* brightRed
+* brightGreen
+* brightYellow
+* brightBlue
+* brightPurple
+* brightCyan
+* white
View
14 package.json
@@ -0,0 +1,14 @@
+{
+ "author": "Sam Taylor <sjltaylor@gmail.com>",
+ "name": "technicolor",
+ "description": "Use node and remind yourself of Teletext.",
+ "version": "0.1.0",
+ "homepage": "http://github.com/sjltaylor/technicolor",
+ "repository": {
+ "url": "git@github.com:sjltaylor/technicolor.git"
+ },
+ "main" : "./technicolor.js",
+ "engines": {
+ "node": "~0.6.0"
+ }
+}
View
99 technicolor.js
@@ -0,0 +1,99 @@
+module.exports = (function () {
+
+ var colors = {
+ black : '30m',
+ red : '31m',
+ green : '32m',
+ yellow : '33m',
+ blue : '34m',
+ purple : '35m',
+ cyan : '36m',
+ darkGrey : '37m',
+ lightGrey : '90m',
+ brightRed : '91m',
+ brightGreen : '92m',
+ brightYellow : '93m',
+ brightBlue : '94m',
+ brightPurple : '95m',
+ brightCyan : '96m',
+ white : '97m'
+ }
+
+ var backgroundColors = {
+ black : '40m',
+ red : '41m',
+ green : '42m',
+ yellow : '43m',
+ blue : '44m',
+ purple : '45m',
+ cyan : '46m',
+ lightGrey : '47m',
+ darkGrey : '100m',
+ brightRed : '101m',
+ brightGreen : '102m',
+ brightYellow : '103m',
+ brightBlue : '104m',
+ brightPurple : '105m',
+ brightCyan : '106m',
+ white : '107m'
+ };
+
+ function technicolor (string, options) {
+
+ var shColor = "\033[COLOUR",
+ shBackground = "\033[BACKGROUND",
+ end = "\033[0m"
+
+ var buffer = "";
+
+ if (options.bold) buffer += "\033[1m";
+ if (options.underline) buffer += "\033[4m";
+
+ var color = colors[options.color];
+ if (color) buffer += shColor.replace('COLOUR', color);
+
+ var background = backgroundColors[options.backgroundColor];
+ if (background) buffer += shBackground.replace('BACKGROUND', background);
+
+ return buffer + string + end;
+ }
+
+ technicolor.colors = colors;
+ technicolor.backgroundColors = backgroundColors;
+
+ technicolor.showAll = function () {
+ for (var color in colors) {
+
+ var combination = "#color text on the current background"
+ .replace('#color', color);
+
+ console.info(technicolor(combination, {
+ color: color
+ }));
+
+ combination = "#color text bold and underlined"
+ .replace('#color', color)
+ .replace('#backgroundColor', backgroundColor);
+
+ console.info(technicolor(combination, {
+ color: color,
+ bold: true,
+ underline: true
+ }));
+
+ for (var backgroundColor in backgroundColors) {
+
+ combination = "#color text on a #backgroundColor background"
+ .replace('#color', color)
+ .replace('#backgroundColor', backgroundColor);
+
+ console.info(technicolor(combination, {
+ color: color,
+ backgroundColor: backgroundColor
+ }));
+ }
+ }
+ }
+
+ return technicolor;
+})();
Please sign in to comment.
Something went wrong with that request. Please try again.