UNPKG

2.65 kBJavaScriptView Raw
1"use strict";
2
3var clc = require("./");
4
5var colors = ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"];
6
7// Write some message.
8var w = function (message) { process.stdout.write(message); };
9
10// Print colors.
11var printColors = function (title, style) {
12 var j = colors.length, color, colorText, tint, i;
13
14 w(" > " + clc.whiteBright(title) + " ");
15 for (i = 0; i < j; i++) {
16 tint = clc;
17 color = colors[i];
18 colorText = color.toUpperCase();
19
20 if (style === "foreground") {
21 tint = tint[color];
22
23 if (color === "black") {
24 tint = tint.bgBlackBright;
25 }
26 }
27
28 if (style === "foregroundBright") {
29 tint = tint[color + "Bright"];
30 }
31
32 if (style === "background") {
33 tint = tint["bg" + color.slice(0, 1).toUpperCase() + color.slice(1)];
34
35 if (color === "white") {
36 tint = tint.whiteBright;
37 }
38 }
39
40 if (style === "backgroundBright") {
41 tint = tint["bg" + color.slice(0, 1).toUpperCase() + color.slice(1) + "Bright"];
42 }
43
44 w(tint(colorText) + " ");
45 }
46 w("\n");
47};
48
49// Smile test.
50w(clc.reset);
51
52w("\n SMILE TEST\n\n");
53
54// Yellow face.
55w(clc(" "));
56w(clc.bgYellowBright(" "));
57w(clc("\n"));
58w(clc(" "));
59w(clc.bgYellowBright(" "));
60w(clc("\n"));
61w(clc(" "));
62w(clc.bgYellowBright(" "));
63w(clc("\n"));
64w(clc(" "));
65w(clc.bgYellowBright(" "));
66w(clc("\n"));
67w(clc(" "));
68w(clc.bgYellowBright(" "));
69w(clc("\n"));
70w(clc(" "));
71w(clc.bgYellowBright(" "));
72w(clc("\n"));
73
74// Move blue eyes.
75w(clc.move(7, -5));
76w(clc.blueBright.bgYellowBright("O"));
77w(clc.move(1, 0));
78w(clc.blueBright.bgYellowBright("O"));
79
80// Red nose.
81w(clc.move.to(8, 5));
82w(clc.redBright.bgYellowBright("\u25A0"));
83
84// Red mouth.
85w(clc.move.down(2));
86w(clc.move.left(2));
87w(clc.red.bgYellowBright("\u2588\u2584\u2588"));
88
89// Move back.
90w(clc.move.to(0, 9));
91
92// Colors test.
93w("\n COLORS TESTS\n");
94printColors("FOREGROUNDS (DEFAULT)", "foreground");
95printColors("FOREGROUNDS (BRIGHT) ", "foregroundBright");
96printColors("BACKGROUNDS (DEFAULT)", "background");
97printColors("BACKGROUNDS (BRIGHT) ", "backgroundBright");
98
99// // Art test.
100w("\n ART TESTS\n\n");
101w(
102 clc.art("\t.01111111112.\n\t.3.........3.\n\t.3.........3.\n\t.41111111115.\n", {
103 "0": clc.bgBlue.yellowBright("\u2554"),
104 "1": clc.bgBlue.yellowBright("\u2550"),
105 "2": clc.bgBlue.yellowBright("\u2557"),
106 "3": clc.bgBlue.yellowBright("\u2551"),
107 "4": clc.bgBlue.yellowBright("\u255A"),
108 "5": clc.bgBlue.yellowBright("\u255D"),
109 ".": clc.bgBlue(" ")
110 })
111);
112w(clc.move(11, -3));
113w(clc.bgBlue.whiteBright("Hello"));
114w(clc.move(-3, 1));
115w(clc.bgBlue.whiteBright("World"));
116w(clc.move(0, 2));
117w("\n");