A Pen by Jakub T. Jankiewicz on CodePen.
Created
August 26, 2022 13:32
-
-
Save zux0x3a/ebf43da761ce1fcc18cc35fe924daf22 to your computer and use it in GitHub Desktop.
Terminal Figlet Demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // check the list of fonts at https://unpkg.com/browse/[email protected]/fonts/ | |
| // the list can also be seen on demo of Figlet library: | |
| // http://patorjk.com/software/taag/#p=display&f=Standard&t=jQuery%20Terminal | |
| figlet.defaults({ fontPath: 'https://unpkg.com/figlet/fonts/' }); | |
| figlet.preloadFonts(['Standard', 'Slant'], ready); | |
| var term; | |
| function ready() { | |
| term = $('body').terminal(function(cmd) { | |
| // echo function will run it in each render, | |
| // so text can be resized based on cols | |
| this.echo(() => render(this, cmd)); | |
| }, { | |
| greetings: false, | |
| onInit() { | |
| this.echo(() => render(this, 'Figlet Demo', 'Slant') + | |
| `\n[[;rgba(255,255,255,0.99);]jQuery Terminal ${$.terminal.version}]. Type something to render figlet text.\n`) | |
| } | |
| }); | |
| } | |
| function render(term, text, font) { | |
| const cols = term.cols(); | |
| return figlet.textSync(text, { | |
| font: font || 'Standard', | |
| width: cols, | |
| whitespaceBreak: true | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> | |
| <script src="https://cdn.jsdelivr.net/gh/jcubic/static/js/wcwidth.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/jquery.terminal/js/jquery.terminal.min.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/js-polyfills/keyboard.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/jquery.terminal/js/unix_formatting.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/[email protected]/prism.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/jquery.terminal/js/less.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/jquery.terminal/js/prism.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/figlet/lib/figlet.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :root { | |
| --size: 1.6; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <link href="https://unpkg.com/prismjs/themes/prism-coy.css" rel="stylesheet" /> | |
| <link href="https://unpkg.com/jquery.terminal/css/jquery.terminal.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment