diff --git a/ReadMe.md b/ReadMe.md index 4d965e3..74acead 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -27,4 +27,4 @@ ### Authors -#### Alexis Sellier (cloudhead) , Marak Squires , Justin Campbell +#### Alexis Sellier (cloudhead) , Marak Squires , Justin Campbell, Dustin Diaz (@ded) diff --git a/colors.js b/colors.js index 977a636..cfe3a35 100644 --- a/colors.js +++ b/colors.js @@ -79,4 +79,113 @@ function stylize(str, style) { }; return '\033[' + styles[style][0] + 'm' + str + '\033[' + styles[style][1] + 'm'; -}; \ No newline at end of file +}; + +// don't summon zalgo +String.prototype.__defineGetter__('zalgo', function () { + return zalgo(this); +}); + +// please no +function zalgo(text, options) { + var soul = { + "up" : [ + '̍','̎','̄','̅', + '̿','̑','̆','̐', + '͒','͗','͑','̇', + '̈','̊','͂','̓', + '̈','͊','͋','͌', + '̃','̂','̌','͐', + '̀','́','̋','̏', + '̒','̓','̔','̽', + '̉','ͣ','ͤ','ͥ', + 'ͦ','ͧ','ͨ','ͩ', + 'ͪ','ͫ','ͬ','ͭ', + 'ͮ','ͯ','̾','͛', + '͆','̚' + ], + "down" : [ + '̖','̗','̘','̙', + '̜','̝','̞','̟', + '̠','̤','̥','̦', + '̩','̪','̫','̬', + '̭','̮','̯','̰', + '̱','̲','̳','̹', + '̺','̻','̼','ͅ', + '͇','͈','͉','͍', + '͎','͓','͔','͕', + '͖','͙','͚','̣' + ], + "mid" : [ + '̕','̛','̀','́', + '͘','̡','̢','̧', + '̨','̴','̵','̶', + '͜','͝','͞', + '͟','͠','͢','̸', + '̷','͡',' ҉' + ] + }, + all = [].concat(soul.up, soul.down, soul.mid), + zalgo = {}; + + function randomNumber(range) { + r = Math.floor(Math.random()*range); + return r; + }; + + function is_char(character) { + var bool = false; + all.filter(function(i){ + bool = (i == character); + }); + return bool; + } + + function heComes(text, options){ + result = ''; + options = options || {}; + options["up"] = options["up"] || true; + options["mid"] = options["mid"] || true; + options["down"] = options["down"] || true; + options["size"] = options["size"] || "maxi"; + var counts; + text = text.split(''); + for(var l in text){ + if(is_char(l)) { continue; } + result = result + text[l]; + + counts = {"up" : 0, "down" : 0, "mid" : 0}; + + switch(options.size) { + case 'mini': + counts.up = randomNumber(8); + counts.min= randomNumber(2); + counts.down = randomNumber(8); + break; + case 'maxi': + counts.up = randomNumber(16) + 3; + counts.min = randomNumber(4) + 1; + counts.down = randomNumber(64) + 3; + break; + default: + counts.up = randomNumber(8) + 1; + counts.mid = randomNumber(6) / 2; + counts.down= randomNumber(8) + 1; + break; + } + + var arr = ["up", "mid", "down"]; + for(var d in arr){ + var index = arr[d]; + for (var i = 0 ; i <= counts[index]; i++) + { + if(options[index]) { + result = result + soul[index][randomNumber(soul[index].length)]; + } + } + } + } + return result; + }; + return heComes(text); +} diff --git a/example.js b/example.js index 5c08c9c..13b9fae 100644 --- a/example.js +++ b/example.js @@ -3,4 +3,5 @@ var colors = require('./colors'); sys.puts('Rainbows are fun!'.rainbow); sys.puts('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse); // styles not widely supported -sys.puts('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported \ No newline at end of file +sys.puts('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported +// sys.puts('zalgo time!'.zalgo); \ No newline at end of file diff --git a/package.json b/package.json index 60a8841..bda1876 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "colors", "description": "get colors in your node.js console like what", - "version": "0.4.1", + "version": "0.5.0", "author": "Marak Squires", "repository": { "type": "git", @@ -10,5 +10,5 @@ "engine": [ "node >=0.1.90" ], - "main": "colors.js" + "main": "colors" }