Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
ascii-art
Advanced tools
Readme
_ _ _
(_)(_) | |
__ _ ___ ___ _ _ ______ __ _ _ __ | |_
/ _` |/ __| / __|| || ||______| / _` || '__|| __|
| (_| |\__ \| (__ | || | | (_| || | | |_
\__,_||___/ \___||_||_| \__,_||_| \__|
###ascii-art.js
Images, fonts and terminal styles in Node.js & the browser. 100% JS.
In the beginning there was colors.js but in the fine tradition of vendors calling out a problem they have the solution to, chalk was introduced. In that same vein, I offer ascii-art
as an update, expansion and generalization of MooAsciiArt and at the same time it can replace your existing ansi colors library.
It features support for Images, Styles, Tables and Figlet Fonts as well as handling multi-line joining automatically.
String.prototype
usage. No __proto__
usage. No BS.npm install ascii-art
If you want to use .image()
or .Image
you must install canvas and if you want to run the chalk tests... you'll need to to install require-uncached
as well.
If you want the gloabally available ascii-art
you'll need to install with the global
flag
npm install -g ascii-art
Otherwise, the binary is available from your project root at ./node_modules/ascii-art/bin/ascii-art
Look at a list of fonts from the maintainers of Figlet:
ascii-art list all
Preview your font in a browser:
ascii-art preview doom
Now, install a figlet font (globally)
ascii-art install doom -g
Render some text
ascii-art text -s green -F doom "some text"
or render an image (use npm run sample
to generate and view a gallery)
ascii-art image -f path/to/my/file.jpg
The font method also allows you to optionally pass styles and supports chaining, so if I want two strings rendered together:
art.font('Prompt', 'Basic', 'red')
.font('v1', 'Doom', 'magenta', function(rendered){
console.log(rendered);
});
There is also an image()
call in the chain, that requires canvas
in Node.js and shims in the browser's Canvas
object (but only when image is used, so that dependency is optional):
art.image({
width : 40,
filepath : parentDir+'/Images/initech.png',
alphabet : 'wide'
}).font('INITECH', 'Doom', 'cyan', function(ascii){
console.log(ascii);
});
Which produces (from this and this):
You can also generate tables in a standard box style (and it will attempt to be smart about column widths without truncating ansi codes):
art.table({
width : 80,
data : [ /* ... */ ],
headerStyle : 'blue_bg+white',
verticalBar : ' ',
horizontalBar : ' ',
intersection : ' ',
columns : [
{
value : 'Product',
style : 'black+gray_bg'
}, {
value : 'Maker',
style : 'white'
}, {
value : 'Location',
style : 'white'
}
]
});
which will output:
check out the documentation for more examples!
Color Table | color | bright_color | color _bg | bright_color _bg |
---|---|---|---|---|
black | ||||
red | ||||
green | ||||
yellow | ||||
blue | ||||
cyan | ||||
magenta | ||||
white |
Styles are: italic, bold, underline, |framed|, |encircled|, overline, blink and inverse .
For example: if I wanted underlined blue text on a white background, my style would be underlined+blue+white_bg
. Check out the detailed style docs for more information.
If you're a chalk user, just use var chalk = require('ascii-art/kaolin');
in place of your existing chalk
references (Much of color.js, too... since chalk is a subset of colors.js). No migration needed, keep using the wacky syntax you are used to(In this mode, refer to their docs, not mine).
Users of ascii-table will also note that interface is supported via require('ascii-art').Table
, though our solution is ansi-aware, lazy rendering and better at sizing columns.
I may support the other colors stuff (extras & themes) eventually, but it's currently a low priority.
####Goals
####Non Goals
In the root directory run:
npm run test
which runs the test suite directly. In order to test it in Chrome try:
npm run browser-test
In order to run the chalk test, use:
npm run chalk-test
Please make sure to run the tests before submitting a patch and report any rough edges. Thanks!
Enjoy,
-Abbey Hawk Sparrow
FAQs
Ansi codes, figlet fonts, and ascii art. 100% JS
The npm package ascii-art receives a total of 1,067 weekly downloads. As such, ascii-art popularity was classified as popular.
We found that ascii-art demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.