Skip to content

Commit

Permalink
Add new tools
Browse files Browse the repository at this point in the history
  • Loading branch information
RedYetiDev committed Mar 17, 2021
1 parent 2bd90a9 commit 3935a3c
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "terminaltools",
"version": "1.8.5",
"version": "1.9.0",
"description": "terminaltools allows you to do tricks in the terminal like play videos, show images and more.",
"main": "tools.js",
"scripts": {
Expand Down Expand Up @@ -44,7 +44,9 @@
"client",
"ascii star wars",
"towel.blinkenlights.nl",
"A lot of keywords"
"A lot of keywords",
"Snow",
"Matrix"
],
"author": "RedYetiDev <[email protected]> (https://RedYetiDev.github.io)",
"license": "MIT",
Expand Down
4 changes: 4 additions & 0 deletions tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ const loader = require("./tools/loader")
const server = require("./tools/server")
const minify = require("./tools/minify")
const mute = require("./tools/mute")
const snow = require("./tools/snow")
const matrix = require("./tools/matrix")
module.exports.image = image
module.exports.loader = loader
module.exports.video = video
module.exports.server = server
module.exports.minify = minify
module.exports.muter = mute
module.exports.snow = snow
module.exports.matrix = matrix
56 changes: 56 additions & 0 deletions tools/matrix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const delay = (ms) => {
return new Promise(resolve => {
setTimeout(resolve, ms)
}
)
}
var domatrix;
async function start() {
domatrix = true
var lines = process.stdout.rows
var columns = process.stdout.columns
console.log("\033[1;40m")
process.stdout.write("\033[2J")
var cols = [];
while (domatrix == true) {
var line = 0
await delay(100)
var random_col = Math.floor(Math.random() * columns)
var letter= Math.floor(Math.random() * 2)
cols[random_col] = 0;
for (col in cols) {
var rnum = Math.floor(Math.random() * 20);
if (cols[col] < 0) {
line =- cols[col];
cols[col] = cols[col] - 1;
var subline = -cols[col] + 1
process.stdout.write("\033[" + line + ";" + col + "H ")
process.stdout.write("\033[\n;" + col + "H \033[0;0H")
if (subline >= lines) {
cols[col] = 0;
} else if (rnum < 1) {
cols[col] = 0
}
} else {
line = cols[col];
cols[col] = cols[col]+1;
if (rnum < 3) {
process.stdout.write("\033[" + line + ";" + col + "H\033[1;32m" + letter + "\033[0m")
} else {
process.stdout.write("\033[" + line + ";" + col + "H\033[2;32m" + letter + "\033[0m")
}
process.stdout.write("\033[" + cols[col] + ";" + col + "H\033[37m" + letter + "\033[0;0H\033[0m")
if (cols[col] >= lines) {
if (rnum < 2) {
cols[col] = 0
} else {
cols[col] = -1;
}
}
}
}
}
}

module.exports.start = start
module.exports.stop = () => {domatrix = false}
20 changes: 20 additions & 0 deletions tools/snow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var C = process.stdout.columns
var a = [];
const delay = (ms) => {return new Promise(resolve => setTimeout(resolve, ms))}
var snow;
async function start() {
snow = true
process.stdout.write("\033[2J")
while (snow == true) {
a[Math.floor(Math.random() * C)] = 0;
a.forEach(function(o, x) {
if (o != undefined) {
a[x]++;
process.stdout.write("\033[" + o + ";" + x + "H \033[" + a[x] + ";" + x + "H❃ \033[0;0H")
}
});
await delay(100)
}
}
module.exports.start = start
module.exports.stop = () => {snow = false}

0 comments on commit 3935a3c

Please sign in to comment.