1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.Characters = void 0;
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | class Characters extends Object {
|
12 | |
13 |
|
14 |
|
15 |
|
16 | |
17 |
|
18 |
|
19 |
|
20 | |
21 |
|
22 |
|
23 |
|
24 | |
25 |
|
26 |
|
27 |
|
28 | |
29 |
|
30 |
|
31 |
|
32 | |
33 |
|
34 |
|
35 | constructor() {
|
36 | super();
|
37 | this.precision = 1;
|
38 | this.stroke = void 0;
|
39 | this._characters = {
|
40 |
|
41 | ' ': 0b00000000000000000000000000000000000000000,
|
42 | 'A': 0b00000000000000000000000000000000000000101,
|
43 | 'B': 0b00000000000000000000000000000000000001101,
|
44 | 'C': 0b00000000000000000000000000000000000010001,
|
45 | 'D': 0b00000000000000000000000000000001000010001,
|
46 | 'E': 0b00000000000000000000000000110000000000001,
|
47 | 'F': 0b00000000000000000000000000010000000000001,
|
48 | 'G': 0b00000000000000000000000100000001000000001,
|
49 | 'H': 0b00000000000000000000000000001100000001101,
|
50 | 'I': 0b00000000000000000000000000000001000000001,
|
51 | 'J': 0b00000000000000000000000000000001100000001,
|
52 | 'K': 0b00000000000000000001101000000000000000001,
|
53 | 'L': 0b00000000000000000000000000000001010000001,
|
54 | 'M': 0b00000000000000000000000000001100000000001,
|
55 | 'N': 0b00000000000000000000000001000000000000001,
|
56 | 'O': 0b00000000000000000000000000000000000000001,
|
57 | 'P': 0b00000000000000000000000000000001001000001,
|
58 | 'Q': 0b00000000000000000000000000000000010000001,
|
59 | 'R': 0b00000000000000000000000100000001001000001,
|
60 | 'S': 0b00000000000000000000000000000000101000001,
|
61 | 'T': 0b00000000000000000000010000000010000000001,
|
62 | 'U': 0b00000000000000000000000000000000000001001,
|
63 | 'V': 0b00000000000000000000000011000000000001001,
|
64 | 'W': 0b00000000000000000000000011000000000110001,
|
65 | 'X': 0b00000000000000000000000011000000000000001,
|
66 | 'Y': 0b00000000000000000000100001000000000000001,
|
67 | 'Z': 0b00000000000000000000000010000000000000001,
|
68 | '0': 0b00000000000000000000000000000000000000011,
|
69 | '1': 0b00000000000000000100000000000000000000011,
|
70 | '2': 0b00000000000000001100000000000000000000011,
|
71 | '3': 0b00000000000011000100000000000000000000011,
|
72 | '4': 0b00000000000000111100000000000000000000011,
|
73 | '5': 0b00000000111100000100000000000000000000011,
|
74 | '6': 0b00000000000000000010000000000000000000011,
|
75 | '7': 0b00000001000000000010000000000000000000011,
|
76 | '8': 0b00000011000000000010000000000000000000011,
|
77 | '9': 0b00001101000000000010000000000000000000011,
|
78 | '.': 0b00000000000000000000000000000000000000010,
|
79 | '-': 0b00110000000000000000000000000000000000000,
|
80 | '\u00C6': 0b11000000000000000000000000000011000000001,
|
81 | '\u00D8': 0b00000000000000000000000000100001000000001,
|
82 | '\u00C5': 0b00000000000000000000000000100000000001001
|
83 |
|
84 |
|
85 | };
|
86 | this._elements = void 0;
|
87 | this.margin = {
|
88 | left: 0,
|
89 | right: 0,
|
90 | top: 0,
|
91 | bottom: 0
|
92 | };
|
93 | }
|
94 | |
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 | |
102 |
|
103 |
|
104 |
|
105 |
|
106 | get centerX() {
|
107 | return this.margin.left + (this.width - (this.margin.left + this.margin.right)) * 0.5;
|
108 | }
|
109 | |
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 | get centerY() {
|
117 | return this.margin.top + (this.height - (this.margin.top + this.margin.bottom)) * 0.5;
|
118 | }
|
119 | |
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 | get width() {
|
127 | return Math.ceil(this.margin.left + this.characterWidth + this.margin.right);
|
128 | }
|
129 | |
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 | get height() {
|
137 | return Math.ceil(this.margin.top + this.characterHeight + this.margin.bottom);
|
138 | }
|
139 | |
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 | round(n) {
|
148 | const x = Math.pow(10, this.precision);
|
149 | return x ? Math.floor(n * x) / x : n;
|
150 | }
|
151 | |
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 | getCharacter(character) {
|
160 | const c = character.toUpperCase();
|
161 | const {
|
162 | _characters
|
163 | } = this;
|
164 | return Object.prototype.hasOwnProperty.call(_characters, c) ? _characters[c] : null;
|
165 | }
|
166 | |
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 | getElements(bits) {
|
180 | const {
|
181 | _elements
|
182 | } = this;
|
183 | const c = [this.centerX, this.centerY];
|
184 | const r = [];
|
185 |
|
186 | for (let i = 0; bits >= 1; bits /= 2, i++) {
|
187 |
|
188 | if (bits & 1) {
|
189 | const e = _elements[i];
|
190 | r.push(e.map((v, i) => this.round(i === 2 && e.length === 3 ? v : v + c[i % 2])));
|
191 | }
|
192 | }
|
193 |
|
194 | return r;
|
195 | }
|
196 | |
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 | getCharacterElements(character) {
|
205 | const bits = this.getCharacter(character);
|
206 | return bits === null ? null : this.getElements(bits);
|
207 | }
|
208 |
|
209 | }
|
210 |
|
211 | exports.Characters = Characters;
|
212 |
|