example.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. var colors = require('./../colour');
  2. //colors.mode = "browser";
  3. var test = colors.red("hopefully colorless output");
  4. console.log('Rainbows are fun!'.rainbow);
  5. console.log('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse); // styles not widely supported
  6. console.log('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported
  7. //console.log('zalgo time!'.zalgo);
  8. console.log(test.stripColors);
  9. console.log("a".grey + " b".black);
  10. console.log("Zebras are so fun!".zebra);
  11. //
  12. // Remark: .strikethrough may not work with Mac OS Terminal App
  13. //
  14. console.log("This is " + "not".strikethrough + " fun.");
  15. console.log(colors.rainbow('Rainbows are fun!'));
  16. console.log(colors.italic('So ') + colors.underline('are') + colors.bold(' styles! ') + colors.inverse('inverse')); // styles not widely supported
  17. console.log(colors.bold(colors.italic(colors.underline(colors.red('Chains are also cool.'))))); // styles not widely supported
  18. //console.log(colors.zalgo('zalgo time!'));
  19. console.log(colors.stripColors(test));
  20. // console.log(colors.grey("a") + colors.black(" b"));
  21. colors.addSequencer("america", function(letter, i, exploded) {
  22. if(letter === " ") return letter;
  23. switch(i%3) {
  24. case 0: return letter.red;
  25. case 1: return letter.white;
  26. case 2: return letter.blue;
  27. }
  28. });
  29. colors.addSequencer("random", (function() {
  30. var available = ['bold', 'underline', 'italic', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'];
  31. return function(letter, i, exploded) {
  32. return letter === " " ? letter : letter[available[Math.round(Math.random() * (available.length - 1))]];
  33. };
  34. })());
  35. console.log("AMERICA! F--K YEAH!".america);
  36. console.log("So apparently I've been to Mars, with all the little green men. But you know, I don't recall.".random);
  37. //
  38. // Custom themes
  39. //
  40. // Load theme with JSON literal
  41. colors.setTheme({
  42. silly: 'rainbow',
  43. input: 'grey',
  44. verbose: 'cyan',
  45. prompt: 'grey',
  46. info: 'green',
  47. data: 'grey',
  48. help: 'cyan',
  49. warn: 'yellow',
  50. debug: 'blue',
  51. error: 'red'
  52. });
  53. // outputs red text
  54. console.log("this is an error".error);
  55. // outputs yellow text
  56. console.log("this is a warning".warn);
  57. // outputs grey text
  58. console.log("this is an input".input);