-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsketch.js
More file actions
157 lines (132 loc) · 16.6 KB
/
sketch.js
File metadata and controls
157 lines (132 loc) · 16.6 KB
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
// Poul-Henning Kamp reverse-engineered the character
// generator on the HP1345A digital vector display, c.1985
// Ported from https://phk.freebsd.dk/hacks/Wargames/index.html
// Uses or adapts the following resources:
// https://phk.freebsd.dk/_downloads/e52aa694fd64ff9d2a1a7291b7697f3e/hp1345_font.py
// https://phk.freebsd.dk/_downloads/a89c073235ca9c2b13d657173d32bf78/01347-80012.bin
// https://phk.freebsd.dk/_downloads/2355976608a6359335e30a88e181f1fc/1816-1500.bin
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*/
let hpLineFont;
//=============================================
function setup() {
createCanvas(800, 450);
hpLineFont = new HP1345AFont();
}
//=============================================
function draw() {
background(0);
noFill();
stroke(255);
strokeWeight(1);
strokeCap(ROUND);
strokeJoin(ROUND);
push();
translate(80,60);
const gridSize = 16;
const cellSize = 40;
for (let i=16; i<(4*16); i++){
let ox = i%16;
let oy = int(i/16);
let px = ox * cellSize;
let py = oy * cellSize;
let ch = String.fromCharCode(i);
hpLineFont.drawCharacter(ch, px,py, 1.0);
}
pop();
hpLineFont.drawString("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 80,250, 1.5, 24);
hpLineFont.drawString("abcdefghijklmnopqrstuvwxyz", 80,300, 1.5, 24);
hpLineFont.drawString("Hello World @1234567890{|}", 80,350, 1.5, 24);
}
function keyPressed(){
if (key == 's'){
save();
}
}
const strokeBytes =
[18,128,0,0,6,0,128,0,0,5,128,13,12,210,0,0,3,14,129,4,3,68,129,4,10,210,0,0,2,0,130,18,4,82,130,18,74,69,140,0,76,72,140,0,6,197,0,0,0,3,131,66,134,0,131,2,128,4,195,2,198,0,195,2,128,4,131,2,134,0,131,66,70,4,128,84,12,129,0,0,140,18,70,68,195,68,195,4,131,4,131,68,3,70,131,68,195,68,195,4,131,4,9,200,12,5,196,69,198,0,194,4,137,10,194,4,196,0,194,68,139,78,6,128,0,0,0,0,5,14,130,4,128,0,11,210,12,66,198,6,128,10,134,6,6,212,0,0,0,66,134,6,128,10,198,6,18,212,0,0,3,2,134,14,70,0,134,78,73,7,140,0,6,201,0,0,6,2,128,14,70,71,140,0,6,201,0,0,4,68,130,5,128,0,12,193,0,9,140,0,6,201,0,0,6,0,128,0,128,0,12,128,140,18,6,210,0,0,0,0,1,2,138,14,1,68,128,70,195,70,198,0,195,6,128,6,131,6,134,0,131,70,6,204,3,0,134,0,67,0,128,18,195,67,15,207,0,15,131,3,134,0,131,67,128,68,202,70,194,69,140,0,6,128,0,0,0,16,131,2,134,0,131,67,128,68,195,66,198,0,6,0,131,66,128,68,195,67,198,0,195,2,18,194,9,0,128,18,201,76,140,0,6,198,0,0,0,2,131,66,134,0,131,2,128,6,195,2,198,0,195,65,130,9,138,0,6,210,0,0,0,7,131,3,134,0,131,67,128,68,195,67,198,0,195,3,128,7,131,5,132,3,11,210,0,0,0,0,0,18,140,0,200,82,14,128,0,0,0,0,3,10,195,3,128,3,131,3,134,0,131,67,128,67,195,67,198,0,195,67,128,68,131,67,134,0,131,3,128,4,195,3,9,202,0,0,5,0,132,3,131,5,128,7,195,3,198,0,195,67,128,68,131,67,134,0,131,3,6,203,0,0,0,0,6,4,128,0,0,10,128,0,12,206,0,0,5,68,130,4,128,0,0,10,128,0,11,202,12,0,204,9,140,9,6,210,0,4,140,0,76,10,140,0,6,206,0,0,140,9,204,9,18,210,0,0,0,15,131,3,134,0,131,67,128,68,198,68,128,67,0,68,128,0,12,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,2,194,66,199,0,195,3,128,12,131,3,134,0,131,67,128,73,199,0,128,7,135,0,6,205,0,0,0,0,0,0,134,18,134,82,73,9,134,0,9,201,0,0,128,18,137,0,131,67,128,67,195,67,201,0,9,0,131,67,128,67,195,67,201,0,18,128,12,3,195,67,198,0,195,3,128,12,131,3,134,0,131,67,6,207,0,0,128,18,137,0,131,67,128,76,195,67,201,0,18,128,0,0,128,18,140,0,76,73,137,0,73,73,140,0,6,128,0,0,128,18,140,0,76,73,137,0,9,201,0,0,12,15,195,3,198,0,195,67,128,76,131,67,134,0,131,3,128,5,199,0,13,200,0,0,128,18,12,82,128,18,76,73,140,0,6,201,2,0,136,0,68,0,128,18,68,0,136,0,8,210,0,0,0,2,131,66,130,0,131,2,128,16,68,0,136,0,6,210,128,18,12,0,204,76,3,3,137,73,6,128,128,18,0,82,140,0,6,128,128,18,134,77,134,13,128,82,6,128,0,0,128,18,140,82,128,18,6,210,3,0,195,3,128,12,131,3,134,0,131,67,128,76,195,67,198,0,15,128,128,18,137,0,131,67,128,68,195,67,201,0,18,200,0,0,3,0,195,3,128,12,131,3,134,0,131,67,128,76,195,67,198,0,4,5,135,71,4,130,128,18,137,0,131,67,128,68,195,67,201,0,7,0,133,72,6,128,0,0,0,2,131,66,134,0,131,3,128,3,195,3,198,0,195,3,128,3,131,3,134,0,131,66,6,208,0,0,6,0,128,18,70,0,140,0,6,210,0,0,0,18,128,79,131,67,134,0,131,3,128,15,6,210,0,0,0,18,134,82,134,18,6,210,0,18,131,82,131,14,131,78,131,18,6,210,140,18,76,0,140,82,6,128,6,0,128,7,198,11,6,75,134,11,6,210,140,18,204,0,12,82,204,0,18,128,0,0,12,20,198,0,128,86,134,0,6,130,0,0,0,18,140,82,6,128,0,0,0,66,134,0,128,22,198,0,18,212,0,0,0,7,134,9,134,73,6,199,82,69,146,0,0,133,0,0,5,18,128,0,130,68,11,206,0,0,0,0,0,10,133,2,134,66,128,72,195,66,196,0,196,2,128,3,139,1,0,68,130,66,5,128,128,18,0,73,134,2,134,66,128,71,198,66,198,2,18,194,11,9,197,2,198,66,128,71,134,66,133,2,7,194,0,0,0,0,0,0,12,2,198,66,198,2,128,7,134,2,134,66,0,9,128,82,6,128,0,0,0,6,140,1,195,5,198,0,195,67,128,71,131,66,134,0,131,2,6,194,4,0,128,16,132,2,132,66,76,71,136,0,10,201,0,0,11,2,197,66,198,2,128,7,134,2,133,66,0,2,128,80,197,66,198,2,18,133,0,0,128,18,0,73,134,2,134,66,128,73,6,128,7,0,128,11,195,0,3,7,128,0,11,210,0,69,132,66,132,2,128,16,0,7,128,0,10,210,0,0,128,18,0,77,140,6,72,68,136,71,6,128,3,0,134,0,67,0,128,18,195,0,15,210,128,12,0,67,132,3,130,67,128,73,0,9,132,3,130,67,128,73,6,128,128,11,0,67,134,3,134,67,128,72,6,128,6,0,198,2,128,7,134,2,134,66,128,71,198,66,12,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,71,128,18,0,66,134,2,134,66,128,71,198,66,198,2,18,194,0,0,11,2,197,66,198,2,128,7,134,2,133,66,0,2,128,81,130,66,5,136,128,11,0,67,134,3,134,67,6,200,0,0,0,2,134,66,134,2,128,3,204,2,128,3,134,2,134,66,6,202,0,0,12,2,196,66,196,2,128,16,68,71,136,0,10,203,0,0,0,11,128,73,134,66,134,2,128,9,6,203,0,0,0,0,0,11,134,75,134,11,6,203,0,11,131,75,131,8,131,72,131,11,6,203,139,11,75,0,139,75,7,128,0,11,135,74,68,72,137,18,6,203,0,0,0,11,140,0,204,75,140,0,6,128,0,0,12,66,197,3,128,5,195,3,131,3,128,5,133,3,6,212,6,0,128,6,0,6,128,6,12,210,0,0,0,66,133,3,128,5,131,3,195,3,128,5,197,3,18,212,128,53,181,0,128,117,245,0,56,128,0,0,82,128,0,0,0,228,0,0,0,164,0,0,64,128,0,0,68,0,136,0,68,128,0,0,0,4,128,72,0,132,0,0,4,4,200,72,4,65,128,10,68,65,136,72,1,4,202,0,5,128,0,0,66,69,195,3,128,4,131,3,132,0,131,67,128,68,195,67,196,0,2,133,0,10,134,8,134,72,70,8,128,82,12,128,6,3,198,6,134,6,70,70,140,0,6,201,0,8,134,72,134,8,70,72,128,18,12,210,6,3,134,6,198,6,70,70,140,0,6,201,0,3,131,67,131,20,135,0,5,212,0,0,3,0,129,12,5,76,128,12,73,66,132,2,133,0,131,2,6,206,0,0,128,4,0,196,128,68,0,132,196,0,4,128,132,0,68,128,132,0,195,7,128,5,131,4,133,0,131,68,128,69,195,71,132,0,5,128,6,16,194,2,128,3,130,2,131,0,130,66,128,67,194,66,195,0,12,208,0,71,131,16,132,3,132,65,130,67,128,68,195,68,197,0,195,3,16,195,132,0,66,0,128,18,66,0,140,0,128,68,6,206,0,0,134,15,134,79,204,0,18,128,0,71,130,18,65,73,133,66,132,2,129,9,65,73,131,66,5,128,0,0,7,0,197,0,194,4,128,6,130,5,131,3,133,0,130,68,128,70,194,69,195,67,71,9,140,0,6,201,19,0,208,0,195,3,128,21,131,3,139,0,6,0,150,0,131,67,128,85,195,67,209,0,76,9,132,18,66,73,132,0,130,66,193,71,2,73,132,18,132,0,130,66,193,69,194,66,197,0,30,201,0,0,0,0,128,18,140,73,204,73,0,3,132,0,128,12,196,0,0,73,136,0,128,6,200,0,0,67,140,0,6,201,0,0,0,0,0,0,0,0,0,137,0,0,0,201,0,0,0,128,0,0,5,18,128,0,130,68,11,206,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,134,10,70,7,131,1,134,80,131,66,6,128,0,71,129,14,130,9,132,2,133,66,128,70,196,66,198,0,6,0,131,65,129,68,195,67,196,0,196,3,17,195,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,13,128,5,12,210,0,0,81,15,137,3,8,210,0,0,0,0,0,0,81,19,138,68,7,207,0,0,0,0,0,0,81,15,133,3,133,67,7,207,0,0,0,0,0,0,0,0,79,17,128,0,6,0,128,0,9,209,0,0,82,23,131,3,134,67,131,3,6,218,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,9,198,2,197,66,128,71,133,66,134,2,70,66,128,68,131,67,195,67,13,138,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,128,13,0,5,128,0,6,210,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,3,198,67,198,3,128,4,134,3,128,4,0,4,128,0,12,210,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,9,134,0,3,8,196,1,194,67,128,77,195,66,195,0,128,2,131,0,131,66,131,0,131,2,6,194,0,0,0,0,128,58,186,0,128,122,250,0,5,5,128,48,176,0,128,112,240,0,0,24,176,0,88,24,128,112,2,24,128,88,2,24,128,88,2,24,128,88,2,24,128,88,2,24,128,88,2,24,128,88,2,24,128,88,2,24,128,88,2,24,128,88,2,24,128,88,2,24,128,88,110,152,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,128,12,134,3,134,67,128,76,198,67,198,3,140,12,6,207,0,0,132,18,131,0,128,82,133,0,0,9,202,0,5,9,133,0,6,210,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,134,0,128,75,198,0,130,5,139,0,128,3,195,3,195,67,128,70,130,66,132,0,5,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,69,146,0,0,133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,70,133,6,69,76,138,12,74,82,143,18,79,88,148,24,84,94,153,30,89,100,158,36,94,106,163,42,99,112,168,48,99,112,168,48,99,112,166,45,97,109,161,39,92,103,156,33,87,97,151,27,82,91,146,21,77,85,141,15,72,79,136,9,67,73,131,3,5,45,197,6,10,70,202,12,15,76,207,18,20,82,212,24,25,88,217,30,30,94,222,36,35,100,227,42,40,106,232,48,45,112,232,48,43,109,230,45,38,103,225,39,33,97,220,33,28,91,215,27,23,85,210,21,18,79,205,15,13,73,200,9,8,67,195,3,109,68,240,0,48,68,240,0,48,68,240,0,48,68,240,0,48,68,240,0,48,68,240,0,48,68,240,0,48,68,240,0,48,68,240,0,48,68,240,0,48,68,240,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,140,10,0,66,195,2,198,0,195,66,128,70,131,66,134,0,131,2,128,6,6,200,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,79,23,128,0,6,0,128,0,9,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,76,23,128,0,12,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,82,16,131,2,134,66,131,2,6,210,0,0,0,0,0,0,0,0,0,0,76,17,128,0,12,209,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,100,23,134,3,134,0,134,67,134,0,134,3,6,218,0,0,128,18,0,73,140,0,6,201,0,0,0,0,100,16,134,2,134,0,134,66,134,0,134,2,6,210,0,0,0,16,131,2,134,66,131,2,6,210,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,73,0,146,0,73,128,0,0,0,9,128,82,0,137,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,161,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,39,181,0,128,103,245,0,56,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,9,0,201,128,73,0,137,201,0,9,128,137,0,73,128,128,39,0,1,128,40,186,0,128,103,0,65,128,104,250,0,5,7,128,33,128,33,176,0,128,97,128,97,240,0,0,33,176,0,88,33,128,97,128,97,2,33,128,97,2,33,128,97,2,33,128,97,2,33,128,97,2,33,128,97,2,33,128,97,2,33,128,97,2,33,128,97,2,33,128,97,2,33,128,97,2,33,128,97,110,161,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,71,134,7,70,78,140,14,76,85,146,21,82,92,152,28,88,99,158,35,94,106,164,42,100,113,170,49,106,120,176,56,112,127,176,56,109,123,173,52,103,116,167,45,97,109,161,38,91,102,155,31,85,95,149,24,79,88,143,17,73,81,137,10,67,74,131,3,6,63,198,7,12,71,204,14,18,78,210,21,24,85,216,28,30,92,222,35,36,99,228,42,42,106,234,49,48,113,240,56,48,113,240,56,48,113,237,52,45,109,231,45,39,102,225,38,33,95,219,31,27,88,213,24,21,81,207,17,15,74,201,10,9,67,195,3,109,75,240,0,48,75,240,0,48,75,240,0,48,75,240,0,48,75,240,128,0,0,0,0,0,0,0,0,0,0,0,0,240,0,48,75,240,0,48,75,240,0,48,75,240,0,48,75,240,0,48,75,240,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
const indexBytes = [222,197,232,222,160,161,162,163,122,221,123,124,220,125,126,128,130,135,140,143,146,149,152,155,183,185,169,164,174,179,190,229,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,0,1,4,7,12,20,26,32,34,37,40,44,47,49,51,53,55,61,64,69,76,79,85,92,95,104,111,114,117,119,122,124,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,135,143,146,152,157,161,165,168,174,177,181,185,188,190,193,195,200,204,210,215,222,225,229,231,234,236,239,242,245,247,250,252,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,223,1,7,11,16,21,26,30,36,39,42,46,49,52,57,60,69,74,79,82,87,91,95,97,100,102,105,108,112,115,119,211,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,197,232,222,160,161,162,163,122,221,123,124,220,125,126,128,130,135,140,143,146,149,152,155,183,185,169,164,174,179,190,229,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,0,1,4,7,12,20,26,32,34,37,40,44,47,49,51,53,55,61,64,69,76,79,85,92,95,104,111,114,117,119,122,124,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,135,143,146,152,157,161,165,168,174,177,181,185,188,190,193,195,200,204,210,215,222,225,229,231,234,236,239,242,245,247,250,252,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,223,1,7,11,16,21,26,30,36,39,42,46,49,52,57,60,69,74,79,82,87,91,95,97,100,102,105,108,112,115,119,211,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222];
//=============================================
class HP1345AFont {
constructor() {
this.v = Array(256).fill([]);
this.used = null;
this.loadROMs();
}
loadROMs() {
this.used = Array(strokeBytes.length).fill(false);
this.buildAllCharacters();
}
buildCharacter(ch) {
const ia = (ch & 0x1f) | ((ch & 0xe0) << 1);
let sa = indexBytes[ia] << 2;
sa |= ((1 ^ (ch >> 5) ^ (ch >> 6)) & 1) << 10;
sa |= ((ch >> 7) & 1) << 11;
if (!strokeBytes[sa] && !strokeBytes[sa + 1]) return;
const l = [];
while (true) {
if (this.used[sa]) return;
this.used[sa] = true;
let dx = strokeBytes[sa] & 0x3f;
if (strokeBytes[sa] & 0x40) dx = -dx;
let dy = strokeBytes[sa + 1] & 0x3f;
if (strokeBytes[sa + 1] & 0x40) dy = -dy;
if (!(strokeBytes[sa] & 0x80)) l.push([]);
if (l.length === 0) l.push([[0, 0]]);
l[l.length - 1].push([dx, dy]);
if (strokeBytes[sa + 1] & 0x80) break;
sa += 2;
}
this.v[ch] = l;
}
buildAllCharacters() {
for (let i = 0; i < 256; i++) {
this.buildCharacter(i);
}
}
vectors(ch) {
return this.v[ch];
}
bbox(ch, bbox = null, x = 0, y = 0) {
if (!bbox) bbox = [0, 0, -999, -999];
this.v[ch].forEach((i) =>
i.forEach(([dx, dy]) => {
x += dx;
y += dy;
bbox[0] = Math.min(bbox[0], x);
bbox[1] = Math.min(bbox[1], y);
bbox[2] = Math.max(bbox[2], x);
bbox[3] = Math.max(bbox[3], y);
})
);
return [bbox, x, y];
}
drawCharacter(ch, px, py, size) {
let asciiCode = ch.charCodeAt(0) & 0xff;
let x = px;
let y = py;
beginShape();
this.vectors(asciiCode).forEach((j) => {
j.forEach(([dx, dy]) => {
x += dx*size;
y -= dy*size;
vertex(x, y);
});
endShape();
beginShape();
});
endShape();
}
drawString(w, px, py, size=1.0, spacing=16) {
for (let i = 0; i < w.length; i++) {
const ch = w[i];
this.drawCharacter(ch, px + i * spacing, py, size);
}
}
}