You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+82-97
Original file line number
Diff line number
Diff line change
@@ -1,103 +1,69 @@
1
-
ascii-art.js
2
-
===========
1
+
_ _ _
2
+
(_)(_) | |
3
+
__ _ ___ ___ _ _ ______ __ _ _ __ | |_
4
+
/ _` |/ __| / __|| || ||______| / _` || '__|| __|
5
+
| (_| |\__ \| (__ | || | | (_| || | | |_
6
+
\__,_||___/ \___||_||_| \__,_||_| \__|
7
+
8
+
###ascii-art.js
9
+
10
+
Images, fonts and terminal styles in Node.js & the browser. 100% JS.
11
+
12
+
It features support for [Images](docs/Images.md), [Styles](docs/Images.md) and [Figlet Fonts](docs/Figlet.md) as well as handling multi-line joining automatically.
13
+
14
+
In the beginning there was [colors.js](https://github.com/Marak/colors.js) but in the fine tradition of vendors calling out a problem they have the solution to, [chalk](https://github.com/yeoman/yo/issues/68) was introduced. In that same vein, I offer `ascii-art` to [solve](docs/Multiline.md)[many](docs/Figlet.md)[problems](docs/Images.md) which chalk ignores.
15
+
16
+
Why would I use this instead of X?
17
+
----------------------------------
18
+
-**zero dependencies** - while the CL utility and test have dependencies, we will never call out to a module for what is supposed to be this lib's core competancy.
19
+
-**color profiles** support - other libraries assume you are running x11
20
+
-**no prototype manipulation** - Nobody is actually forcing String.prototype on anyone, but that doesn't stop it being a hot topic. In addition, we don't use `__proto__` under the hood and pretending we aren't doing dynamic prototype manipulation (zing!).
21
+
- handles the ugly [intersection of **multiline text and ansi codes**](doc/Multiline.md) for you.
22
+
- runs in the **browser and Node.js** (CommonJS, AMD, globals or webpack)
23
+
-**JS + Canvas** Ascii image generation utilities in node don't actually touch any pixels, but usually call out to a binary, we do 100% of our transform in JS, which allows us plug into averaging, distance and other logic dynamically, in powerful ways.
24
+
-**Expressive API** is a buzzword for chaining from days of yore, but the other guys are excited about having one and we have one too.
25
+
- It **works like a package manager** for figlet fonts.
26
+
- The other libraries out there do too little and focus on logging above other domains.
27
+
-**Actively maintained** If we don't update the code we'll tweak a code of conduct or something... maybe just re-up with self congratulatory pull requests, just to keep kicking that can. We might even add badges if we get saucy.
28
+
-**Supports your existing API** We allow you to use the colors.js/chalk API *or* our own (where we reserve chaining for more useful activities).
29
+
-**Loads nothing that isn't used** (Images, Fonts, Image Logic, etc.)
30
+
- It's **awesome** and that thing you're holding is looking played out.
3
31
4
-
Draw images, render fonts and manipulate terminal styles in Node.js & the browser. 100% JS.
5
-
6
-
Figlet fonts
7
-
------------
8
-
A slight mod of [Figlet.js](https://github.com/scottgonzalez/figlet-js) which I hope will make it to NPM in pure js form someday, rather than requiring a command line dependency.
9
-
10
-
Figlet fonts are an ASCII art font standard, widely used for terminal output.
11
-
12
-
It looks something like this:
13
-
14
-
______ _
15
-
| _ \ | |
16
-
| | | | ___ _ __ ___ ___ | |
17
-
| | | | / _ \| '_ ` _ \ / _ \ | |
18
-
| |/ / | __/| | | | | || (_) ||_|
19
-
|___/ \___||_| |_| |_| \___/ (_)
20
-
21
-
To set the directory of the fonts:
22
-
23
-
art.Figlet.fontPath = 'Fonts';
24
-
25
-
Then to render some text:
26
-
27
-
art.font('my text', 'Doom', function(rendered){
28
-
//do stuff here
29
-
});
30
-
31
-
Styles
32
-
------
33
-
ANSI terminals allow us to output style which format the text in the terminal. In order to do this you just need to:
34
-
35
-
art.style('my text', 'red+underline');
36
-
37
-
1.**colors**
38
-
Foreground colors for characters are: black, red, green, yellow, blue, magenta, cyan, white and in some terminal environments: bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white (These generally default to their non-bright variants on systems without them)
or render an image (use `npm run sample` to generate and view a gallery)
78
55
79
56
ascii-art image -f path/to/my/file.jpg
80
-
81
-
82
-
Chaining
83
-
--------
84
-
85
-
The font method also allows you to optionally pass styles and supports chaining, so if I want something a little more complex I could do something like this:
57
+
58
+
In your Code
59
+
------------
60
+
The font method also allows you to optionally pass styles and supports chaining, so if I want two strings rendered together:
and that will look like this (in color, of course) and it will totally respect the multiline chars and add in ansi codes per line, so things look how you'd expect:
Of course to match the `.font()` chain, there is also an `image()` chain, you can blend them like so:
66
+
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):
101
67
102
68
art.image({
103
69
width : 40,
@@ -107,9 +73,32 @@ Of course to match the `.font()` chain, there is also an `image()` chain, you ca
107
73
console.log(ascii);
108
74
});
109
75
110
-
Which produces something like:
76
+
Which produces (from [this](Images/initech.png) and [this](Fonts/doom.flf)):
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](docs/Styles.md) for more information.
If you're a [chalk](https://www.npmjs.com/package/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).
100
+
101
+
I may support the other [colors](https://www.npmjs.com/package/colors) stuff (extras & themes) eventually, but it's currently a low priority.
113
102
114
103
Testing
115
104
-------
@@ -121,15 +110,11 @@ which runs the test suite directly. In order to test it in Chrome try:
121
110
122
111
npm run browser-test
123
112
124
-
Please make sure to run the test suite before submitting a patch. Thanks!
125
-
126
-
Sample
127
-
------
128
-
To view a sample of graphics try:
113
+
In order to run the chalk test, use:
129
114
130
-
npm run sample
131
-
132
-
Hope that helps, please report any rough edges!
115
+
npm run chalk-test
116
+
117
+
Please make sure to run the tests before submitting a patch and report any rough edges. Thanks!
0 commit comments