matrix-rain
Advanced tools
Comparing version 1.1.0 to 2.0.0
{ | ||
"name": "matrix-rain", | ||
"version": "1.1.0", | ||
"description": "Matrix Rain effect in cli. Characters from a file can also be used.", | ||
"main": "matrixRain", | ||
"version": "2.0.0", | ||
"description": "The famous Matrix rain effect of falling green characters as a cli command", | ||
"main": "index.js", | ||
"preferGlobal": true, | ||
"bin": { | ||
"matrix-rain": "matrixRain" | ||
"matrix-rain": "index.js" | ||
}, | ||
@@ -27,3 +27,9 @@ "repository": { | ||
}, | ||
"homepage": "https://github.com/nojvek/matrix-rain" | ||
"homepage": "https://github.com/nojvek/matrix-rain", | ||
"dependencies": { | ||
"argparse": "1.0.10" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^5.9.0" | ||
} | ||
} |
@@ -1,3 +0,5 @@ | ||
# Matrix Rain in terminal with node | ||
# Matrix Rain | ||
The famous Matrix rain effect of falling green characters in a terminal with node. | ||
## Installation | ||
@@ -12,7 +14,20 @@ | ||
``` | ||
matrix-rain --help | ||
Usage: matrix-rain opts? filePath? | ||
opts: --direction=v|h = change direction. If reading from file direction is h (horizontal) | ||
filePath: Read characters from file and set direction=h | ||
By default generate random ascii chars in v (vertical) direction | ||
usage: matrix-rain [-h] [-v] [-d {h,v}] | ||
[-c {green,red,blue,yellow,magenta,cyan,white}] | ||
[-k {ascii,binary,braille,emoji,kanji}] [-f FILEPATH] | ||
The famous Matrix rain effect of falling green characters as a cli command | ||
Optional arguments: | ||
-h, --help Show this help message and exit. | ||
-d, --direction {h,v} | ||
Change direction of rain. h=horizontal, v=vertical | ||
-c , --color {green,red,blue,yellow,magenta,cyan,white} | ||
Rain color. NOTE: droplet start is always white | ||
-k, --char-range {ascii,binary,braille,emoji,kanji} | ||
Use rain characters from char-range | ||
-f, --file-path FILEPATH | ||
Read characters from a file instead of random | ||
characters from char-range | ||
``` | ||
@@ -26,22 +41,7 @@ ## Screenshots | ||
## Story Time | ||
On christmas eve I watched the The Matrix (1999) and was inspired by the matrix effect. I was curious to see if I could replicate this effect without using other node modules. | ||
On 2016 christmas eve, I watched the The Matrix (1999) and was inspired by the matrix rain effect. I was curious to see if I could replicate this effect in nodejs. | ||
There's [blessed](https://github.com/chjj/blessed) and [node-ncurses](https://github.com/mscdex/node-ncurses) which would have helped but rather than using the library I wanted to learn how console cursor manipulation works behind the scenes. I browsed through the source code of [colors.js](https://github.com/marak/colors.js/) and got a few pointers. Thank you github. | ||
There's [blessed](https://github.com/chjj/blessed) and [node-ncurses](https://github.com/mscdex/node-ncurses) which would have helped but rather than using the library I wanted to learn how console cursor manipulation works behind the scenes. I browsed through the source code of [colors.js](https://github.com/marak/colors.js/) and got a few pointers. On that day I discovered terminal escape codes [VT100 ANSI codes table](http://ascii-table.com/ansi-escape-sequences-vt-100.php) | ||
I've been programming for 6 years full time but on that day I discovered terminal escape codes. I googled around and found [VT100 ANSI codes table](http://ascii-table.com/ansi-escape-sequences-vt-100.php) | ||
Node's process.stdout has a columns and rows property. It also fires resize events like the browser. With escape codes I can treat the terminal as a canvas and paint on it. I discovered a new medium to show my art. | ||
I disovered process.stdout has a columns and rows property. It also fires a resize even when console is resized. With escape codes I can clear the screen, move the cursor to any position in the screen, change colors and do really cool things which previously I thought was vodoo magic. There's even support for 8 bit colors in console. Whoah! All I have to do is write the appropriate escape code sequence in stdout and that is it. | ||
![oh my god!](http://suptg.thisisnotatrueending.com/archive/25731506/images/1372606872145.gif) | ||
I learned a couple of things | ||
* Its faster if I flush commands to stdout when I have finished rendering a frame rather than doing it immediately | ||
* Writing utf-8 is slower than ascii. I tried random kanji characters but it was about twice as slow. Not sure why. | ||
* Rather than clearing entire screen and drawing the everything again, its much faster to only modify parts of screen that have changed. | ||
Initial algorithm somewhat worked. I wondered what else I could do. I used a trick to change swap numRows and numCols and I could render the matrix horizontally. Rather than generate random ascii characters, what if I could read characters from a file. | ||
This had an interesting side effect that it was a great visualization of the source code. It looked like the computer was programming itself in parallel. I changed the code so it uses jquery.js and voila! I was reading snippets of jquery source code. While I took my dog for a run, I left it running. My wife (non-technical) sent me a message "Hey your computer is in the matrix, its really cool!". Younger noj would be very impressed of older noj. | ||
The source code matrixRain.coffee is < 200 lines of code. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
43348
7
255
1
1
3
+ Addedargparse@1.0.10
+ Addedargparse@1.0.10(transitive)
+ Addedsprintf-js@1.0.3(transitive)