Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 75 lines (51 sloc) 2.68 kb
b5c9b93 Abbey Hawk Sparrow first commit
authored
1 ascii-art.js
2 ===========
3
4 A bunch of utilities for outputting textual art
5
6 Figlet fonts
7 ------------
3bd388c Abbey Hawk Sparrow font() chaining & optional style param
authored
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.
b5c9b93 Abbey Hawk Sparrow first commit
authored
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)
39
40 2. **background colors**
41 Background terminal colors available are: black_bg, red_bg, green_bg, yellow_bg, blue_bg, magenta_bg, cyan_bg, white_bg
42
43 3. **styles**
44 To style the text you may use: bold, italic, underline, framed, encircled, overline, blink, inverse
45
46 4. **controls**
47 Control styles are: off, hidden
48
49 Images
50 ------
3bd388c Abbey Hawk Sparrow font() chaining & optional style param
authored
51 Will be coming soon™!
52
53 Chaining
54 --------
55
56 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 art.font('Prompt', 'Basic', 'red').font('v1', 'Doom', 'magenta', function(rendered){
59 console.log(rendered);
60 });
61
62 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:
63
64 d8888b. d8888b. .d88b. .88b d88. d8888b. d888888b __
65 88 `8D 88 `8D .8P Y8. 88'YbdP`88 88 `8D `~~88~~' / |
66 88oodD' 88oobY' 88 88 88 88 88 88oodD' 88 __ __`| |
67 88~~~ 88`8b 88 88 88 88 88 88~~~ 88 \ \ / / | |
68 88 88 `88. `8b d8' 88 88 88 88 88 \ V / _| |_
69 88 88 YD `Y88P' YP YP YP 88 YP \_/ \___/
b5c9b93 Abbey Hawk Sparrow first commit
authored
70
71 Hope that helps, please report any rough edges!
72
73 Enjoy,
74
75 -Abbey Hawk Sparrow
Something went wrong with that request. Please try again.