Skip to content

Commit bd74ec5

Browse files
committed
add ascii-art definitions
1 parent 3ea5ad1 commit bd74ec5

File tree

4 files changed

+266
-0
lines changed

4 files changed

+266
-0
lines changed

types/ascii-art/ascii-art-tests.ts

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
import art from 'ascii-art';
2+
3+
art.font('test', 'doom').toPromise();
4+
5+
art.font('my text', 'Doom', (rendered: string) => {
6+
rendered.big();
7+
});
8+
9+
art.font('my text', 'Doom', '', (rendered) => {
10+
rendered.big();
11+
});
12+
13+
art.artwork({
14+
artwork: 'textfiles.com/art/st-char.asc'
15+
}).lines(31, 45, function(rendered: string) {
16+
// cleanup non-unix terminators
17+
rendered = rendered.replace(/\r/g, '');
18+
art.image({
19+
filepath : '~/Images/earth_in_space.jpg',
20+
alphabet : 'ultra-wide'
21+
}).overlay(rendered, {
22+
x: 0,
23+
y: -1,
24+
style: 'red+blink',
25+
transparent: '&'
26+
}, function(_final: any) {});
27+
});
28+
29+
art.font('Ghost Wire BBS', 'Doom', function(logo) {
30+
art.font('No place like home', 'rusted', function(subtext) {
31+
art.table({
32+
verticalBar : ' ',
33+
horizontalBar : ' ',
34+
intersection : ' ',
35+
data: [
36+
{name: art.style('current users', 'red'), value: '203'},
37+
{name: 'operator', value: 'vince.vega'},
38+
{name: 'dial-in', value: '(917)555-4202'},
39+
]
40+
}).lines(2, function(table: any) {
41+
art.image({
42+
filepath : '~/Images/starburst_red.jpg',
43+
alphabet : 'ultra-wide'
44+
}).lines(2, 30).overlay(logo, {
45+
x: 0,
46+
y: 0,
47+
style: 'blue',
48+
}).overlay(subtext, {
49+
x: 19,
50+
y: 8,
51+
style: 'yellow',
52+
}).overlay(table, {
53+
x: -1,
54+
y: -1,
55+
style: 'green',
56+
}, function(_final: any) {
57+
});
58+
});
59+
});
60+
});
61+
62+
art.image({
63+
width : 40,
64+
filepath : '/Images/initech.png',
65+
alphabet : 'wide'
66+
}).font('INITECH', 'Doom', 'cyan', function(_ascii) {
67+
});
68+
69+
art.table({
70+
data: [
71+
{text: ' .\'ANDRE. '},
72+
{text: ' ..THE.GIANT\'. '},
73+
{text: '.With.Bobby."The.Brain"'},
74+
{text: '.Heenan.'}
75+
],
76+
verticalBar : ' ',
77+
horizontalBar : ' ',
78+
intersection : ' '
79+
}).lines(2, function(table: any) {
80+
art.strings([
81+
'ANDRE',
82+
'the',
83+
'GIANT',
84+
'POSSE',
85+
'7\'4"',
86+
'520 LB'
87+
], 'rusted', function(andre: any, the: any, giant: any, posse: any, height: any, weight: any) {
88+
art.strings([ 'has', 'a'], 'twopoint', function(has: any, a: any) {
89+
art.image({
90+
filepath : '/Images/andre_has_a_posse.jpeg',
91+
alphabet : 'ultra-wide'
92+
}).overlay(andre, {
93+
x: 8, y: 4,
94+
style: 'white'
95+
}).overlay(the, {
96+
x: 10, y: 7,
97+
style: 'white',
98+
transparent : true
99+
}).overlay(giant, {
100+
x: 8, y: 10,
101+
style: 'white',
102+
transparent : true
103+
}).overlay(has, {
104+
x: 10, y: 14,
105+
style: 'white'
106+
}).overlay(a, {
107+
x: 13, y: 17,
108+
style: 'white'
109+
}).overlay(posse, {
110+
x: 5, y: 20,
111+
style: 'bright_black',
112+
transparent: true
113+
}).overlay(height, {
114+
x: 59, y: 3,
115+
style: 'bright_black',
116+
transparent: true
117+
}).overlay(weight, {
118+
x: 59, y: 8,
119+
style: 'bright_black',
120+
transparent: true
121+
}).overlay(table, {
122+
x: 6, y: -6,
123+
style: 'bright_black',
124+
transparent: true
125+
}, function(_final: any) {
126+
});
127+
});
128+
});
129+
});
130+
131+
art.Figlet.fontPath = 'Fonts';
132+
133+
const image = new art.Image({
134+
filepath: '~/Images/metropolis.jpg',
135+
alphabet: 'variant4'
136+
});
137+
image.write(function(_err: any, _rendered: string) {
138+
});
139+
140+
art.font('Prompt', 'Basic', 'red').font('v1', 'Doom', 'magenta', function(_rendered) {
141+
});
142+
143+
art.image({
144+
width : 40,
145+
filepath : '/Images/initech.png',
146+
alphabet : 'wide'
147+
}).font('INITECH', 'Doom', 'cyan', function(_ascii) {
148+
});
149+
150+
art.style('my text', 'red+underline');
151+
152+
art.table({
153+
width : 80,
154+
data : [ /* ... */ ],
155+
verticalBar : ' ',
156+
horizontalBar : ' ',
157+
intersection : ' ',
158+
columns : [
159+
{
160+
value : 'Product',
161+
style : 'black+gray_bg'
162+
}, {
163+
value : 'Maker',
164+
style : 'white'
165+
}, {
166+
value : 'Location',
167+
style : 'white'
168+
}
169+
]
170+
}, function(_rendered) {
171+
// use rendered text
172+
});
173+
174+
art.table({
175+
width : 80,
176+
data : [ /* ... */ ],
177+
bars : {
178+
ul_corner: '┏',
179+
ur_corner: '┓',
180+
lr_corner: '┛',
181+
ll_corner: '┗',
182+
bottom_t: '┻',
183+
top_t: '┳',
184+
right_t: '┫',
185+
left_t: '┣',
186+
intersection: '╋',
187+
vertical: '┃',
188+
horizontal: '━',
189+
},
190+
borderColor : 'bright_white',
191+
}, function(_rendered) {
192+
// use rendered text
193+
});

types/ascii-art/index.d.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Type definitions for ascii-art 1.4
2+
// Project: https://github.com/khrome/ascii-art
3+
// Definitions by: Lukas Elmer <https://github.com/lukaselmer>
4+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5+
// TypeScript Version: 2.2
6+
7+
export type StyleType = (text: string, style?: string, close?: boolean) => Art;
8+
export type FontType = ((text: string, font?: string, styleOrCallback?: string | Cb, callback?: Cb) => Art);
9+
export type ImageType = (options: object, callback?: Cb) => Art;
10+
export type TableType = (options: object, callback?: Cb) => Art;
11+
export type ArtworkType = (options: object, callback?: Cb) => Art;
12+
export type LinesType = (...options: any[]) => Art;
13+
export type OverlayType = (...options: any[]) => Art;
14+
export type JoinType = (...options: any[]) => Art;
15+
export type StringsType = (...options: any[]) => Art;
16+
17+
export const style: StyleType;
18+
export const font: FontType;
19+
export const image: ImageType;
20+
export const table: TableType;
21+
export const artwork: ArtworkType;
22+
export const lines: LinesType;
23+
export const overlay: OverlayType;
24+
export const join: JoinType;
25+
export const strings: StringsType;
26+
export const Figlet: any;
27+
export const Image: any;
28+
29+
export interface Art {
30+
style: StyleType;
31+
font: FontType;
32+
image: ImageType;
33+
table: TableType;
34+
artwork: ArtworkType;
35+
lines: LinesType;
36+
overlay: OverlayType;
37+
join: JoinType;
38+
working: boolean;
39+
40+
toPromise: (() => Promise<string>);
41+
}
42+
43+
export type Cb = (result: string) => void;

types/ascii-art/tsconfig.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"lib": [
5+
"es6"
6+
],
7+
"allowSyntheticDefaultImports": true,
8+
"noImplicitAny": true,
9+
"noImplicitThis": true,
10+
"strictNullChecks": true,
11+
"strictFunctionTypes": true,
12+
"baseUrl": "../",
13+
"typeRoots": [
14+
"../"
15+
],
16+
"types": [],
17+
"noEmit": true,
18+
"forceConsistentCasingInFileNames": true
19+
},
20+
"files": [
21+
"index.d.ts",
22+
"ascii-art-tests.ts"
23+
]
24+
}

types/ascii-art/tslint.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "dtslint/dt.json",
3+
"rules":{
4+
"only-arrow-functions": false
5+
}
6+
}

0 commit comments

Comments
 (0)