-
Notifications
You must be signed in to change notification settings - Fork 311
/
Copy pathbwip-js.d.ts
189 lines (168 loc) · 6.85 KB
/
bwip-js.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// Type definitions for bwip-js __BWIPJS_VERS__
//
// THIS DEFINITION FILE IS MACHINE GENERATED - DO NOT EDIT
//
// Project: https://github.com/metafloor/bwip-js
//
// This definition file was based on:
//
// Definitions by: TANAKA Koichi <https://github.com/MugeSo>
// Guillaume VanderEst <https://github.com/gvanderest>
// Ryan Jentzsch <https://github.com/RyanNerd>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// platform-specific includes
declare namespace BwipJs {
export interface BwippOptions {
includecheck?: boolean | undefined;
includecheckintext?: boolean | undefined;
parse?: boolean | undefined;
parsefnc?: boolean | undefined;
height?: number | undefined;
width?: number | undefined;
inkspread?: number | undefined;
inkspreadh?: number | undefined;
inkspreadv?: number | undefined;
dotty?: boolean | undefined;
binarytext?: boolean | undefined; // really a bwip-js option but better positioned here
includetext?: boolean | undefined;
textfont?: string | undefined;
textsize?: number | undefined;
textgaps?: number | undefined;
alttext?: string | undefined;
textxalign?: 'offleft' | 'left' | 'center' | 'right' | 'offright' | 'justify' | undefined;
textyalign?: 'below' | 'center' | 'above' | undefined;
textxoffset?: number | undefined;
textyoffset?: number | undefined;
showborder?: boolean | undefined;
borderwidth?: number | undefined;
borderleft?: number | undefined;
borderright?: number | undefined;
bordertop?: number | undefined;
borderbottom?: number | undefined;
barcolor?: string | undefined;
backgroundcolor?: string | undefined;
bordercolor?: string | undefined;
textcolor?: string | undefined;
addontextxoffset?: number | undefined;
addontextyoffset?: number | undefined;
addontextfont?: string | undefined;
addontextsize?: number | undefined;
guardwhitespace?: boolean | undefined;
guardwidth?: number | undefined;
guardheight?: number | undefined;
guardleftpos?: number | undefined;
guardrightpos?: number | undefined;
guardleftypos?: number | undefined;
guardrightypos?: number | undefined;
}
export interface RenderOptions extends BwippOptions {
bcid: string;
text: string;
scaleX?: number | undefined;
scaleY?: number | undefined;
scale?: number | undefined;
rotate?: 'N' | 'R' | 'L' | 'I' | undefined;
paddingwidth?: number | undefined;
paddingheight?: number | undefined;
paddingleft?: number | undefined;
paddingright?: number | undefined;
paddingtop?: number | undefined;
paddingbottom?: number | undefined;
monochrome?: boolean | undefined;
sizelimit?: number | undefined;
}
export interface RawOptions extends BwippOptions {
bcid: string;
text: string;
}
export interface DrawingContext<T> {
setopts?(options: RenderOptions): void;
scale(sx: number, sy: number): [number, number] | null;
measure(
str: string,
font: string,
fwidth: number,
fheight: number,
): { width: number; ascent: number; descent: number };
init(width: number, height: number): void;
line(x0: number, y0: number, x1: number, y1: number, lw: number, rgb: string): void;
polygon(pts: Array<[number, number]>): void;
hexagon(pts: [[number, number], [number, number], [number, number], [number, number], [number, number]]): void;
ellipse(x: number, y: number, rx: number, ry: number, ccw: boolean): void;
fill(rgb: string): void;
text(
x: number,
y: number,
str: string,
rgb: string,
font: { name: string; width: number; height: number; dx: number },
): void;
end(): T;
}
export function render<T>(params: RenderOptions, drawing: DrawingContext<T>): T;
export function raw(
options: RawOptions,
):
| Array<{ bbs: number[]; bhs: number[]; sbs: number[] }>
| Array<{ pixs: number[]; pixx: number; pixy: number; height: number; width: number }>;
export function raw(
bcid: string,
text: string,
opts: string,
):
| Array<{ bbs: number[]; bhs: number[]; sbs: number[] }>
| Array<{ pixs: number[]; pixx: number; pixy: number; height: number; width: number }>;
export function raw(
bcid: string,
text: string,
opts?: BwippOptions,
):
| Array<{ bbs: number[]; bhs: number[]; sbs: number[] }>
| Array<{ pixs: number[]; pixx: number; pixy: number; height: number; width: number }>;
export const BWIPP_VERSION: string;
export const BWIPJS_VERSION: string;
// wrapper around FontLib.loadFont()
export function loadFont(name: string, data: string | Uint8Array): void;
export function loadFont(name: string, mult: number, data: string | Uint8Array): void;
export function loadFont(name: string, multy: number, multx: number, data: string | Uint8Array): void;
export namespace FontLib {
export interface PathData
extends Array<
| { type: 'M'; x: number; y: number }
| { type: 'L'; x: number; y: number }
| { type: 'Q'; x: number; y: number; cx: number; cy: number }
| { type: 'C'; x: number; y: number; cx1: number; cy1: number; cx2: number; cy2: number }
> {
ascent: number;
descent: number;
advance: number;
}
export function lookup(font: string): number;
export function monochrome(mono: boolean): void;
export function getglyph(
fontid: number,
charcode: number,
width: number,
height: number,
): {
glyph: number;
top: number;
left: number;
width: number;
height: number;
advance: number;
pixels: Uint8Array;
bytes: Uint8Array;
cachekey: string;
offset: number;
};
export function getpaths(fontid: number, charcode: number, width: number, height: number): PathData;
export function loadFont(name: string, data: string | Uint8Array): void;
export function loadFont(name: string, mult: number, data: string | Uint8Array): void;
export function loadFont(name: string, multy: number, multx: number, data: string | Uint8Array): void;
}
export function toSVG(opts: RenderOptions): string;
export function drawingSVG(): DrawingContext<string>;
// platform-specific exports
}
export = BwipJs