This repository has been archived on 2023-11-14. You can view files and clone it, but cannot push or open issues/pull-requests.
valnet/lib/title.js

91 lines
3.5 KiB
JavaScript
Raw Normal View History

2020-11-11 19:38:39 -05:00
const formPhrase = require("font-ascii").default;
const { strlen, ansiEscapeCodes} = require ('printable-characters');
const chalk = require('chalk').default;
const gradient = require('gradient-string');
2020-11-11 22:06:45 -05:00
module.exports.title = function(component, cls = true) {
if(cls) {
process.stdout.cursorTo(0, 0);
process.stdout.clearScreenDown();
}
2020-11-11 22:07:31 -05:00
const bigDisplay = process.stdout.getWindowSize()[1] > 45
if(bigDisplay) console.log();
2020-11-11 19:38:39 -05:00
// centerString(`
// /\\ .-. .-. .-.-.;;;;;;'
// .;. .-._ / | ;' (_) ; : .;;;.\`-' (_) .;
// \`; .' ( / | . .:' .;: : ;; (_) :
// ;; .' \`/.__|_.' .:' .;' \\ : .;;; .-. .:'
// ;; ; .:' / | .-:. .-..:'.; \\: ;; .; ; .-:._
// \`;.' (__.' \`-'(_/ \`;._. (__.' \`.\`;.___.' (_/ \`-
// `);
centerString(`
/\\ .-. .-. .-.--------'
.-. .-._ / | / (_) / | .---;\`-' (_) /
) / ( / | . / /\\ | ( (_) /
/ / \`/.__|_.' / / \\ | )-- /
( .' .:' / | .-/. .-..-' / \\| ( / .-/._
\\/ (__.' \`-'(_/ \`-._. (__.' \`.\`\\___.' (_/ \`- `);
if(bigDisplay) centerString(`
______________________
/\\ __________________ \\
/XX\\ \\________________/\\ \\
/X/\\X\\ \\ /X/\\X\\ \\
/X/ /\\X\\ \\ /X/ /\\X\\ \\
/X/ / \\X\\ \\________/_/_/__\\_\\ \\____________________
/X/ / \\X\\____________________ __________________ \\
/X/ / /X/ __________________/\\ \\________________/\\ \\
/X/ /_____/X/ /_____/X/ /_____/X/\\X\\ \\____ /X/\\X\\ \\
/X/_/_____/X/ /______\\/_/_____/X/ /\\X\\ \\__ \\ /X/ /\\X\\ \\
\\X\\ \\____/X/ /_______/\\ \\____/X/ /__\\X\\ \\/\\ \\____/_/_/__\\_\\ \\
\\X\\ \\ /X/ / /X/\\X\\ \\ /X/ / \\X\\_____________________\\
\\X\\ \\/X/ / /X/ /\\X\\_\\/X/ / /X/ __________________ /
\\X\\/X/ /_____/_/_/__\\_\\/X/_/_____/X/ /__\\_\\/X/_/ /X/ /
\\XX/_/________________\\/_/_____/X/ /______\\/_/ /X/ /
/XX\\ \\________________/\\ \\____/X/ /______ /\\ \\ /X/ /
/X/\\X\\ \\ /X/ /_____/X/\\X\\ \\__/X/ / /X/\\X\\ \\ /X/ /
/X/ /\\X\\ \\/X/_/_____/X/ /\\X\\ \\/X/ / /X/ /\\X\\ \\/X/ /
/X/ / \\X\\ \\_\\_\\____/_/_/__\\_\\/X/ /\\____/_/_/__\\_\\/X/ /
/X/ / \\X\\___________________\\/ /________________\\/ /
/X/ / /X/ __________________ ____________________/
/X/ /_____/X/ /__\\_\\/X/ /_____/X/ /__\\_\\/X/ /
/X/_/_____/X/ /______\\/_/_____/X/ /______\\/ /
\\X\\ \\____/X/ /_______/\\ \\____/X/ /_________/
\\X\\ \\ /X/ / \\X\\ \\ /X/ /
\\X\\ \\/X/ / \\X\\ \\/X/ /
\\X\\/X/ /____________\\_\\/X/ /
\\XX/ /________________\\/ /
\\/_____________________/`);
console.log();
if(bigDisplay) console.log();
centerString((formPhrase(component, {
typeface: 'Small',
color: 'yellow',
silent: true
})))
}
function centerString(string, options = {}) {
const windowWidth = process.stdout.getWindowSize()[0];
const text = string.replace(ansiEscapeCodes, '').split('\n');
const textWidth = Math.max.apply(this, text.map(v => strlen(v)));
const padding = ' '.repeat(Math.floor((windowWidth - textWidth) / 2));
for(const line of
gradient.pastel.multiline(text.join('\n')).split('\n')
) {
console.log(padding + line);
}
}